* [PATCH] perf bench numa: Fix for loop in do_work
@ 2023-03-30 7:42 Andreas Herrmann
2023-03-30 8:31 ` James Clark
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Herrmann @ 2023-03-30 7:42 UTC (permalink / raw)
To: Arnaldo Carvalho de Melo; +Cc: linux-kernel, linux-perf-users, Andreas Herrmann
j is of type int and start/end are of type long. Thus j might become
negative and cause segfault in access_data(). Fix it by using long for
j as well.
Signed-off-by: Andreas Herrmann <aherrmann@suse.de>
---
tools/perf/bench/numa.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Example of segfault (with 6.3.0-rc4) is:
# ./perf bench numa mem -d -m -p 2 -t 12 -P 25425
...
threads initialized in 6.052135 seconds.
#
perf: bench/numa.c:1654: __bench_numa: Assertion `!(!(((wait_stat) & 0x7f) == 0))' failed.
Aborted (core dumped)
# dmesg | grep segfault
[78812.711311] thread 1/3[43215]: segfault at 7f07936c9ec0 ip 00000000004ab6d0 sp 00007f0acb1f9cb0 error 4
[78812.711309] thread 1/9[43221]: segfault at 7f08bda71a70 ip 00000000004ab6d0 sp 00007f0ac81f3cb0 error 4
[78812.711316] thread 1/4[43216]: segfault at 7f07ccf76a08 ip 00000000004ab6d0 sp 00007f0aca9f8cb0 error 4
[78812.711325] thread 1/2[43214]: segfault at 7f08be2f44b0 ip 00000000004ab6d0 sp 00007f0acb9facb0 error 4
[78812.711328] thread 1/8[43220]: segfault at 7f06d3096b20 ip 00000000004ab6d0 sp 00007f0ac89f4cb0 error 4
[78812.711345] thread 1/6[43218]: segfault at 7f0774b46a18 ip 00000000004ab6d0 sp 00007f0ac99f6cb0 error 4 in perf[400000+caa000] likely on CPU 6 (core 8, socket 0)
[78812.711366] thread 0/0[43224]: segfault at 7f08a936b130 ip 00000000004ab6d0 sp 00007f0acc9fccb0 error 4 in perf[400000+caa000] likely on CPU 1 (core 1, socket 0)
diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
index 9717c6c17433..1fbd7c947abc 100644
--- a/tools/perf/bench/numa.c
+++ b/tools/perf/bench/numa.c
@@ -847,7 +847,7 @@ static u64 do_work(u8 *__data, long bytes, int nr, int nr_max, int loop, u64 val
if (g->p.data_rand_walk) {
u32 lfsr = nr + loop + val;
- int j;
+ long j;
for (i = 0; i < words/1024; i++) {
long start, end;
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] perf bench numa: Fix for loop in do_work
2023-03-30 7:42 [PATCH] perf bench numa: Fix for loop in do_work Andreas Herrmann
@ 2023-03-30 8:31 ` James Clark
2023-03-30 21:16 ` Arnaldo Carvalho de Melo
0 siblings, 1 reply; 3+ messages in thread
From: James Clark @ 2023-03-30 8:31 UTC (permalink / raw)
To: Andreas Herrmann, Arnaldo Carvalho de Melo; +Cc: linux-kernel, linux-perf-users
On 30/03/2023 08:42, Andreas Herrmann wrote:
> j is of type int and start/end are of type long. Thus j might become
> negative and cause segfault in access_data(). Fix it by using long for
> j as well.
>
> Signed-off-by: Andreas Herrmann <aherrmann@suse.de>
> ---
> tools/perf/bench/numa.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> Example of segfault (with 6.3.0-rc4) is:
>
> # ./perf bench numa mem -d -m -p 2 -t 12 -P 25425
> ...
> threads initialized in 6.052135 seconds.
> #
> perf: bench/numa.c:1654: __bench_numa: Assertion `!(!(((wait_stat) & 0x7f) == 0))' failed.
> Aborted (core dumped)
> # dmesg | grep segfault
> [78812.711311] thread 1/3[43215]: segfault at 7f07936c9ec0 ip 00000000004ab6d0 sp 00007f0acb1f9cb0 error 4
> [78812.711309] thread 1/9[43221]: segfault at 7f08bda71a70 ip 00000000004ab6d0 sp 00007f0ac81f3cb0 error 4
> [78812.711316] thread 1/4[43216]: segfault at 7f07ccf76a08 ip 00000000004ab6d0 sp 00007f0aca9f8cb0 error 4
> [78812.711325] thread 1/2[43214]: segfault at 7f08be2f44b0 ip 00000000004ab6d0 sp 00007f0acb9facb0 error 4
> [78812.711328] thread 1/8[43220]: segfault at 7f06d3096b20 ip 00000000004ab6d0 sp 00007f0ac89f4cb0 error 4
> [78812.711345] thread 1/6[43218]: segfault at 7f0774b46a18 ip 00000000004ab6d0 sp 00007f0ac99f6cb0 error 4 in perf[400000+caa000] likely on CPU 6 (core 8, socket 0)
> [78812.711366] thread 0/0[43224]: segfault at 7f08a936b130 ip 00000000004ab6d0 sp 00007f0acc9fccb0 error 4 in perf[400000+caa000] likely on CPU 1 (core 1, socket 0)
>
> diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
> index 9717c6c17433..1fbd7c947abc 100644
> --- a/tools/perf/bench/numa.c
> +++ b/tools/perf/bench/numa.c
> @@ -847,7 +847,7 @@ static u64 do_work(u8 *__data, long bytes, int nr, int nr_max, int loop, u64 val
>
> if (g->p.data_rand_walk) {
> u32 lfsr = nr + loop + val;
> - int j;
> + long j;
>
> for (i = 0; i < words/1024; i++) {
> long start, end;
Reviewed-by: James Clark <james.clark@arm.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] perf bench numa: Fix for loop in do_work
2023-03-30 8:31 ` James Clark
@ 2023-03-30 21:16 ` Arnaldo Carvalho de Melo
0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-30 21:16 UTC (permalink / raw)
To: James Clark; +Cc: Andreas Herrmann, linux-kernel, linux-perf-users
Em Thu, Mar 30, 2023 at 09:31:31AM +0100, James Clark escreveu:
>
>
> On 30/03/2023 08:42, Andreas Herrmann wrote:
> > j is of type int and start/end are of type long. Thus j might become
> > negative and cause segfault in access_data(). Fix it by using long for
> > j as well.
> > Signed-off-by: Andreas Herrmann <aherrmann@suse.de>
> > ---
> > tools/perf/bench/numa.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > Example of segfault (with 6.3.0-rc4) is:
> >
> > # ./perf bench numa mem -d -m -p 2 -t 12 -P 25425
> > ...
> > threads initialized in 6.052135 seconds.
> > #
> > perf: bench/numa.c:1654: __bench_numa: Assertion `!(!(((wait_stat) & 0x7f) == 0))' failed.
> > Aborted (core dumped)
> > # dmesg | grep segfault
> > [78812.711311] thread 1/3[43215]: segfault at 7f07936c9ec0 ip 00000000004ab6d0 sp 00007f0acb1f9cb0 error 4
> > [78812.711309] thread 1/9[43221]: segfault at 7f08bda71a70 ip 00000000004ab6d0 sp 00007f0ac81f3cb0 error 4
> > [78812.711316] thread 1/4[43216]: segfault at 7f07ccf76a08 ip 00000000004ab6d0 sp 00007f0aca9f8cb0 error 4
> > [78812.711325] thread 1/2[43214]: segfault at 7f08be2f44b0 ip 00000000004ab6d0 sp 00007f0acb9facb0 error 4
> > [78812.711328] thread 1/8[43220]: segfault at 7f06d3096b20 ip 00000000004ab6d0 sp 00007f0ac89f4cb0 error 4
> > [78812.711345] thread 1/6[43218]: segfault at 7f0774b46a18 ip 00000000004ab6d0 sp 00007f0ac99f6cb0 error 4 in perf[400000+caa000] likely on CPU 6 (core 8, socket 0)
> > [78812.711366] thread 0/0[43224]: segfault at 7f08a936b130 ip 00000000004ab6d0 sp 00007f0acc9fccb0 error 4 in perf[400000+caa000] likely on CPU 1 (core 1, socket 0)
> >
> > diff --git a/tools/perf/bench/numa.c b/tools/perf/bench/numa.c
> > index 9717c6c17433..1fbd7c947abc 100644
> > --- a/tools/perf/bench/numa.c
> > +++ b/tools/perf/bench/numa.c
> > @@ -847,7 +847,7 @@ static u64 do_work(u8 *__data, long bytes, int nr, int nr_max, int loop, u64 val
> >
> > if (g->p.data_rand_walk) {
> > u32 lfsr = nr + loop + val;
> > - int j;
> > + long j;
> >
> > for (i = 0; i < words/1024; i++) {
> > long start, end;
>
> Reviewed-by: James Clark <james.clark@arm.com>
Thanks, applied.
- Arnaldo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-30 21:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-30 7:42 [PATCH] perf bench numa: Fix for loop in do_work Andreas Herrmann
2023-03-30 8:31 ` James Clark
2023-03-30 21:16 ` Arnaldo Carvalho de Melo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.