* [PATCH v2] perf libunwind: Fixup conversion perf_sample->user_regs to a pointer
@ 2025-03-13 3:31 Ian Rogers
2025-03-15 1:11 ` Namhyung Kim
2025-03-18 18:02 ` Namhyung Kim
0 siblings, 2 replies; 4+ messages in thread
From: Ian Rogers @ 2025-03-13 3:31 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Mark Rutland, Alexander Shishkin, Jiri Olsa,
Ian Rogers, Adrian Hunter, Kan Liang, Yunseong Kim, James Clark,
linux-perf-users, linux-kernel
Cc: Arnaldo Carvalho de Melo, Andi Kleen, Charlie Jenkins, John Garry,
Leo Yan, Michael Petlan, Tavian Barnes, Veronika Molnarova,
coresight, linux-arm-kernel
From: Arnaldo Carvalho de Melo <acme@redhat.com>
The dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional") misses
the changes to a file, resulting in this problem:
$ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin
<SNIP>
CC /tmp/build/perf-tools-next/util/unwind-libunwind-local.o
CC /tmp/build/perf-tools-next/util/unwind-libunwind.o
<SNIP>
util/unwind-libunwind-local.c: In function ‘access_mem’:
util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’?
582 | if (__write || !stack || !ui->sample->user_regs.regs) {
| ^
| ->
util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types]
587 | ret = perf_reg_value(&start, &ui->sample->user_regs,
| ^~~~~~~~~~~~~~~~~~~~~~
| |
| struct regs_dump **
<SNIP>
⬢ [acme@toolbox perf-tools-next]$ git bisect bad
dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit
commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD)
Author: Ian Rogers <irogers@google.com>
Date: Mon Jan 13 11:43:45 2025 -0800
perf sample: Make user_regs and intr_regs optional
Detected using:
make -C tools/perf build-test
Fixes: dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Charlie Jenkins <charlie@rivosinc.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linux.dev>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Petlan <mpetlan@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Tavian Barnes <tavianator@tavianator.com>
Cc: Veronika Molnarova <vmolnaro@redhat.com>
Cc: coresight@lists.linaro.org
Cc: linux-arm-kernel@lists.infradead.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Reviewed-by: Ian Rogers <irogers@google.com>
---
v2: Ensure user_regs isn't NULL when read, spotted by Namhyung.
---
tools/perf/util/unwind-libunwind-local.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
index 16c2b03831f3..5f4387e2423a 100644
--- a/tools/perf/util/unwind-libunwind-local.c
+++ b/tools/perf/util/unwind-libunwind-local.c
@@ -579,12 +579,12 @@ static int access_mem(unw_addr_space_t __maybe_unused as,
int ret;
/* Don't support write, probably not needed. */
- if (__write || !stack || !ui->sample->user_regs.regs) {
+ if (__write || !stack || !ui->sample->user_regs || !ui->sample->user_regs->regs) {
*valp = 0;
return 0;
}
- ret = perf_reg_value(&start, &ui->sample->user_regs,
+ ret = perf_reg_value(&start, perf_sample__user_regs(ui->sample),
perf_arch_reg_sp(arch));
if (ret)
return ret;
@@ -628,7 +628,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
return 0;
}
- if (!ui->sample->user_regs.regs) {
+ if (!ui->sample->user_regs || !ui->sample->user_regs->regs) {
*valp = 0;
return 0;
}
@@ -637,7 +637,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
if (id < 0)
return -EINVAL;
- ret = perf_reg_value(&val, &ui->sample->user_regs, id);
+ ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample), id);
if (ret) {
if (!ui->best_effort)
pr_err("unwind: can't read reg %d\n", regnum);
@@ -741,7 +741,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
unw_cursor_t c;
int ret, i = 0;
- ret = perf_reg_value(&val, &ui->sample->user_regs,
+ ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample),
perf_arch_reg_ip(arch));
if (ret)
return ret;
@@ -808,7 +808,7 @@ static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg,
.best_effort = best_effort
};
- if (!data->user_regs.regs)
+ if (!data->user_regs || !data->user_regs->regs)
return -EINVAL;
if (max_stack <= 0)
--
2.49.0.rc0.332.g42c0ae87b1-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2] perf libunwind: Fixup conversion perf_sample->user_regs to a pointer
2025-03-13 3:31 [PATCH v2] perf libunwind: Fixup conversion perf_sample->user_regs to a pointer Ian Rogers
@ 2025-03-15 1:11 ` Namhyung Kim
2025-03-17 16:02 ` Ian Rogers
2025-03-18 18:02 ` Namhyung Kim
1 sibling, 1 reply; 4+ messages in thread
From: Namhyung Kim @ 2025-03-15 1:11 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
Kan Liang, Yunseong Kim, James Clark, linux-perf-users,
linux-kernel, Arnaldo Carvalho de Melo, Andi Kleen,
Charlie Jenkins, John Garry, Leo Yan, Michael Petlan,
Tavian Barnes, Veronika Molnarova, coresight, linux-arm-kernel
On Wed, Mar 12, 2025 at 08:31:21PM -0700, Ian Rogers wrote:
> From: Arnaldo Carvalho de Melo <acme@redhat.com>
>
> The dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional") misses
> the changes to a file, resulting in this problem:
>
> $ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin
> <SNIP>
> CC /tmp/build/perf-tools-next/util/unwind-libunwind-local.o
> CC /tmp/build/perf-tools-next/util/unwind-libunwind.o
> <SNIP>
> util/unwind-libunwind-local.c: In function ‘access_mem’:
> util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’?
> 582 | if (__write || !stack || !ui->sample->user_regs.regs) {
> | ^
> | ->
> util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types]
> 587 | ret = perf_reg_value(&start, &ui->sample->user_regs,
> | ^~~~~~~~~~~~~~~~~~~~~~
> | |
> | struct regs_dump **
> <SNIP>
> ⬢ [acme@toolbox perf-tools-next]$ git bisect bad
> dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit
> commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD)
> Author: Ian Rogers <irogers@google.com>
> Date: Mon Jan 13 11:43:45 2025 -0800
>
> perf sample: Make user_regs and intr_regs optional
>
> Detected using:
>
> make -C tools/perf build-test
>
> Fixes: dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Charlie Jenkins <charlie@rivosinc.com>
> Cc: Ian Rogers <irogers@google.com>
> Cc: Ingo Molnar <mingo@redhat.com>
> Cc: James Clark <james.clark@linaro.org>
> Cc: John Garry <john.g.garry@oracle.com>
> Cc: Kan Liang <kan.liang@linux.intel.com>
> Cc: Leo Yan <leo.yan@linux.dev>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Michael Petlan <mpetlan@redhat.com>
> Cc: Namhyung Kim <namhyung@kernel.org>
> Cc: Peter Zijlstra <peterz@infradead.org>
> Cc: Tavian Barnes <tavianator@tavianator.com>
> Cc: Veronika Molnarova <vmolnaro@redhat.com>
> Cc: coresight@lists.linaro.org
> Cc: linux-arm-kernel@lists.infradead.org
> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> Reviewed-by: Ian Rogers <irogers@google.com>
I think you need to add your own Signed-off-by in this case.
I'll change it for you, ok?
Thanks,
Namhyung
> ---
> v2: Ensure user_regs isn't NULL when read, spotted by Namhyung.
> ---
> tools/perf/util/unwind-libunwind-local.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/util/unwind-libunwind-local.c b/tools/perf/util/unwind-libunwind-local.c
> index 16c2b03831f3..5f4387e2423a 100644
> --- a/tools/perf/util/unwind-libunwind-local.c
> +++ b/tools/perf/util/unwind-libunwind-local.c
> @@ -579,12 +579,12 @@ static int access_mem(unw_addr_space_t __maybe_unused as,
> int ret;
>
> /* Don't support write, probably not needed. */
> - if (__write || !stack || !ui->sample->user_regs.regs) {
> + if (__write || !stack || !ui->sample->user_regs || !ui->sample->user_regs->regs) {
> *valp = 0;
> return 0;
> }
>
> - ret = perf_reg_value(&start, &ui->sample->user_regs,
> + ret = perf_reg_value(&start, perf_sample__user_regs(ui->sample),
> perf_arch_reg_sp(arch));
> if (ret)
> return ret;
> @@ -628,7 +628,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
> return 0;
> }
>
> - if (!ui->sample->user_regs.regs) {
> + if (!ui->sample->user_regs || !ui->sample->user_regs->regs) {
> *valp = 0;
> return 0;
> }
> @@ -637,7 +637,7 @@ static int access_reg(unw_addr_space_t __maybe_unused as,
> if (id < 0)
> return -EINVAL;
>
> - ret = perf_reg_value(&val, &ui->sample->user_regs, id);
> + ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample), id);
> if (ret) {
> if (!ui->best_effort)
> pr_err("unwind: can't read reg %d\n", regnum);
> @@ -741,7 +741,7 @@ static int get_entries(struct unwind_info *ui, unwind_entry_cb_t cb,
> unw_cursor_t c;
> int ret, i = 0;
>
> - ret = perf_reg_value(&val, &ui->sample->user_regs,
> + ret = perf_reg_value(&val, perf_sample__user_regs(ui->sample),
> perf_arch_reg_ip(arch));
> if (ret)
> return ret;
> @@ -808,7 +808,7 @@ static int _unwind__get_entries(unwind_entry_cb_t cb, void *arg,
> .best_effort = best_effort
> };
>
> - if (!data->user_regs.regs)
> + if (!data->user_regs || !data->user_regs->regs)
> return -EINVAL;
>
> if (max_stack <= 0)
> --
> 2.49.0.rc0.332.g42c0ae87b1-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] perf libunwind: Fixup conversion perf_sample->user_regs to a pointer
2025-03-15 1:11 ` Namhyung Kim
@ 2025-03-17 16:02 ` Ian Rogers
0 siblings, 0 replies; 4+ messages in thread
From: Ian Rogers @ 2025-03-17 16:02 UTC (permalink / raw)
To: Namhyung Kim
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
Kan Liang, Yunseong Kim, James Clark, linux-perf-users,
linux-kernel, Arnaldo Carvalho de Melo, Andi Kleen,
Charlie Jenkins, John Garry, Leo Yan, Michael Petlan,
Tavian Barnes, Veronika Molnarova, coresight, linux-arm-kernel
On Fri, Mar 14, 2025 at 6:12 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> On Wed, Mar 12, 2025 at 08:31:21PM -0700, Ian Rogers wrote:
> > From: Arnaldo Carvalho de Melo <acme@redhat.com>
> >
> > The dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional") misses
> > the changes to a file, resulting in this problem:
> >
> > $ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin
> > <SNIP>
> > CC /tmp/build/perf-tools-next/util/unwind-libunwind-local.o
> > CC /tmp/build/perf-tools-next/util/unwind-libunwind.o
> > <SNIP>
> > util/unwind-libunwind-local.c: In function ‘access_mem’:
> > util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’?
> > 582 | if (__write || !stack || !ui->sample->user_regs.regs) {
> > | ^
> > | ->
> > util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types]
> > 587 | ret = perf_reg_value(&start, &ui->sample->user_regs,
> > | ^~~~~~~~~~~~~~~~~~~~~~
> > | |
> > | struct regs_dump **
> > <SNIP>
> > ⬢ [acme@toolbox perf-tools-next]$ git bisect bad
> > dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit
> > commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD)
> > Author: Ian Rogers <irogers@google.com>
> > Date: Mon Jan 13 11:43:45 2025 -0800
> >
> > perf sample: Make user_regs and intr_regs optional
> >
> > Detected using:
> >
> > make -C tools/perf build-test
> >
> > Fixes: dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional")
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
> > Cc: Andi Kleen <ak@linux.intel.com>
> > Cc: Charlie Jenkins <charlie@rivosinc.com>
> > Cc: Ian Rogers <irogers@google.com>
> > Cc: Ingo Molnar <mingo@redhat.com>
> > Cc: James Clark <james.clark@linaro.org>
> > Cc: John Garry <john.g.garry@oracle.com>
> > Cc: Kan Liang <kan.liang@linux.intel.com>
> > Cc: Leo Yan <leo.yan@linux.dev>
> > Cc: Mark Rutland <mark.rutland@arm.com>
> > Cc: Michael Petlan <mpetlan@redhat.com>
> > Cc: Namhyung Kim <namhyung@kernel.org>
> > Cc: Peter Zijlstra <peterz@infradead.org>
> > Cc: Tavian Barnes <tavianator@tavianator.com>
> > Cc: Veronika Molnarova <vmolnaro@redhat.com>
> > Cc: coresight@lists.linaro.org
> > Cc: linux-arm-kernel@lists.infradead.org
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > Reviewed-by: Ian Rogers <irogers@google.com>
>
> I think you need to add your own Signed-off-by in this case.
> I'll change it for you, ok?
Sure.
Thanks,
Ian
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] perf libunwind: Fixup conversion perf_sample->user_regs to a pointer
2025-03-13 3:31 [PATCH v2] perf libunwind: Fixup conversion perf_sample->user_regs to a pointer Ian Rogers
2025-03-15 1:11 ` Namhyung Kim
@ 2025-03-18 18:02 ` Namhyung Kim
1 sibling, 0 replies; 4+ messages in thread
From: Namhyung Kim @ 2025-03-18 18:02 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Mark Rutland, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
Kan Liang, Yunseong Kim, James Clark, linux-perf-users,
linux-kernel, Ian Rogers
Cc: Arnaldo Carvalho de Melo, Andi Kleen, Charlie Jenkins, John Garry,
Leo Yan, Michael Petlan, Tavian Barnes, Veronika Molnarova,
coresight, linux-arm-kernel
On Wed, 12 Mar 2025 20:31:21 -0700, Ian Rogers wrote:
> The dc6d2bc2d893a878 ("perf sample: Make user_regs and intr_regs optional") misses
> the changes to a file, resulting in this problem:
>
> $ make LIBUNWIND=1 -C tools/perf O=/tmp/build/perf-tools-next install-bin
> <SNIP>
> CC /tmp/build/perf-tools-next/util/unwind-libunwind-local.o
> CC /tmp/build/perf-tools-next/util/unwind-libunwind.o
> <SNIP>
> util/unwind-libunwind-local.c: In function ‘access_mem’:
> util/unwind-libunwind-local.c:582:56: error: ‘ui->sample->user_regs’ is a pointer; did you mean to use ‘->’?
> 582 | if (__write || !stack || !ui->sample->user_regs.regs) {
> | ^
> | ->
> util/unwind-libunwind-local.c:587:38: error: passing argument 2 of ‘perf_reg_value’ from incompatible pointer type [-Wincompatible-pointer-types]
> 587 | ret = perf_reg_value(&start, &ui->sample->user_regs,
> | ^~~~~~~~~~~~~~~~~~~~~~
> | |
> | struct regs_dump **
> <SNIP>
> ⬢ [acme@toolbox perf-tools-next]$ git bisect bad
> dc6d2bc2d893a878e7b58578ff01b4738708deb4 is the first bad commit
> commit dc6d2bc2d893a878e7b58578ff01b4738708deb4 (HEAD)
> Author: Ian Rogers <irogers@google.com>
> Date: Mon Jan 13 11:43:45 2025 -0800
>
> [...]
Applied to perf-tools-next, thanks!
Best regards,
Namhyung
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-03-18 18:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-13 3:31 [PATCH v2] perf libunwind: Fixup conversion perf_sample->user_regs to a pointer Ian Rogers
2025-03-15 1:11 ` Namhyung Kim
2025-03-17 16:02 ` Ian Rogers
2025-03-18 18:02 ` Namhyung Kim
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).