Skip to contentSkip to conversation

perf: arm64: Fix build with refcount checking

PATCH Applied James Clark 3 participants 3 messages May 4, 2023 – May 10, 2023

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: arm64: Fix build with refcount checking

With EXTRA_CFLAGS=-DREFCNT_CHECKING=1 and build-test, some unwrapped map accesses appear. Wrap it in the new accessor to fix the error:

error: 'struct perf_cpu_map' has no member named 'map'

---
 tools/perf/arch/arm64/util/header.c | 4 ++--
 tools/perf/arch/arm64/util/pmu.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/arch/arm64/util/header.c +2 -2
index d730666ab95d..80b9f6287fe2 100644
@@ -29,8 +29,8 @@ static int _get_cpuid(char *buf, size_t sz, struct perf_cpu_map *cpus)
 		char path[PATH_MAX];
 		FILE *file;
 
-		scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR,
-				sysfs, cpus->map[cpu]);
+		scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d" MIDR,
+			  sysfs, RC_CHK_ACCESS(cpus)->map[cpu].cpu);
 
 		file = fopen(path, "r");
 		if (!file) {
tools/perf/arch/arm64/util/pmu.c +1 -1
index fa143acb4c8d..ef1ed645097c 100644
@@ -18,7 +18,7 @@ static struct perf_pmu *pmu__find_core_pmu(void)
 		 * The cpumap should cover all CPUs. Otherwise, some CPUs may
 		 * not support some events or have different event IDs.
 		 */
-		if (pmu->cpus->nr != cpu__max_cpu().cpu)
+		if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu)
 			return NULL;
 
 		return pmu;
Signature · 1 line
2.34.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · James Clark

With EXTRA_CFLAGS=-DREFCNT_CHECKING=1 and build-test, some unwrapped map accesses appear. Wrap it in the new accessor to fix the error:

error: 'struct perf_cpu_map' has no member named 'map'

Thanks James and sorry for the breakage!

Ian

Quoted 36 lines
---
 tools/perf/arch/arm64/util/header.c | 4 ++--
 tools/perf/arch/arm64/util/pmu.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/arch/arm64/util/header.c +2 -2
index d730666ab95d..80b9f6287fe2 100644
@@ -29,8 +29,8 @@ static int _get_cpuid(char *buf, size_t sz, struct perf_cpu_map *cpus)
                char path[PATH_MAX];
                FILE *file;
 
-               scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR,
-                               sysfs, cpus->map[cpu]);
+               scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d" MIDR,
+                         sysfs, RC_CHK_ACCESS(cpus)->map[cpu].cpu);
 
                file = fopen(path, "r");
                if (!file) {
tools/perf/arch/arm64/util/pmu.c +1 -2
index fa143acb4c8d..ef1ed645097c 100644
@@ -18,7 +18,7 @@ static struct perf_pmu *pmu__find_core_pmu(void)
                 * The cpumap should cover all CPUs. Otherwise, some CPUs may
                 * not support some events or have different event IDs.
                 */
-               if (pmu->cpus->nr != cpu__max_cpu().cpu)
+               if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu)
                        return NULL;
 
                return pmu;
--

2.34.1

maintainer Applied
#2 lore raw

Em Thu, May 04, 2023 at 09:28:21AM -0700, Ian Rogers escreveu:

Quoted 11 lines · James Clark
Quoted 7 lines

With EXTRA_CFLAGS=-DREFCNT_CHECKING=1 and build-test, some unwrapped map accesses appear. Wrap it in the new accessor to fix the error:

error: 'struct perf_cpu_map' has no member named 'map'

Thanks James and sorry for the breakage!

Thanks, applied.

- Arnaldo

Quoted 38 lines

Ian

Quoted 36 lines
---
 tools/perf/arch/arm64/util/header.c | 4 ++--
 tools/perf/arch/arm64/util/pmu.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/perf/arch/arm64/util/header.c +2 -2
index d730666ab95d..80b9f6287fe2 100644
@@ -29,8 +29,8 @@ static int _get_cpuid(char *buf, size_t sz, struct perf_cpu_map *cpus)
                char path[PATH_MAX];
                FILE *file;
 
-               scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d"MIDR,
-                               sysfs, cpus->map[cpu]);
+               scnprintf(path, PATH_MAX, "%s/devices/system/cpu/cpu%d" MIDR,
+                         sysfs, RC_CHK_ACCESS(cpus)->map[cpu].cpu);
 
                file = fopen(path, "r");
                if (!file) {
tools/perf/arch/arm64/util/pmu.c +1 -2
index fa143acb4c8d..ef1ed645097c 100644
@@ -18,7 +18,7 @@ static struct perf_pmu *pmu__find_core_pmu(void)
                 * The cpumap should cover all CPUs. Otherwise, some CPUs may
                 * not support some events or have different event IDs.
                 */
-               if (pmu->cpus->nr != cpu__max_cpu().cpu)
+               if (RC_CHK_ACCESS(pmu->cpus)->nr != cpu__max_cpu().cpu)
                        return NULL;
 
                return pmu;
--

2.34.1

Signature · 1 line
- Arnaldo