summaryrefslogtreecommitdiff
path: root/include/net/page_pool
diff options
context:
space:
mode:
authorAlexander Lobakin <aleksander.lobakin@intel.com>2024-05-07 14:20:23 +0300
committerChristoph Hellwig <hch@lst.de>2024-05-07 14:29:54 +0300
commit1f20a5769446a1acae67ac9e63d07a594829a789 (patch)
tree5f29270133b89801f9feff5ef2ec5884c69eb730 /include/net/page_pool
parentea01fa703150025806a21c960761c821736f4757 (diff)
downloadlinux-1f20a5769446a1acae67ac9e63d07a594829a789.tar.xz
page_pool: make sure frag API fields don't span between cachelines
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 + 1 int). This ensures 16-byte alignment for the 32-bit architectures and 32-byte alignment for the 64-bit ones, excluding unnecessary false-sharing. ::page_state_hold_cnt is used quite intensively on hotpath no matter if frag API is used, so move it to the newly created hole in the first cacheline. Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'include/net/page_pool')
-rw-r--r--include/net/page_pool/types.h12
1 files changed, 11 insertions, 1 deletions
diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h
index 5e43a08d3231..5460cbab5de0 100644
--- a/include/net/page_pool/types.h
+++ b/include/net/page_pool/types.h
@@ -130,12 +130,22 @@ struct page_pool {
struct page_pool_params_fast p;
int cpuid;
+ u32 pages_state_hold_cnt;
bool has_init_callback;
+ /* The following block must stay within one cacheline. On 32-bit
+ * systems, sizeof(long) == sizeof(int), so that the block size is
+ * ``3 * sizeof(long)``. On 64-bit systems, the actual size is
+ * ``2 * sizeof(long) + sizeof(int)``. The closest pow-2 to both of
+ * them is ``4 * sizeof(long)``, so just use that one for simplicity.
+ * Having it aligned to a cacheline boundary may be excessive and
+ * doesn't bring any good.
+ */
+ __cacheline_group_begin(frag) __aligned(4 * sizeof(long));
long frag_users;
struct page *frag_page;
unsigned int frag_offset;
- u32 pages_state_hold_cnt;
+ __cacheline_group_end(frag);
struct delayed_work release_dw;
void (*disconnect)(void *pool);