Skip to contentSkip to conversation

i40e: Fix preempt count leak in napi poll tracepoint

PATCH Thomas Gleixner 3 participants 6 messages Feb 7 – Feb 10

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Using get_cpu() in the tracepoint assignment causes an obvious preempt count leak because nothing invokes put_cpu() to undo it:

softirq: huh, entered softirq 3 NET_RX with preempt_count 00000100, exited with 00000101?

This clearly has seen a lot of testing in the last 3+ years...

Use smp_processor_id() instead.

Fixes 6d4d584a7ea8 ("i40e: Add i40e_napi_poll tracepoint")
Cc Tony Nguyen <[email protected]>
Cc Przemek Kitszel <[email protected]>
---
 drivers/net/ethernet/intel/i40e/i40e_trace.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_trace.h +1 -1
@@ -88,7 +88,7 @@ TRACE_EVENT(i40e_napi_poll,
 		__entry->rx_clean_complete = rx_clean_complete;
 		__entry->tx_clean_complete = tx_clean_complete;
 		__entry->irq_num = q->irq_num;
-		__entry->curr_cpu = get_cpu();
+		__entry->curr_cpu = smp_processor_id();
 		__assign_str(qname);
 		__assign_str(dev_name);
 		__assign_bitmask(irq_affinity, cpumask_bits(&q->affinity_mask),
Reviewed-by
#1 lore raw
Quoted 6 lines · Thomas Gleixner

Using get_cpu() in the tracepoint assignment causes an obvious preempt count leak because nothing invokes put_cpu() to undo it:

softirq: huh, entered softirq 3 NET_RX with preempt_count 00000100, exited with 00000101?

This clearly has seen a lot of testing in the last 3+ years...

I'm the author who introduced the bug. FWIW, I did use it quite a bit when I had i40e devices.

Quoted 1 line

Use smp_processor_id() instead.

Thanks.

Quoted 14 lines
Fixes 6d4d584a7ea8 ("i40e: Add i40e_napi_poll tracepoint")
Cc Tony Nguyen <[email protected]>
Cc Przemek Kitszel <[email protected]>
---
 drivers/net/ethernet/intel/i40e/i40e_trace.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

drivers/net/ethernet/intel/i40e/i40e_trace.h TRACE_EVENT(i40e_napi_poll, · line 94

Quoted 8 lines
drivers/net/ethernet/intel/i40e/i40e_trace.h +1 -1
@@ -88,7 +88,7 @@ TRACE_EVENT(i40e_napi_poll,
 		__entry->rx_clean_complete = rx_clean_complete;
 		__entry->tx_clean_complete = tx_clean_complete;
 		__entry->irq_num = q->irq_num;
-		__entry->curr_cpu = get_cpu();
+		__entry->curr_cpu = smp_processor_id();
 		__assign_str(qname);
 		__assign_str(dev_name);
 		__assign_bitmask(irq_affinity, cpumask_bits(&q->affinity_mask),
#2 lore raw
Quoted 10 lines · Joe Damato
Quoted 6 lines · Thomas Gleixner

Using get_cpu() in the tracepoint assignment causes an obvious preempt count leak because nothing invokes put_cpu() to undo it:

softirq: huh, entered softirq 3 NET_RX with preempt_count 00000100, exited with 00000101?

This clearly has seen a lot of testing in the last 3+ years...

I'm the author who introduced the bug. FWIW, I did use it quite a bit when I had i40e devices.

Right, but always with PREEMPT_NONE and no debug option which would enforce PREEMPT_COUNT ...

#3 lore raw
Quoted 8 lines · Thomas Gleixner
Quoted 6 lines · Joe Damato
Quoted 5 lines · Thomas Gleixner

Using get_cpu() in the tracepoint assignment causes an obvious preempt count leak because nothing invokes put_cpu() to undo it:

softirq: huh, entered softirq 3 NET_RX with preempt_count 00000100, exited with 00000101?

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

This clearly has seen a lot of testing in the last 3+ years...

I'm the author who introduced the bug. FWIW, I did use it quite a bit when I had i40e devices.

Right, but always with PREEMPT_NONE and no debug option which would enforce PREEMPT_COUNT ...

Forgot to mention that's what is required before submitting patches according to Documentation/process/submit-checklist.rst

But who cares about documentation aside of the people who write it?

Thanks,

tglx

#4 lore raw
Quoted 11 lines · Thomas Gleixner
Quoted 10 lines · Thomas Gleixner
Quoted 8 lines · Joe Damato
Quoted 6 lines · Thomas Gleixner

Using get_cpu() in the tracepoint assignment causes an obvious preempt count leak because nothing invokes put_cpu() to undo it:

softirq: huh, entered softirq 3 NET_RX with preempt_count 00000100, exited with 00000101?

This clearly has seen a lot of testing in the last 3+ years...

Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

I'm the author who introduced the bug. FWIW, I did use it quite a bit when I had i40e devices.

Right, but always with PREEMPT_NONE and no debug option which would enforce PREEMPT_COUNT ...

Forgot to mention that's what is required before submitting patches according to Documentation/process/submit-checklist.rst

This is a very helpful reply, thanks!

Quoted 1 line

But who cares about documentation aside of the people who write it?

I've written a lot of documentation, too, but sometimes people just make mistakes.

- Joe

#5 lore raw
In reply to Thomas Gleixner
Quoted 43 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Thomas Gleixner
Sent: Saturday, February 7, 2026 11:50 AM
To: [email protected]
Cc: Nguyen, Anthony L <[email protected]>; Kitszel, Przemyslaw <[email protected]>; [email protected]
Subject: [Intel-wired-lan] i40e: Fix preempt count leak in napi poll tracepoint

Using get_cpu() in the tracepoint assignment causes an obvious preempt count leak because nothing invokes put_cpu() to undo it:

softirq: huh, entered softirq 3 NET_RX with preempt_count 00000100,
exited with 00000101?

This clearly has seen a lot of testing in the last 3+ years...

Use smp_processor_id() instead.

Fixes 6d4d584a7ea8 ("i40e: Add i40e_napi_poll tracepoint")
Cc Tony Nguyen <[email protected]>
Cc Przemek Kitszel <[email protected]>
---
 drivers/net/ethernet/intel/i40e/i40e_trace.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/i40e/i40e_trace.h +1 -1
@@ -88,7 +88,7 @@ TRACE_EVENT(i40e_napi_poll,
 		__entry->rx_clean_complete = rx_clean_complete;
 		__entry->tx_clean_complete = tx_clean_complete;
 		__entry->irq_num = q->irq_num;
-		__entry->curr_cpu = get_cpu();
+		__entry->curr_cpu = smp_processor_id();
 		__assign_str(qname);
 		__assign_str(dev_name);
 		__assign_bitmask(irq_affinity, cpumask_bits(&q-
Quoted 1 line
Quoted 1 line

affinity_mask),