From: Ian Rogers <irogers@google.com>
To: Namhyung Kim <namhyung@kernel.org>, bpf@vger.kernel.org
Cc: Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>,
Martin KaFai Lau <martin.lau@kernel.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] perf lock contention: Fix builtin detection
Date: Mon, 6 Mar 2023 21:56:38 -0800 [thread overview]
Message-ID: <CAP-5=fUQNimNSKjwZaCASyikjXJXBZdw7Z=APYEB4RyX-dXMfQ@mail.gmail.com> (raw)
In-Reply-To: <CAM9d7ci6FWx2oYAbqhVW2-tjB4p8ji3w87n-ndwxidMov+kVZw@mail.gmail.com>
On Mon, Mar 6, 2023 at 8:43 PM Namhyung Kim <namhyung@kernel.org> wrote:
>
> Hi Ian,
>
> On Mon, Mar 6, 2023 at 7:21 PM Ian Rogers <irogers@google.com> wrote:
> >
> > __has_builtin was passed the macro rather than the actual builtin
> > feature.
>
> Oh, I missed it's a macro define in tools/lib/bpf/bpf_core_read.h file.
>
> Looking at some BPF test codes, it seems you also need to check the
> clang compiler version. Please take a look at the file below:
>
> tools/testing/selftests/bpf/progs/test_core_reloc_type_base.c
>
> Thanks,
> Namhyung
Hmm..
tools/testing/selftests/bpf/progs/test_core_reloc_kernel.c:
...
/* 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 we require for this test.
*/
#if __has_builtin(__builtin_preserve_type_info) && __clang_major__ >= 15
...
I'm not sure we need to worry about development clang builds and just
the __has_builtin is cleaner. Perhaps the BPF folks can chime in.
Thanks,
Ian
> >
> > 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 | 2 +-
> > 1 file changed, 1 insertion(+), 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..e422eee0f942 100644
> > --- a/tools/perf/util/bpf_skel/lock_contention.bpf.c
> > +++ b/tools/perf/util/bpf_skel/lock_contention.bpf.c
> > @@ -182,7 +182,7 @@ 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)
> > +#if __has_builtin(__builtin_preserve_type_info)
> > 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
> >
next prev parent reply other threads:[~2023-03-07 5:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 3:21 [PATCH] perf lock contention: Fix builtin detection Ian Rogers
2023-03-07 4:43 ` Namhyung Kim
2023-03-07 5:56 ` Ian Rogers [this message]
2023-03-07 16:52 ` Namhyung Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP-5=fUQNimNSKjwZaCASyikjXJXBZdw7Z=APYEB4RyX-dXMfQ@mail.gmail.com' \
--to=irogers@google.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=bpf@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=martin.lau@kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).