From: Mark Rutland <mark.rutland@arm.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, will.deacon@arm.com,
robin.murphy@arm.com, julien.thierry@arm.com
Subject: Re: [PATCH v3 4/7] arm_pmu: Tidy up clear_event_idx call backs
Date: Fri, 29 Jun 2018 14:27:25 +0100 [thread overview]
Message-ID: <20180629132724.ztcfelcnb2dt2u35@lakrids.cambridge.arm.com> (raw)
In-Reply-To: <1529403342-17899-5-git-send-email-suzuki.poulose@arm.com>
On Tue, Jun 19, 2018 at 11:15:39AM +0100, Suzuki K Poulose wrote:
> The armpmu uses get_event_idx callback to allocate an event
> counter for a given event, which marks the selected counter
> as "used". Now, when we delete the counter, the arm_pmu goes
> ahead and clears the "used" bit and then invokes the "clear_event_idx"
> call back, which kind of splits the job between the core code
> and the backend. Tidy this up by relying on the clear_event_idx
> to do the book keeping, if available. Otherwise, let the core
> driver do the default "clear" bit operation. This will be useful
> for adding the chained event support, where we leave the event
> idx maintenance to the backend.
>
> Also, when an event is removed from the PMU, reset the hw.idx
> to indicate that a counter is not allocated for this event,
> to help the backends do better checks. This will be also used
> for the chain counter support.
>
> Cc: Mark Rutland <mark.rutland@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Reviewed-by: Julien Thierry <julien.thierry@arm.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
TBH, I think it might be better to make clear_event_idx() mandatory,
such that each backend provides both clear / set, next to each other in
the code.
It's a bit more code, but it would restore orthogonality to the API.
Mark.
> ---
> Changes since v2:
> - Reset the event counter after an event is removed.
> ---
> arch/arm/kernel/perf_event_v7.c | 2 ++
> drivers/perf/arm_pmu.c | 17 +++++++++++++----
> 2 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/kernel/perf_event_v7.c b/arch/arm/kernel/perf_event_v7.c
> index fd7ce01..765d265 100644
> --- a/arch/arm/kernel/perf_event_v7.c
> +++ b/arch/arm/kernel/perf_event_v7.c
> @@ -1637,6 +1637,7 @@ static void krait_pmu_clear_event_idx(struct pmu_hw_events *cpuc,
> bool venum_event = EVENT_VENUM(hwc->config_base);
> bool krait_event = EVENT_CPU(hwc->config_base);
>
> + clear_bit(hwc->idx, cpuc->used_mask);
> if (venum_event || krait_event) {
> bit = krait_event_to_bit(event, region, group);
> clear_bit(bit, cpuc->used_mask);
> @@ -1966,6 +1967,7 @@ static void scorpion_pmu_clear_event_idx(struct pmu_hw_events *cpuc,
> bool venum_event = EVENT_VENUM(hwc->config_base);
> bool scorpion_event = EVENT_CPU(hwc->config_base);
>
> + clear_bit(hwc->idx, cpuc->used_mask);
> if (venum_event || scorpion_event) {
> bit = scorpion_event_to_bit(event, region, group);
> clear_bit(bit, cpuc->used_mask);
> diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
> index e3766a8..6e10e8c 100644
> --- a/drivers/perf/arm_pmu.c
> +++ b/drivers/perf/arm_pmu.c
> @@ -227,6 +227,16 @@ static void armpmu_start(struct perf_event *event, int flags)
> armpmu->enable(event);
> }
>
> +static void armpmu_clear_event_idx(struct arm_pmu *armpmu,
> + struct pmu_hw_events *hw_events,
> + struct perf_event *event)
> +{
> + if (armpmu->clear_event_idx)
> + armpmu->clear_event_idx(hw_events, event);
> + else
> + clear_bit(event->hw.idx, hw_events->used_mask);
> +}
> +
> static void
> armpmu_del(struct perf_event *event, int flags)
> {
> @@ -237,11 +247,10 @@ armpmu_del(struct perf_event *event, int flags)
>
> armpmu_stop(event, PERF_EF_UPDATE);
> hw_events->events[idx] = NULL;
> - clear_bit(idx, hw_events->used_mask);
> - if (armpmu->clear_event_idx)
> - armpmu->clear_event_idx(hw_events, event);
> -
> + armpmu_clear_event_idx(armpmu, hw_events, event);
> perf_event_update_userpage(event);
> + /* Clear the allocated counter */
> + hwc->idx = -1;
> }
>
> static int
> --
> 2.7.4
>
next prev parent reply other threads:[~2018-06-29 13:27 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-19 10:15 [PATCH v3 0/7] arm64: perf: Support for chained counters Suzuki K Poulose
2018-06-19 10:15 ` [PATCH v3 1/7] arm_pmu: Clean up maximum period handling Suzuki K Poulose
2018-06-19 10:45 ` Mark Rutland
2018-06-19 10:15 ` [PATCH v3 2/7] arm_pmu: Change API to support 64bit counter values Suzuki K Poulose
2018-06-19 10:52 ` Mark Rutland
2018-06-19 10:15 ` [PATCH v3 3/7] arm_pmu: Add support for 64bit event counters Suzuki K Poulose
2018-06-19 10:57 ` Mark Rutland
2018-06-19 10:15 ` [PATCH v3 4/7] arm_pmu: Tidy up clear_event_idx call backs Suzuki K Poulose
2018-06-29 13:27 ` Mark Rutland [this message]
2018-06-29 13:40 ` Mark Rutland
2018-06-29 14:18 ` Suzuki K Poulose
2018-06-29 14:29 ` Mark Rutland
2018-06-19 10:15 ` [PATCH v3 5/7] arm64: perf: Clean up armv8pmu_select_counter Suzuki K Poulose
2018-06-29 13:29 ` Mark Rutland
2018-06-19 10:15 ` [PATCH v3 6/7] arm64: perf: Disable PMU while processing counter overflows Suzuki K Poulose
2018-06-19 10:43 ` Mark Rutland
2018-06-19 10:15 ` [PATCH v3 7/7] arm64: perf: Add support for chaining event counters Suzuki K Poulose
2018-06-29 14:01 ` Mark Rutland
2018-06-29 14:29 ` Suzuki K Poulose
2018-06-29 14:39 ` Mark Rutland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180629132724.ztcfelcnb2dt2u35@lakrids.cambridge.arm.com \
--to=mark.rutland@arm.com \
--cc=julien.thierry@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).