mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Song Liu <songliubraving@fb.com>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Kan Liang <kan.liang@linux.intel.com>,
	lkml <linux-kernel@vger.kernel.org>,
	Ingo Molnar <mingo@kernel.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Namhyung Kim <namhyung@kernel.org>,
	"bpf@vger.kernel.org" <bpf@vger.kernel.org>,
	Daniel Xu <dxu@dxuuu.xyz>
Subject: Re: [PATCH -tip] bpf: Check flags for branch stack in bpf_read_branch_records helper
Date: Tue, 27 Sep 2022 21:50:36 +0000	[thread overview]
Message-ID: <CE965785-D811-4E37-8EFB-0FCF79F69A04@fb.com> (raw)
In-Reply-To: <A702994E-0649-4B05-970D-9CB8694E86F7@fb.com>



> On Sep 27, 2022, at 2:49 PM, Song Liu <songliubraving@fb.com> wrote:
> 
> 
> 
>> On Sep 27, 2022, at 1:32 PM, Jiri Olsa <jolsa@kernel.org> wrote:
>> 
>> Recent commit [1] changed branch stack data indication from
>> br_stack pointer to sample_flags in perf_sample_data struct.
>> 
>> We need to check sample_flags for PERF_SAMPLE_BRANCH_STACK
>> bit for valid branch stack data.
>> 
>> [1] a9a931e26668 ("perf: Use sample_flags for branch stack")
>> 
>> Cc: Kan Liang <kan.liang@linux.intel.com>
>> Fixes: a9a931e26668 ("perf: Use sample_flags for branch stack")
>> Signed-off-by: Jiri Olsa <jolsa@kernel.org>

Acked-by: Song Liu <song@kernel.org>

> 
> Thanks for the fix! I noticed the issue last week, but haven't
> got time to look into it. 
> 
> Song
> 
>> ---
>> NOTE sending on top of tip/master because [1] is not
>>    merged in bpf-next/master yet
>> 
>> kernel/trace/bpf_trace.c | 3 +++
>> 1 file changed, 3 insertions(+)
>> 
>> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
>> index 68e5cdd24cef..1fcd1234607e 100644
>> --- a/kernel/trace/bpf_trace.c
>> +++ b/kernel/trace/bpf_trace.c
>> @@ -1507,6 +1507,9 @@ BPF_CALL_4(bpf_read_branch_records, struct bpf_perf_event_data_kern *, ctx,
>> 	if (unlikely(flags & ~BPF_F_GET_BRANCH_RECORDS_SIZE))
>> 		return -EINVAL;
>> 
>> +	if (unlikely(!(ctx->data->sample_flags & PERF_SAMPLE_BRANCH_STACK)))
>> +		return -ENOENT;
>> +
>> 	if (unlikely(!br_stack))
>> 		return -ENOENT;
>> 
>> -- 
>> 2.37.3


  reply	other threads:[~2022-09-27 21:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-27 20:32 Jiri Olsa
2022-09-27 20:41 ` Liang, Kan
2022-09-27 20:46 ` Peter Zijlstra
2022-09-27 21:24   ` Jiri Olsa
2022-09-27 21:49 ` Song Liu
2022-09-27 21:50   ` Song Liu [this message]
2022-09-28  6:57 ` [tip: perf/core] " tip-bot2 for Jiri Olsa

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=CE965785-D811-4E37-8EFB-0FCF79F69A04@fb.com \
    --to=songliubraving@fb.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@kernel.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=dxu@dxuuu.xyz \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.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

all inboxes | Powered by JetHome®