[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <7a03fdf5-f080-4580-8850-20dc88003d14@linux.intel.com>
Date: Thu, 6 Feb 2025 10:25:59 +0800
From: "Mi, Dapeng" <dapeng1.mi@...ux.intel.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo
<acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>, Adrian Hunter <adrian.hunter@...el.com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Kan Liang <kan.liang@...ux.intel.com>, Andi Kleen <ak@...ux.intel.com>,
Eranian Stephane <eranian@...gle.com>, linux-kernel@...r.kernel.org,
linux-perf-users@...r.kernel.org, Dapeng Mi <dapeng1.mi@...el.com>
Subject: Re: [PATCH 06/20] perf/x86/intel: Initialize architectural PEBS
On 1/28/2025 7:22 PM, Peter Zijlstra wrote:
> On Thu, Jan 23, 2025 at 02:07:07PM +0000, Dapeng Mi wrote:
>
>
>> diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c
>> index e8a06c8486af..1b33a6a60584 100644
>> --- a/arch/x86/events/intel/ds.c
>> +++ b/arch/x86/events/intel/ds.c
>> @@ -1537,6 +1537,9 @@ void intel_pmu_pebs_enable(struct perf_event *event)
>>
>> cpuc->pebs_enabled |= 1ULL << hwc->idx;
>>
>> + if (x86_pmu.arch_pebs)
>> + return;
>> +
>> if ((event->hw.flags & PERF_X86_EVENT_PEBS_LDLAT) && (x86_pmu.version < 5))
>> cpuc->pebs_enabled |= 1ULL << (hwc->idx + 32);
>> else if (event->hw.flags & PERF_X86_EVENT_PEBS_ST)
>> @@ -1606,6 +1609,11 @@ void intel_pmu_pebs_disable(struct perf_event *event)
>>
>> cpuc->pebs_enabled &= ~(1ULL << hwc->idx);
>>
>> + hwc->config |= ARCH_PERFMON_EVENTSEL_INT;
>> +
>> + if (x86_pmu.arch_pebs)
>> + return;
>> +
>> if ((event->hw.flags & PERF_X86_EVENT_PEBS_LDLAT) &&
>> (x86_pmu.version < 5))
>> cpuc->pebs_enabled &= ~(1ULL << (hwc->idx + 32));
>> @@ -1616,15 +1624,13 @@ void intel_pmu_pebs_disable(struct perf_event *event)
>>
>> if (cpuc->enabled)
>> wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
>> -
>> - hwc->config |= ARCH_PERFMON_EVENTSEL_INT;
>> }
>>
>> void intel_pmu_pebs_enable_all(void)
>> {
>> struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
>>
>> - if (cpuc->pebs_enabled)
>> + if (!x86_pmu.arch_pebs && cpuc->pebs_enabled)
>> wrmsrl(MSR_IA32_PEBS_ENABLE, cpuc->pebs_enabled);
>> }
>>
>> @@ -1632,7 +1638,7 @@ void intel_pmu_pebs_disable_all(void)
>> {
>> struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
>>
>> - if (cpuc->pebs_enabled)
>> + if (!x86_pmu.arch_pebs && cpuc->pebs_enabled)
>> __intel_pmu_pebs_disable_all();
>> }
> So there's a ton of if (arch_pebs) sprinkled around. Can't we avoid that
> by using a few static_call()s ?
Sure. Let me try it.
Powered by blists - more mailing lists