Skip to content

Commit

Permalink
tracing/net_sched: Fix tracepoints that save qdisc_dev() as a string
Browse files Browse the repository at this point in the history
I'm updating __assign_str() and will be removing the second parameter. To
make sure that it does not break anything, I make sure that it matches the
__string() field, as that is where the string is actually going to be
saved in. To make sure there's nothing that breaks, I added a WARN_ON() to
make sure that what was used in __string() is the same that is used in
__assign_str().

In doing this change, an error was triggered as __assign_str() now expects
the string passed in to be a char * value. I instead had the following
warning:

include/trace/events/qdisc.h: In function ‘trace_event_raw_event_qdisc_reset’:
include/trace/events/qdisc.h:91:35: error: passing argument 1 of 'strcmp' from incompatible pointer type [-Werror=incompatible-pointer-types]
   91 |                 __assign_str(dev, qdisc_dev(q));

That's because the qdisc_enqueue() and qdisc_reset() pass in qdisc_dev(q)
to __assign_str() and to __string(). But that function returns a pointer
to struct net_device and not a string.

It appears that these events are just saving the pointer as a string and
then reading it as a string as well.

Use qdisc_dev(q)->name to save the device instead.

Fixes: a34dac0 ("net_sched: add tracepoints for qdisc_reset() and qdisc_destroy()")
Signed-off-by: Steven Rostedt (Google) <[email protected]>
Reviewed-by: Jamal Hadi Salim <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
rostedt authored and davem330 committed Mar 4, 2024
1 parent 1c61728 commit 51270d5
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions include/trace/events/qdisc.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,14 @@ TRACE_EVENT(qdisc_reset,
TP_ARGS(q),

TP_STRUCT__entry(
__string( dev, qdisc_dev(q) )
__string( kind, q->ops->id )
__field( u32, parent )
__field( u32, handle )
__string( dev, qdisc_dev(q)->name )
__string( kind, q->ops->id )
__field( u32, parent )
__field( u32, handle )
),

TP_fast_assign(
__assign_str(dev, qdisc_dev(q));
__assign_str(dev, qdisc_dev(q)->name);
__assign_str(kind, q->ops->id);
__entry->parent = q->parent;
__entry->handle = q->handle;
Expand All @@ -106,14 +106,14 @@ TRACE_EVENT(qdisc_destroy,
TP_ARGS(q),

TP_STRUCT__entry(
__string( dev, qdisc_dev(q) )
__string( kind, q->ops->id )
__field( u32, parent )
__field( u32, handle )
__string( dev, qdisc_dev(q)->name )
__string( kind, q->ops->id )
__field( u32, parent )
__field( u32, handle )
),

TP_fast_assign(
__assign_str(dev, qdisc_dev(q));
__assign_str(dev, qdisc_dev(q)->name);
__assign_str(kind, q->ops->id);
__entry->parent = q->parent;
__entry->handle = q->handle;
Expand Down

0 comments on commit 51270d5

Please sign in to comment.