From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Jesper Dangaard Brouer <brouer@redhat.com>,
Ong Boon Leong <boon.leong.ong@intel.com>
Cc: brouer@redhat.com, Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
"David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Toshiaki Makita <makita.toshiaki@lab.ntt.co.jp>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model
Date: Mon, 29 Mar 2021 18:25:08 +0200 [thread overview]
Message-ID: <87lfa6rkpn.fsf@toke.dk> (raw)
In-Reply-To: <20210329170209.6db77c3d@carbon>
Jesper Dangaard Brouer <brouer@redhat.com> writes:
> On Mon, 29 Mar 2021 16:00:39 +0800
> Ong Boon Leong <boon.leong.ong@intel.com> wrote:
>
>> xdp_return_frame() may be called outside of NAPI context to return
>> xdpf back to page_pool. xdp_return_frame() calls __xdp_return() with
>> napi_direct = false. For page_pool memory model, __xdp_return() calls
>> xdp_return_frame_no_direct() unconditionally and below false negative
>> kernel BUG throw happened under preempt-rt build:
>>
>> [ 430.450355] BUG: using smp_processor_id() in preemptible [00000000] code: modprobe/3884
>> [ 430.451678] caller is __xdp_return+0x1ff/0x2e0
>> [ 430.452111] CPU: 0 PID: 3884 Comm: modprobe Tainted: G U E 5.12.0-rc2+ #45
>>
>> So, this patch fixes the issue by adding "if (napi_direct)" condition
>> to skip calling xdp_return_frame_no_direct() if napi_direct = false.
>>
>> Fixes: 2539650fadbf ("xdp: Helpers for disabling napi_direct of xdp_return_frame")
>> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
>> ---
>
> This looks correct to me.
>
> Acked-by: Jesper Dangaard Brouer <brouer@redhat.com>
>
>
>> net/core/xdp.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/net/core/xdp.c b/net/core/xdp.c
>> index 05354976c1fc..4eaa28972af2 100644
>> --- a/net/core/xdp.c
>> +++ b/net/core/xdp.c
>> @@ -350,7 +350,8 @@ static void __xdp_return(void *data, struct xdp_mem_info *mem, bool napi_direct,
>> /* mem->id is valid, checked in xdp_rxq_info_reg_mem_model() */
>> xa = rhashtable_lookup(mem_id_ht, &mem->id, mem_id_rht_params);
>> page = virt_to_head_page(data);
>> - napi_direct &= !xdp_return_frame_no_direct();
>> + if (napi_direct)
>> + napi_direct &= !xdp_return_frame_no_direct();
>
> if (napi_direct && xdp_return_frame_no_direct())
> napi_direct = false;
>
> I wonder if this code would be easier to understand?
Yes, IMO it would! :)
-Toke
next prev parent reply other threads:[~2021-03-29 16:26 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-29 8:00 [PATCH net 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Ong Boon Leong
2021-03-29 15:02 ` Jesper Dangaard Brouer
2021-03-29 16:25 ` Toke Høiland-Jørgensen [this message]
2021-03-31 12:59 ` Ong, Boon Leong
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=87lfa6rkpn.fsf@toke.dk \
--to=toke@redhat.com \
--cc=ast@kernel.org \
--cc=boon.leong.ong@intel.com \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=makita.toshiaki@lab.ntt.co.jp \
--cc=netdev@vger.kernel.org \
/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).