John Busch
2017-04-26 15:20:38 UTC
Hello,
I’m new to SystemTap, and trying to print information about kernel
work queues. I’ve used the example code in section 4.3 [1] of the
tutorial as my starting point, and I’m working on an up-to-date Fedora
25 system.
The example code in the tutorial works just fine. However, when I
essentially swap out variable and struct names to modify the example
to walk through workqueue_structs (instead of task_structs), I get a
“dereferencing pointer to incomplete type ‘struct workqueue_struct’”
compilation error on the line containing list_for_each_safe. Code
sample below.
workqueue_struct is defined in workqueue.h [2] and workqueue.c [4],
and I’m trying to access the global variable system_wq [3, 5]. How
would I gain access to these objects in systemtap? I must be doing
something wrong, but can't figure out what it is.
Thanks!
[1] https://sourceware.org/systemtap/tutorial/Tapsets.html
[2] http://lxr.free-electrons.com/source/include/linux/workqueue.h#L16
[3] http://lxr.free-electrons.com/source/include/linux/workqueue.h#L365
[4] http://lxr.free-electrons.com/source/kernel/workqueue.c#L239
[5] http://lxr.free-electrons.com/source/kernel/workqueue.c#L338
%{
#include <linux/workqueue.h>
#include <linux/list.h>
%}
function read_wq_list:long ()
%{
int ret = 0;
struct workqueue_struct *wq;
struct list_head *p, *n;
list_for_each_safe(p, n, system_wq->list) {
wq = list_entry(p, struct workqueue_struct, list);
_stp_printf("workqueue struct %s\n", wq->name);
}
STAP_RETURN(ret);
%}
probe begin
{
printf("reading list of workqueues\n")
read_wq_list()
exit()
}
I’m new to SystemTap, and trying to print information about kernel
work queues. I’ve used the example code in section 4.3 [1] of the
tutorial as my starting point, and I’m working on an up-to-date Fedora
25 system.
The example code in the tutorial works just fine. However, when I
essentially swap out variable and struct names to modify the example
to walk through workqueue_structs (instead of task_structs), I get a
“dereferencing pointer to incomplete type ‘struct workqueue_struct’”
compilation error on the line containing list_for_each_safe. Code
sample below.
workqueue_struct is defined in workqueue.h [2] and workqueue.c [4],
and I’m trying to access the global variable system_wq [3, 5]. How
would I gain access to these objects in systemtap? I must be doing
something wrong, but can't figure out what it is.
Thanks!
[1] https://sourceware.org/systemtap/tutorial/Tapsets.html
[2] http://lxr.free-electrons.com/source/include/linux/workqueue.h#L16
[3] http://lxr.free-electrons.com/source/include/linux/workqueue.h#L365
[4] http://lxr.free-electrons.com/source/kernel/workqueue.c#L239
[5] http://lxr.free-electrons.com/source/kernel/workqueue.c#L338
%{
#include <linux/workqueue.h>
#include <linux/list.h>
%}
function read_wq_list:long ()
%{
int ret = 0;
struct workqueue_struct *wq;
struct list_head *p, *n;
list_for_each_safe(p, n, system_wq->list) {
wq = list_entry(p, struct workqueue_struct, list);
_stp_printf("workqueue struct %s\n", wq->name);
}
STAP_RETURN(ret);
%}
probe begin
{
printf("reading list of workqueues\n")
read_wq_list()
exit()
}