container_of - complex indirections - guru code - workqueues

Turgis, Frederic f-turgis@ti.com
Fri Sep 30 15:12:00 GMT 2011


>  offsetof(type, member) = & @cast(0, "type")->member
>  container_of(ptr, type, member) = ptr - & @cast(0, "type")->member
Very nice. In fact, I was not aware of the "&" and the 0 of @cast(0, ...) from reading the doc (even if & makes sense and @cast(0,...) is used in tapset). It opens new ideas to me

>> On top of that, I also have the issue that definitions are sometimes
>> internal to C file like "struct cpu_workqueue_struct" so I mix guru
>> code and @cast (summarized below):
Thanks for the rewrite.
In fact, I shall better explain this point. "atomic_long_read(& $work->data)" + "workqueue &= %{ WORK_STRUCT_WQ_DATA_MASK %}" are already duplication of content of get_work_cwq(...), which is static so guru can't call it. So I shall duplicate code.
But tapset + & + @cast(0, ...) + rest of syntax are powerful enough to avoid guru for most of my needs.

>Yes, please share -- we like getting new examples, as many
>people start by only running those scripts.
I will rewrite based on your inputs and share it. This is interesting for workqueues and also in terms in syntax. Eventually new keywords shall be added for syntax itself

Regards
Fred

Texas Instruments France SA, 821 Avenue Jack Kilby, 06270 Villeneuve Loubet. 036 420 040 R.C.S Antibes. Capital de EUR 753.920





More information about the Systemtap mailing list