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

From: Alex Shi
Date: Mon Aug 31 2020 - 04:40:59 EST




在 2020/8/30 下午6:18, Matthew Wilcox 写道:
> On Sun, Aug 30, 2020 at 06:14:33PM +0800, Alex Shi wrote:
>> +++ b/mm/page_alloc.c
>> @@ -532,9 +536,18 @@ void set_pfnblock_flags_mask(struct page *page, unsigned long flags,
>> mask <<= bitidx;
>> flags <<= bitidx;
>>
>> +#ifdef CONFIG_CPU_V6
>> + byte = (unsigned long)READ_ONCE(bitmap[byte_bitidx]);
>> +#else
>> byte = READ_ONCE(bitmap[byte_bitidx]);
>> +#endif
>> for (;;) {
>> +#ifdef CONFIG_CPU_V6
>> + /* arm v6 has no cmpxchgb function, so still false sharing long word */
>> + old_byte = cmpxchg((unsigned long*)&bitmap[byte_bitidx], byte, (byte & ~mask) | flags);
>> +#else
>> old_byte = cmpxchg(&bitmap[byte_bitidx], byte, (byte & ~mask) | flags);
>> +#endif
>
> Good grief, no. Either come up with an appropriate abstraction or
> abandon this patch. We can't possibly put this kind of ifdef in the
> memory allocator!
>

Hi Matthew,

Thanks a lot for comments! How about the following patch?