[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191210120450.3375fc4a@carbon>
Date: Tue, 10 Dec 2019 12:05:09 +0100
From: Jesper Dangaard Brouer <brouer@...hat.com>
To: Björn Töpel <bjorn.topel@...il.com>
Cc: brouer@...hat.com, netdev@...r.kernel.org, ast@...nel.org,
daniel@...earbox.net,
Björn Töpel <bjorn.topel@...el.com>,
bpf@...r.kernel.org, magnus.karlsson@...il.com,
magnus.karlsson@...el.com, jonathan.lemon@...il.com,
ecree@...arflare.com, thoiland@...hat.com,
andrii.nakryiko@...il.com
Subject: Re: [PATCH bpf-next v3 5/6] selftests: bpf: add xdp_perf test
On Mon, 9 Dec 2019 14:55:21 +0100
Björn Töpel <bjorn.topel@...il.com> wrote:
> From: Björn Töpel <bjorn.topel@...el.com>
>
> The xdp_perf is a dummy XDP test, only used to measure the the cost of
> jumping into a XDP program.
I really like this idea of performance measuring XDP-core in isolation.
This is the ultimate zoom-in micro-benchmarking. I see a use-case for
this, where I will measure the XDP-core first, and then run same XDP
prog (e.g. XDP_DROP) on a NIC driver, then I can deduct/isolate the
driver-code and hardware overhead. We/I can also use it to optimize
e.g. REDIRECT code-core (although redir might not actually work).
IMHO it would be valuable to have bpf_prog_load() also measure the
perf-HW counters for 'cycles' and 'instructions', as in your case the
performance optimization was to improve the instructions-per-cycle
(which you showed via perf stat in cover letter).
If you send a V4 please describe how to use this prog to measure the
cost, as you describe in cover letter.
from selftests/bpf run:
# test_progs -v -t xdp_perf
(This is a nitpick, so only do this if something request a V4)
> Signed-off-by: Björn Töpel <bjorn.topel@...el.com>
> ---
> .../selftests/bpf/prog_tests/xdp_perf.c | 25 +++++++++++++++++++
> 1 file changed, 25 insertions(+)
> create mode 100644 tools/testing/selftests/bpf/prog_tests/xdp_perf.c
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_perf.c b/tools/testing/selftests/bpf/prog_tests/xdp_perf.c
> new file mode 100644
> index 000000000000..7185bee16fe4
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_perf.c
> @@ -0,0 +1,25 @@
> +// SPDX-License-Identifier: GPL-2.0
> +#include <test_progs.h>
> +
> +void test_xdp_perf(void)
> +{
> + const char *file = "./xdp_dummy.o";
> + __u32 duration, retval, size;
> + struct bpf_object *obj;
> + char in[128], out[128];
> + int err, prog_fd;
> +
> + err = bpf_prog_load(file, BPF_PROG_TYPE_XDP, &obj, &prog_fd);
> + if (CHECK_FAIL(err))
> + return;
> +
> + err = bpf_prog_test_run(prog_fd, 1000000, &in[0], 128,
> + out, &size, &retval, &duration);
> +
> + CHECK(err || retval != XDP_PASS || size != 128,
> + "xdp-perf",
> + "err %d errno %d retval %d size %d\n",
> + err, errno, retval, size);
> +
> + bpf_object__close(obj);
> +}
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
Powered by blists - more mailing lists