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-next>] [day] [month] [year] [list]
Message-Id: <20220218093127.1844241-1-zhengjun.xing@linux.intel.com>
Date:   Fri, 18 Feb 2022 17:31:27 +0800
From:   zhengjun.xing@...ux.intel.com
To:     acme@...nel.org, peterz@...radead.org, mingo@...hat.com,
        alexander.shishkin@...el.com, jolsa@...hat.com
Cc:     linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
        irogers@...gle.com, adrian.hunter@...el.com, ak@...ux.intel.com,
        kan.liang@...ux.intel.com, zhengjun.xing@...ux.intel.com
Subject: [PATCH] perf tools: fix failed to use cpu list for uncore events

From: Zhengjun Xing <zhengjun.xing@...ux.intel.com>

The 'perf record' and 'perf stat' commands have supported the option
'-C/--cpus' to count or collect only on the list of CPUs provided.
commit 1d3351e631fc ("perf tools: Enable on a list of CPUs for hybrid")
add it to be supported for hybrid. For hybrid support, it checks the
cpu list are available on hybrid PMU. But when we test only uncore
events(or events not in cpu_core and cpu_atom), there is a bug:

Before:
 # perf stat -C0  -e uncore_clock/clockticks/ sleep 1
   failed to use cpu list 0

In this case, for uncore event, its pmu_name is not cpu_core or cpu_atom,
so in evlist__fix_hybrid_cpus, perf_pmu__find_hybrid_pmu should return
NULL,both events_nr and unmatched_count should be 0 ,then the cpu list
check function evlist__fix_hybrid_cpus return -1 and the error "failed
to use cpu list 0" will happen. Bypass "events_nr=0" case then the issue
is fixed.

After:
 # perf stat -C0  -e uncore_clock/clockticks/ sleep 1

 Performance counter stats for 'CPU(s) 0':

       195,476,873      uncore_clock/clockticks/

       1.004518677 seconds time elapsed

When testing with at least one core event and uncore events, it has no
issue.

 # perf stat -C0  -e cpu_core/cpu-cycles/,uncore_clock/clockticks/ sleep 1

 Performance counter stats for 'CPU(s) 0':

         5,993,774      cpu_core/cpu-cycles/
       301,025,912      uncore_clock/clockticks/

       1.003964934 seconds time elapsed

Fixes: 1d3351e631fc ("perf tools: Enable on a list of CPUs for hybrid")
Reviewed-by: Kan Liang <kan.liang@...ux.intel.com>
Signed-off-by: Zhengjun Xing <zhengjun.xing@...ux.intel.com>
---
 tools/perf/util/evlist-hybrid.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/evlist-hybrid.c b/tools/perf/util/evlist-hybrid.c
index 7f234215147d..57f02beef023 100644
--- a/tools/perf/util/evlist-hybrid.c
+++ b/tools/perf/util/evlist-hybrid.c
@@ -154,8 +154,8 @@ int evlist__fix_hybrid_cpus(struct evlist *evlist, const char *cpu_list)
 		perf_cpu_map__put(matched_cpus);
 		perf_cpu_map__put(unmatched_cpus);
 	}
-
-	ret = (unmatched_count == events_nr) ? -1 : 0;
+	if (events_nr)
+		ret = (unmatched_count == events_nr) ? -1 : 0;
 out:
 	perf_cpu_map__put(cpus);
 	return ret;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ