On 2023/05/12 12:45, Andrew Morton wrote: > On Thu, 11 May 2023 22:47:36 +0900 Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxxxxx> wrote: > >> Commit 73444bc4d8f9 ("mm, page_alloc: do not wake kswapd with zone lock >> held") moved wakeup_kswapd() from steal_suitable_fallback() to rmqueue() >> using ZONE_BOOSTED_WATERMARK flag. But since zone->flags is a shared >> variable, a thread doing !__GFP_KSWAPD_RECLAIM allocation request might >> observe this flag being set immediately after another thread doing >> __GFP_KSWAPD_RECLAIM allocation request set this flag. > > What are the user-visible runtime effects of this flaw? Potential deadlock upon __GFP_HIGH (I mean, !__GFP_KSWAPD_RECLAIM) allocation requests (like debugobject code is about to start doing). > >> Signed-off-by: Tetsuo Handa <penguin-kernel@xxxxxxxxxxxxxxxx.j >> +++ b/mm/page_alloc.c >> @@ -3052,7 +3052,8 @@ struct page *rmqueue(struct zone *preferred_zone, >> >> out: >> /* Separate test+clear to avoid unnecessary atomics */ >> - if (unlikely(test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags))) { >> + if (unlikely(test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags)) >> + && (alloc_flags & ALLOC_KSWAPD)) { >> clear_bit(ZONE_BOOSTED_WATERMARK, &zone->flags); >> wakeup_kswapd(zone, 0, 0, zone_idx(zone)); >> } > > Thanks, I'll queue this up for some testing while awaiting input from > Mel. >