Netdev List
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <brouer@redhat.com>
To: unlisted-recipients:; (no To-header on input)
Cc: "Toke Høiland-Jørgensen" <toke@redhat.com>,
	netdev@vger.kernel.org,
	"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
	"Jesper Dangaard Brouer" <brouer@redhat.com>,
	"Saeed Mahameed" <saeedm@mellanox.com>,
	"Matteo Croce" <mcroce@redhat.com>,
	"Jonathan Lemon" <jonathan.lemon@gmail.com>,
	"Lorenzo Bianconi" <lorenzo@kernel.org>,
	"Tariq Toukan" <tariqt@mellanox.com>
Subject: [net-next v1 PATCH 3/4] page_pool: block alloc cache during shutdown
Date: Fri, 15 Nov 2019 16:06:09 +0100	[thread overview]
Message-ID: <157383036914.3173.12541360542055110975.stgit@firesoul> (raw)
In-Reply-To: <157383032789.3173.11648581637167135301.stgit@firesoul>

It is documented that driver API users, have to disconnect
the page_pool, before starting shutdown phase, but is it only
documentation, there is not code catching such violations.

Given (in page_pool_empty_alloc_cache_once) alloc cache is only
flushed once, there is now an opportunity to catch this case.

This patch blocks the RX/alloc-side cache, via pretending it is
full and poison last element.  This code change will enforce that
drivers cannot use alloc cache during shutdown phase.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 net/core/page_pool.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index e28db2ef8e12..b31f3bb7818d 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -364,6 +364,10 @@ static void page_pool_empty_alloc_cache_once(struct page_pool *pool)
 		page = pool->alloc.cache[--pool->alloc.count];
 		__page_pool_return_page(pool, page);
 	}
+
+	/* Block alloc cache, pretend it's full and poison last element */
+	pool->alloc.cache[PP_ALLOC_CACHE_SIZE - 1] = NULL;
+	pool->alloc.count = PP_ALLOC_CACHE_SIZE;
 }
 
 static void page_pool_scrub(struct page_pool *pool)


  parent reply	other threads:[~2019-11-15 15:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-15 15:05 [net-next v1 PATCH 0/4] page_pool: followup changes to restore tracepoint features Jesper Dangaard Brouer
2019-11-15 15:05 ` [net-next v1 PATCH 1/4] xdp: remove memory poison on free for struct xdp_mem_allocator Jesper Dangaard Brouer
2019-11-15 15:06 ` [net-next v1 PATCH 2/4] page_pool: add destroy attempts counter and rename tracepoint Jesper Dangaard Brouer
2019-11-15 16:33   ` Toke Høiland-Jørgensen
2019-11-16 10:56     ` Jesper Dangaard Brouer
2019-11-15 15:06 ` Jesper Dangaard Brouer [this message]
2019-11-15 18:38   ` [net-next v1 PATCH 3/4] page_pool: block alloc cache during shutdown Jonathan Lemon
2019-11-16 10:47     ` Jesper Dangaard Brouer
2019-11-15 15:06 ` [net-next v1 PATCH 4/4] page_pool: extend tracepoint to also include the page PFN Jesper Dangaard Brouer

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=157383036914.3173.12541360542055110975.stgit@firesoul \
    --to=brouer@redhat.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=jonathan.lemon@gmail.com \
    --cc=lorenzo@kernel.org \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.com \
    --cc=tariqt@mellanox.com \
    --cc=toke@redhat.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