From: Peter Zijlstra <peterz@infradead.org>
To: Dapeng Mi <dapeng1.mi@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Namhyung Kim <namhyung@kernel.org>,
Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Eranian Stephane <eranian@google.com>,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
Dapeng Mi <dapeng1.mi@intel.com>,
Kan Liang <kan.liang@linux.intel.com>
Subject: Re: [Patch v8 06/12] perf/x86/intel/ds: Factor out PEBS record processing code to functions
Date: Wed, 22 Oct 2025 13:49:17 +0200 [thread overview]
Message-ID: <20251022114917.GT3245006@noisy.programming.kicks-ass.net> (raw)
In-Reply-To: <20251015064422.47437-7-dapeng1.mi@linux.intel.com>
On Wed, Oct 15, 2025 at 02:44:16PM +0800, Dapeng Mi wrote:
> Beside some PEBS record layout difference, arch-PEBS can share most of
> PEBS record processing code with adaptive PEBS. Thus, factor out these
> common processing code to independent inline functions, so they can be
> reused by subsequent arch-PEBS handler.
>
> Suggested-by: Kan Liang <kan.liang@linux.intel.com>
> Signed-off-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
> ---
> arch/x86/events/intel/ds.c | 101 ++++++++++++++++++++++++-------------
> 1 file changed, 66 insertions(+), 35 deletions(-)
>
> diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
> index a80881a20321..41acbf0a11c9 100644
> --- a/arch/x86/events/intel/ds.c
> +++ b/arch/x86/events/intel/ds.c
> @@ -2629,6 +2629,64 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs, struct perf_sample_d
> }
> }
>
> +static inline void __intel_pmu_handle_pebs_record(struct pt_regs *iregs,
> + struct pt_regs *regs,
> + struct perf_sample_data *data,
> + void *at, u64 pebs_status,
> + struct perf_event *events[],
> + short *counts, void **last,
> + setup_fn setup_sample)
> +{
> + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> + struct perf_event *event;
> + int bit;
> +
> + for_each_set_bit(bit, (unsigned long *)&pebs_status, X86_PMC_IDX_MAX) {
> + event = cpuc->events[bit];
> +
> + if (WARN_ON_ONCE(!event) ||
> + WARN_ON_ONCE(!event->attr.precise_ip))
> + continue;
> +
> + if (counts[bit]++)
> + __intel_pmu_pebs_event(event, iregs, regs, data,
> + last[bit], setup_sample);
> +
> + last[bit] = at;
> + /*
> + * perf_event_overflow() called by below __intel_pmu_pebs_last_event()
> + * could trigger interrupt throttle and clear all event pointers of
> + * the group in cpuc->events[] to NULL. So snapshot the event[] before
> + * it could be cleared. This avoids the possible NULL event pointer
> + * access and PEBS record loss.
> + */
> + if (counts[bit] && !events[bit])
> + events[bit] = cpuc->events[bit];
> + }
> +}
> +
> +static inline void
> +__intel_pmu_handle_last_pebs_record(struct pt_regs *iregs, struct pt_regs *regs,
> + struct perf_sample_data *data, u64 mask,
> + struct perf_event *events[],
> + short *counts, void **last,
> + setup_fn setup_sample)
> +{
> + struct perf_event *event;
> + int bit;
> +
> + for_each_set_bit(bit, (unsigned long *)&mask, X86_PMC_IDX_MAX) {
> + if (!counts[bit])
> + continue;
> +
> + event = events[bit];
> +
> + __intel_pmu_pebs_last_event(event, iregs, regs, data, last[bit],
> + counts[bit], setup_sample);
> + }
> +
> +}
These need to be __always_inline, like the other functions that take
setup_fn. Otherwise the compiler might decide to not inline and then it
can't constant propagate this function and we get indirect calls.
next prev parent reply other threads:[~2025-10-22 11:49 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-15 6:44 [Patch v8 00/12] arch-PEBS enabling for Intel platforms Dapeng Mi
2025-10-15 6:44 ` [Patch v8 01/12] perf/x86: Remove redundant is_x86_event() prototype Dapeng Mi
2025-10-15 6:44 ` [Patch v8 02/12] perf/x86/intel: Fix NULL event access and potential PEBS record loss Dapeng Mi
2025-10-22 8:12 ` Mi, Dapeng
2025-10-22 11:24 ` Peter Zijlstra
2025-10-23 2:29 ` Mi, Dapeng
2025-10-15 6:44 ` [Patch v8 03/12] perf/x86/intel: Replace x86_pmu.drain_pebs calling with static call Dapeng Mi
2025-10-15 6:44 ` [Patch v8 04/12] perf/x86/intel: Correct large PEBS flag check Dapeng Mi
2025-10-15 6:44 ` [Patch v8 05/12] perf/x86/intel: Initialize architectural PEBS Dapeng Mi
2025-10-21 15:43 ` Peter Zijlstra
2025-10-22 5:27 ` Mi, Dapeng
2025-10-15 6:44 ` [Patch v8 06/12] perf/x86/intel/ds: Factor out PEBS record processing code to functions Dapeng Mi
2025-10-21 15:49 ` Peter Zijlstra
2025-10-22 5:32 ` Mi, Dapeng
2025-10-22 11:49 ` Peter Zijlstra [this message]
2025-10-23 1:06 ` Mi, Dapeng
2025-10-15 6:44 ` [Patch v8 07/12] perf/x86/intel/ds: Factor out PEBS group " Dapeng Mi
2025-10-15 6:44 ` [Patch v8 08/12] perf/x86/intel: Process arch-PEBS records or record fragments Dapeng Mi
2025-10-15 6:44 ` [Patch v8 09/12] perf/x86/intel: Allocate arch-PEBS buffer and initialize PEBS_BASE MSR Dapeng Mi
2025-10-15 6:44 ` [Patch v8 10/12] perf/x86/intel: Update dyn_constranit base on PEBS event precise level Dapeng Mi
2025-10-15 6:44 ` [Patch v8 11/12] perf/x86/intel: Setup PEBS data configuration and enable legacy groups Dapeng Mi
2025-10-15 6:44 ` [Patch v8 12/12] perf/x86/intel: Add counter group support for arch-PEBS Dapeng Mi
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=20251022114917.GT3245006@noisy.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=ak@linux.intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=dapeng1.mi@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