Re: [PATCH 1/2] mm/pageblock: mitigation cmpxchg false sharing in pageblock flags

From: Matthew Wilcox
Date: Sun Aug 16 2020 - 00:09:39 EST


On Sun, Aug 16, 2020 at 11:47:56AM +0800, Alex Shi wrote:
> +++ b/mm/page_alloc.c
> @@ -467,6 +467,8 @@ static inline int pfn_to_bitidx(struct page *page, unsigned long pfn)
> return (pfn >> pageblock_order) * NR_PAGEBLOCK_BITS;
> }
>
> +#define BITS_PER_CHAR 8

include/linux/bits.h:#define BITS_PER_BYTE 8

> bitmap = get_pageblock_bitmap(page, pfn);
> bitidx = pfn_to_bitidx(page, pfn);
> - word_bitidx = bitidx / BITS_PER_LONG;
> - bitidx &= (BITS_PER_LONG-1);
> + word_bitidx = bitidx / BITS_PER_CHAR;
> + bitidx &= (BITS_PER_CHAR-1);

It's not a word any more. it's a byte.