]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
perf pmus: Fix name comparisons on 32-bit systems
authorIan Rogers <irogers@google.com>
Sat, 31 Aug 2024 07:04:10 +0000 (00:04 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Tue, 3 Sep 2024 14:21:09 +0000 (11:21 -0300)
The hex PMU suffix maybe 64-bit but the comparisons were "unsigned
long" or 32-bit on 32-bit systems. This was causing the "PMU name
comparison" test to fail in a 32-bit build.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Chaitanya S Prakash <chaitanyas.prakash@arm.com>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: David Ahern <dsa@cumulusnetworks.com>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@linaro.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: Junhao He <hejunhao3@huawei.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yang Jihong <yangjihong@bytedance.com>
Link: https://lore.kernel.org/r/20240831070415.506194-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/pmus.c

index 3fcabfd8fca190bf3870b9f6fe5fbc2674b3ff4f..769b920d9250d3221c4b0c21df9ddf1026487b0d 100644 (file)
@@ -69,7 +69,7 @@ size_t pmu_name_len_no_suffix(const char *str)
 
 int pmu_name_cmp(const char *lhs_pmu_name, const char *rhs_pmu_name)
 {
-       unsigned long lhs_num = 0, rhs_num = 0;
+       unsigned long long lhs_num = 0, rhs_num = 0;
        size_t lhs_pmu_name_len = pmu_name_len_no_suffix(lhs_pmu_name);
        size_t rhs_pmu_name_len = pmu_name_len_no_suffix(rhs_pmu_name);
        int ret = strncmp(lhs_pmu_name, rhs_pmu_name,
@@ -79,9 +79,9 @@ int pmu_name_cmp(const char *lhs_pmu_name, const char *rhs_pmu_name)
                return ret;
 
        if (lhs_pmu_name_len + 1 < strlen(lhs_pmu_name))
-               lhs_num = strtoul(&lhs_pmu_name[lhs_pmu_name_len + 1], NULL, 16);
+               lhs_num = strtoull(&lhs_pmu_name[lhs_pmu_name_len + 1], NULL, 16);
        if (rhs_pmu_name_len + 1 < strlen(rhs_pmu_name))
-               rhs_num = strtoul(&rhs_pmu_name[rhs_pmu_name_len + 1], NULL, 16);
+               rhs_num = strtoull(&rhs_pmu_name[rhs_pmu_name_len + 1], NULL, 16);
 
        return lhs_num < rhs_num ? -1 : (lhs_num > rhs_num ? 1 : 0);
 }