Skip to contentSkip to conversation

trace event skb fix unassigned field

RFC PATCH Frederic Weisbecker 4 participants 7 messages Jan 4, 2011 – Jan 6, 2011 1 message not in the archive Tracing

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 13 lines · On Tue, Jan 04, 2011 at 06:46:06PM -0500, [email protected] wrote:

Acked- by: Neil Horman <[email protected]>

Sent from my Verizon Wireless Phone

----- Reply message -----
From: "Mathieu Desnoyers" <[email protected]>
Date: Tue, Jan 4, 2011 6:16 pm
Subject: [RFC patch 2/5] trace event skb fix unassigned field
To: "LKML" <[email protected]>
Cc: "Mathieu Desnoyers" <[email protected]>, "Steven Rostedt" <[email protected]>, "Frederic Weisbecker" <[email protected]>, "Ingo Molnar" <[email protected]>, "Neil Horman" <[email protected]>, "Thomas Gleixner" <[email protected]>

Quoted 3 lines

The field "protocol" in event kfree_skb is left unassigned if skb is NULL, leaving its trace output as garbage. Assign the value to 0 when skb is NULL instead.

Hm, if the skb is already null, we probably shouldn't send any trace.

What about using TP_CONDITION() ?

Quoted 28 lines
CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
CC Neil Horman <[email protected]>
CC Thomas Gleixner <[email protected]>
---
 include/trace/events/skb.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux-2.6-lttng/include/trace/events/skb.h
===================================================================

include/trace/events/skb.h +1 -3
@@ -25,9 +25,7 @@ TRACE_EVENT(kfree_skb,
 
 	TP_fast_assign(
 		__entry->skbaddr = skb;
-		if (skb) {
-			__entry->protocol = ntohs(skb->protocol);
-		}
+		__entry->protocol = skb ? ntohs(skb->protocol) : 0;
 		__entry->location = location;
 	),
 
#2 lore raw
Quoted 14 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 13 lines · On Tue, Jan 04, 2011 at 06:46:06PM -0500, [email protected] wrote:

Acked- by: Neil Horman <[email protected]>

Sent from my Verizon Wireless Phone

----- Reply message -----
From: "Mathieu Desnoyers" <[email protected]>
Date: Tue, Jan 4, 2011 6:16 pm
Subject: [RFC patch 2/5] trace event skb fix unassigned field
To: "LKML" <[email protected]>
Cc: "Mathieu Desnoyers" <[email protected]>, "Steven Rostedt" <[email protected]>, "Frederic Weisbecker" <[email protected]>, "Ingo Molnar" <[email protected]>, "Neil Horman" <[email protected]>, "Thomas Gleixner" <[email protected]>

Quoted 7 lines
Quoted 3 lines

The field "protocol" in event kfree_skb is left unassigned if skb is NULL, leaving its trace output as garbage. Assign the value to 0 when skb is NULL instead.

Hm, if the skb is already null, we probably shouldn't send any trace.

What about using TP_CONDITION() ?

Hrm, let's see. It's been introduced by commit
5cb3d1d9d34ac04bcaa2034139345b2a5fea54c1
by Zhaolei.

Event at the time of that commit, the only caller looked like:

void kfree_skb(struct sk_buff *skb)

{
        if (unlikely(!skb))
                return;
        if (likely(atomic_read(&skb->users) == 1))
                smp_rmb();
        else if (likely(!atomic_dec_and_test(&skb->users)))
                return;
        trace_kfree_skb(skb, __builtin_return_address(0));
        __kfree_skb(skb);
}

EXPORT_SYMBOL(kfree_skb);

So it already checks for a null pointer before calling the tracepoint. This leads me to wonder why why this check was added in the first place ?

Mathieu

Quoted 29 lines
Quoted 29 lines
CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
CC Neil Horman <[email protected]>
CC Thomas Gleixner <[email protected]>
---
 include/trace/events/skb.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux-2.6-lttng/include/trace/events/skb.h
===================================================================

include/trace/events/skb.h +1 -3
@@ -25,9 +25,7 @@ TRACE_EVENT(kfree_skb,
 
 	TP_fast_assign(
 		__entry->skbaddr = skb;
-		if (skb) {
-			__entry->protocol = ntohs(skb->protocol);
-		}
+		__entry->protocol = skb ? ntohs(skb->protocol) : 0;
 		__entry->location = location;
 	),
 
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
#3 lore raw
Quoted 40 lines · Mathieu Desnoyers
Quoted 14 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 13 lines · On Tue, Jan 04, 2011 at 06:46:06PM -0500, [email protected] wrote:

Acked- by: Neil Horman <[email protected]>

Sent from my Verizon Wireless Phone

----- Reply message -----
From: "Mathieu Desnoyers" <[email protected]>
Date: Tue, Jan 4, 2011 6:16 pm
Subject: [RFC patch 2/5] trace event skb fix unassigned field
To: "LKML" <[email protected]>
Cc: "Mathieu Desnoyers" <[email protected]>, "Steven Rostedt" <[email protected]>, "Frederic Weisbecker" <[email protected]>, "Ingo Molnar" <[email protected]>, "Neil Horman" <[email protected]>, "Thomas Gleixner" <[email protected]>

Quoted 7 lines
Quoted 3 lines

The field "protocol" in event kfree_skb is left unassigned if skb is NULL, leaving its trace output as garbage. Assign the value to 0 when skb is NULL instead.

Hm, if the skb is already null, we probably shouldn't send any trace.

What about using TP_CONDITION() ?

Hrm, let's see. It's been introduced by commit
5cb3d1d9d34ac04bcaa2034139345b2a5fea54c1
by Zhaolei.

Event at the time of that commit, the only caller looked like:

void kfree_skb(struct sk_buff *skb)

{
        if (unlikely(!skb))
                return;
        if (likely(atomic_read(&skb->users) == 1))
                smp_rmb();
        else if (likely(!atomic_dec_and_test(&skb->users)))
                return;
        trace_kfree_skb(skb, __builtin_return_address(0));
        __kfree_skb(skb);
}
Quoted 4 lines

EXPORT_SYMBOL(kfree_skb);

So it already checks for a null pointer before calling the tracepoint. This leads me to wonder why why this check was added in the first place ?

Likely for no strong reasons :)

So I guess we can remove the check from the tracepoint?

#4 lore raw
Quoted 43 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 42 lines · Mathieu Desnoyers
Quoted 14 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 13 lines · On Tue, Jan 04, 2011 at 06:46:06PM -0500, [email protected] wrote:

Acked- by: Neil Horman <[email protected]>

Sent from my Verizon Wireless Phone

----- Reply message -----
From: "Mathieu Desnoyers" <[email protected]>
Date: Tue, Jan 4, 2011 6:16 pm
Subject: [RFC patch 2/5] trace event skb fix unassigned field
To: "LKML" <[email protected]>
Cc: "Mathieu Desnoyers" <[email protected]>, "Steven Rostedt" <[email protected]>, "Frederic Weisbecker" <[email protected]>, "Ingo Molnar" <[email protected]>, "Neil Horman" <[email protected]>, "Thomas Gleixner" <[email protected]>

Quoted 7 lines
Quoted 3 lines

The field "protocol" in event kfree_skb is left unassigned if skb is NULL, leaving its trace output as garbage. Assign the value to 0 when skb is NULL instead.

Hm, if the skb is already null, we probably shouldn't send any trace.

What about using TP_CONDITION() ?

Hrm, let's see. It's been introduced by commit
5cb3d1d9d34ac04bcaa2034139345b2a5fea54c1
by Zhaolei.

Event at the time of that commit, the only caller looked like:

void kfree_skb(struct sk_buff *skb)

{
        if (unlikely(!skb))
                return;
        if (likely(atomic_read(&skb->users) == 1))
                smp_rmb();
        else if (likely(!atomic_dec_and_test(&skb->users)))
                return;
        trace_kfree_skb(skb, __builtin_return_address(0));
        __kfree_skb(skb);
}

EXPORT_SYMBOL(kfree_skb);

Quoted 6 lines
Quoted 2 lines

So it already checks for a null pointer before calling the tracepoint. This leads me to wonder why why this check was added in the first place ?

Likely for no strong reasons :)

So I guess we can remove the check from the tracepoint?

Yep, leading to this patch instead:

trace event skb remove duplicate null-pointer check

The check for NULL skb in the kfree_skb trace event is a duplicate from the check already done in its only caller, kfree_skb(). Remove this duplicate check.

CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Neil Horman <[email protected]>
---
 include/trace/events/skb.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
include/trace/events/skb.h +1 -3
Index: linux-2.6-lttng/include/trace/events/skb.h
===================================================================
@@ -25,9 +25,7 @@ TRACE_EVENT(kfree_skb,
 
 	TP_fast_assign(
 		__entry->skbaddr = skb;
-		if (skb) {
-			__entry->protocol = ntohs(skb->protocol);
-		}
+		__entry->protocol = ntohs(skb->protocol);
 		__entry->location = location;
 	),
 
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
Acked-by
#5 lore raw
Quoted 75 lines · Mathieu Desnoyers
Quoted 43 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 42 lines · Mathieu Desnoyers
Quoted 14 lines · * Frederic Weisbecker ([email protected]) wrote:
Quoted 13 lines · On Tue, Jan 04, 2011 at 06:46:06PM -0500, [email protected] wrote:

Acked- by: Neil Horman <[email protected]>

Sent from my Verizon Wireless Phone

----- Reply message -----
From: "Mathieu Desnoyers" <[email protected]>
Date: Tue, Jan 4, 2011 6:16 pm
Subject: [RFC patch 2/5] trace event skb fix unassigned field
To: "LKML" <[email protected]>
Cc: "Mathieu Desnoyers" <[email protected]>, "Steven Rostedt" <[email protected]>, "Frederic Weisbecker" <[email protected]>, "Ingo Molnar" <[email protected]>, "Neil Horman" <[email protected]>, "Thomas Gleixner" <[email protected]>

Quoted 7 lines
Quoted 3 lines

The field "protocol" in event kfree_skb is left unassigned if skb is NULL, leaving its trace output as garbage. Assign the value to 0 when skb is NULL instead.

Hm, if the skb is already null, we probably shouldn't send any trace.

What about using TP_CONDITION() ?

Hrm, let's see. It's been introduced by commit
5cb3d1d9d34ac04bcaa2034139345b2a5fea54c1
by Zhaolei.

Event at the time of that commit, the only caller looked like:

void kfree_skb(struct sk_buff *skb)

{
        if (unlikely(!skb))
                return;
        if (likely(atomic_read(&skb->users) == 1))
                smp_rmb();
        else if (likely(!atomic_dec_and_test(&skb->users)))
                return;
        trace_kfree_skb(skb, __builtin_return_address(0));
        __kfree_skb(skb);
}

EXPORT_SYMBOL(kfree_skb);

Quoted 6 lines
Quoted 2 lines

So it already checks for a null pointer before calling the tracepoint. This leads me to wonder why why this check was added in the first place ?

Likely for no strong reasons :)

So I guess we can remove the check from the tracepoint?

Yep, leading to this patch instead:

trace event skb remove duplicate null-pointer check

The check for NULL skb in the kfree_skb trace event is a duplicate from the check already done in its only caller, kfree_skb(). Remove this duplicate check.

CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Neil Horman <[email protected]>
---
 include/trace/events/skb.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux-2.6-lttng/include/trace/events/skb.h
===================================================================

include/trace/events/skb.h TRACE_EVENT(kfree_skb, · line 31

Quoted 10 lines
include/trace/events/skb.h +1 -3
@@ -25,9 +25,7 @@ TRACE_EVENT(kfree_skb,
 
 	TP_fast_assign(
 		__entry->skbaddr = skb;
-		if (skb) {
-			__entry->protocol = ntohs(skb->protocol);
-		}
+		__entry->protocol = ntohs(skb->protocol);
 		__entry->location = location;
 	),
 
Quoted 6 lines
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
#6 lore raw

* Neil Horman ([email protected]) wrote:
[...]

Quoted 21 lines
Quoted 21 lines

trace event skb remove duplicate null-pointer check

The check for NULL skb in the kfree_skb trace event is a duplicate from the check already done in its only caller, kfree_skb(). Remove this duplicate check.

CC Steven Rostedt <[email protected]>
CC Frederic Weisbecker <[email protected]>
CC Ingo Molnar <[email protected]>
CC Thomas Gleixner <[email protected]>
CC Neil Horman <[email protected]>
---
 include/trace/events/skb.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux-2.6-lttng/include/trace/events/skb.h
===================================================================

include/trace/events/skb.h +0 -0
@@ -25,9 +25,7 @@ TRACE_EVENT(kfree_skb,
 
Quoted 12 lines

include/trace/events/skb.h TRACE_EVENT(kfree_skb, · line 31

Quoted 11 lines
include/trace/events/skb.h +1 -3
 	TP_fast_assign(
 		__entry->skbaddr = skb;
-		if (skb) {
-			__entry->protocol = ntohs(skb->protocol);
-		}
+		__entry->protocol = ntohs(skb->protocol);
 		__entry->location = location;
 	),
 

Thanks!

Mathieu

Quoted 7 lines
Quoted 7 lines
Signature · 5 lines
-- 
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
Signature · 4 lines
Mathieu Desnoyers
Operating System Efficiency R&D Consultant
EfficiOS Inc.
http://www.efficios.com
maintainer
#7 lore raw
In reply to Neil Horman
Quoted 9 lines · Neil Horman
Quoted 7 lines

Yep, leading to this patch instead:

trace event skb remove duplicate null-pointer check

The check for NULL skb in the kfree_skb trace event is a duplicate from the check already done in its only caller, kfree_skb(). Remove this duplicate check.

Mathieu, can you repost this as a non-RFC patch, and include Neil's acked-by.

Thanks,

-- Steve