From: Eric Dumazet <edumazet@google.com>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: David Miller <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
linmiaohe <linmiaohe@huawei.com>,
martin.varghese@nokia.com, Florian Westphal <fw@strlen.de>,
Davide Caratti <dcaratti@redhat.com>,
Steffen Klassert <steffen.klassert@secunet.com>,
Paolo Abeni <pabeni@redhat.com>,
kyk.segfault@gmail.com, Saeed Mahameed <saeed@kernel.org>,
netdev <netdev@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
linuxarm@huawei.com
Subject: Re: [PATCH net-next] net: use in_softirq() to indicate the NAPI context in napi_consume_skb()
Date: Mon, 21 Sep 2020 09:19:20 +0200 [thread overview]
Message-ID: <CANn89iLHH=CRzz5tavy_KEg0mhgXkhD9DBfh9bhcqSkcZ2xaaA@mail.gmail.com> (raw)
In-Reply-To: <1600653893-206277-1-git-send-email-linyunsheng@huawei.com>
On Mon, Sep 21, 2020 at 4:08 AM Yunsheng Lin <linyunsheng@huawei.com> wrote:
>
> When napi_consume_skb() is called in the tx desc cleaning process,
> it is usually in the softirq context(BH disabled, or are processing
> softirqs), but it may also be in the task context, such as in the
> netpoll or loopback selftest process.
>
> Currently napi_consume_skb() uses non-zero budget to indicate the
> NAPI context, the driver writer may provide the wrong budget when
> tx desc cleaning function is reused for both NAPI and non-NAPI
> context, see [1].
>
> So this patch uses in_softirq() to indicate the NAPI context, which
> doesn't necessarily mean in NAPI context, but it shouldn't care if
> NAPI context or not as long as it runs in softirq context or with BH
> disabled, then _kfree_skb_defer() will push the skb to the particular
> cpu' napi_alloc_cache atomically.
>
> [1] https://lkml.org/lkml/2020/9/15/38
>
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
> ---
> note that budget parameter is not removed in this patch because it
> involves many driver changes, we can remove it in separate patch if
> this patch is accepted.
> ---
> net/core/skbuff.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index e077447..03d0d28 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -895,8 +895,10 @@ void __kfree_skb_defer(struct sk_buff *skb)
>
> void napi_consume_skb(struct sk_buff *skb, int budget)
> {
> - /* Zero budget indicate non-NAPI context called us, like netpoll */
> - if (unlikely(!budget)) {
> + /* called by non-softirq context, which usually means non-NAPI
> + * context, like netpoll.
> + */
> + if (unlikely(!in_softirq())) {
> dev_consume_skb_any(skb);
> return;
> }
> --
I do not think we should add this kind of fuzzy logic, just because
_one_ driver author made a mistake.
Add a disable_bh() in the driver slow path, and accept the _existing_
semantic, the one that was understood by dozens.
next prev parent reply other threads:[~2020-09-21 7:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-21 2:04 [PATCH net-next] net: use in_softirq() to indicate the NAPI context in napi_consume_skb() Yunsheng Lin
2020-09-21 7:19 ` Eric Dumazet [this message]
2020-09-21 8:09 ` Yunsheng Lin
2020-09-21 8:17 ` Eric Dumazet
2020-09-21 8:40 ` Yunsheng Lin
2020-09-21 9:09 ` Eric Dumazet
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='CANn89iLHH=CRzz5tavy_KEg0mhgXkhD9DBfh9bhcqSkcZ2xaaA@mail.gmail.com' \
--to=edumazet@google.com \
--cc=davem@davemloft.net \
--cc=dcaratti@redhat.com \
--cc=fw@strlen.de \
--cc=kuba@kernel.org \
--cc=kyk.segfault@gmail.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=linyunsheng@huawei.com \
--cc=martin.varghese@nokia.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeed@kernel.org \
--cc=steffen.klassert@secunet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).