From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: "Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Toke Høiland-Jørgensen" <toke@redhat.com>
Cc: brouer@redhat.com, netdev@vger.kernel.org, bpf@vger.kernel.org,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
"David S. Miller" <davem@davemloft.net>,
Ingo Molnar <mingo@redhat.com>, Jakub Kicinski <kuba@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>, Martin KaFai Lau <kafai@fb.com>,
Song Liu <songliubraving@fb.com>,
Steven Rostedt <rostedt@goodmis.org>,
Thomas Gleixner <tglx@linutronix.de>, Yonghong Song <yhs@fb.com>
Subject: Re: [PATCH net] xdp: xdp_mem_allocator can be NULL in trace_mem_connect().
Date: Thu, 3 Mar 2022 18:31:11 +0100 [thread overview]
Message-ID: <d6621a7b-12ad-1e3d-848f-fff576be2dfd@redhat.com> (raw)
In-Reply-To: <YiDM0WRlWuM2jjNJ@linutronix.de>
On 03/03/2022 15.12, Sebastian Andrzej Siewior wrote:
> On 2022-03-03 14:59:47 [+0100], Toke Høiland-Jørgensen wrote:
>> Sebastian Andrzej Siewior <bigeasy@linutronix.de> writes:
>>
>>> Since the commit mentioned below __xdp_reg_mem_model() can return a NULL
>>> pointer. This pointer is dereferenced in trace_mem_connect() which leads
>>> to segfault. It can be reproduced with enabled trace events during ifup.
>>>
>>> Only assign the arguments in the trace-event macro if `xa' is set.
>>> Otherwise set the parameters to 0.
>>>
>>> Fixes: 4a48ef70b93b8 ("xdp: Allow registering memory model without rxq reference")
>>> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
>>
>> Hmm, so before the commit you mention, the tracepoint wasn't triggered
>> at all in the code path that now sets xdp_alloc is NULL. So I'm
>> wondering if we should just do the same here? Is the trace event useful
>> in all cases?
>
> Correct. It says:
> | ip-1230 [003] ..... 3.053473: mem_connect: mem_id=0 mem_type=PAGE_SHARED allocator=0000000000000000 ifindex=2
>
>> Alternatively, if we keep it, I think the mem.id and mem.type should be
>> available from rxq->mem, right?
>
> Yes, if these are the same things. In my case they are also 0:
>
> | ip-1245 [000] ..... 3.045684: mem_connect: mem_id=0 mem_type=PAGE_SHARED allocator=0000000000000000 ifindex=2
> | ifconfig-1332 [003] ..... 21.030879: mem_connect: mem_id=0 mem_type=PAGE_SHARED allocator=0000000000000000 ifindex=3
>
> So depends on what makes sense that tp can be skipped for xa == NULL or
> remain with
> __entry->mem_id = rxq->mem.id;
> __entry->mem_type = rxq->mem.type;
> __entry->allocator = xa ? xa->allocator : NULL;
>
> if it makes sense.
>
I have two bpftrace scripts [1] and [2] that use this tracepoint.
It is scripts to help driver developers detect memory leaks when using
page_pool from their drivers.
I'm a little pressured on time, so I've not evaluated if your change
makes sense.
In the scripts I do use both mem.id and mem.type.
[1]
https://github.com/xdp-project/xdp-project/blob/master/areas/mem/bpftrace/xdp_mem_track01.bt
[2]
https://github.com/xdp-project/xdp-project/blob/master/areas/mem/bpftrace/xdp_mem_track02.bt
--Jesper
next prev parent reply other threads:[~2022-03-03 17:31 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-03 12:26 [PATCH net] xdp: xdp_mem_allocator can be NULL in trace_mem_connect() Sebastian Andrzej Siewior
2022-03-03 13:59 ` Toke Høiland-Jørgensen
2022-03-03 14:12 ` Sebastian Andrzej Siewior
2022-03-03 17:31 ` Jesper Dangaard Brouer [this message]
2022-03-07 16:50 ` Toke Høiland-Jørgensen
2022-03-07 17:59 ` Sebastian Andrzej Siewior
2022-03-07 18:07 ` Toke Høiland-Jørgensen
2022-03-09 17:15 ` Jakub Kicinski
2022-03-09 20:48 ` Sebastian Andrzej Siewior
2022-03-09 21:03 ` Jakub Kicinski
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=d6621a7b-12ad-1e3d-848f-fff576be2dfd@redhat.com \
--to=jbrouer@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=bpf@vger.kernel.org \
--cc=brouer@redhat.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=tglx@linutronix.de \
--cc=toke@redhat.com \
--cc=yhs@fb.com \
/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