Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf lock contention: Fix compiler builtin detection

__has_builtin was passed the macro rather than the actual builtin
feature. The builtin test isn't sufficient and a clang version test
also needs to be performed.

Fixes: 1bece1351c653c3d ("perf lock contention: Support old rw_semaphore type")
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: bpf@vger.kernel.org
Link: https://lore.kernel.org/r/20230308003020.3653271-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Ian Rogers and committed by
Arnaldo Carvalho de Melo
17535a33 e5af1397

+7 -1
+7 -1
tools/perf/util/bpf_skel/lock_contention.bpf.c
··· 182 182 struct mutex *mutex = (void *)lock; 183 183 owner = BPF_CORE_READ(mutex, owner.counter); 184 184 } else if (flags == LCB_F_READ || flags == LCB_F_WRITE) { 185 - #if __has_builtin(bpf_core_type_matches) 185 + /* 186 + * Support for the BPF_TYPE_MATCHES argument to the 187 + * __builtin_preserve_type_info builtin was added at some point during 188 + * development of clang 15 and it's what is needed for 189 + * bpf_core_type_matches. 190 + */ 191 + #if __has_builtin(__builtin_preserve_type_info) && __clang_major__ >= 15 186 192 if (bpf_core_type_matches(struct rw_semaphore___old)) { 187 193 struct rw_semaphore___old *rwsem = (void *)lock; 188 194 owner = (unsigned long)BPF_CORE_READ(rwsem, owner);