LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Song Liu <songliubraving@fb.com>
Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
acme@kernel.org, mingo@redhat.com, kernel-team@fb.com
Subject: Re: [PATCH bpf-next 1/3] perf: enable branch record for software events
Date: Wed, 25 Aug 2021 14:09:23 +0200 [thread overview]
Message-ID: <YSYy87ta1GpXCCzk@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20210824060157.3889139-2-songliubraving@fb.com>
On Mon, Aug 23, 2021 at 11:01:55PM -0700, Song Liu wrote:
> arch/x86/events/intel/core.c | 5 ++++-
> arch/x86/events/intel/lbr.c | 12 ++++++++++++
> arch/x86/events/perf_event.h | 2 ++
> include/linux/perf_event.h | 33 +++++++++++++++++++++++++++++++++
> kernel/events/core.c | 28 ++++++++++++++++++++++++++++
> 5 files changed, 79 insertions(+), 1 deletion(-)
No PowerPC support :/
> +void intel_pmu_snapshot_branch_stack(void)
> +{
> + struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
> +
> + intel_pmu_lbr_disable_all();
> + intel_pmu_lbr_read();
> + memcpy(this_cpu_ptr(&perf_branch_snapshot_entries), cpuc->lbr_entries,
> + sizeof(struct perf_branch_entry) * x86_pmu.lbr_nr);
> + *this_cpu_ptr(&perf_branch_snapshot_size) = x86_pmu.lbr_nr;
> + intel_pmu_lbr_enable_all(false);
> +}
Still has the layering violation and issues vs PMI.
> +#ifdef CONFIG_HAVE_STATIC_CALL
> +DECLARE_STATIC_CALL(perf_snapshot_branch_stack,
> + perf_default_snapshot_branch_stack);
> +#else
> +extern void (*perf_snapshot_branch_stack)(void);
> +#endif
That's weird, static call should work unconditionally, and fall back to
a regular function pointer exactly like you do here. Search for:
"Generic Implementation" in include/linux/static_call.h
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 011cc5069b7ba..b42cc20451709 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> +#ifdef CONFIG_HAVE_STATIC_CALL
> +DEFINE_STATIC_CALL(perf_snapshot_branch_stack,
> + perf_default_snapshot_branch_stack);
> +#else
> +void (*perf_snapshot_branch_stack)(void) = perf_default_snapshot_branch_stack;
> +#endif
Idem.
Something like:
DEFINE_STATIC_CALL_NULL(perf_snapshot_branch_stack, void (*)(void));
with usage like: static_call_cond(perf_snapshot_branch_stack)();
Should unconditionally work.
> +int perf_read_branch_snapshot(void *buf, size_t len)
> +{
> + int cnt;
> +
> + memcpy(buf, *this_cpu_ptr(&perf_branch_snapshot_entries),
> + min_t(u32, (u32)len,
> + sizeof(struct perf_branch_entry) * MAX_BRANCH_SNAPSHOT));
> + cnt = *this_cpu_ptr(&perf_branch_snapshot_size);
> +
> + return (cnt > 0) ? cnt : -EOPNOTSUPP;
> +}
Doesn't seem used at all..
next prev parent reply other threads:[~2021-08-25 12:10 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 6:01 [PATCH bpf-next 0/3] bpf: introduce bpf_get_branch_trace Song Liu
2021-08-24 6:01 ` [PATCH bpf-next 1/3] perf: enable branch record for software events Song Liu
2021-08-25 12:09 ` Peter Zijlstra [this message]
2021-08-25 15:22 ` Song Liu
2021-08-26 7:56 ` kajoljain
2021-08-26 16:41 ` Song Liu
2021-08-24 6:01 ` [PATCH bpf-next 2/3] bpf: introduce helper bpf_get_branch_trace Song Liu
2021-08-25 1:14 ` kernel test robot
2021-08-24 6:01 ` [PATCH bpf-next 3/3] selftests/bpf: add test for bpf_get_branch_trace Song Liu
2021-08-31 1:30 [selftests/bpf] 8dff2c1958: BUG:using_smp_processor_id()in_preemptible kernel test robot
2021-08-31 4:45 ` Song Liu
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=YSYy87ta1GpXCCzk@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=songliubraving@fb.com \
--subject='Re: [PATCH bpf-next 1/3] perf: enable branch record for software events' \
/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
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).