lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250128112202.GA7145@noisy.programming.kicks-ass.net>
Date: Tue, 28 Jan 2025 12:22:02 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Dapeng Mi <dapeng1.mi@...ux.intel.com>
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 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 ?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ