]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
page_pool: use __cacheline_group_{begin, end}_aligned()
authorAlexander Lobakin <aleksander.lobakin@intel.com>
Thu, 20 Jun 2024 13:53:35 +0000 (15:53 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Wed, 10 Jul 2024 17:28:23 +0000 (10:28 -0700)
Instead of doing __cacheline_group_begin() __aligned(), use the new
__cacheline_group_{begin,end}_aligned(), so that it will take care
of the group alignment itself.
Also replace open-coded `4 * sizeof(long)` in two places with
a definition.

Signed-off-by: Alexander Lobakin <aleksander.lobakin@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
include/net/page_pool/types.h
net/core/page_pool.c

index b70bcc14cedad41e84f2f121e9e8d029885a2215..50569fed7868eaaa82962b6c1c0f788fff6ae5d8 100644 (file)
@@ -129,6 +129,16 @@ struct page_pool_stats {
 };
 #endif
 
+/* The whole frag API 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.
+ */
+#define PAGE_POOL_FRAG_GROUP_ALIGN     (4 * sizeof(long))
+
 struct page_pool {
        struct page_pool_params_fast p;
 
@@ -142,19 +152,11 @@ struct page_pool {
        bool system:1;                  /* This is a global percpu pool */
 #endif
 
-       /* 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));
+       __cacheline_group_begin_aligned(frag, PAGE_POOL_FRAG_GROUP_ALIGN);
        long frag_users;
        netmem_ref frag_page;
        unsigned int frag_offset;
-       __cacheline_group_end(frag);
+       __cacheline_group_end_aligned(frag, PAGE_POOL_FRAG_GROUP_ALIGN);
 
        struct delayed_work release_dw;
        void (*disconnect)(void *pool);
index 855271a6cad247f055b94d92fd8fd6bcc464111e..2abe6e919224d98ba72a645c699e8de5ba6e414a 100644 (file)
@@ -178,7 +178,8 @@ static void page_pool_struct_check(void)
        CACHELINE_ASSERT_GROUP_MEMBER(struct page_pool, frag, frag_users);
        CACHELINE_ASSERT_GROUP_MEMBER(struct page_pool, frag, frag_page);
        CACHELINE_ASSERT_GROUP_MEMBER(struct page_pool, frag, frag_offset);
-       CACHELINE_ASSERT_GROUP_SIZE(struct page_pool, frag, 4 * sizeof(long));
+       CACHELINE_ASSERT_GROUP_SIZE(struct page_pool, frag,
+                                   PAGE_POOL_FRAG_GROUP_ALIGN);
 }
 
 static int page_pool_init(struct page_pool *pool,