From: Matteo Croce <mcroce@linux•microsoft.com>
To: netdev@vger•kernel.org
Cc: linux-kernel@vger•kernel.org,
Jonathan Lemon <jonathan.lemon@gmail•com>,
"David S. Miller" <davem@davemloft•net>,
Ilias Apalodimas <ilias.apalodimas@linaro•org>,
Jesper Dangaard Brouer <hawk@kernel•org>,
Lorenzo Bianconi <lorenzo@kernel•org>,
Saeed Mahameed <saeedm@nvidia•com>,
David Ahern <dsahern@gmail•com>,
Saeed Mahameed <saeed@kernel•org>, Andrew Lunn <andrew@lunn•ch>
Subject: [PATCH net-next 2/6] mm: add a signature in struct page
Date: Mon, 22 Mar 2021 18:02:57 +0100 [thread overview]
Message-ID: <20210322170301.26017-3-mcroce@linux.microsoft.com> (raw)
In-Reply-To: <20210322170301.26017-1-mcroce@linux.microsoft.com>
From: Matteo Croce <mcroce@microsoft•com>
This is needed by the page_pool to avoid recycling a page not allocated
via page_pool.
Signed-off-by: Matteo Croce <mcroce@microsoft•com>
---
include/linux/mm_types.h | 1 +
include/net/page_pool.h | 2 ++
net/core/page_pool.c | 4 ++++
3 files changed, 7 insertions(+)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index 0974ad501a47..67caade433e4 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -100,6 +100,7 @@ struct page {
* 32-bit architectures.
*/
dma_addr_t dma_addr;
+ unsigned long signature;
};
struct { /* slab, slob and slub */
union {
diff --git a/include/net/page_pool.h b/include/net/page_pool.h
index b5b195305346..b30405e84b5e 100644
--- a/include/net/page_pool.h
+++ b/include/net/page_pool.h
@@ -63,6 +63,8 @@
*/
#define PP_ALLOC_CACHE_SIZE 128
#define PP_ALLOC_CACHE_REFILL 64
+#define PP_SIGNATURE 0x20210303
+
struct pp_alloc_cache {
u32 count;
void *cache[PP_ALLOC_CACHE_SIZE];
diff --git a/net/core/page_pool.c b/net/core/page_pool.c
index ad8b0707af04..2ae9b554ef98 100644
--- a/net/core/page_pool.c
+++ b/net/core/page_pool.c
@@ -232,6 +232,8 @@ static struct page *__page_pool_alloc_pages_slow(struct page_pool *pool,
page_pool_dma_sync_for_device(pool, page, pool->p.max_len);
skip_dma_map:
+ page->signature = PP_SIGNATURE;
+
/* Track how many pages are held 'in-flight' */
pool->pages_state_hold_cnt++;
@@ -302,6 +304,8 @@ void page_pool_release_page(struct page_pool *pool, struct page *page)
DMA_ATTR_SKIP_CPU_SYNC);
page->dma_addr = 0;
skip_dma_unmap:
+ page->signature = 0;
+
/* This may be the last page returned, releasing the pool, so
* it is not safe to reference pool afterwards.
*/
--
2.30.2
next prev parent reply other threads:[~2021-03-22 17:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-22 17:02 [PATCH net-next 0/6] page_pool: recycle buffers Matteo Croce
2021-03-22 17:02 ` [PATCH net-next 1/6] xdp: reduce size of struct xdp_mem_info Matteo Croce
2021-03-22 17:02 ` Matteo Croce [this message]
2021-03-22 17:02 ` [PATCH net-next 3/6] page_pool: DMA handling and allow to recycles frames via SKB Matteo Croce
2021-03-22 19:38 ` Matteo Croce
2021-03-22 17:02 ` [PATCH net-next 4/6] net: change users of __skb_frag_unref() and add an extra argument Matteo Croce
2021-03-22 17:03 ` [PATCH net-next 5/6] mvpp2: recycle buffers Matteo Croce
2021-03-22 17:03 ` [PATCH net-next 6/6] mvneta: " Matteo Croce
2021-03-23 15:06 ` Jesper Dangaard Brouer
2021-03-24 9:28 ` Lorenzo Bianconi
2021-03-24 21:48 ` Ilias Apalodimas
2021-03-23 14:57 ` [PATCH net-next 0/6] page_pool: " David Ahern
2021-03-23 15:03 ` Ilias Apalodimas
2021-03-23 15:41 ` Alexander Lobakin
2021-03-23 15:47 ` Ilias Apalodimas
2021-03-23 16:04 ` Jesper Dangaard Brouer
2021-03-23 16:10 ` Ilias Apalodimas
2021-03-23 16:28 ` Matteo Croce
2021-03-23 16:55 ` Alexander Lobakin
2021-03-23 17:01 ` Ilias Apalodimas
2021-03-23 20:03 ` Alexander Lobakin
2021-03-24 7:50 ` Ilias Apalodimas
2021-03-24 11:42 ` Alexander Lobakin
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=20210322170301.26017-3-mcroce@linux.microsoft.com \
--to=mcroce@linux$(echo .)microsoft.com \
--cc=andrew@lunn$(echo .)ch \
--cc=davem@davemloft$(echo .)net \
--cc=dsahern@gmail$(echo .)com \
--cc=hawk@kernel$(echo .)org \
--cc=ilias.apalodimas@linaro$(echo .)org \
--cc=jonathan.lemon@gmail$(echo .)com \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=lorenzo@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=saeed@kernel$(echo .)org \
--cc=saeedm@nvidia$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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