From: "Huang, Ying" <ying.huang@intel.com>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: Mel Gorman <mgorman@techsingularity.net>,
Andrew Morton <akpm@linux-foundation.org>,
Vlastimil Babka <vbabka@suse.cz>, linux-mm <linux-mm@kvack.org>
Subject: Re: [PATCH v2] mm/page_alloc: don't wake kswapd from rmqueue() unless __GFP_KSWAPD_RECLAIM is specified
Date: Mon, 15 May 2023 14:03:19 +0800 [thread overview]
Message-ID: <87edni872w.fsf@yhuang6-desk2.ccr.corp.intel.com> (raw)
In-Reply-To: <c3c3dacf-dd3b-77c9-f96a-d0982b4b2a4f@I-love.SAKURA.ne.jp> (Tetsuo Handa's message of "Sun, 14 May 2023 09:28:56 +0900")
Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> writes:
> 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.
>
> Only allocation contexts that include ALLOC_KSWAPD (which corresponds to
> __GFP_KSWAPD_RECLAIM) should wake kswapd, for callers are supposed to
> remove __GFP_KSWAPD_RECLAIM if trying to hold pgdat->kswapd_wait has a
> risk of deadlock. 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, causing possibility of deadlock.
Sorry, I don't understand what is the deadlock here.
I checked commit 73444bc4d8f9 ("mm, page_alloc: do not wake kswapd with
zone lock held") and the corresponding mail thread. From the below
mail,
https://lore.kernel.org/all/20190107204627.GA25526@cmpxchg.org/
commit 73444bc4d8f9 fixed a circular locking ordering as follows,
pi lock -> rq lock -> timer base lock -> zone lock -> wakeup lock
(kswapd_wait, fixed) -> pi lock
But I don't know what is the deadlock that your patch fixed. Can you
teach me on that?
Best Regards,
Huang, Ying
> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
> Fixes: 73444bc4d8f9 ("mm, page_alloc: do not wake kswapd with zone lock held")
> ---
> Changes in v2:
> Check ALLOC_KSWAPD before checking ZONE_BOOSTED_WATERMARK and update
> description, suggested by Mel Gorman <mgorman@techsingularity.net>.
>
> mm/page_alloc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index 47421bedc12b..ecad680cec53 100644
> --- a/mm/page_alloc.c
> +++ 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 ((alloc_flags & ALLOC_KSWAPD) &&
> + unlikely(test_bit(ZONE_BOOSTED_WATERMARK, &zone->flags))) {
> clear_bit(ZONE_BOOSTED_WATERMARK, &zone->flags);
> wakeup_kswapd(zone, 0, 0, zone_idx(zone));
> }
next prev parent reply other threads:[~2023-05-15 6:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 13:47 [PATCH] mm/page_alloc: don't wake up " Tetsuo Handa
2023-05-12 3:45 ` Andrew Morton
2023-05-13 9:38 ` Tetsuo Handa
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 [this message]
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=87edni872w.fsf@yhuang6-desk2.ccr.corp.intel.com \
--to=ying.huang@intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@techsingularity.net \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--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