From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Namhyung Kim <namhyung@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Ian Rogers <irogers@google.com>,
Mingwei Zhang <mizhang@google.com>
Subject: Re: [PATCH 2/3] perf/core: Reduce PMU access to adjust sample freq
Date: Tue, 21 Nov 2023 10:57:54 -0500 [thread overview]
Message-ID: <d1117d48-2e3e-4e8e-bc47-d5f182dac928@linux.intel.com> (raw)
In-Reply-To: <20231120221932.213710-2-namhyung@kernel.org>
On 2023-11-20 5:19 p.m., Namhyung Kim wrote:
> For throttled events, it first starts the event and then stop
> unnecessarily. As it's already stopped, it can directly adjust
> the frequency and then move on.
>
> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Reviewed-by: Kan Liang <kan.liang@linux.intel.com>
Thanks,
Kan
> ---
> kernel/events/core.c | 13 ++++++++++---
> 1 file changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 53e2ad73102d..fd3449e4d081 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -4119,10 +4119,15 @@ static void perf_adjust_freq_unthr_events(struct list_head *event_list)
> if (hwc->interrupts == MAX_INTERRUPTS) {
> hwc->interrupts = 0;
> perf_log_throttle(event, 1);
> - event->pmu->start(event, 0);
> - }
>
> - if (!event->attr.freq || !event->attr.sample_freq)
> + if (!event->attr.freq || !event->attr.sample_freq) {
> + delta = 0;
> + goto next;
> + }
> +
> + if (event->hw.state & PERF_HES_STOPPED)
> + goto adjust;
> + } else if (!event->attr.freq || !event->attr.sample_freq)
> continue;
>
> /*
> @@ -4130,6 +4135,7 @@ static void perf_adjust_freq_unthr_events(struct list_head *event_list)
> */
> event->pmu->stop(event, PERF_EF_UPDATE);
>
> +adjust:
> now = local64_read(&event->count);
> delta = now - hwc->freq_count_stamp;
> hwc->freq_count_stamp = now;
> @@ -4144,6 +4150,7 @@ static void perf_adjust_freq_unthr_events(struct list_head *event_list)
> if (delta > 0)
> perf_adjust_period(event, period, delta, false);
>
> +next:
> event->pmu->start(event, delta > 0 ? PERF_EF_RELOAD : 0);
> }
> }
next prev parent reply other threads:[~2023-11-21 15:58 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-20 22:19 [PATCH 1/3] perf/core: Update perf_adjust_freq_unthr_context() Namhyung Kim
2023-11-20 22:19 ` [PATCH 2/3] perf/core: Reduce PMU access to adjust sample freq Namhyung Kim
2023-11-21 15:57 ` Liang, Kan [this message]
2023-11-20 22:19 ` [PATCH 3/3] perf/x86: Add CAP_NO_INTERRUPT for uncore PMUs Namhyung Kim
2023-11-21 15:59 ` Liang, Kan
2023-11-21 18:30 ` Namhyung Kim
2023-11-21 19:26 ` Liang, Kan
2023-12-01 20:29 ` Namhyung Kim
2023-11-20 22:41 ` [PATCH 1/3] perf/core: Update perf_adjust_freq_unthr_context() Ian Rogers
2023-11-20 23:23 ` Mingwei Zhang
2023-11-21 18:21 ` Namhyung Kim
2023-11-21 23:01 ` Mingwei Zhang
2023-11-24 0:50 ` Mingwei Zhang
2023-11-21 15:57 ` Liang, Kan
2023-12-02 6:16 ` Mingwei Zhang
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=d1117d48-2e3e-4e8e-bc47-d5f182dac928@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=irogers@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@kernel.org \
--cc=mizhang@google.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/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
all inboxes | Powered by JetHome®