mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-20 09:34:44 +08:00
selftests/xsk: do not change XDP program when not necessary
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> Link: https://lore.kernel.org/r/20230516103109.3066-2-magnus.karlsson@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
parent
0697e43942
commit
d2e5414949
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user