linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Vlastimil Babka <vbabka@suse.cz>,
	Mel Gorman <mgorman@techsingularity.net>,
	linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH] mm/page_alloc: don't wake up kswapd from rmqueue() unless __GFP_KSWAPD_RECLAIM is specified
Date: Sat, 13 May 2023 18:38:41 +0900	[thread overview]
Message-ID: <439be4d1-8c19-7a63-26db-67a97bd517b8@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <20230511204507.fbcc234616378b3c28599712@linux-foundation.org>

On 2023/05/12 12:45, Andrew Morton wrote:
> On Thu, 11 May 2023 22:47:36 +0900 Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> 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@I-love.SAKURA.ne.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.
> 



  reply	other threads:[~2023-05-13  9:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11 13:47 Tetsuo Handa
2023-05-12  3:45 ` Andrew Morton
2023-05-13  9:38   ` Tetsuo Handa [this message]
2023-05-13 10:23 ` Mel Gorman
2023-05-14  0:28   ` [PATCH v2] mm/page_alloc: don't wake " Tetsuo Handa
2023-05-15  6:03     ` Huang, Ying
2023-05-15  6:35       ` Huang, Ying
2023-05-15  7:38     ` Mel Gorman
2023-05-15 10:17       ` Tetsuo Handa
2023-05-16  1:44         ` Huang, Ying
2023-05-22 13:57           ` Tetsuo Handa
2023-05-22 14:58             ` Mel Gorman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=439be4d1-8c19-7a63-26db-67a97bd517b8@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=akpm@linux-foundation.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=vbabka@suse.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox