> On Jun 26, 2020, at 4:00 AM, Peter Zijlstra <pet...@infradead.org> wrote: > > On Thu, Jun 25, 2020 at 05:13:29PM -0700, Song Liu wrote: >> This would be used by bpf stack mapo. > > Would it make sense to sanitize the API a little before exposing it? I will fold this in the next version. Thanks, Song > > diff --git a/kernel/events/callchain.c b/kernel/events/callchain.c > index 334d48b16c36..016894b0d2c2 100644 > --- a/kernel/events/callchain.c > +++ b/kernel/events/callchain.c > @@ -159,8 +159,10 @@ static struct perf_callchain_entry > *get_callchain_entry(int *rctx) > return NULL; > > entries = rcu_dereference(callchain_cpus_entries); > - if (!entries) > + if (!entries) { > + put_recursion_context(this_cpu_ptr(callchain_recursion), rctx); > return NULL; > + } > > cpu = smp_processor_id(); > > @@ -183,12 +185,9 @@ get_perf_callchain(struct pt_regs *regs, u32 init_nr, > bool kernel, bool user, > int rctx; > > entry = get_callchain_entry(&rctx); > - if (rctx == -1) > + if (!entry || rctx == -1) > return NULL; > > - if (!entry) > - goto exit_put; > - > ctx.entry = entry; > ctx.max_stack = max_stack; > ctx.nr = entry->nr = init_nr;
- [PATCH v2 bpf-next 4/4] selftests/bpf: add bpf_iter test w... Song Liu
- Re: [PATCH v2 bpf-next 4/4] selftests/bpf: add bpf_it... Yonghong Song
- Re: [PATCH v2 bpf-next 4/4] selftests/bpf: add bpf_it... Andrii Nakryiko
- Re: [PATCH v2 bpf-next 4/4] selftests/bpf: add bp... Song Liu
- Re: [PATCH v2 bpf-next 4/4] selftests/bpf: ad... Andrii Nakryiko
- [PATCH v2 bpf-next 1/4] perf: export get/put_chain_entry() Song Liu
- Re: [PATCH v2 bpf-next 1/4] perf: export get/put_chai... Peter Zijlstra
- Re: [PATCH v2 bpf-next 1/4] perf: export get/put_... Andrii Nakryiko
- Re: [PATCH v2 bpf-next 1/4] perf: export get/put_... Song Liu
- [PATCH v2 bpf-next 2/4] bpf: introduce helper bpf_get_task... Song Liu
- Re: [PATCH v2 bpf-next 2/4] bpf: introduce helper bpf... Yonghong Song
- Re: [PATCH v2 bpf-next 2/4] bpf: introduce helper bpf... Andrii Nakryiko
- Re: [PATCH v2 bpf-next 2/4] bpf: introduce helper... Andrii Nakryiko
- Re: [PATCH v2 bpf-next 2/4] bpf: introduce helper... Song Liu
- Re: [PATCH v2 bpf-next 2/4] bpf: introduce he... Andrii Nakryiko
- Re: [PATCH v2 bpf-next 2/4] bpf: introduc... Song Liu
- Re: [PATCH v2 bpf-next 2/4] bpf: int... Andrii Nakryiko
- [PATCH v2 bpf-next 3/4] bpf: allow %pB in bpf_seq_printf()... Song Liu