linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Mel Gorman <mgorman@techsingularity.net>
To: Vlastimil Babka <vbabka@suse.cz>
Cc: Lecopzer Chen <lecopzer.chen@mediatek.com>,
	akpm@linux-foundation.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, nsaenzju@redhat.com, yj.chiang@mediatek.com,
	Mark-pk Tsai <mark-pk.tsai@mediatek.com>,
	Joe Liu <joe.liu@mediatek.com>
Subject: Re: [PATCH] mm: page_alloc: fix cma pageblock was stolen in rmqueue fallback
Date: Tue, 5 Sep 2023 13:28:57 +0100	[thread overview]
Message-ID: <20230905122857.b3kwlxm6qxa2tgpb@techsingularity.net> (raw)
In-Reply-To: <bf16a7ea-22db-700b-7194-c4fa1d943baa@suse.cz>

On Tue, Sep 05, 2023 at 11:37:30AM +0200, Vlastimil Babka wrote:
> On 9/5/23 11:09, Mel Gorman wrote:
> > On Wed, Aug 30, 2023 at 07:13:33PM +0800, Lecopzer Chen wrote:
> >> commit 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a
> >> spinlock") fallback freeing page to free_one_page() if pcp trylock
> >> failed. This make MIGRATE_CMA be able to fallback and be stolen
> >> whole pageblock by MIGRATE_UNMOVABLE in the page allocation.
> >> 
> >> PCP free is fine because free_pcppages_bulk() will always get
> >> migratetype again before freeing the page, thus this only happen when
> >> someone tried to put CMA page in to other MIGRATE_TYPE's freelist.
> >> 
> >> Fixes: 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock")
> >> Reported-by: Joe Liu <joe.liu@mediatek.com>
> >> Signed-off-by: Lecopzer Chen <lecopzer.chen@mediatek.com>
> >> Cc: Mark-pk Tsai <mark-pk.tsai@mediatek.com>
> >> Cc: Joe Liu <joe.liu@mediatek.com>
> > 
> > Sorry for the long delay and thanks Lecopzer for the patch.
> > 
> > This changelog is difficult to parse but the fix may also me too specific
> > and could be more robust against types other than CMA. It is true that
> > a failed PCP acquire may return a !is_migrate_isolate page to the wrong
> > list but it's more straight-forward to unconditionally lookup the PCP
> > migratetype of the spinlock is not acquired.
> > 
> > How about this? It unconditionally looks up the PCP migratetype after
> > spinlock contention. It's build tested only
> > 
> > --8<--
> > mm: page_alloc: Free pages to correct buddy list after PCP lock contention
> > 
> > Commit 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock")
> > returns pages to the buddy list on PCP lock contention. However, for
> > migratetypes that are not MIGRATE_PCPTYPES, the migratetype may have
> > been clobbered already for pages that are not being isolated. In
> > practice, this means that CMA pages may be returned to the wrong
> > buddy list. While this might be harmless in some cases as it is
> > MIGRATE_MOVABLE, the pageblock could be reassigned in rmqueue_fallback
> > and prevent a future CMA allocation. Lookup the PCP migratetype
> > against unconditionally if the PCP lock is contended.
> > 
> > [lecopzer.chen@mediatek.com: CMA-specific fix]
> > Fixes: 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock")
> 
> I think we should Cc: stable for the sake of 6.1 LTS?
> 

Yep.

> > Reported-by: Joe Liu <joe.liu@mediatek.com>
> > Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
> 
> Acked-by: Vlastimil Babka <vbabka@suse.cz>
> 

Thanks.

-- 
Mel Gorman
SUSE Labs


  reply	other threads:[~2023-09-05 12:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-30 11:13 [PATCH] mm: page_alloc: fix cma pageblock was stolen in rmqueue fallback Lecopzer Chen
2023-09-05  9:09 ` Mel Gorman
2023-09-05  9:22   ` Lecopzer Chen
2023-09-05  9:37   ` Vlastimil Babka
2023-09-05 12:28     ` Mel Gorman [this message]
2023-09-11 15:57   ` Johannes Weiner
2023-09-11 16:13     ` Vlastimil Babka
2023-09-11 18:11       ` Johannes Weiner
2023-09-11 19:59         ` Vlastimil Babka

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=20230905122857.b3kwlxm6qxa2tgpb@techsingularity.net \
    --to=mgorman@techsingularity.net \
    --cc=akpm@linux-foundation.org \
    --cc=joe.liu@mediatek.com \
    --cc=lecopzer.chen@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mark-pk.tsai@mediatek.com \
    --cc=nsaenzju@redhat.com \
    --cc=vbabka@suse.cz \
    --cc=yj.chiang@mediatek.com \
    /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;
as well as URLs for NNTP newsgroup(s).