* [PATCH bpf-next] libbpf: fix perf_buffer__free() API for sparse allocs
@ 2020-05-27 8:42 Eelco Chaudron
2020-05-27 17:58 ` Andrii Nakryiko
0 siblings, 1 reply; 4+ messages in thread
From: Eelco Chaudron @ 2020-05-27 8:42 UTC (permalink / raw)
To: bpf; +Cc: davem, netdev, ast, daniel, kafai, songliubraving, yhs, andriin, toke
In case the cpu_bufs are sparsely allocated they are not
all free'ed. These changes will fix this.
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
tools/lib/bpf/libbpf.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 5d60de6fd818..74d967619dcf 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -8137,9 +8137,12 @@ void perf_buffer__free(struct perf_buffer *pb)
if (!pb)
return;
if (pb->cpu_bufs) {
- for (i = 0; i < pb->cpu_cnt && pb->cpu_bufs[i]; i++) {
+ for (i = 0; i < pb->cpu_cnt; i++) {
struct perf_cpu_buf *cpu_buf = pb->cpu_bufs[i];
+ if (!cpu_buf)
+ continue;
+
bpf_map_delete_elem(pb->map_fd, &cpu_buf->map_key);
perf_buffer__free_cpu_buf(pb, cpu_buf);
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix perf_buffer__free() API for sparse allocs
2020-05-27 8:42 [PATCH bpf-next] libbpf: fix perf_buffer__free() API for sparse allocs Eelco Chaudron
@ 2020-05-27 17:58 ` Andrii Nakryiko
2020-05-28 7:24 ` Eelco Chaudron
0 siblings, 1 reply; 4+ messages in thread
From: Andrii Nakryiko @ 2020-05-27 17:58 UTC (permalink / raw)
To: Eelco Chaudron
Cc: bpf, David S. Miller, Networking, Alexei Starovoitov,
Daniel Borkmann, Martin Lau, Song Liu, Yonghong Song,
Andrii Nakryiko, Toke Høiland-Jørgensen
On Wed, May 27, 2020 at 1:42 AM Eelco Chaudron <echaudro@redhat.com> wrote:
>
> In case the cpu_bufs are sparsely allocated they are not
> all free'ed. These changes will fix this.
>
> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> ---
Thanks a lot!
You forgot:
Fixes: fb84b8224655 ("libbpf: add perf buffer API")
Acked-by: Andrii Nakryiko <andriin@fb.com>
> tools/lib/bpf/libbpf.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 5d60de6fd818..74d967619dcf 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -8137,9 +8137,12 @@ void perf_buffer__free(struct perf_buffer *pb)
> if (!pb)
> return;
> if (pb->cpu_bufs) {
> - for (i = 0; i < pb->cpu_cnt && pb->cpu_bufs[i]; i++) {
> + for (i = 0; i < pb->cpu_cnt; i++) {
> struct perf_cpu_buf *cpu_buf = pb->cpu_bufs[i];
>
> + if (!cpu_buf)
> + continue;
> +
> bpf_map_delete_elem(pb->map_fd, &cpu_buf->map_key);
> perf_buffer__free_cpu_buf(pb, cpu_buf);
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix perf_buffer__free() API for sparse allocs
2020-05-27 17:58 ` Andrii Nakryiko
@ 2020-05-28 7:24 ` Eelco Chaudron
2020-05-28 13:52 ` Daniel Borkmann
0 siblings, 1 reply; 4+ messages in thread
From: Eelco Chaudron @ 2020-05-28 7:24 UTC (permalink / raw)
To: Andrii Nakryiko, Daniel Borkmann
Cc: bpf, David S. Miller, Networking, Alexei Starovoitov, Martin Lau,
Song Liu, Yonghong Song, Andrii Nakryiko,
Toke Høiland-Jørgensen
On 27 May 2020, at 19:58, Andrii Nakryiko wrote:
> On Wed, May 27, 2020 at 1:42 AM Eelco Chaudron <echaudro@redhat.com>
> wrote:
>>
>> In case the cpu_bufs are sparsely allocated they are not
>> all free'ed. These changes will fix this.
>>
>> Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
>> ---
>
> Thanks a lot!
>
> You forgot:
>
> Fixes: fb84b8224655 ("libbpf: add perf buffer API")
Thanks, I forgot that :( Daniel do you want me to send a v2, or will
you add it when you apply it?
> Acked-by: Andrii Nakryiko <andriin@fb.com>
>
>> tools/lib/bpf/libbpf.c | 5 ++++-
>> 1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
>> index 5d60de6fd818..74d967619dcf 100644
>> --- a/tools/lib/bpf/libbpf.c
>> +++ b/tools/lib/bpf/libbpf.c
>> @@ -8137,9 +8137,12 @@ void perf_buffer__free(struct perf_buffer *pb)
>> if (!pb)
>> return;
>> if (pb->cpu_bufs) {
>> - for (i = 0; i < pb->cpu_cnt && pb->cpu_bufs[i]; i++)
>> {
>> + for (i = 0; i < pb->cpu_cnt; i++) {
>> struct perf_cpu_buf *cpu_buf =
>> pb->cpu_bufs[i];
>>
>> + if (!cpu_buf)
>> + continue;
>> +
>> bpf_map_delete_elem(pb->map_fd,
>> &cpu_buf->map_key);
>> perf_buffer__free_cpu_buf(pb, cpu_buf);
>> }
>>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH bpf-next] libbpf: fix perf_buffer__free() API for sparse allocs
2020-05-28 7:24 ` Eelco Chaudron
@ 2020-05-28 13:52 ` Daniel Borkmann
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Borkmann @ 2020-05-28 13:52 UTC (permalink / raw)
To: Eelco Chaudron
Cc: Andrii Nakryiko, bpf, David S. Miller, Networking,
Alexei Starovoitov, Martin Lau, Song Liu, Yonghong Song,
Andrii Nakryiko, Toke Høiland-Jørgensen
On Thu, May 28, 2020 at 09:24:58AM +0200, Eelco Chaudron wrote:
> On 27 May 2020, at 19:58, Andrii Nakryiko wrote:
> > On Wed, May 27, 2020 at 1:42 AM Eelco Chaudron <echaudro@redhat.com>
> > wrote:
> > >
> > > In case the cpu_bufs are sparsely allocated they are not
> > > all free'ed. These changes will fix this.
> > >
> > > Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
> > > ---
> >
> > Thanks a lot!
> >
> > You forgot:
> >
> > Fixes: fb84b8224655 ("libbpf: add perf buffer API")
>
> Thanks, I forgot that :( Daniel do you want me to send a v2, or will you
> add it when you apply it?
No worries, added it. Applied to bpf-next, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-05-28 13:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-27 8:42 [PATCH bpf-next] libbpf: fix perf_buffer__free() API for sparse allocs Eelco Chaudron
2020-05-27 17:58 ` Andrii Nakryiko
2020-05-28 7:24 ` Eelco Chaudron
2020-05-28 13:52 ` Daniel Borkmann
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.