struct assignment?

julie Sullivan kernelmail.jms at gmail.com
Sat Feb 19 17:15:31 EST 2011


Hi Miloody

> I found there seems no declaring about "struct ftrace_entry".
> below the greping result of my kernel source code:

> # grep -rwn 'struct ftrace_entry' *
> kernel/trace/trace.h:214:               IF_ASSIGN(var, ent, struct ftrace_entry, TRACE_FN);     \
> kernel/trace/trace_events.c:1483:       struct ftrace_entry *entry;
> kernel/trace/trace_output.c:818:        struct ftrace_entry *field;
> kernel/trace/trace_output.c:845:        struct ftrace_entry *field;
> kernel/trace/trace_output.c:859:        struct ftrace_entry *field;
> kernel/trace/trace_output.c:872:        struct ftrace_entry *field;
> kernel/trace/trace.c:1098:      struct ftrace_entry *entry;

> usually we use a struct we will declare its elements such as:
>
> struct usb_host_endpoint {
>        struct usb_endpoint_descriptor  desc;
>        struct list_head                urb_list;
>        void                            *hcpriv;
> ......................
> };
>

I think this struct is not explicitly declared but generated by a macro. Look in

kernel/trace/trace_entries.h

The code that uses struct ftrace_entry all seems to #include this file
either directly or indirectly:

Directly by kernel/trace/trace_export.c and kernel/trace/trace.h

Then kernel/trace/trace.c includes trace.h
kernel/trace/trace_output.h includes trace.h
kernel/trace/trace_output.c and kernel/trace/trace_events.c include
trace_output.h

I don't know why there is an advantage to creating a struct this way
(perhaps a performance/storage advantage?) but then I haven't looked
at the code in a lot of detail.

Cheers
Julie



More information about the Kernelnewbies mailing list