[PATCH net-next v5 01/14] page_pool: make sure frag API fields don't span between cachelines

From: Alexander Lobakin
Date: Fri Nov 24 2023 - 10:50:08 EST


After commit 5027ec19f104 ("net: page_pool: split the page_pool_params
into fast and slow") that made &page_pool contain only "hot" params at
the start, cacheline boundary chops frag API fields group in the middle
again.
To not bother with this each time fast params get expanded or shrunk,
let's just align them to `4 * sizeof(long)`, the closest upper pow-2 to
their actual size (2 longs + 2 ints). This ensures 16-byte alignment for
the 32-bit architectures and 32-byte alignment for the 64-bit ones,
excluding unnecessary false-sharing.

Signed-off-by: Alexander Lobakin <aleksander.lobakin@xxxxxxxxx>
---
include/net/page_pool/types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
index e1bb92c192de..989d07b831fc 100644
--- a/include/net/page_pool/types.h
+++ b/include/net/page_pool/types.h
@@ -127,7 +127,7 @@ struct page_pool {

bool has_init_callback;

- long frag_users;
+ long frag_users __aligned(4 * sizeof(long));
struct page *frag_page;
unsigned int frag_offset;
u32 pages_state_hold_cnt;
--
2.42.0