From: Anand Kumar Shaw <anandkrshawheritage@gmail.com>
To: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net,
hawk@kernel.org, john.fastabend@gmail.com, kuba@kernel.org,
davem@davemloft.net, sdf@fomichev.me, andrii@kernel.org,
martin.lau@linux.dev,
Anand Kumar Shaw <anandkrshawheritage@gmail.com>
Subject: [PATCH] bpf: devmap: hoist loop-invariant xdp buff pointer setup
Date: Mon, 16 Feb 2026 20:23:06 +0530 [thread overview]
Message-ID: <20260216145306.96108-1-anandkrshawheritage@gmail.com> (raw)
In dev_map_bpf_prog_run(), xdp.txq and xdp.rxq are assigned the same
stack-local pointers on every iteration. xdp_convert_frame_to_buff()
does not modify these fields, so the assignments are loop-invariant.
Hoist them before the loop, matching the pattern already used by
cpu_map_bpf_prog_run_xdp() in cpumap.c.
No functional change.
Signed-off-by: Anand Kumar Shaw <anandkrshawheritage@gmail.com>
---
kernel/bpf/devmap.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 2625601de..568477ce7 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -341,14 +341,15 @@ static int dev_map_bpf_prog_run(struct bpf_prog *xdp_prog,
struct xdp_buff xdp;
int i, nframes = 0;
+ xdp.txq = &txq;
+ xdp.rxq = &rxq;
+
for (i = 0; i < n; i++) {
struct xdp_frame *xdpf = frames[i];
u32 act;
int err;
xdp_convert_frame_to_buff(xdpf, &xdp);
- xdp.txq = &txq;
- xdp.rxq = &rxq;
act = bpf_prog_run_xdp(xdp_prog, &xdp);
switch (act) {
--
2.39.5 (Apple Git-154)
next reply other threads:[~2026-02-16 14:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-16 14:53 Anand Kumar Shaw [this message]
2026-02-20 2:53 ` [PATCH] bpf: devmap: hoist loop-invariant xdp buff pointer setup Alexei Starovoitov
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=20260216145306.96108-1-anandkrshawheritage@gmail.com \
--to=anandkrshawheritage@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
/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