diff mbox series

[bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation

Message ID 20210209082451.GA44021@jeru.linux.bs1.fc.nec.co.jp (mailing list archive)
State Accepted
Delegated to: BPF
Headers show
Series [bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for bpf
netdev/subject_prefix success Link
netdev/cc_maintainers warning 9 maintainers not CCed: yhs@fb.com hawk@kernel.org davem@davemloft.net kafai@fb.com songliubraving@fb.com kpsingh@kernel.org john.fastabend@gmail.com kuba@kernel.org andrii@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 1 this patch: 1
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch warning WARNING: From:/Signed-off-by: email name mismatch: 'From: "NOMURA JUNICHI(野村 淳=?UTF-8?q?=E4=B8=80=29?=" <junichi.nomura@nec.com>' != 'Signed-off-by: Jun'ichi Nomura <junichi.nomura@nec.com>'
netdev/build_allmodconfig_warn success Errors and warnings before: 1 this patch: 1
netdev/header_inline success Link
netdev/stable success Stable not CCed

Commit Message

NOMURA JUNICHI(野村 淳一) Feb. 9, 2021, 8:24 a.m. UTC
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>

Comments

Daniel Borkmann Feb. 12, 2021, 11:17 p.m. UTC | #1
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!
diff mbox series

Patch

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;