bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation
@ 2021-02-09  8:24 NOMURA JUNICHI(野村 淳一)
  2021-02-12 23:17 ` Daniel Borkmann
  0 siblings, 1 reply; 2+ messages in thread
From: NOMURA JUNICHI(野村 淳一) @ 2021-02-09  8:24 UTC (permalink / raw)
  To: bpf, netdev
  Cc: ast, daniel, toke,
	NOMURA JUNICHI(野村 淳一),
	linux-kernel

The devmap bulk queue is allocated with GFP_ATOMIC and the allocation may
fail if there is no available space in existing percpu pool.

Since commit 75ccae62cb8d42 ("xdp: Move devmap bulk queue into struct net_device")
moved the bulk queue allocation to NETDEV_REGISTER callback, whose context
is allowed to sleep, use GFP_KERNEL instead of GFP_ATOMIC to let percpu
allocator extend the pool when needed and avoid possible failure of netdev
registration.

As the required alignment is natural, we can simply use alloc_percpu().

Signed-off-by: Jun'ichi Nomura <junichi.nomura@nec.com>

diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index f6e9c68afdd4..f4d3fe8e0652 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -803,8 +803,7 @@ static int dev_map_notification(struct notifier_block *notifier,
 
 		/* will be freed in free_netdev() */
 		netdev->xdp_bulkq =
-			__alloc_percpu_gfp(sizeof(struct xdp_dev_bulk_queue),
-					   sizeof(void *), GFP_ATOMIC);
+			alloc_percpu(struct xdp_dev_bulk_queue);
 		if (!netdev->xdp_bulkq)
 			return NOTIFY_BAD;
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation
  2021-02-09  8:24 [PATCH bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation NOMURA JUNICHI(野村 淳一)
@ 2021-02-12 23:17 ` Daniel Borkmann
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Borkmann @ 2021-02-12 23:17 UTC (permalink / raw)
  To: NOMURA JUNICHI(野村 淳一), bpf, netdev
  Cc: ast, toke, linux-kernel

On 2/9/21 9:24 AM, NOMURA JUNICHI(野村 淳一) wrote:
> The devmap bulk queue is allocated with GFP_ATOMIC and the allocation may
> fail if there is no available space in existing percpu pool.
> 
> Since commit 75ccae62cb8d42 ("xdp: Move devmap bulk queue into struct net_device")
> moved the bulk queue allocation to NETDEV_REGISTER callback, whose context
> is allowed to sleep, use GFP_KERNEL instead of GFP_ATOMIC to let percpu
> allocator extend the pool when needed and avoid possible failure of netdev
> registration.
> 
> As the required alignment is natural, we can simply use alloc_percpu().
> 
> Signed-off-by: Jun'ichi Nomura <junichi.nomura@nec.com>

Applied, thanks!

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-02-12 23:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-09  8:24 [PATCH bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation NOMURA JUNICHI(野村 淳一)
2021-02-12 23:17 ` Daniel Borkmann

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).