lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260206002715.1885869-2-vishs@meta.com>
Date: Thu, 5 Feb 2026 16:27:14 -0800
From: Vishwanath Seshagiri <vishs@...a.com>
To: "Michael S . Tsirkin" <mst@...hat.com>, Jason Wang <jasowang@...hat.com>
CC: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>,
        Eugenio Pérez
	<eperezma@...hat.com>,
        Andrew Lunn <andrew+netdev@...n.ch>,
        "David S .
 Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>, Jakub
 Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>, David Wei
	<dw@...idwei.uk>,
        Matteo Croce <technoboy85@...il.com>,
        Ilias Apalodimas
	<ilias.apalodimas@...aro.org>,
        <netdev@...r.kernel.org>, <virtualization@...ts.linux.dev>,
        <linux-kernel@...r.kernel.org>, <kernel-team@...a.com>
Subject: [PATCH net-next v5 1/2] page_pool: add page_pool_frag_offset_add() helper

Add a helper function to advance the fragment offset without performing
an allocation. This is needed by drivers that extend a buffer to consume
unused space at the end of a page fragment to avoid internal fragmentation.

When a driver uses page_pool_alloc_frag() and determines that the
remaining space in the page is too small for another buffer, it may
extend the current buffer to include that space. However, page_pool's
internal frag_offset is not aware of this extension, which could cause
the next allocation to overlap with the extended buffer.

page_pool_frag_offset_add() allows drivers to advance frag_offset to
match the actual consumed space.

Signed-off-by: Vishwanath Seshagiri <vishs@...a.com>
---
 include/net/page_pool/helpers.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h
index 3247026e096a..14907c3badae 100644
--- a/include/net/page_pool/helpers.h
+++ b/include/net/page_pool/helpers.h
@@ -96,6 +96,26 @@ static inline struct page *page_pool_dev_alloc_pages(struct page_pool *pool)
 	return page_pool_alloc_pages(pool, gfp);
 }
 
+/**
+ * page_pool_frag_offset_add() - advance fragment offset without allocation
+ * @pool: pool to update
+ * @bytes: number of bytes to skip
+ *
+ * Advance the fragment offset by @bytes without performing an allocation.
+ * This is useful when a driver extends a buffer to consume unused space
+ * at the end of a page fragment (to avoid internal fragmentation), and
+ * needs to ensure the next allocation doesn't overlap.
+ *
+ * Must be called in the same context as page_pool_alloc_frag() to avoid
+ * racing with fragment allocations.
+ *
+ */
+static inline void page_pool_frag_offset_add(struct page_pool *pool,
+					     unsigned int bytes)
+{
+	pool->frag_offset += bytes;
+}
+
 /**
  * page_pool_dev_alloc_frag() - allocate a page fragment.
  * @pool: pool from which to allocate
-- 
2.47.3


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ