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: <31c90c4d-f6db-4f98-9b38-83260b0f8aa2@linux.intel.com>
Date: Thu, 25 Jan 2024 09:48:22 -0500
From: "Liang, Kan" <kan.liang@...ux.intel.com>
To: Ian Rogers <irogers@...gle.com>, Peter Zijlstra <peterz@...radead.org>,
 Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo <acme@...nel.org>,
 Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>,
 Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
 Jiri Olsa <jolsa@...nel.org>, Adrian Hunter <adrian.hunter@...el.com>,
 James Clark <james.clark@....com>, linux-perf-users@...r.kernel.org,
 linux-kernel@...r.kernel.org, Perry Taylor <perry.taylor@...el.com>,
 Samantha Alt <samantha.alt@...el.com>,
 Caleb Biggers <caleb.biggers@...el.com>, Weilin Wang
 <weilin.wang@...el.com>, Edward Baker <edward.baker@...el.com>
Subject: Re: [PATCH v1] perf pmu: Treat the msr pmu as software



On 2024-01-24 6:42 p.m., Ian Rogers wrote:
> The msr PMU is a software one, meaning msr events may be grouped
> with events in a hardware context. As the msr PMU isn't marked as a
> software PMU by perf_pmu__is_software, groups with the msr PMU in
> are broken and the msr events placed in a different group. This
> may lead to multiplexing errors where a hardware event isn't
> counted while the msr event, such as tsc, is. Fix all of this by
> marking the msr PMU as software, which agrees with the driver.

Yes, the MSR PMU is in SW context, perf_sw_context.

Reviewed-by: Kan Liang <kan.liang@...ux.intel.com>

Thanks,
Kan

> 
> Before:
> ```
> $ perf stat -e '{slots,tsc}' -a true
> WARNING: events were regrouped to match PMUs
> 
>  Performance counter stats for 'system wide':
> 
>          1,750,335      slots
>          4,243,557      tsc
> 
>        0.001456717 seconds time elapsed
> ```
> 
> After:
> ```
> $ perf stat -e '{slots,tsc}' -a true
>  Performance counter stats for 'system wide':
> 
>         12,526,380      slots
>          3,415,163      tsc
> 
>        0.001488360 seconds time elapsed
> ```
> 
> Fixes: 251aa040244a ("perf parse-events: Wildcard most "numeric" events")
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> ---
> The fixes tag is close enough rather than being fully accurate. The
> regression was introduced earlier by the automatic event regrouping.
> ---
>  tools/perf/util/pmu.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
> index 3c9609944a2f..88b9aa7d3a27 100644
> --- a/tools/perf/util/pmu.c
> +++ b/tools/perf/util/pmu.c
> @@ -1760,6 +1760,12 @@ bool pmu__name_match(const struct perf_pmu *pmu, const char *pmu_name)
>  
>  bool perf_pmu__is_software(const struct perf_pmu *pmu)
>  {
> +	const char *known_sw_pmus[] = {
> +		"kprobe",
> +		"msr",
> +		"uprobe",
> +	};
> +
>  	if (pmu->is_core || pmu->is_uncore || pmu->auxtrace)
>  		return false;
>  	switch (pmu->type) {
> @@ -1771,7 +1777,11 @@ bool perf_pmu__is_software(const struct perf_pmu *pmu)
>  	case PERF_TYPE_BREAKPOINT:	return true;
>  	default: break;
>  	}
> -	return !strcmp(pmu->name, "kprobe") || !strcmp(pmu->name, "uprobe");
> +	for (size_t i = 0; i < ARRAY_SIZE(known_sw_pmus); i++) {
> +		if (!strcmp(pmu->name, known_sw_pmus[i]))
> +			return true;
> +	}
> +	return false;
>  }
>  
>  FILE *perf_pmu__open_file(const struct perf_pmu *pmu, const char *name)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ