[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200210093624.GB14879@hirez.programming.kicks-ass.net>
Date: Mon, 10 Feb 2020 10:36:24 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Amol Grover <frextrite@...il.com>
Cc: Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...hat.com>,
Namhyung Kim <namhyung@...nel.org>,
linux-kernel@...r.kernel.org,
linux-kernel-mentees@...ts.linuxfoundation.org,
Joel Fernandes <joel@...lfernandes.org>,
Madhuparna Bhowmik <madhuparnabhowmik10@...il.com>,
"Paul E . McKenney" <paulmck@...nel.org>
Subject: Re: [PATCH] events: Annotate parent_ctx with __rcu
On Sat, Feb 08, 2020 at 08:16:49PM +0530, Amol Grover wrote:
> parent_ctx is used under RCU context in kernel/events/core.c,
> tell sparse about it aswell.
>
> Fixes the following instances of sparse error:
> kernel/events/core.c:3221:18: error: incompatible types in comparison
> kernel/events/core.c:3222:23: error: incompatible types in comparison
>
> This introduces the following two sparse errors:
> kernel/events/core.c:3117:18: error: incompatible types in comparison
> kernel/events/core.c:3121:30: error: incompatible types in comparison
>
> Hence, use rcu_dereference() to access parent_ctx and silence
> the newly introduced errors.
>
> Signed-off-by: Amol Grover <frextrite@...il.com>
> ---
> include/linux/perf_event.h | 2 +-
> kernel/events/core.c | 11 ++++++++---
> 2 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 6d4c22aee384..e18a7bdc6f98 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -810,7 +810,7 @@ struct perf_event_context {
> * These fields let us detect when two contexts have both
> * been cloned (inherited) from a common ancestor.
> */
> - struct perf_event_context *parent_ctx;
> + struct perf_event_context __rcu *parent_ctx;
> u64 parent_gen;
> u64 generation;
> int pin_count;
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 2173c23c25b4..2a8c5670b254 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3106,26 +3106,31 @@ static void ctx_sched_out(struct perf_event_context *ctx,
> static int context_equiv(struct perf_event_context *ctx1,
> struct perf_event_context *ctx2)
> {
> + struct perf_event_context *parent_ctx1, *parent_ctx2;
> +
> lockdep_assert_held(&ctx1->lock);
> lockdep_assert_held(&ctx2->lock);
>
> + parent_ctx1 = rcu_dereference(ctx1->parent_ctx);
> + parent_ctx2 = rcu_dereference(ctx2->parent_ctx);
Bah.
Why are you fixing all this sparse crap and making the code worse?
Powered by blists - more mailing lists