Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

page_pool: use __cacheline_group_{begin, end}_aligned()

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>

authored by

Alexander Lobakin and committed by
Tony Nguyen
39daa09d 2cb13dec

+14 -11
+12 -10
include/net/page_pool/types.h
··· 129 129 }; 130 130 #endif 131 131 132 + /* The whole frag API block must stay within one cacheline. On 32-bit systems, 133 + * sizeof(long) == sizeof(int), so that the block size is ``3 * sizeof(long)``. 134 + * On 64-bit systems, the actual size is ``2 * sizeof(long) + sizeof(int)``. 135 + * The closest pow-2 to both of them is ``4 * sizeof(long)``, so just use that 136 + * one for simplicity. 137 + * Having it aligned to a cacheline boundary may be excessive and doesn't bring 138 + * any good. 139 + */ 140 + #define PAGE_POOL_FRAG_GROUP_ALIGN (4 * sizeof(long)) 141 + 132 142 struct page_pool { 133 143 struct page_pool_params_fast p; 134 144 ··· 152 142 bool system:1; /* This is a global percpu pool */ 153 143 #endif 154 144 155 - /* The following block must stay within one cacheline. On 32-bit 156 - * systems, sizeof(long) == sizeof(int), so that the block size is 157 - * ``3 * sizeof(long)``. On 64-bit systems, the actual size is 158 - * ``2 * sizeof(long) + sizeof(int)``. The closest pow-2 to both of 159 - * them is ``4 * sizeof(long)``, so just use that one for simplicity. 160 - * Having it aligned to a cacheline boundary may be excessive and 161 - * doesn't bring any good. 162 - */ 163 - __cacheline_group_begin(frag) __aligned(4 * sizeof(long)); 145 + __cacheline_group_begin_aligned(frag, PAGE_POOL_FRAG_GROUP_ALIGN); 164 146 long frag_users; 165 147 netmem_ref frag_page; 166 148 unsigned int frag_offset; 167 - __cacheline_group_end(frag); 149 + __cacheline_group_end_aligned(frag, PAGE_POOL_FRAG_GROUP_ALIGN); 168 150 169 151 struct delayed_work release_dw; 170 152 void (*disconnect)(void *pool);
+2 -1
net/core/page_pool.c
··· 178 178 CACHELINE_ASSERT_GROUP_MEMBER(struct page_pool, frag, frag_users); 179 179 CACHELINE_ASSERT_GROUP_MEMBER(struct page_pool, frag, frag_page); 180 180 CACHELINE_ASSERT_GROUP_MEMBER(struct page_pool, frag, frag_offset); 181 - CACHELINE_ASSERT_GROUP_SIZE(struct page_pool, frag, 4 * sizeof(long)); 181 + CACHELINE_ASSERT_GROUP_SIZE(struct page_pool, frag, 182 + PAGE_POOL_FRAG_GROUP_ALIGN); 182 183 } 183 184 184 185 static int page_pool_init(struct page_pool *pool,