dereferencing pointer to incomplete type ‘struct workqueue_struct’

Frank Ch. Eigler fche@redhat.com
Fri Apr 28 14:36:00 GMT 2017


jbusch175 / dsmith wrote:

>> [...]  However, the problem is iterating through that list in script
>> language. To do that correctly, you'd need embedded-C as you've got
>> here.  [...]

Iterating through the list in script language is possible though.
The workqueue structure is available via 
   p = @var("system_wq")
Its list_head field is accessible via
   n = @cast(p, "workqueue_struct")->list->next
One can get back to the workqueue_struct from a list pointer via
   p = & @container_of(n, "workqueue_struct", list)

So putting it together:

# stap -DMAXACTION=50000  -e '
probe oneshot { 
  p=@var("system_wq")
  while (max++ < 5000) {
    printf("p=%p name=%s\n", p, @cast(p,"workqueue_struct")->name$);
    n = @cast(p, "workqueue_struct")->list->next;
    ne = & @cast(p, "workqueue_struct")->list;
    if (n == ne) break;
    p = & @container_of(n, "workqueue_struct", list);
  }
}
'

- FChE



More information about the Systemtap mailing list