Subject: Re: [PATCH net-next v2] net: add net cookie for trace_net_dev_xmit_timeout

From: Ido Schimmel <[email-masked]>
Date: Sun, 26 Oct 2025 17:13:39 +0200

On Fri, Oct 24, 2025 at 08:18:53PM +0800, Tonghao Zhang wrote:
> In a multi-network card or container environment, provide more information.

I suggest explaining that this is needed in order to differentiate
between trace events relating to net devices that exist in different
network namespaces and share the same name.

> 
> [002] ..s1.  1838.311662: net_dev_xmit_timeout: dev=eth0 driver=virtio_net queue=10 net_cookie=3
> [007] ..s1.  1839.335650: net_dev_xmit_timeout: dev=eth4 driver=virtio_net queue=10 net_cookie=4100
> [007] ..s1.  1844.455659: net_dev_xmit_timeout: dev=eth0 driver=virtio_net queue=10 net_cookie=3
> [007] ..s1.  1845.479663: net_dev_xmit_timeout: dev=eth4 driver=virtio_net queue=10 net_cookie=4100
> [002] ..s1.  1850.087647: net_dev_xmit_timeout: dev=eth0 driver=virtio_net queue=10 net_cookie=3
> 
> Cc: Eran Ben Elisha <[email-masked]>
> Cc: Jiri Pirko <[email-masked]>
> Cc: Cong Wang <[email-masked]>
> Cc: Ido Schimmel <[email-masked]>
> Cc: Jakub Kicinski <[email-masked]>
> Signed-off-by: Tonghao Zhang <[email-masked]>
> ---
> v2: use net cookie instead of ifindex.
> ---
>  include/trace/events/net.h | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/trace/events/net.h b/include/trace/events/net.h
> index d55162c12f90..8d064bf1ae7f 100644
> --- a/include/trace/events/net.h
> +++ b/include/trace/events/net.h
> @@ -107,16 +107,20 @@ TRACE_EVENT(net_dev_xmit_timeout,
>  		__string(	name,		dev->name	)
>  		__string(	driver,		netdev_drivername(dev))
>  		__field(	int,		queue_index	)
> +		__field(	u64,		net_cookie	)

Seems a bit random to only patch one trace event in this file. There are
other events that also print the net device name. I suggest patching
them as well.

>  	),
>  
>  	TP_fast_assign(
>  		__assign_str(name);
>  		__assign_str(driver);
>  		__entry->queue_index = queue_index;
> +		__entry->net_cookie = dev_net(dev)->net_cookie;
>  	),
>  
> -	TP_printk("dev=%s driver=%s queue=%d",
> -		__get_str(name), __get_str(driver), __entry->queue_index)
> +	TP_printk("dev=%s driver=%s queue=%d net_cookie=%llu",
> +		__get_str(name), __get_str(driver),
> +		__entry->queue_index,
> +		__entry->net_cookie)
>  );
>  
>  DECLARE_EVENT_CLASS(net_dev_template,
> -- 
> 2.34.1
>