From: Peter Zijlstra <peterz@infradead.org>
To: kan.liang@linux.intel.com
Cc: mingo@redhat.com, acme@kernel.org, namhyung@kernel.org,
irogers@google.com, adrian.hunter@intel.com,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
ak@linux.intel.com, eranian@google.com,
dapeng1.mi@linux.intel.com
Subject: Re: [PATCH V9 3/3] perf/x86/intel: Support PEBS counters snapshotting
Date: Thu, 16 Jan 2025 12:47:51 +0100 [thread overview]
Message-ID: <20250116114751.GJ8362@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20250115184318.2854459-3-kan.liang@linux.intel.com>
On Wed, Jan 15, 2025 at 10:43:18AM -0800, kan.liang@linux.intel.com wrote:
> Reviewed-by: Andi Kleen <ak@linux.intel.com>
> Reviewed-by: Ian Rogers <irogers@google.com>
Did they really read all the various versions without spotting any of
the problems, or are you just rubber stamping things at this point :/
Best to drop review tags after serious changes to patches.
> Suggested-by: Peter Zijlstra (Intel) <peterz@infradead.org>
> Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
> ---
> diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
> index 8f218ac0d445..79a4aad5a0a3 100644
> --- a/arch/x86/events/core.c
> +++ b/arch/x86/events/core.c
> @@ -94,6 +94,8 @@ DEFINE_STATIC_CALL_NULL(x86_pmu_pebs_aliases, *x86_pmu.pebs_aliases);
>
> DEFINE_STATIC_CALL_NULL(x86_pmu_filter, *x86_pmu.filter);
>
> +DEFINE_STATIC_CALL_NULL(x86_pmu_late_config, x86_pmu_late_config);
So all these static call are through struct x86_pmu (hence the naming),
but not this one ?!?
> /*
> * This one is magic, it will get called even when PMU init fails (because
> * there is no PMU), in which case it should simply return NULL.
> @@ -1329,7 +1331,16 @@ static void x86_pmu_enable(struct pmu *pmu)
> }
>
> /*
> - * step2: reprogram moved events into new counters
> + * step2:
> + * The late config (after counters are scheduled)
> + * is required for some cases, e.g., PEBS counters
> + * snapshotting. Because an accurate counter index
> + * is needed.
> + */
> + static_call_cond(x86_pmu_late_config)();
> +
> + /*
> + * step3: reprogram moved events into new counters
> */
> for (i = 0; i < cpuc->n_events; i++) {
> event = cpuc->event_list[i];
Placement and naming are weird.
These 2 loops migrate all counters that got a new place, the first loop
taking out pre-existing counters that got a new place, the second loop
setting up these same and new counters.
Why do the pebs config in the middle, where the least number of counters
are set-up?
AFAICT all it really needs is cpuc->assignp[], which is unchanged
throughout. You can call this at any time before clearing n_added,
sticking it in the middle just seems weird.
Then naming, config is typically what we do at event creation,
x86_pmu_hw_config() like. This is not at all related, so perhaps pick a
different name?
Bah, we're so very close between x86_pmu::{enable, disable, assign}() :/
Also, I think I found you another bug... Consider what happens to the
counter value when we reschedule a HES_STOPPED counter, then we skip
x86_pmu_start(RELOAD) on step2, which leave the counter value with
'random' crap from whatever was there last.
But meanwhile you do program PEBS to sample it. That will happily sample
this garbage.
Hmm?
next prev parent reply other threads:[~2025-01-16 11:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-15 18:43 [PATCH V9 1/3] perf/x86/intel: Avoid pmu_disable/enable if !cpuc->enabled in sample read kan.liang
2025-01-15 18:43 ` [PATCH V9 2/3] perf: Avoid the read if the count is already updated kan.liang
2025-01-15 18:43 ` [PATCH V9 3/3] perf/x86/intel: Support PEBS counters snapshotting kan.liang
2025-01-16 11:47 ` Peter Zijlstra [this message]
2025-01-16 15:55 ` Liang, Kan
2025-01-16 20:42 ` Peter Zijlstra
2025-01-16 20:56 ` Peter Zijlstra
2025-01-16 21:50 ` Liang, Kan
2025-01-21 15:25 ` Liang, Kan
2025-01-23 9:14 ` Peter Zijlstra
2025-01-23 15:36 ` Liang, Kan
2025-01-16 12:02 ` Peter Zijlstra
2025-01-16 10:32 ` [PATCH V9 1/3] perf/x86/intel: Avoid pmu_disable/enable if !cpuc->enabled in sample read Peter Zijlstra
2025-01-16 10:51 ` Peter Zijlstra
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=20250116114751.GJ8362@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=dapeng1.mi@linux.intel.com \
--cc=eranian@google.com \
--cc=irogers@google.com \
--cc=kan.liang@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.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