Re: [PATCH 4/4] perf tools: Honor namespace when synthesizing build-id
From: Adrian Hunter
Date: Tue Sep 20 2022 - 09:37:13 EST
On 16/09/22 20:59, Namhyung Kim wrote:
> It needs to go into a namespace before reading a file.
This looks like a fix, in which case make it the first patch
and add a fixes tag?
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxxx>
> ---
> tools/perf/util/synthetic-events.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/tools/perf/util/synthetic-events.c b/tools/perf/util/synthetic-events.c
> index e6978b2dee8f..d0d540d09196 100644
> --- a/tools/perf/util/synthetic-events.c
> +++ b/tools/perf/util/synthetic-events.c
> @@ -391,6 +391,8 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
> struct build_id _bid, *bid = &_bid;
> struct dso *dso = NULL;
> struct dso_id id;
> + struct nsinfo *nsi;
> + struct nscookie nc;
> int rc;
>
> if (is_kernel) {
> @@ -410,8 +412,14 @@ static void perf_record_mmap2__read_build_id(struct perf_record_mmap2 *event,
> goto out;
> }
>
> + nsi = nsinfo__new(event->pid);
> + nsinfo__mountns_enter(nsi, &nc);
> +
> rc = filename__read_build_id(event->filename, bid) > 0 ? 0 : -1;
>
> + nsinfo__mountns_exit(&nc);
> + nsinfo__put(nsi);
> +
> out:
> if (rc == 0) {
> memcpy(event->build_id, bid->data, sizeof(bid->data));