netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: "Björn Töpel" <bjorn.topel@gmail.com>
Cc: brouer@redhat.com, netdev@vger.kernel.org, ast@kernel.org,
	daniel@iogearbox.net, "Björn Töpel" <bjorn.topel@intel.com>,
	bpf@vger.kernel.org, magnus.karlsson@gmail.com,
	magnus.karlsson@intel.com, jonathan.lemon@gmail.com,
	ecree@solarflare.com, thoiland@redhat.com,
	andrii.nakryiko@gmail.com
Subject: Re: [PATCH bpf-next v3 5/6] selftests: bpf: add xdp_perf test
Date: Tue, 10 Dec 2019 12:05:09 +0100	[thread overview]
Message-ID: <20191210120450.3375fc4a@carbon> (raw)
In-Reply-To: <20191209135522.16576-6-bjorn.topel@gmail.com>

On Mon,  9 Dec 2019 14:55:21 +0100
Björn Töpel <bjorn.topel@gmail.com> wrote:

> From: Björn Töpel <bjorn.topel@intel.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@intel.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


  reply	other threads:[~2019-12-10 11:05 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 13:55 [PATCH bpf-next v3 0/6] Introduce the BPF dispatcher Björn Töpel
2019-12-09 13:55 ` [PATCH bpf-next v3 1/6] bpf: move trampoline JIT image allocation to a function Björn Töpel
2019-12-09 13:55 ` [PATCH bpf-next v3 2/6] bpf: introduce BPF dispatcher Björn Töpel
2019-12-10  5:50   ` Alexei Starovoitov
2019-12-10  5:54     ` Björn Töpel
2019-12-09 13:55 ` [PATCH bpf-next v3 3/6] bpf, xdp: start using the BPF dispatcher for XDP Björn Töpel
2019-12-09 13:55 ` [PATCH bpf-next v3 4/6] bpf: start using the BPF dispatcher in BPF_TEST_RUN Björn Töpel
2019-12-09 13:55 ` [PATCH bpf-next v3 5/6] selftests: bpf: add xdp_perf test Björn Töpel
2019-12-10 11:05   ` Jesper Dangaard Brouer [this message]
2019-12-10 11:56     ` Björn Töpel
2019-12-09 13:55 ` [PATCH bpf-next v3 6/6] bpf, x86: align dispatcher branch targets to 16B Björn Töpel
2019-12-09 15:00 ` [PATCH bpf-next v3 0/6] Introduce the BPF dispatcher Toke Høiland-Jørgensen
2019-12-09 17:42   ` Björn Töpel
2019-12-11 12:38     ` Björn Töpel
2019-12-11 13:17       ` Toke Høiland-Jørgensen
2019-12-09 17:00 ` Jesper Dangaard Brouer
2019-12-09 17:45   ` Björn Töpel
2019-12-09 19:50     ` Jesper Dangaard Brouer
2019-12-10 19:28 ` Samudrala, Sridhar
2019-12-10 20:04   ` Björn Töpel
2019-12-10 19:59 ` Björn Töpel

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=20191210120450.3375fc4a@carbon \
    --to=brouer@redhat.com \
    --cc=andrii.nakryiko@gmail.com \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@gmail.com \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=ecree@solarflare.com \
    --cc=jonathan.lemon@gmail.com \
    --cc=magnus.karlsson@gmail.com \
    --cc=magnus.karlsson@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=thoiland@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).