* [PATCH net v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model
@ 2021-03-31 13:25 Ong Boon Leong
2021-03-31 13:38 ` Jesper Dangaard Brouer
2021-03-31 22:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Ong Boon Leong @ 2021-03-31 13:25 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, David S . Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Toshiaki Makita
Cc: netdev, bpf, linux-kernel, Ong Boon Leong
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
Changes in v2:
- This patch fixes the issue by making xdp_return_frame_no_direct() is
only called if napi_direct = true, as recommended for better by
Jesper Dangaard Brouer. Thanks!
Fixes: 2539650fadbf ("xdp: Helpers for disabling napi_direct of xdp_return_frame")
Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.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..858276e72c68 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 && xdp_return_frame_no_direct())
+ napi_direct = false;
page_pool_put_full_page(xa->page_pool, page, napi_direct);
rcu_read_unlock();
break;
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model
2021-03-31 13:25 [PATCH net v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Ong Boon Leong
@ 2021-03-31 13:38 ` Jesper Dangaard Brouer
2021-03-31 22:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Jesper Dangaard Brouer @ 2021-03-31 13:38 UTC (permalink / raw)
To: Ong Boon Leong
Cc: brouer, Alexei Starovoitov, Daniel Borkmann, David S . Miller,
Jakub Kicinski, Jesper Dangaard Brouer, John Fastabend,
Toshiaki Makita, netdev, bpf, linux-kernel
On Wed, 31 Mar 2021 21:25:03 +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
>
> Changes in v2:
> - This patch fixes the issue by making xdp_return_frame_no_direct() is
> only called if napi_direct = true, as recommended for better by
> Jesper Dangaard Brouer. Thanks!
>
> Fixes: 2539650fadbf ("xdp: Helpers for disabling napi_direct of xdp_return_frame")
> Signed-off-by: Ong Boon Leong <boon.leong.ong@intel.com>
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..858276e72c68 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 && xdp_return_frame_no_direct())
> + napi_direct = false;
> page_pool_put_full_page(xa->page_pool, page, napi_direct);
> rcu_read_unlock();
> break;
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model
2021-03-31 13:25 [PATCH net v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Ong Boon Leong
2021-03-31 13:38 ` Jesper Dangaard Brouer
@ 2021-03-31 22:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-03-31 22:20 UTC (permalink / raw)
To: Ong Boon Leong
Cc: ast, daniel, davem, kuba, hawk, john.fastabend, makita.toshiaki,
netdev, bpf, linux-kernel
Hello:
This patch was applied to netdev/net.git (refs/heads/master):
On Wed, 31 Mar 2021 21:25:03 +0800 you 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
>
> [...]
Here is the summary with links:
- [net,v2,1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model
https://git.kernel.org/netdev/net/c/622d13694b5f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-31 22:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-31 13:25 [PATCH net v2 1/1] xdp: fix xdp_return_frame() kernel BUG throw for page_pool memory model Ong Boon Leong
2021-03-31 13:38 ` Jesper Dangaard Brouer
2021-03-31 22:20 ` patchwork-bot+netdevbpf
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).