From: Magnus Karlsson <magnus.karlsson@gmail.com>
To: magnus.karlsson@intel.com, bjorn@kernel.org, ast@kernel.org,
daniel@iogearbox.net, netdev@vger.kernel.org,
maciej.fijalkowski@intel.com, bpf@vger.kernel.org, yhs@fb.com,
andrii@kernel.org, martin.lau@linux.dev, song@kernel.org,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com,
haoluo@google.com, jolsa@kernel.org, tirthendu.sarkar@intel.com
Subject: [PATCH bpf-next v2 01/10] selftests/xsk: do not change XDP program when not necessary
Date: Tue, 16 May 2023 12:31:00 +0200 [thread overview]
Message-ID: <20230516103109.3066-2-magnus.karlsson@gmail.com> (raw)
In-Reply-To: <20230516103109.3066-1-magnus.karlsson@gmail.com>
From: Magnus Karlsson <magnus.karlsson@intel.com>
Do not change the XDP program for the Tx thread when not needed. It
was erroneously compared to the XDP program for the Rx thread, which
is always going to be different, which meant that the code made
unnecessary switches to the same program it had before. This did not
affect functionality, just performance.
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
tools/testing/selftests/bpf/xskxceiver.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/bpf/xskxceiver.c b/tools/testing/selftests/bpf/xskxceiver.c
index f144d0604ddf..f7950af576e1 100644
--- a/tools/testing/selftests/bpf/xskxceiver.c
+++ b/tools/testing/selftests/bpf/xskxceiver.c
@@ -1402,11 +1402,20 @@ static void handler(int signum)
pthread_exit(NULL);
}
-static bool xdp_prog_changed(struct test_spec *test, struct ifobject *ifobj)
+static bool xdp_prog_changed_rx(struct test_spec *test)
{
+ struct ifobject *ifobj = test->ifobj_rx;
+
return ifobj->xdp_prog != test->xdp_prog_rx || ifobj->mode != test->mode;
}
+static bool xdp_prog_changed_tx(struct test_spec *test)
+{
+ struct ifobject *ifobj = test->ifobj_tx;
+
+ return ifobj->xdp_prog != test->xdp_prog_tx || ifobj->mode != test->mode;
+}
+
static void xsk_reattach_xdp(struct ifobject *ifobj, struct bpf_program *xdp_prog,
struct bpf_map *xskmap, enum test_mode mode)
{
@@ -1433,13 +1442,13 @@ static void xsk_reattach_xdp(struct ifobject *ifobj, struct bpf_program *xdp_pro
static void xsk_attach_xdp_progs(struct test_spec *test, struct ifobject *ifobj_rx,
struct ifobject *ifobj_tx)
{
- if (xdp_prog_changed(test, ifobj_rx))
+ if (xdp_prog_changed_rx(test))
xsk_reattach_xdp(ifobj_rx, test->xdp_prog_rx, test->xskmap_rx, test->mode);
if (!ifobj_tx || ifobj_tx->shared_umem)
return;
- if (xdp_prog_changed(test, ifobj_tx))
+ if (xdp_prog_changed_tx(test))
xsk_reattach_xdp(ifobj_tx, test->xdp_prog_tx, test->xskmap_tx, test->mode);
}
--
2.34.1
next prev parent reply other threads:[~2023-05-16 10:31 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 10:30 [PATCH bpf-next v2 00/10] seltests/xsk: prepare for AF_XDP multi-buffer testing Magnus Karlsson
2023-05-16 10:31 ` Magnus Karlsson [this message]
2023-05-16 10:31 ` [PATCH bpf-next v2 02/10] selftests/xsk: generate simpler packets with variable length Magnus Karlsson
2023-05-16 10:31 ` [PATCH bpf-next v2 03/10] selftests/xsk: add varying payload pattern within packet Magnus Karlsson
2023-05-16 10:31 ` [PATCH bpf-next v2 04/10] selftests/xsk: dump packet at error Magnus Karlsson
2023-05-16 10:31 ` [PATCH bpf-next v2 05/10] selftests/xsk: add packet iterator for tx to packet stream Magnus Karlsson
2023-05-16 10:31 ` [PATCH bpf-next v2 06/10] selftests/xsk: store offset in pkt instead of addr Magnus Karlsson
2023-05-16 10:31 ` [PATCH bpf-next v2 07/10] selftests/xsx: test for huge pages only once Magnus Karlsson
2023-05-16 12:58 ` Maciej Fijalkowski
2023-05-16 13:06 ` Maciej Fijalkowski
2023-05-16 14:26 ` Magnus Karlsson
2023-05-16 14:25 ` Magnus Karlsson
2023-05-16 14:40 ` Maciej Fijalkowski
2023-05-16 10:31 ` [PATCH bpf-next v2 08/10] selftests/xsk: populate fill ring based on frags needed Magnus Karlsson
2023-05-16 10:31 ` [PATCH bpf-next v2 09/10] selftests/xsk: generate data for multi-buffer packets Magnus Karlsson
2023-05-16 10:31 ` [PATCH bpf-next v2 10/10] selftests/xsk: adjust packet pacing for multi-buffer support Magnus Karlsson
2023-05-17 5:40 ` [PATCH bpf-next v2 00/10] seltests/xsk: prepare for AF_XDP multi-buffer testing patchwork-bot+netdevbpf
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=20230516103109.3066-2-magnus.karlsson@gmail.com \
--to=magnus.karlsson@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=tirthendu.sarkar@intel.com \
--cc=yhs@fb.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).