From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Jonathan Lemon <jonathan.lemon@gmail.com>
Cc: <netdev@vger.kernel.org>, <davem@davemloft.net>,
<kernel-team@fb.com>, <ilias.apalodimas@linaro.org>,
brouer@redhat.com
Subject: Re: [net-next PATCH v2 2/2] page_pool: remove hold/release count from tracepoints
Date: Thu, 14 Nov 2019 22:07:15 +0100 [thread overview]
Message-ID: <20191114220715.1ac54ddf@carbon> (raw)
In-Reply-To: <20191114163715.4184099-3-jonathan.lemon@gmail.com>
On Thu, 14 Nov 2019 08:37:15 -0800
Jonathan Lemon <jonathan.lemon@gmail.com> wrote:
> When the last page is released from the page pool, it is possible
> that the delayed removal thread sees inflight == 0, and frees the
> pool. While the freed pointer is only copied by the tracepoint
> and not dereferenced, it really isn't correct. Avoid this case by
> reporting the page release before releasing the page.
I don't like this patch!
I'm actually using these counters, in my current version of my bpftrace
leak detector for page_pool:
https://github.com/xdp-project/xdp-project/blob/master/areas/mem/bpftrace/page_pool_track_leaks01.bt
> This also removes a second atomic operation from the release path.
>
> Signed-off-by: Jonathan Lemon <jonathan.lemon@gmail.com>
> ---
> include/trace/events/page_pool.h | 24 ++++++++++--------------
> net/core/page_pool.c | 8 +++++---
> 2 files changed, 15 insertions(+), 17 deletions(-)
[...]
> @@ -222,9 +222,11 @@ static void __page_pool_clean_page(struct page_pool *pool,
> DMA_ATTR_SKIP_CPU_SYNC);
> page->dma_addr = 0;
> skip_dma_unmap:
> + trace_page_pool_page_release(pool, page);
> + /* This may be the last page returned, releasing the pool, so
> + * it is not safe to reference pool afterwards.
> + */
> atomic_inc(&pool->pages_state_release_cnt);
> - trace_page_pool_state_release(pool, page,
> - atomic_read(&pool->pages_state_release_cnt));
> }
I will prefer that you do an atomic_inc_return, and send the cnt to the
existing tracepoint. I'm not dereferencing the pool in my tracepoint
use-case, and as Alexei wrote, this would still be 'safe' (as in not
crashing) for a tracepoint if someone do.
--
Best regards,
Jesper Dangaard Brouer
MSc.CS, Principal Kernel Engineer at Red Hat
LinkedIn: http://www.linkedin.com/in/brouer
next prev parent reply other threads:[~2019-11-14 21:07 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-14 16:37 [net-next PATCH v2 0/2] Change page_pool timeout handling Jonathan Lemon
2019-11-14 16:37 ` [net-next PATCH v2 1/2] page_pool: do not release pool until inflight == 0 Jonathan Lemon
2019-11-14 21:27 ` Jesper Dangaard Brouer
2019-11-14 16:37 ` [net-next PATCH v2 2/2] page_pool: remove hold/release count from tracepoints Jonathan Lemon
2019-11-14 20:53 ` kbuild test robot
2019-11-14 20:53 ` kbuild test robot
2019-11-14 21:07 ` Jesper Dangaard Brouer [this message]
2019-11-14 21:56 ` Jonathan Lemon
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=20191114220715.1ac54ddf@carbon \
--to=brouer@redhat.com \
--cc=davem@davemloft.net \
--cc=ilias.apalodimas@linaro.org \
--cc=jonathan.lemon@gmail.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.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 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.