Skip to contentSkip to conversation

net: tracepoint: fix print wrong sysctl_mem value

PATCH Superseded Dust Li 2 participants 3 messages Sep 7, 2020 – Sep 8, 2020

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Dust Li

author
#0 lore raw

PATCH 1/1 net: tracepoint: fix print wrong sysctl_mem value

sysctl_mem is an point, and tracepoint entry do not support been visited like an array. Use 3 long type to get sysctl_mem instead.

tracpoint output with and without this fix:
- without fix:
28821.074 sock:sock_exceed_buf_limit:proto:UDP sysctl_mem=-1741233440,19,322156906942464 allocated=19 sysctl_rmem=4096 rmem_alloc=75008 sysctl_wmem=4096 wmem_alloc=1 wmem_queued=0 kind=SK_MEM_RECV

- with fix:
2126.136 sock:sock_exceed_buf_limit:proto:UDP sysctl_mem=18,122845,184266 allocated=19 sysctl_rmem=4096 rmem_alloc=73728 sysctl_wmem=4096 wmem_alloc=1 wmem_queued=0 kind=SK_MEM_RECV

Fixes 3847ce32aea9fdf ("core: add tracepoints for queueing skb to rcvbuf")
---
 include/trace/events/sock.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
include/trace/events/sock.h +9 -5
index a966d4b5ab37..9118dd2353b7 100644
@@ -98,7 +98,9 @@ TRACE_EVENT(sock_exceed_buf_limit,
 
 	TP_STRUCT__entry(
 		__array(char, name, 32)
-		__field(long *, sysctl_mem)
+		__field(long, sysctl_mem0)
+		__field(long, sysctl_mem1)
+		__field(long, sysctl_mem2)
 		__field(long, allocated)
 		__field(int, sysctl_rmem)
 		__field(int, rmem_alloc)
@@ -110,7 +112,9 @@ TRACE_EVENT(sock_exceed_buf_limit,
 
 	TP_fast_assign(
 		strncpy(__entry->name, prot->name, 32);
-		__entry->sysctl_mem = prot->sysctl_mem;
+		__entry->sysctl_mem0 = prot->sysctl_mem[0];
+		__entry->sysctl_mem1 = prot->sysctl_mem[1];
+		__entry->sysctl_mem2 = prot->sysctl_mem[2];
 		__entry->allocated = allocated;
 		__entry->sysctl_rmem = sk_get_rmem0(sk, prot);
 		__entry->rmem_alloc = atomic_read(&sk->sk_rmem_alloc);
@@ -122,9 +126,9 @@ TRACE_EVENT(sock_exceed_buf_limit,
 
 	TP_printk("proto:%s sysctl_mem=%ld,%ld,%ld allocated=%ld sysctl_rmem=%d rmem_alloc=%d sysctl_wmem=%d wmem_alloc=%d wmem_queued=%d kind=%s",
 		__entry->name,
-		__entry->sysctl_mem[0],
-		__entry->sysctl_mem[1],
-		__entry->sysctl_mem[2],
+		__entry->sysctl_mem0,
+		__entry->sysctl_mem1,
+		__entry->sysctl_mem2,
 		__entry->allocated,
 		__entry->sysctl_rmem,
 		__entry->rmem_alloc,
Signature · 1 line
2.19.1.3.ge56e4f7
maintainer
#1 lore raw
Quoted 28 lines · On Mon, 7 Sep 2020 22:47:57 +0800 Dust Li wrote:

sysctl_mem is an point, and tracepoint entry do not support been visited like an array. Use 3 long type to get sysctl_mem instead.

tracpoint output with and without this fix:
- without fix:

   28821.074 sock:sock_exceed_buf_limit:proto:UDP
   sysctl_mem=-1741233440,19,322156906942464 allocated=19 sysctl_rmem=4096
   rmem_alloc=75008 sysctl_wmem=4096 wmem_alloc=1 wmem_queued=0
   kind=SK_MEM_RECV

- with fix:
2126.136 sock:sock_exceed_buf_limit:proto:UDP sysctl_mem=18,122845,184266 allocated=19 sysctl_rmem=4096 rmem_alloc=73728 sysctl_wmem=4096 wmem_alloc=1 wmem_queued=0 kind=SK_MEM_RECV

Fixes 3847ce32aea9fdf ("core: add tracepoints for queueing skb to rcvbuf")
---
 include/trace/events/sock.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
include/trace/events/sock.h +0 -0
index a966d4b5ab37..9118dd2353b7 100644

include/trace/events/sock.h TRACE_EVENT(sock_exceed_buf_limit, · line 103

Quoted 7 lines
include/trace/events/sock.h +3 -1
@@ -98,7 +98,9 @@ TRACE_EVENT(sock_exceed_buf_limit,
 
 	TP_STRUCT__entry(
 		__array(char, name, 32)
-		__field(long *, sysctl_mem)
+		__field(long, sysctl_mem0)
+		__field(long, sysctl_mem1)
+		__field(long, sysctl_mem2)

Why not make it an __array() ?

Quoted 3 lines
include/trace/events/sock.h +0 -0
 		__field(long, allocated)
 		__field(int, sysctl_rmem)
 		__field(int, rmem_alloc)
author
#2 lore raw
Quoted 30 lines · Jakub Kicinski
Quoted 29 lines · On Mon, 7 Sep 2020 22:47:57 +0800 Dust Li wrote:

sysctl_mem is an point, and tracepoint entry do not support been visited like an array. Use 3 long type to get sysctl_mem instead.

tracpoint output with and without this fix:
- without fix:

   28821.074 sock:sock_exceed_buf_limit:proto:UDP
   sysctl_mem=-1741233440,19,322156906942464 allocated=19 sysctl_rmem=4096
   rmem_alloc=75008 sysctl_wmem=4096 wmem_alloc=1 wmem_queued=0
   kind=SK_MEM_RECV

- with fix:
2126.136 sock:sock_exceed_buf_limit:proto:UDP sysctl_mem=18,122845,184266 allocated=19 sysctl_rmem=4096 rmem_alloc=73728 sysctl_wmem=4096 wmem_alloc=1 wmem_queued=0 kind=SK_MEM_RECV

Fixes 3847ce32aea9fdf ("core: add tracepoints for queueing skb to rcvbuf")
---
 include/trace/events/sock.h | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
include/trace/events/sock.h +0 -0
index a966d4b5ab37..9118dd2353b7 100644
@@ -98,7 +98,9 @@ TRACE_EVENT(sock_exceed_buf_limit,
 
Quoted 8 lines

include/trace/events/sock.h TRACE_EVENT(sock_exceed_buf_limit, · line 103

Quoted 6 lines
include/trace/events/sock.h +3 -1
 	TP_STRUCT__entry(
 		__array(char, name, 32)
-		__field(long *, sysctl_mem)
+		__field(long, sysctl_mem0)
+		__field(long, sysctl_mem1)
+		__field(long, sysctl_mem2)

Why not make it an __array() ?

Yeah, it's better using an __array(), I will send a v2. Thanks !

Quoted 4 lines
Quoted 4 lines
include/trace/events/sock.h +0 -0
 		__field(long, allocated)
 		__field(int, sysctl_rmem)
 		__field(int, rmem_alloc)