From: "NOMURA JUNICHI(野村 淳一)" <junichi.nomura@nec.com>
To: "bpf@vger.kernel.org" <bpf@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "ast@kernel.org" <ast@kernel.org>,
"daniel@iogearbox.net" <daniel@iogearbox.net>,
"toke@redhat.com" <toke@redhat.com>,
"NOMURA JUNICHI(野村 淳一)" <junichi.nomura@nec.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: [PATCH bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation
Date: Tue, 9 Feb 2021 08:24:52 +0000 [thread overview]
Message-ID: <20210209082451.GA44021@jeru.linux.bs1.fc.nec.co.jp> (raw)
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;
next reply other threads:[~2021-02-09 8:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 8:24 NOMURA JUNICHI(野村 淳一) [this message]
2021-02-12 23:17 ` [PATCH bpf] devmap: Use GFP_KERNEL for xdp bulk queue allocation Daniel Borkmann
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=20210209082451.GA44021@jeru.linux.bs1.fc.nec.co.jp \
--to=junichi.nomura@nec.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=toke@redhat.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).