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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <870180d96abffb8859fe8663115c2da86fcecc60.camel@intel.com>
Date: Fri, 12 Jul 2024 03:20:45 +0000
From: "Zhang, Rui" <rui.zhang@...el.com>
To: "alexander.shishkin@...ux.intel.com" <alexander.shishkin@...ux.intel.com>,
	"dave.hansen@...ux.intel.com" <dave.hansen@...ux.intel.com>, "Hunter, Adrian"
	<adrian.hunter@...el.com>, "mingo@...hat.com" <mingo@...hat.com>,
	"irogers@...gle.com" <irogers@...gle.com>, "tglx@...utronix.de"
	<tglx@...utronix.de>, "gustavoars@...nel.org" <gustavoars@...nel.org>,
	"kan.liang@...ux.intel.com" <kan.liang@...ux.intel.com>, "kees@...nel.org"
	<kees@...nel.org>, "mark.rutland@....com" <mark.rutland@....com>,
	"peterz@...radead.org" <peterz@...radead.org>, "Dhananjay.Ugwekar@....com"
	<Dhananjay.Ugwekar@....com>, "bp@...en8.de" <bp@...en8.de>, "acme@...nel.org"
	<acme@...nel.org>, "oleksandr@...alenko.name" <oleksandr@...alenko.name>,
	"jolsa@...nel.org" <jolsa@...nel.org>, "x86@...nel.org" <x86@...nel.org>,
	"namhyung@...nel.org" <namhyung@...nel.org>
CC: "ravi.bangoria@....com" <ravi.bangoria@....com>, "kprateek.nayak@....com"
	<kprateek.nayak@....com>, "gautham.shenoy@....com" <gautham.shenoy@....com>,
	"linux-perf-users@...r.kernel.org" <linux-perf-users@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-hardening@...r.kernel.org" <linux-hardening@...r.kernel.org>,
	"sandipan.das@....com" <sandipan.das@....com>, "ananth.narayan@....com"
	<ananth.narayan@....com>, "linux-pm@...r.kernel.org"
	<linux-pm@...r.kernel.org>
Subject: Re: [PATCH v4 06/11] perf/x86/rapl: Add wrapper for online/offline
 functions

On Thu, 2024-07-11 at 10:24 +0000, Dhananjay Ugwekar wrote:
> This is in preparation for the addition of per-core RAPL counter
> support
> for AMD CPUs.
> 
> The CPU online and offline functions will need to handle the setting
> up and
> migration of the new per-core PMU as well. The wrapper functions
> added
> below will make it easier to pass the corresponding args for both the
> PMUs.
> 
> No functional change.
> 
> Signed-off-by: Dhananjay Ugwekar <Dhananjay.Ugwekar@....com>

Reviewed-by: Zhang Rui <rui.zhang@...el.com>

-rui

> ---
>  arch/x86/events/rapl.c | 30 +++++++++++++++++++++---------
>  1 file changed, 21 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/events/rapl.c b/arch/x86/events/rapl.c
> index e3d0a82e12b9..1d36565d0cb9 100644
> --- a/arch/x86/events/rapl.c
> +++ b/arch/x86/events/rapl.c
> @@ -565,10 +565,10 @@ static struct perf_msr amd_rapl_msrs[] = {
>         [PERF_RAPL_PSYS] = { 0, &rapl_events_psys_group,  NULL,
> false, 0 },
>  };
>  
> -static int rapl_cpu_offline(unsigned int cpu)
> +static int __rapl_cpu_offline(struct rapl_pmus *rapl_pmus, unsigned
> int rapl_pmu_idx,
> +                             const struct cpumask *event_cpumask,
> unsigned int cpu)
>  {
> -       const struct cpumask *rapl_pmu_cpumask =
> get_rapl_pmu_cpumask(cpu);
> -       struct rapl_pmu *rapl_pmu = cpu_to_rapl_pmu(cpu);
> +       struct rapl_pmu *rapl_pmu = rapl_pmus-
> >rapl_pmu[rapl_pmu_idx];
>         int target;
>  
>         /* Check if exiting cpu is used for collecting rapl events */
> @@ -577,7 +577,7 @@ static int rapl_cpu_offline(unsigned int cpu)
>  
>         rapl_pmu->cpu = -1;
>         /* Find a new cpu to collect rapl events */
> -       target = cpumask_any_but(rapl_pmu_cpumask, cpu);
> +       target = cpumask_any_but(event_cpumask, cpu);
>  
>         /* Migrate rapl events to the new target */
>         if (target < nr_cpu_ids) {
> @@ -588,11 +588,16 @@ static int rapl_cpu_offline(unsigned int cpu)
>         return 0;
>  }
>  
> -static int rapl_cpu_online(unsigned int cpu)
> +static int rapl_cpu_offline(unsigned int cpu)
>  {
> -       unsigned int rapl_pmu_idx = get_rapl_pmu_idx(cpu);
> -       const struct cpumask *rapl_pmu_cpumask =
> get_rapl_pmu_cpumask(cpu);
> -       struct rapl_pmu *rapl_pmu = cpu_to_rapl_pmu(cpu);
> +       return __rapl_cpu_offline(rapl_pmus, get_rapl_pmu_idx(cpu),
> +                                 get_rapl_pmu_cpumask(cpu), cpu);
> +}
> +
> +static int __rapl_cpu_online(struct rapl_pmus *rapl_pmus, unsigned
> int rapl_pmu_idx,
> +                            const struct cpumask *event_cpumask,
> unsigned int cpu)
> +{
> +       struct rapl_pmu *rapl_pmu = rapl_pmus-
> >rapl_pmu[rapl_pmu_idx];
>         int target;
>  
>         if (!rapl_pmu) {
> @@ -613,7 +618,7 @@ static int rapl_cpu_online(unsigned int cpu)
>          * Check if there is an online cpu in the package which
> collects rapl
>          * events already.
>          */
> -       target = cpumask_any_and(rapl_pmus->cpumask,
> rapl_pmu_cpumask);
> +       target = cpumask_any_and(rapl_pmus->cpumask, event_cpumask);
>         if (target < nr_cpu_ids)
>                 return 0;
>  
> @@ -622,6 +627,13 @@ static int rapl_cpu_online(unsigned int cpu)
>         return 0;
>  }
>  
> +static int rapl_cpu_online(unsigned int cpu)
> +{
> +       return __rapl_cpu_online(rapl_pmus, get_rapl_pmu_idx(cpu),
> +                                get_rapl_pmu_cpumask(cpu), cpu);
> +}
> +
> +
>  static int rapl_check_hw_unit(void)
>  {
>         u64 msr_rapl_power_unit_bits;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ