[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211013172633.GB5400@C02TD0UTHF1T.local>
Date: Wed, 13 Oct 2021 18:26:33 +0100
From: Mark Rutland <mark.rutland@....com>
To: Rob Herring <robh@...nel.org>
Cc: Will Deacon <will@...nel.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>,
Catalin Marinas <catalin.marinas@....com>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
Jiri Olsa <jolsa@...hat.com>,
Kan Liang <kan.liang@...ux.intel.com>,
Ian Rogers <irogers@...gle.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
honnappa.nagarahalli@....com, Zachary.Leaf@....com,
Raphael Gault <raphael.gault@....com>,
Jonathan Cameron <Jonathan.Cameron@...wei.com>,
Namhyung Kim <namhyung@...nel.org>,
Itaru Kitayama <itaru.kitayama@...il.com>,
Vince Weaver <vincent.weaver@...ne.edu>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v10 2/5] perf: Add a counter for number of user access
events in context
On Tue, Sep 14, 2021 at 03:47:57PM -0500, Rob Herring wrote:
> For controlling user space counter access, we need to know if any event
> in a context (currently scheduled or not) is using user space counters.
> Walking the context's list of events would be slow, so add a counter
> to track this.
>
> Signed-off-by: Rob Herring <robh@...nel.org>
Reviewed-by: Mark Rutland <mark.rutland@....com>
Mark.
> ---
> v10:
> - Re-added.
> - Maintain the count in the perf core
> v9:
> - Dropped
> v8:
> - new patch
> ---
> include/linux/perf_event.h | 1 +
> kernel/events/core.c | 4 ++++
> 2 files changed, 5 insertions(+)
>
> diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
> index 12debf008d39..4f82a4d47139 100644
> --- a/include/linux/perf_event.h
> +++ b/include/linux/perf_event.h
> @@ -821,6 +821,7 @@ struct perf_event_context {
>
> int nr_events;
> int nr_active;
> + int nr_user;
> int is_active;
> int nr_stat;
> int nr_freq;
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 744e8726c5b2..01290d150da3 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -1808,6 +1808,8 @@ list_add_event(struct perf_event *event, struct perf_event_context *ctx)
>
> list_add_rcu(&event->event_entry, &ctx->event_list);
> ctx->nr_events++;
> + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT)
> + ctx->nr_user++;
> if (event->attr.inherit_stat)
> ctx->nr_stat++;
>
> @@ -1999,6 +2001,8 @@ list_del_event(struct perf_event *event, struct perf_event_context *ctx)
> event->attach_state &= ~PERF_ATTACH_CONTEXT;
>
> ctx->nr_events--;
> + if (event->hw.flags & PERF_EVENT_FLAG_USER_READ_CNT)
> + ctx->nr_user--;
> if (event->attr.inherit_stat)
> ctx->nr_stat--;
>
> --
> 2.30.2
>
Powered by blists - more mailing lists