* [PATCH net-next] net: add net cookie for net device trace events
@ 2025-10-28 4:32 Tonghao Zhang
2025-10-29 7:39 ` Ido Schimmel
2025-11-04 9:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Tonghao Zhang @ 2025-10-28 4:32 UTC (permalink / raw)
To: netdev
Cc: Tonghao Zhang, Eran Ben Elisha, Jiri Pirko, Cong Wang,
Jakub Kicinski, Eric Dumazet, Simon Horman, Paolo Abeni,
Ido Schimmel
In a multi-network card or container environment, 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.
for xmit_timeout trace events:
[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=eth0 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
[002] ..s1. 1850.087647: net_dev_xmit_timeout: dev=eth0 driver=virtio_net queue=10 net_cookie=3
Cc: Eran Ben Elisha <eranbe@mellanox.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Simon Horman <horms@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Suggested-by: Ido Schimmel <idosch@idosch.org>
Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
---
original patch: https://patchwork.kernel.org/project/netdevbpf/patch/20251024121853.94199-1-tonghao@bamaicloud.com/
---
include/trace/events/net.h | 37 +++++++++++++++++++++++++++----------
1 file changed, 27 insertions(+), 10 deletions(-)
diff --git a/include/trace/events/net.h b/include/trace/events/net.h
index d55162c12f90..fdd9ad474ce3 100644
--- a/include/trace/events/net.h
+++ b/include/trace/events/net.h
@@ -35,6 +35,7 @@ TRACE_EVENT(net_dev_start_xmit,
__field( u16, gso_size )
__field( u16, gso_segs )
__field( u16, gso_type )
+ __field( u64, net_cookie )
),
TP_fast_assign(
@@ -57,16 +58,18 @@ TRACE_EVENT(net_dev_start_xmit,
__entry->gso_size = skb_shinfo(skb)->gso_size;
__entry->gso_segs = skb_shinfo(skb)->gso_segs;
__entry->gso_type = skb_shinfo(skb)->gso_type;
+ __entry->net_cookie = dev_net(dev)->net_cookie;
),
- TP_printk("dev=%s queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d len=%u data_len=%u network_offset=%d transport_offset_valid=%d transport_offset=%d tx_flags=%d gso_size=%d gso_segs=%d gso_type=%#x",
+ TP_printk("dev=%s queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d len=%u data_len=%u network_offset=%d transport_offset_valid=%d transport_offset=%d tx_flags=%d gso_size=%d gso_segs=%d gso_type=%#x net_cookie=%llu",
__get_str(name), __entry->queue_mapping, __entry->skbaddr,
__entry->vlan_tagged, __entry->vlan_proto, __entry->vlan_tci,
__entry->protocol, __entry->ip_summed, __entry->len,
__entry->data_len,
__entry->network_offset, __entry->transport_offset_valid,
__entry->transport_offset, __entry->tx_flags,
- __entry->gso_size, __entry->gso_segs, __entry->gso_type)
+ __entry->gso_size, __entry->gso_segs,
+ __entry->gso_type, __entry->net_cookie)
);
TRACE_EVENT(net_dev_xmit,
@@ -83,17 +86,21 @@ TRACE_EVENT(net_dev_xmit,
__field( unsigned int, len )
__field( int, rc )
__string( name, dev->name )
+ __field( u64, net_cookie )
),
TP_fast_assign(
__entry->skbaddr = skb;
__entry->len = skb_len;
__entry->rc = rc;
+ __entry->net_cookie = dev_net(dev)->net_cookie;
__assign_str(name);
),
- TP_printk("dev=%s skbaddr=%p len=%u rc=%d",
- __get_str(name), __entry->skbaddr, __entry->len, __entry->rc)
+ TP_printk("dev=%s skbaddr=%p len=%u rc=%d net_cookie=%llu",
+ __get_str(name), __entry->skbaddr,
+ __entry->len, __entry->rc,
+ __entry->net_cookie)
);
TRACE_EVENT(net_dev_xmit_timeout,
@@ -107,16 +114,19 @@ TRACE_EVENT(net_dev_xmit_timeout,
__string( name, dev->name )
__string( driver, netdev_drivername(dev))
__field( int, queue_index )
+ __field( u64, net_cookie )
),
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,
@@ -129,16 +139,20 @@ DECLARE_EVENT_CLASS(net_dev_template,
__field( void *, skbaddr )
__field( unsigned int, len )
__string( name, skb->dev->name )
+ __field( u64, net_cookie )
),
TP_fast_assign(
__entry->skbaddr = skb;
__entry->len = skb->len;
+ __entry->net_cookie = dev_net(skb->dev)->net_cookie;
__assign_str(name);
),
- TP_printk("dev=%s skbaddr=%p len=%u",
- __get_str(name), __entry->skbaddr, __entry->len)
+ TP_printk("dev=%s skbaddr=%p len=%u net_cookie=%llu",
+ __get_str(name), __entry->skbaddr,
+ __entry->len,
+ __entry->net_cookie)
)
DEFINE_EVENT(net_dev_template, net_dev_queue,
@@ -188,6 +202,7 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
__field( unsigned char, nr_frags )
__field( u16, gso_size )
__field( u16, gso_type )
+ __field( u64, net_cookie )
),
TP_fast_assign(
@@ -214,16 +229,18 @@ DECLARE_EVENT_CLASS(net_dev_rx_verbose_template,
__entry->nr_frags = skb_shinfo(skb)->nr_frags;
__entry->gso_size = skb_shinfo(skb)->gso_size;
__entry->gso_type = skb_shinfo(skb)->gso_type;
+ __entry->net_cookie = dev_net(skb->dev)->net_cookie;
),
- TP_printk("dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x",
+ TP_printk("dev=%s napi_id=%#x queue_mapping=%u skbaddr=%p vlan_tagged=%d vlan_proto=0x%04x vlan_tci=0x%04x protocol=0x%04x ip_summed=%d hash=0x%08x l4_hash=%d len=%u data_len=%u truesize=%u mac_header_valid=%d mac_header=%d nr_frags=%d gso_size=%d gso_type=%#x net_cookie=%llu",
__get_str(name), __entry->napi_id, __entry->queue_mapping,
__entry->skbaddr, __entry->vlan_tagged, __entry->vlan_proto,
__entry->vlan_tci, __entry->protocol, __entry->ip_summed,
__entry->hash, __entry->l4_hash, __entry->len,
__entry->data_len, __entry->truesize,
__entry->mac_header_valid, __entry->mac_header,
- __entry->nr_frags, __entry->gso_size, __entry->gso_type)
+ __entry->nr_frags, __entry->gso_size,
+ __entry->gso_type, __entry->net_cookie)
);
DEFINE_EVENT(net_dev_rx_verbose_template, napi_gro_frags_entry,
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: add net cookie for net device trace events
2025-10-28 4:32 [PATCH net-next] net: add net cookie for net device trace events Tonghao Zhang
@ 2025-10-29 7:39 ` Ido Schimmel
2025-11-04 9:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2025-10-29 7:39 UTC (permalink / raw)
To: Tonghao Zhang
Cc: netdev, Eran Ben Elisha, Jiri Pirko, Cong Wang, Jakub Kicinski,
Eric Dumazet, Simon Horman, Paolo Abeni
On Tue, Oct 28, 2025 at 12:32:44PM +0800, Tonghao Zhang wrote:
> In a multi-network card or container environment, 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.
>
> for xmit_timeout trace events:
> [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=eth0 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
> [002] ..s1. 1850.087647: net_dev_xmit_timeout: dev=eth0 driver=virtio_net queue=10 net_cookie=3
>
> Cc: Eran Ben Elisha <eranbe@mellanox.com>
> Cc: Jiri Pirko <jiri@mellanox.com>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Simon Horman <horms@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Suggested-by: Ido Schimmel <idosch@idosch.org>
> Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: add net cookie for net device trace events
2025-10-28 4:32 [PATCH net-next] net: add net cookie for net device trace events Tonghao Zhang
2025-10-29 7:39 ` Ido Schimmel
@ 2025-11-04 9:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-04 9:10 UTC (permalink / raw)
To: Tonghao Zhang
Cc: netdev, eranbe, jiri, xiyou.wangcong, kuba, edumazet, horms,
pabeni, idosch
Hello:
This patch was applied to netdev/net-next.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Tue, 28 Oct 2025 12:32:44 +0800 you wrote:
> In a multi-network card or container environment, 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.
>
> for xmit_timeout trace events:
> [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=eth0 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
> [002] ..s1. 1850.087647: net_dev_xmit_timeout: dev=eth0 driver=virtio_net queue=10 net_cookie=3
>
> [...]
Here is the summary with links:
- [net-next] net: add net cookie for net device trace events
https://git.kernel.org/netdev/net-next/c/27cb3de7f43a
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-04 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-28 4:32 [PATCH net-next] net: add net cookie for net device trace events Tonghao Zhang
2025-10-29 7:39 ` Ido Schimmel
2025-11-04 9:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).