lkml.org 
[lkml]   [2022]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v4] mm: fix is_pinnable_page against on cma page
From
On 5/11/22 17:26, Minchan Kim wrote:
>>> Let me try to say this more clearly: I don't think that the following
>>> __READ_ONCE() statement can actually help anything, given that
>>> get_pageblock_migratetype() is non-inlined:
>>>
>>> + int __mt = get_pageblock_migratetype(page);
>>> + int mt = __READ_ONCE(__mt);
>>> +
>>> + if (mt & (MIGRATE_CMA | MIGRATE_ISOLATE))
>>> + return false;
>>>
>>>
>>> Am I missing anything here?
>>
>> In the absence of future aggression from link-time optimizations (LTO),
>> you are missing nothing.
>
> A thing I want to note is Android kernel uses LTO full mode.

Thanks Paul for explaining the state of things.

Minchan, how about something like very close to your original draft,
then, but with a little note, and the "&" as well:

int __mt = get_pageblock_migratetype(page);

/*
* Defend against future compiler LTO features, or code refactoring
* that inlines the above function, by forcing a single read. Because, this
* routine races with set_pageblock_migratetype(), and we want to avoid
* reading zero, when actually one or the other flags was set.
*/
int mt = __READ_ONCE(__mt);

if (mt & (MIGRATE_CMA | MIGRATE_ISOLATE))
return false;


...which should make everyone comfortable and protected from the
future sins of the compiler and linker teams? :)


thanks,
--
John Hubbard
NVIDIA

\
 
 \ /
  Last update: 2022-05-12 02:35    [W:0.163 / U:0.092 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site