From: Yonghong Song <yhs@fb.com>
To: Jiri Olsa <jolsa@kernel.org>, Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Alexei Starovoitov <ast@kernel.org>,
Song Liu <songliubraving@fb.com>,
lkml <linux-kernel@vger.kernel.org>, <bpf@vger.kernel.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Ingo Molnar <mingo@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Namhyung Kim <namhyung@kernel.org>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Michael Petlan <mpetlan@redhat.com>,
Ian Rogers <irogers@google.com>,
Stephane Eranian <eranian@google.com>,
Alexei Budankov <abudankov@huawei.com>,
Andi Kleen <ak@linux.intel.com>,
Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH bpf-next 2/3] bpf: Add size arg to build_id_parse function
Date: Thu, 14 Jan 2021 10:56:33 -0800 [thread overview]
Message-ID: <19f16729-96d6-cc8e-5bd5-c3f5940365d4@fb.com> (raw)
In-Reply-To: <20210114134044.1418404-3-jolsa@kernel.org>
On 1/14/21 5:40 AM, Jiri Olsa wrote:
> It's possible to have other build id types (other than default SHA1).
> Currently there's also ld support for MD5 build id.
Currently, bpf build_id based stackmap does not returns the size of
the build_id. Did you see an issue here? I guess user space can check
the length of non-zero bits of the build id to decide what kind of
type it is, right?
>
> Adding size argument to build_id_parse function, that returns (if defined)
> size of the parsed build id, so we can recognize the build id type.
>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Song Liu <songliubraving@fb.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
> include/linux/buildid.h | 3 ++-
> kernel/bpf/stackmap.c | 2 +-
> lib/buildid.c | 29 +++++++++++++++++++++--------
> 3 files changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/buildid.h b/include/linux/buildid.h
> index 08028a212589..40232f90db6e 100644
> --- a/include/linux/buildid.h
> +++ b/include/linux/buildid.h
> @@ -6,6 +6,7 @@
>
> #define BUILD_ID_SIZE_MAX 20
>
> -int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id);
> +int build_id_parse(struct vm_area_struct *vma, unsigned char *build_id,
> + __u32 *size);
>
> #endif
> diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c
> index 55d254a59f07..cabaf7db8efc 100644
> --- a/kernel/bpf/stackmap.c
> +++ b/kernel/bpf/stackmap.c
> @@ -189,7 +189,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
>
> for (i = 0; i < trace_nr; i++) {
> vma = find_vma(current->mm, ips[i]);
> - if (!vma || build_id_parse(vma, id_offs[i].build_id)) {
> + if (!vma || build_id_parse(vma, id_offs[i].build_id, NULL)) {
> /* per entry fall back to ips */
> id_offs[i].status = BPF_STACK_BUILD_ID_IP;
> id_offs[i].ip = ips[i];
> diff --git a/lib/buildid.c b/lib/buildid.c
> index 4a4f520c0e29..6156997c3895 100644
> --- a/lib/buildid.c
> +++ b/lib/buildid.c
> @@ -12,6 +12,7 @@
> */
> static inline int parse_build_id(void *page_addr,
> unsigned char *build_id,
> + __u32 *size,
> void *note_start,
> Elf32_Word note_size)
> {
> @@ -38,6 +39,8 @@ static inline int parse_build_id(void *page_addr,
> nhdr->n_descsz);
> memset(build_id + nhdr->n_descsz, 0,
> BUILD_ID_SIZE_MAX - nhdr->n_descsz);
> + if (size)
> + *size = nhdr->n_descsz;
> return 0;
> }
> new_offs = note_offs + sizeof(Elf32_Nhdr) +
> @@ -50,7 +53,8 @@ static inline int parse_build_id(void *page_addr,
> }
>
[...]
next prev parent reply other threads:[~2021-01-14 18:58 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-14 13:40 [PATCHv7 bpf-next 0/3] perf: Add mmap2 build id support Jiri Olsa
2021-01-14 13:40 ` [PATCH bpf-next 1/3] bpf: Move stack_map_get_build_id into lib Jiri Olsa
2021-01-14 13:40 ` [PATCH bpf-next 2/3] bpf: Add size arg to build_id_parse function Jiri Olsa
2021-01-14 18:56 ` Yonghong Song [this message]
2021-01-14 20:01 ` Jiri Olsa
2021-01-14 21:05 ` Yonghong Song
2021-01-14 22:02 ` Jiri Olsa
2021-01-14 23:43 ` Yonghong Song
2021-01-15 3:47 ` Alexei Starovoitov
2021-01-26 20:52 ` Jiri Olsa
2021-01-26 21:00 ` Yonghong Song
2021-01-14 13:40 ` [PATCH bpf-next 3/3] perf: Add build id data in mmap2 event Jiri Olsa
2021-01-15 3:50 ` [PATCHv7 bpf-next 0/3] perf: Add mmap2 build id support 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=19f16729-96d6-cc8e-5bd5-c3f5940365d4@fb.com \
--to=yhs@fb.com \
--cc=a.p.zijlstra@chello.nl \
--cc=abudankov@huawei.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mpetlan@redhat.com \
--cc=namhyung@kernel.org \
--cc=songliubraving@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).