All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] perf lock contention: Fix builtin detection
@ 2023-03-08  0:30 Ian Rogers
  2023-03-08  1:41 ` Namhyung Kim
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Rogers @ 2023-03-08  0:30 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Ian Rogers, Martin KaFai Lau, linux-perf-users, linux-kernel,
	bpf

__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: 1bece1351c65 ("perf lock contention: Support old rw_semaphore type")
Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/bpf_skel/lock_contention.bpf.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/bpf_skel/lock_contention.bpf.c b/tools/perf/util/bpf_skel/lock_contention.bpf.c
index e6007eaeda1a..141b36d13b19 100644
--- a/tools/perf/util/bpf_skel/lock_contention.bpf.c
+++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c
@@ -182,7 +182,13 @@ static inline struct task_struct *get_lock_owner(__u64 lock, __u32 flags)
 		struct mutex *mutex = (void *)lock;
 		owner = BPF_CORE_READ(mutex, owner.counter);
 	} else if (flags == LCB_F_READ || flags == LCB_F_WRITE) {
-#if __has_builtin(bpf_core_type_matches)
+	/*
+	 * Support for the BPF_TYPE_MATCHES argument to the
+	 * __builtin_preserve_type_info builtin was added at some point during
+	 * development of clang 15 and it's what is needed for
+	 * bpf_core_type_matches.
+	 */
+#if __has_builtin(__builtin_preserve_type_info) && __clang_major__ >= 15
 		if (bpf_core_type_matches(struct rw_semaphore___old)) {
 			struct rw_semaphore___old *rwsem = (void *)lock;
 			owner = (unsigned long)BPF_CORE_READ(rwsem, owner);
-- 
2.40.0.rc0.216.gc4246ad0f0-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] perf lock contention: Fix builtin detection
  2023-03-08  0:30 [PATCH v2] perf lock contention: Fix builtin detection Ian Rogers
@ 2023-03-08  1:41 ` Namhyung Kim
  2023-03-13 19:14   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Namhyung Kim @ 2023-03-08  1:41 UTC (permalink / raw)
  To: Ian Rogers
  Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Martin KaFai Lau,
	linux-perf-users, linux-kernel, bpf

On Tue, Mar 7, 2023 at 4:30 PM Ian Rogers <irogers@google.com> wrote:
>
> __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: 1bece1351c65 ("perf lock contention: Support old rw_semaphore type")
> Signed-off-by: Ian Rogers <irogers@google.com>

Reviewed-by: Namhyung Kim <namhyung@kernel.org>

Thanks,
Namhyung


> ---
>  tools/perf/util/bpf_skel/lock_contention.bpf.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/bpf_skel/lock_contention.bpf.c b/tools/perf/util/bpf_skel/lock_contention.bpf.c
> index e6007eaeda1a..141b36d13b19 100644
> --- a/tools/perf/util/bpf_skel/lock_contention.bpf.c
> +++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c
> @@ -182,7 +182,13 @@ static inline struct task_struct *get_lock_owner(__u64 lock, __u32 flags)
>                 struct mutex *mutex = (void *)lock;
>                 owner = BPF_CORE_READ(mutex, owner.counter);
>         } else if (flags == LCB_F_READ || flags == LCB_F_WRITE) {
> -#if __has_builtin(bpf_core_type_matches)
> +       /*
> +        * Support for the BPF_TYPE_MATCHES argument to the
> +        * __builtin_preserve_type_info builtin was added at some point during
> +        * development of clang 15 and it's what is needed for
> +        * bpf_core_type_matches.
> +        */
> +#if __has_builtin(__builtin_preserve_type_info) && __clang_major__ >= 15
>                 if (bpf_core_type_matches(struct rw_semaphore___old)) {
>                         struct rw_semaphore___old *rwsem = (void *)lock;
>                         owner = (unsigned long)BPF_CORE_READ(rwsem, owner);
> --
> 2.40.0.rc0.216.gc4246ad0f0-goog
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] perf lock contention: Fix builtin detection
  2023-03-08  1:41 ` Namhyung Kim
@ 2023-03-13 19:14   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2023-03-13 19:14 UTC (permalink / raw)
  To: Namhyung Kim
  Cc: Ian Rogers, Peter Zijlstra, Ingo Molnar, Mark Rutland,
	Alexander Shishkin, Jiri Olsa, Martin KaFai Lau,
	linux-perf-users, linux-kernel, bpf

Em Tue, Mar 07, 2023 at 05:41:19PM -0800, Namhyung Kim escreveu:
> On Tue, Mar 7, 2023 at 4:30 PM Ian Rogers <irogers@google.com> wrote:
> >
> > __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: 1bece1351c65 ("perf lock contention: Support old rw_semaphore type")
> > Signed-off-by: Ian Rogers <irogers@google.com>
> 
> Reviewed-by: Namhyung Kim <namhyung@kernel.org>

Thanks, applied.

- Arnaldo

 
> Thanks,
> Namhyung
> 
> 
> > ---
> >  tools/perf/util/bpf_skel/lock_contention.bpf.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/perf/util/bpf_skel/lock_contention.bpf.c b/tools/perf/util/bpf_skel/lock_contention.bpf.c
> > index e6007eaeda1a..141b36d13b19 100644
> > --- a/tools/perf/util/bpf_skel/lock_contention.bpf.c
> > +++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c
> > @@ -182,7 +182,13 @@ static inline struct task_struct *get_lock_owner(__u64 lock, __u32 flags)
> >                 struct mutex *mutex = (void *)lock;
> >                 owner = BPF_CORE_READ(mutex, owner.counter);
> >         } else if (flags == LCB_F_READ || flags == LCB_F_WRITE) {
> > -#if __has_builtin(bpf_core_type_matches)
> > +       /*
> > +        * Support for the BPF_TYPE_MATCHES argument to the
> > +        * __builtin_preserve_type_info builtin was added at some point during
> > +        * development of clang 15 and it's what is needed for
> > +        * bpf_core_type_matches.
> > +        */
> > +#if __has_builtin(__builtin_preserve_type_info) && __clang_major__ >= 15
> >                 if (bpf_core_type_matches(struct rw_semaphore___old)) {
> >                         struct rw_semaphore___old *rwsem = (void *)lock;
> >                         owner = (unsigned long)BPF_CORE_READ(rwsem, owner);
> > --
> > 2.40.0.rc0.216.gc4246ad0f0-goog
> >

-- 

- Arnaldo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-03-13 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08  0:30 [PATCH v2] perf lock contention: Fix builtin detection Ian Rogers
2023-03-08  1:41 ` Namhyung Kim
2023-03-13 19:14   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.