From: Heiner Kallweit <hkallweit1@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: Alexandre Torgue <alexandre.torgue@st.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com,
Eric Dumazet <edumazet@google.com>,
Jose Abreu <joabreu@synopsys.com>,
John Keeping <john@metanate.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
"David S. Miller" <davem@davemloft.net>,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] net: stmmac: Don't call _irqoff() with hardirqs enabled
Date: Sun, 11 Oct 2020 15:42:24 +0200 [thread overview]
Message-ID: <04d10b06-ca1c-3bfa-0a5f-730a9c8a2744@gmail.com> (raw)
In-Reply-To: <20201010082248.22cc7656@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On 10.10.2020 17:22, Jakub Kicinski wrote:
> On Sat, 10 Oct 2020 15:08:15 +0200 Heiner Kallweit wrote:
>> On 09.10.2020 18:06, Heiner Kallweit wrote:
>>> On 09.10.2020 17:58, Jakub Kicinski wrote:
>>>> On Fri, 9 Oct 2020 16:54:06 +0200 Heiner Kallweit wrote:
>>>>> I'm thinking about a __napi_schedule version that disables hard irq's
>>>>> conditionally, based on variable force_irqthreads, exported by the irq
>>>>> subsystem. This would allow to behave correctly with threadirqs set,
>>>>> whilst not loosing the _irqoff benefit with threadirqs unset.
>>>>> Let me come up with a proposal.
>>>>
>>>> I think you'd need to make napi_schedule_irqoff() behave like that,
>>>> right? Are there any uses of napi_schedule_irqoff() that are disabling
>>>> irqs and not just running from an irq handler?
>>>>
>>> Right, the best approach depends on the answer to the latter question.
>>> I didn't check this yet, therefore I described the least intrusive approach.
>>>
>>
>> With some help from coccinelle I identified the following functions that
>> call napi_schedule_irqoff() or __napi_schedule_irqoff() and do not run
>> from an irq handler (at least not at the first glance).
>>
>> dpaa2_caam_fqdan_cb
>> qede_simd_fp_handler
>> mlx4_en_rx_irq
>> mlx4_en_tx_irq
>
> Don't know the others but FWIW the mlx4 ones run from an IRQ handler,
> AFAICT:
>
> static irqreturn_t mlx4_interrupt(int irq, void *dev_ptr)
> static irqreturn_t mlx4_msi_x_interrupt(int irq, void *eq_ptr)
> mlx4_eq_int()
> mlx4_cq_completion
> cq->comp()
>
>> qeth_qdio_poll
>> netvsc_channel_cb
>> napi_watchdog
>
> This one runs from a hrtimer, which I believe will be a hard irq
> context on anything but RT. I could be wrong.
>
Typically forced irq threading will not be enabled, therefore going
back to use napi_schedule() in drivers in most cases will cause
losing the benefit of the irqoff version. Something like the following
should be better. Only small drawback I see is that in case of forced
irq threading hrtimers will still run in hardirq context and we lose
the benefit of the irqoff version in napi_watchdog().
diff --git a/net/core/dev.c b/net/core/dev.c
index a146bac84..7d18560b2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6393,7 +6393,11 @@ EXPORT_SYMBOL(napi_schedule_prep);
*/
void __napi_schedule_irqoff(struct napi_struct *n)
{
- ____napi_schedule(this_cpu_ptr(&softnet_data), n);
+ /* hard irqs may not be masked in case of forced irq threading */
+ if (force_irqthreads)
+ __napi_schedule(n);
+ else
+ ____napi_schedule(this_cpu_ptr(&softnet_data), n);
}
EXPORT_SYMBOL(__napi_schedule_irqoff);
--
2.28.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
WARNING: multiple messages have this Message-ID (diff)
From: Heiner Kallweit <hkallweit1@gmail.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: John Keeping <john@metanate.com>,
netdev@vger.kernel.org,
Giuseppe Cavallaro <peppe.cavallaro@st.com>,
Alexandre Torgue <alexandre.torgue@st.com>,
Jose Abreu <joabreu@synopsys.com>,
"David S. Miller" <davem@davemloft.net>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
linux-stm32@st-md-mailman.stormreply.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Eric Dumazet <edumazet@google.com>
Subject: Re: [PATCH] net: stmmac: Don't call _irqoff() with hardirqs enabled
Date: Sun, 11 Oct 2020 15:42:24 +0200 [thread overview]
Message-ID: <04d10b06-ca1c-3bfa-0a5f-730a9c8a2744@gmail.com> (raw)
In-Reply-To: <20201010082248.22cc7656@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>
On 10.10.2020 17:22, Jakub Kicinski wrote:
> On Sat, 10 Oct 2020 15:08:15 +0200 Heiner Kallweit wrote:
>> On 09.10.2020 18:06, Heiner Kallweit wrote:
>>> On 09.10.2020 17:58, Jakub Kicinski wrote:
>>>> On Fri, 9 Oct 2020 16:54:06 +0200 Heiner Kallweit wrote:
>>>>> I'm thinking about a __napi_schedule version that disables hard irq's
>>>>> conditionally, based on variable force_irqthreads, exported by the irq
>>>>> subsystem. This would allow to behave correctly with threadirqs set,
>>>>> whilst not loosing the _irqoff benefit with threadirqs unset.
>>>>> Let me come up with a proposal.
>>>>
>>>> I think you'd need to make napi_schedule_irqoff() behave like that,
>>>> right? Are there any uses of napi_schedule_irqoff() that are disabling
>>>> irqs and not just running from an irq handler?
>>>>
>>> Right, the best approach depends on the answer to the latter question.
>>> I didn't check this yet, therefore I described the least intrusive approach.
>>>
>>
>> With some help from coccinelle I identified the following functions that
>> call napi_schedule_irqoff() or __napi_schedule_irqoff() and do not run
>> from an irq handler (at least not at the first glance).
>>
>> dpaa2_caam_fqdan_cb
>> qede_simd_fp_handler
>> mlx4_en_rx_irq
>> mlx4_en_tx_irq
>
> Don't know the others but FWIW the mlx4 ones run from an IRQ handler,
> AFAICT:
>
> static irqreturn_t mlx4_interrupt(int irq, void *dev_ptr)
> static irqreturn_t mlx4_msi_x_interrupt(int irq, void *eq_ptr)
> mlx4_eq_int()
> mlx4_cq_completion
> cq->comp()
>
>> qeth_qdio_poll
>> netvsc_channel_cb
>> napi_watchdog
>
> This one runs from a hrtimer, which I believe will be a hard irq
> context on anything but RT. I could be wrong.
>
Typically forced irq threading will not be enabled, therefore going
back to use napi_schedule() in drivers in most cases will cause
losing the benefit of the irqoff version. Something like the following
should be better. Only small drawback I see is that in case of forced
irq threading hrtimers will still run in hardirq context and we lose
the benefit of the irqoff version in napi_watchdog().
diff --git a/net/core/dev.c b/net/core/dev.c
index a146bac84..7d18560b2 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -6393,7 +6393,11 @@ EXPORT_SYMBOL(napi_schedule_prep);
*/
void __napi_schedule_irqoff(struct napi_struct *n)
{
- ____napi_schedule(this_cpu_ptr(&softnet_data), n);
+ /* hard irqs may not be masked in case of forced irq threading */
+ if (force_irqthreads)
+ __napi_schedule(n);
+ else
+ ____napi_schedule(this_cpu_ptr(&softnet_data), n);
}
EXPORT_SYMBOL(__napi_schedule_irqoff);
--
2.28.0
next prev parent reply other threads:[~2020-10-11 13:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-08 16:27 [PATCH] net: stmmac: Don't call _irqoff() with hardirqs enabled John Keeping
2020-10-08 16:27 ` John Keeping
2020-10-08 23:46 ` Vladimir Oltean
2020-10-08 23:46 ` Vladimir Oltean
2020-10-09 9:59 ` John Keeping
2020-10-09 9:59 ` John Keeping
2020-10-09 10:12 ` Vladimir Oltean
2020-10-09 10:12 ` Vladimir Oltean
2020-10-09 14:54 ` Heiner Kallweit
2020-10-09 14:54 ` Heiner Kallweit
2020-10-09 15:58 ` Jakub Kicinski
2020-10-09 15:58 ` Jakub Kicinski
2020-10-09 16:06 ` Heiner Kallweit
2020-10-09 16:06 ` Heiner Kallweit
2020-10-10 13:08 ` Heiner Kallweit
2020-10-10 13:08 ` Heiner Kallweit
2020-10-10 15:22 ` Jakub Kicinski
2020-10-10 15:22 ` Jakub Kicinski
2020-10-11 9:24 ` Heiner Kallweit
2020-10-11 9:24 ` Heiner Kallweit
2020-10-11 16:06 ` Jakub Kicinski
2020-10-11 16:06 ` Jakub Kicinski
2020-10-11 13:42 ` Heiner Kallweit [this message]
2020-10-11 13:42 ` Heiner Kallweit
2020-10-11 15:56 ` Jakub Kicinski
2020-10-11 15:56 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=04d10b06-ca1c-3bfa-0a5f-730a9c8a2744@gmail.com \
--to=hkallweit1@gmail.com \
--cc=alexandre.torgue@st.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=joabreu@synopsys.com \
--cc=john@metanate.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=peppe.cavallaro@st.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.