Re: [PATCH v5 01/12] libtracefs: New APIs for dynamic events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 5, 2021 at 5:03 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
> On Fri,  5 Nov 2021 14:16:13 +0200
> "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote:
>
> > +static void init_devent_desc(void)
> > +{
> > +     int i;
> > +
> > +     BUILD_BUG_ON(ARRAY_SIZE(dynevents) != max_dyn_index);
> > +
> > +     /* Use  ftrace dynamic_events, if available */
> > +     if (tracefs_file_exists(NULL, DYNEVENTS_EVENTS)) {
> > +             for (i = 0; i < max_dyn_index; i++)
> > +                     dynevents[i].file = DYNEVENTS_EVENTS;
> > +             return;
> > +     }
> > +
> > +     if (tracefs_file_exists(NULL, KPROBE_EVENTS)) {
> > +             dynevents[ffs(TRACEFS_DYNEVENT_KPROBE) - 1].file = KPROBE_EVENTS;
> > +             dynevents[ffs(TRACEFS_DYNEVENT_KRETPROBE) - 1].file = KPROBE_EVENTS;
> > +     }
> > +     if (tracefs_file_exists(NULL, UPROBE_EVENTS)) {
> > +             dynevents[ffs(TRACEFS_DYNEVENT_UPROBE) - 1].file = UPROBE_EVENTS;
> > +             dynevents[ffs(TRACEFS_DYNEVENT_URETPROBE) - 1].file = UPROBE_EVENTS;
> > +     }
> > +     if (tracefs_file_exists(NULL, SYNTH_EVENTS)) {
> > +             dynevents[ffs(TRACEFS_DYNEVENT_SYNTH) - 1].file = SYNTH_EVENTS;
> > +             dynevents[ffs(TRACEFS_DYNEVENT_SYNTH) - 1].prefix = "";
> > +     }
> > +}
> > +
>
> I would have kept your bit_index() function to simplify the above. I just
> meant to use ffs in that function.
>
> static inline bit_index(unsigned int bits)
> {
>         return ffs(bits) - 1;
> }
>
> -- Steve
>

The problem with that function is that it cannot be used to initialise
constant variables, gcc complains about that. The ffs() API has no
such problem

-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux