Skip to contentSkip to conversation

net: Handle threadirqs in __napi_schedule_irqoff

PATCH In review Sean Anderson 4 participants 8 messages Sep 13, 2024 – Sep 30, 2024

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

PATCH 1/1 net: Handle threadirqs in __napi_schedule_irqoff

The threadirqs kernel parameter can be used to force threaded IRQs even on non-PREEMPT_RT kernels. Use force_irqthreads to determine if we can skip disabling local interrupts. This defaults to false on regular kernels, and is always true on PREEMPT_RT kernels.

---

 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index 1e740faf9e78..112e871bc2b0 100644
@@ -6202,7 +6202,7 @@ EXPORT_SYMBOL(napi_schedule_prep);
  */
 void __napi_schedule_irqoff(struct napi_struct *n)
 {
-	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+	if (!force_irqthreads())
 		____napi_schedule(this_cpu_ptr(&softnet_data), n);
 	else
 		__napi_schedule(n);
Signature · 1 line
2.35.1.1320.gc452695387.dirty
#1 lore raw
Quoted 26 lines · Sean Anderson

The threadirqs kernel parameter can be used to force threaded IRQs even on non-PREEMPT_RT kernels. Use force_irqthreads to determine if we can skip disabling local interrupts. This defaults to false on regular kernels, and is always true on PREEMPT_RT kernels.

---

 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -2
index 1e740faf9e78..112e871bc2b0 100644
@@ -6202,7 +6202,7 @@ EXPORT_SYMBOL(napi_schedule_prep);
  */
 void __napi_schedule_irqoff(struct napi_struct *n)
 {
-       if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+       if (!force_irqthreads())
                ____napi_schedule(this_cpu_ptr(&softnet_data), n);
        else
                __napi_schedule(n);
--
Quoted 2 lines

2.35.1.1320.gc452695387.dirty

Seems reasonable, can you update the comment (kdoc) as well ?

It says :

* On PREEMPT_RT enabled kernels this maps to __napi_schedule()
* because the interrupt disabled assumption might not be true
* due to force-threaded interrupts and spinlock substitution.

Also always specify net or net-next for networking patches.

Thanks.

#2 lore raw
Quoted 32 lines · Eric Dumazet
Quoted 26 lines · Sean Anderson

The threadirqs kernel parameter can be used to force threaded IRQs even on non-PREEMPT_RT kernels. Use force_irqthreads to determine if we can skip disabling local interrupts. This defaults to false on regular kernels, and is always true on PREEMPT_RT kernels.

---

 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -2
index 1e740faf9e78..112e871bc2b0 100644
@@ -6202,7 +6202,7 @@ EXPORT_SYMBOL(napi_schedule_prep);
  */
 void __napi_schedule_irqoff(struct napi_struct *n)
 {
-       if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+       if (!force_irqthreads())
                ____napi_schedule(this_cpu_ptr(&softnet_data), n);
        else
                __napi_schedule(n);
--
Quoted 2 lines

2.35.1.1320.gc452695387.dirty

Seems reasonable, can you update the comment (kdoc) as well ?

Quoted 5 lines

It says :

* On PREEMPT_RT enabled kernels this maps to __napi_schedule()
* because the interrupt disabled assumption might not be true
* due to force-threaded interrupts and spinlock substitution.

OK

Quoted 1 line

Also always specify net or net-next for networking patches.

Ah, sorry. Should be net-next.

--Sean

#3 lore raw
Quoted 42 lines · Sean Anderson

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 32 lines · Eric Dumazet
Quoted 26 lines · Sean Anderson

The threadirqs kernel parameter can be used to force threaded IRQs even on non-PREEMPT_RT kernels. Use force_irqthreads to determine if we can skip disabling local interrupts. This defaults to false on regular kernels, and is always true on PREEMPT_RT kernels.

---

  net/core/dev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -2
index 1e740faf9e78..112e871bc2b0 100644
@@ -6202,7 +6202,7 @@ EXPORT_SYMBOL(napi_schedule_prep);
   */
  void __napi_schedule_irqoff(struct napi_struct *n)
  {
-       if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+       if (!force_irqthreads())
                 ____napi_schedule(this_cpu_ptr(&softnet_data), n);
         else
                 __napi_schedule(n);
--
Quoted 2 lines

2.35.1.1320.gc452695387.dirty

Seems reasonable, can you update the comment (kdoc) as well ?

Quoted 5 lines

It says :

* On PREEMPT_RT enabled kernels this maps to __napi_schedule()
* because the interrupt disabled assumption might not be true
* due to force-threaded interrupts and spinlock substitution.

Quoted 5 lines

OK

Quoted 1 line

Also always specify net or net-next for networking patches.

Ah, sorry. Should be net-next.

Is this worthy for a fixes/net tag?

Thanks,

Brett

Quoted 4 lines

--Sean

#4 lore raw
Quoted 45 lines · Brett Creeley
Quoted 42 lines · Sean Anderson

Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.

Quoted 37 lines · Eric Dumazet
Quoted 28 lines · Sean Anderson

The threadirqs kernel parameter can be used to force threaded IRQs even on non-PREEMPT_RT kernels. Use force_irqthreads to determine if we can skip disabling local interrupts. This defaults to false on regular kernels, and is always true on PREEMPT_RT kernels.

---

  net/core/dev.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
net/core/dev.c +1 -1
index 1e740faf9e78..112e871bc2b0 100644
@@ -6202,7 +6202,7 @@ EXPORT_SYMBOL(napi_schedule_prep);
   */
  void __napi_schedule_irqoff(struct napi_struct *n)
  {
-       if (!IS_ENABLED(CONFIG_PREEMPT_RT))
+       if (!force_irqthreads())
                 ____napi_schedule(this_cpu_ptr(&softnet_data), n);
         else
                 __napi_schedule(n);
Signature · 1 line
2.35.1.1320.gc452695387.dirty

Seems reasonable, can you update the comment (kdoc) as well ?

It says :

* On PREEMPT_RT enabled kernels this maps to __napi_schedule()
* because the interrupt disabled assumption might not be true
* due to force-threaded interrupts and spinlock substitution.

Quoted 7 lines
Quoted 5 lines

OK

Quoted 1 line

Also always specify net or net-next for networking patches.

Ah, sorry. Should be net-next.

Is this worthy for a fixes/net tag?

Maybe? Commit 8380c81d5c4f ("net: Treat __napi_schedule_irqoff() as __napi_schedule() on PREEMPT_RT") originally introduced the condition on PREEMPT_RT but didn't include any fixes. And that's probably because there's nothing wrong with the original behavior as long as you add IRQF_NO_THREAD to your interrupt. Although at the time threadirqs had existed for a while, so maybe this commit should fix that one.

--Sean

#5 lore raw
In reply to Sean Anderson
Quoted 4 lines · Sean Anderson

The threadirqs kernel parameter can be used to force threaded IRQs even on non-PREEMPT_RT kernels. Use force_irqthreads to determine if we can skip disabling local interrupts. This defaults to false on regular kernels, and is always true on PREEMPT_RT kernels.

Is this fixing a behaviour or is this from the clean up/ make it pretty category?
The forced-threaded interrupts run with disabled interrupts on !RT so this change should not fix anything.

Quoted 1 line

Sebastian

#6 lore raw
Quoted 8 lines · Sebastian Andrzej Siewior
Quoted 4 lines · Sean Anderson

The threadirqs kernel parameter can be used to force threaded IRQs even on non-PREEMPT_RT kernels. Use force_irqthreads to determine if we can skip disabling local interrupts. This defaults to false on regular kernels, and is always true on PREEMPT_RT kernels.

Is this fixing a behaviour or is this from the clean up/ make it pretty category?

It's in response to [1].

[1] https://lore.kernel.org/netdev/[email protected]/

Quoted 2 lines

The forced-threaded interrupts run with disabled interrupts on !RT so this change should not fix anything.

OK, so maybe this isn't necessary at all?

--Sean

#7 lore raw
Quoted 3 lines · Sean Anderson

It's in response to [1].

[1] https://lore.kernel.org/netdev/[email protected]/

thanks

Quoted 4 lines
Quoted 2 lines

The forced-threaded interrupts run with disabled interrupts on !RT so this change should not fix anything.

OK, so maybe this isn't necessary at all?

Based on your reasoning so far, yes, not needed.

Quoted 1 line

--Sean

Sebastian