From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: daniel@iogearbox.net, oss-drivers@netronome.com,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@redhat.com>, Namhyung Kim <namhyung@kernel.org>
Subject: Re: [PATCH bpf-next 09/10] tools: bpftool: add simple perf event output reader
Date: Fri, 4 May 2018 15:28:57 -0700 [thread overview]
Message-ID: <20180504152857.071870b2@cakuba.netronome.com> (raw)
In-Reply-To: <20180504212501.hn2rnv7t3ik563mg@ast-mbp>
CC perf folks
On Fri, 4 May 2018 14:25:03 -0700, Alexei Starovoitov wrote:
> > +static void
> > +perf_event_read(struct event_ring_info *ring, void **buf, size_t *buf_len)
> > +{
> > + volatile struct perf_event_mmap_page *header = ring->mem;
> > + __u64 buffer_size = MMAP_PAGE_CNT * get_page_size();
> > + __u64 data_tail = header->data_tail;
> > + __u64 data_head = header->data_head;
> > + void *base, *begin, *end;
> > +
> > + asm volatile("" ::: "memory"); /* in real code it should be smp_rmb() */
> > + if (data_head == data_tail)
> > + return;
>
> this function was copied several times into different places.
> I think it's time to put into common lib. Like libbpf.
Agreed, I think libbpf would work, although there is nothing BPF
specific in this loop AFAICT now.
> Would be great if you can do it in the follow up.
Looking into it now, I found these:
$ git grep 'data_head == data_tail'
tools/bpf/bpftool/map_perf_ring.c: if (data_head == data_tail)
tools/testing/selftests/bpf/trace_helpers.c: if (data_head == data_tail)
Are there any other copies I should try to cater to? I have change a few
things compared to the selftest, I guess others may have modified their
copy too. Just trying to make sure what we put in libbpf would cater
to most possible use cases.
Should I also move bpf_perf_event_open()/test_bpf_perf_event() to libbpf?
> for the set:
> Acked-by: Alexei Starovoitov <ast@kernel.org>
Thanks!
next prev parent reply other threads:[~2018-05-04 22:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-04 1:37 [PATCH bpf-next 00/10] bpf: support offload of bpf_event_output() Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 01/10] bpf: offload: allow offloaded programs to use perf event arrays Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 02/10] nfp: bpf: record offload neutral maps in the driver Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 03/10] bpf: export bpf_event_output() Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 04/10] bpf: replace map pointer loads before calling into offloads Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 05/10] nfp: bpf: perf event output helpers support Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 06/10] nfp: bpf: rewrite map pointers with NFP TIDs Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 07/10] tools: bpftool: fold hex keyword in command help Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 08/10] tools: bpftool: move get_possible_cpus() to common code Jakub Kicinski
2018-05-04 1:37 ` [PATCH bpf-next 09/10] tools: bpftool: add simple perf event output reader Jakub Kicinski
2018-05-04 21:25 ` Alexei Starovoitov
2018-05-04 22:28 ` Jakub Kicinski [this message]
2018-05-04 21:53 ` Daniel Borkmann
2018-05-04 1:37 ` [PATCH bpf-next 10/10] bpf: fix references to free_bpf_prog_info() in comments Jakub Kicinski
2018-05-04 21:46 ` [PATCH bpf-next 00/10] bpf: support offload of bpf_event_output() Daniel Borkmann
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=20180504152857.071870b2@cakuba.netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=jolsa@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
--cc=peterz@infradead.org \
/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