Re: [PATCH 3/7] perf/bench-futex: Factor out futex_flag

From: Arnaldo Carvalho de Melo
Date: Mon Aug 09 2021 - 10:54:12 EST


Em Sun, Aug 08, 2021 at 09:32:57PM -0700, Davidlohr Bueso escreveu:
> This is common across all tests, move it into futex.h.

Wouldn't be better to have it defined in one place and then in futex.h
just have a 'extern int futex_flag;' declaration?

I applied the first two patches already.

- Arnaldo

> Signed-off-by: Davidlohr Bueso <dbueso@xxxxxxx>
> ---
> tools/perf/bench/futex-hash.c | 1 -
> tools/perf/bench/futex-lock-pi.c | 1 -
> tools/perf/bench/futex-requeue.c | 1 -
> tools/perf/bench/futex-wake-parallel.c | 1 -
> tools/perf/bench/futex-wake.c | 1 -
> tools/perf/bench/futex.h | 3 +++
> 6 files changed, 3 insertions(+), 5 deletions(-)
>
> diff --git a/tools/perf/bench/futex-hash.c b/tools/perf/bench/futex-hash.c
> index ddca7558e559..b71a34204b79 100644
> --- a/tools/perf/bench/futex-hash.c
> +++ b/tools/perf/bench/futex-hash.c
> @@ -30,7 +30,6 @@
> #include <err.h>
>
> static bool done = false;
> -static int futex_flag = 0;
>
> struct timeval bench__start, bench__end, bench__runtime;
> static pthread_mutex_t thread_lock;
> diff --git a/tools/perf/bench/futex-lock-pi.c b/tools/perf/bench/futex-lock-pi.c
> index ce980df23bb0..bc208edf3de3 100644
> --- a/tools/perf/bench/futex-lock-pi.c
> +++ b/tools/perf/bench/futex-lock-pi.c
> @@ -32,7 +32,6 @@ struct worker {
> static u_int32_t global_futex = 0;
> static struct worker *worker;
> static bool done = false;
> -static int futex_flag = 0;
> static pthread_mutex_t thread_lock;
> static unsigned int threads_starting;
> static struct stats throughput_stats;
> diff --git a/tools/perf/bench/futex-requeue.c b/tools/perf/bench/futex-requeue.c
> index 66747bfe22cf..4001312122be 100644
> --- a/tools/perf/bench/futex-requeue.c
> +++ b/tools/perf/bench/futex-requeue.c
> @@ -36,7 +36,6 @@ static pthread_mutex_t thread_lock;
> static pthread_cond_t thread_parent, thread_worker;
> static struct stats requeuetime_stats, requeued_stats;
> static unsigned int threads_starting;
> -static int futex_flag = 0;
>
> static struct bench_futex_parameters params = {
> /*
> diff --git a/tools/perf/bench/futex-wake-parallel.c b/tools/perf/bench/futex-wake-parallel.c
> index 958372ad159c..ea4fdea6e2f3 100644
> --- a/tools/perf/bench/futex-wake-parallel.c
> +++ b/tools/perf/bench/futex-wake-parallel.c
> @@ -53,7 +53,6 @@ static pthread_cond_t thread_parent, thread_worker;
> static pthread_barrier_t barrier;
> static struct stats waketime_stats, wakeup_stats;
> static unsigned int threads_starting;
> -static int futex_flag = 0;
>
> static struct bench_futex_parameters params;
>
> diff --git a/tools/perf/bench/futex-wake.c b/tools/perf/bench/futex-wake.c
> index 9ed4d65416f3..1cf651c8ee5c 100644
> --- a/tools/perf/bench/futex-wake.c
> +++ b/tools/perf/bench/futex-wake.c
> @@ -37,7 +37,6 @@ static pthread_mutex_t thread_lock;
> static pthread_cond_t thread_parent, thread_worker;
> static struct stats waketime_stats, wakeup_stats;
> static unsigned int threads_starting;
> -static int futex_flag = 0;
>
> static struct bench_futex_parameters params = {
> /*
> diff --git a/tools/perf/bench/futex.h b/tools/perf/bench/futex.h
> index 6f8b85b67348..f7cd22bbd677 100644
> --- a/tools/perf/bench/futex.h
> +++ b/tools/perf/bench/futex.h
> @@ -13,6 +13,9 @@
> #include <sys/types.h>
> #include <linux/futex.h>
>
> +/* FUTEX_PRIVATE_FLAG or zero */
> +static int futex_flag = 0;
> +
> struct bench_futex_parameters {
> bool silent;
> bool fshared;
> --
> 2.26.2
>

--

- Arnaldo