2020-03-05 08:38:20

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 2/3] perf bench futex-wake: Restore thread count default to online CPU count

Since commit 3b2323c2c1c4 ("perf bench futex: Use cpumaps") the default
number of threads the benchmark uses got changed from number of online
CPUs to zero:

$ perf bench futex wake
# Running 'futex/wake' benchmark:
Run summary [PID 15930]: blocking on 0 threads (at [private] futex 0x558b8ee4bfac), waking up 1 at a time.
[Run 1]: Wokeup 0 of 0 threads in 0.0000 ms
[...]
[Run 10]: Wokeup 0 of 0 threads in 0.0000 ms
Wokeup 0 of 0 threads in 0.0004 ms (+-40.82%)

Restore the old behavior by grabbing the number of online CPUs via
cpu->nr:

$ perf bench futex wake
# Running 'futex/wake' benchmark:
Run summary [PID 18356]: blocking on 8 threads (at [private] futex 0xb3e62c), waking up 1 at a time.
[Run 1]: Wokeup 8 of 8 threads in 0.0260 ms
[...]
[Run 10]: Wokeup 8 of 8 threads in 0.0270 ms
Wokeup 8 of 8 threads in 0.0419 ms (+-24.35%)

Fixes: 3b2323c2c1c4 ("perf bench futex: Use cpumaps")
Signed-off-by: Tommi Rantala <[email protected]>
---
tools/perf/bench/futex-wake.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
index df810096abfef..58906e9499bb0 100644
--- a/tools/perf/bench/futex-wake.c
+++ b/tools/perf/bench/futex-wake.c
@@ -43,7 +43,7 @@ static bool done = false, silent = false, fshared = false;
static pthread_mutex_t thread_lock;
static pthread_cond_t thread_parent, thread_worker;
static struct stats waketime_stats, wakeup_stats;
-static unsigned int ncpus, threads_starting, nthreads = 0;
+static unsigned int threads_starting, nthreads = 0;
static int futex_flag = 0;

static const struct option options[] = {
@@ -141,7 +141,7 @@ int bench_futex_wake(int argc, const char **argv)
sigaction(SIGINT, &act, NULL);

if (!nthreads)
- nthreads = ncpus;
+ nthreads = cpu->nr;

worker = calloc(nthreads, sizeof(*worker));
if (!worker)
--
2.21.1


2020-03-05 14:52:29

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 2/3] perf bench futex-wake: Restore thread count default to online CPU count

Em Thu, Mar 05, 2020 at 10:37:13AM +0200, Tommi Rantala escreveu:
> Since commit 3b2323c2c1c4 ("perf bench futex: Use cpumaps") the default
> number of threads the benchmark uses got changed from number of online
> CPUs to zero:
>
> $ perf bench futex wake
> # Running 'futex/wake' benchmark:
> Run summary [PID 15930]: blocking on 0 threads (at [private] futex 0x558b8ee4bfac), waking up 1 at a time.
> [Run 1]: Wokeup 0 of 0 threads in 0.0000 ms
> [...]
> [Run 10]: Wokeup 0 of 0 threads in 0.0000 ms
> Wokeup 0 of 0 threads in 0.0004 ms (+-40.82%)
>
> Restore the old behavior by grabbing the number of online CPUs via
> cpu->nr:
>
> $ perf bench futex wake
> # Running 'futex/wake' benchmark:
> Run summary [PID 18356]: blocking on 8 threads (at [private] futex 0xb3e62c), waking up 1 at a time.
> [Run 1]: Wokeup 8 of 8 threads in 0.0260 ms
> [...]
> [Run 10]: Wokeup 8 of 8 threads in 0.0270 ms
> Wokeup 8 of 8 threads in 0.0419 ms (+-24.35%)
>
> Fixes: 3b2323c2c1c4 ("perf bench futex: Use cpumaps")

Thanks, tested and applied.

- Arnaldo

> Signed-off-by: Tommi Rantala <[email protected]>
> ---
> tools/perf/bench/futex-wake.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
> index df810096abfef..58906e9499bb0 100644
> --- a/tools/perf/bench/futex-wake.c
> +++ b/tools/perf/bench/futex-wake.c
> @@ -43,7 +43,7 @@ static bool done = false, silent = false, fshared = false;
> static pthread_mutex_t thread_lock;
> static pthread_cond_t thread_parent, thread_worker;
> static struct stats waketime_stats, wakeup_stats;
> -static unsigned int ncpus, threads_starting, nthreads = 0;
> +static unsigned int threads_starting, nthreads = 0;
> static int futex_flag = 0;
>
> static const struct option options[] = {
> @@ -141,7 +141,7 @@ int bench_futex_wake(int argc, const char **argv)
> sigaction(SIGINT, &act, NULL);
>
> if (!nthreads)
> - nthreads = ncpus;
> + nthreads = cpu->nr;
>
> worker = calloc(nthreads, sizeof(*worker));
> if (!worker)
> --
> 2.21.1
>

--

- Arnaldo

2020-03-05 15:47:37

by Davidlohr Bueso

[permalink] [raw]
Subject: Re: [PATCH 2/3] perf bench futex-wake: Restore thread count default to online CPU count

On Thu, 05 Mar 2020, Arnaldo Carvalho de Melo wrote:

>Em Thu, Mar 05, 2020 at 10:37:13AM +0200, Tommi Rantala escreveu:
>> Since commit 3b2323c2c1c4 ("perf bench futex: Use cpumaps") the default
>> number of threads the benchmark uses got changed from number of online
>> CPUs to zero:
>>
>> $ perf bench futex wake
>> # Running 'futex/wake' benchmark:
>> Run summary [PID 15930]: blocking on 0 threads (at [private] futex 0x558b8ee4bfac), waking up 1 at a time.
>> [Run 1]: Wokeup 0 of 0 threads in 0.0000 ms
>> [...]
>> [Run 10]: Wokeup 0 of 0 threads in 0.0000 ms
>> Wokeup 0 of 0 threads in 0.0004 ms (+-40.82%)
>>
>> Restore the old behavior by grabbing the number of online CPUs via
>> cpu->nr:
>>
>> $ perf bench futex wake
>> # Running 'futex/wake' benchmark:
>> Run summary [PID 18356]: blocking on 8 threads (at [private] futex 0xb3e62c), waking up 1 at a time.
>> [Run 1]: Wokeup 8 of 8 threads in 0.0260 ms
>> [...]
>> [Run 10]: Wokeup 8 of 8 threads in 0.0270 ms
>> Wokeup 8 of 8 threads in 0.0419 ms (+-24.35%)
>>
>> Fixes: 3b2323c2c1c4 ("perf bench futex: Use cpumaps")
>
>Thanks, tested and applied.

Thanks!

2020-03-05 18:16:18

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 2/3] perf bench futex-wake: Restore thread count default to online CPU count



On March 5, 2020 12:34:34 PM GMT-03:00, Davidlohr Bueso <[email protected]> wrote:
>On Thu, 05 Mar 2020, Arnaldo Carvalho de Melo wrote:
>
>>Em Thu, Mar 05, 2020 at 10:37:13AM +0200, Tommi Rantala escreveu:
>>> Since commit 3b2323c2c1c4 ("perf bench futex: Use cpumaps") the
>default
>>> number of threads the benchmark uses got changed from number of
>online
>>> CPUs to zero:
>>>
>>> $ perf bench futex wake
>>> # Running 'futex/wake' benchmark:
>>> Run summary [PID 15930]: blocking on 0 threads (at [private] futex
>0x558b8ee4bfac), waking up 1 at a time.
>>> [Run 1]: Wokeup 0 of 0 threads in 0.0000 ms
>>> [...]
>>> [Run 10]: Wokeup 0 of 0 threads in 0.0000 ms
>>> Wokeup 0 of 0 threads in 0.0004 ms (+-40.82%)
>>>
>>> Restore the old behavior by grabbing the number of online CPUs via
>>> cpu->nr:
>>>
>>> $ perf bench futex wake
>>> # Running 'futex/wake' benchmark:
>>> Run summary [PID 18356]: blocking on 8 threads (at [private] futex
>0xb3e62c), waking up 1 at a time.
>>> [Run 1]: Wokeup 8 of 8 threads in 0.0260 ms
>>> [...]
>>> [Run 10]: Wokeup 8 of 8 threads in 0.0270 ms
>>> Wokeup 8 of 8 threads in 0.0419 ms (+-24.35%)
>>>
>>> Fixes: 3b2323c2c1c4 ("perf bench futex: Use cpumaps")
>>
>>Thanks, tested and applied.
>
>Thanks!

Taking that as an Acked-by, ok?

--
Sent from my Android device with K-9 Mail. Please excuse my brevity.

Subject: [tip: perf/urgent] perf bench futex-wake: Restore thread count default to online CPU count

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID: f649bd9dd5d5004543bbc3c50b829577b49f5d75
Gitweb: https://git.kernel.org/tip/f649bd9dd5d5004543bbc3c50b829577b49f5d75
Author: Tommi Rantala <[email protected]>
AuthorDate: Thu, 05 Mar 2020 10:37:13 +02:00
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitterDate: Fri, 06 Mar 2020 08:30:47 -03:00

perf bench futex-wake: Restore thread count default to online CPU count

Since commit 3b2323c2c1c4 ("perf bench futex: Use cpumaps") the default
number of threads the benchmark uses got changed from number of online
CPUs to zero:

$ perf bench futex wake
# Running 'futex/wake' benchmark:
Run summary [PID 15930]: blocking on 0 threads (at [private] futex 0x558b8ee4bfac), waking up 1 at a time.
[Run 1]: Wokeup 0 of 0 threads in 0.0000 ms
[...]
[Run 10]: Wokeup 0 of 0 threads in 0.0000 ms
Wokeup 0 of 0 threads in 0.0004 ms (+-40.82%)

Restore the old behavior by grabbing the number of online CPUs via
cpu->nr:

$ perf bench futex wake
# Running 'futex/wake' benchmark:
Run summary [PID 18356]: blocking on 8 threads (at [private] futex 0xb3e62c), waking up 1 at a time.
[Run 1]: Wokeup 8 of 8 threads in 0.0260 ms
[...]
[Run 10]: Wokeup 8 of 8 threads in 0.0270 ms
Wokeup 8 of 8 threads in 0.0419 ms (+-24.35%)

Fixes: 3b2323c2c1c4 ("perf bench futex: Use cpumaps")
Signed-off-by: Tommi Rantala <[email protected]>
Tested-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Darren Hart <[email protected]>
Cc: Davidlohr Bueso <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/bench/futex-wake.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
index df81009..58906e9 100644
--- a/tools/perf/bench/futex-wake.c
+++ b/tools/perf/bench/futex-wake.c
@@ -43,7 +43,7 @@ static bool done = false, silent = false, fshared = false;
static pthread_mutex_t thread_lock;
static pthread_cond_t thread_parent, thread_worker;
static struct stats waketime_stats, wakeup_stats;
-static unsigned int ncpus, threads_starting, nthreads = 0;
+static unsigned int threads_starting, nthreads = 0;
static int futex_flag = 0;

static const struct option options[] = {
@@ -141,7 +141,7 @@ int bench_futex_wake(int argc, const char **argv)
sigaction(SIGINT, &act, NULL);

if (!nthreads)
- nthreads = ncpus;
+ nthreads = cpu->nr;

worker = calloc(nthreads, sizeof(*worker));
if (!worker)