On Wed, 19 Dec 2018 08:36:43 +0100
Jesper Dangaard Brouer <bro...@redhat.com> wrote:

> > +TRACE_EVENT(net_dev_notifier_entry,
> > +
> > +   TP_PROTO(const struct netdev_notifier_info *info, unsigned long val),
> > +
> > +   TP_ARGS(info, val),
> > +
> > +   TP_STRUCT__entry(
> > +           __string(       name,            info->dev->name )
> > +           __field(        enum netdev_cmd, event           )
> > +   ),
> > +
> > +   TP_fast_assign(
> > +           __assign_str(name, info->dev->name);
> > +           __entry->event = val;
> > +       ),  
> 
> These __string and __assign_str are costly and behind the scenes does a
> strcpy.

True. But you could also make this into a memcpy with:

                __array(        char,   name,   IFNAMSIZ)


And in TP_fast_assign:

                memcpy(__entry->name, info->dev->name, IFNAMSIZ);

And for the TP_printk:

                "dev=%s", __entry->name


Yes, ifindex is still faster, but this does give you the name in a way
that I think even BPF can use it. I also believe that memcopy on a
constant is faster than a strcpy.

-- Steve

Reply via email to