The patch titled Subject: mm: page_alloc: free pages to correct buddy list after PCP lock contention has been added to the -mm mm-hotfixes-unstable branch. Its filename is mm-page_alloc-free-pages-to-correct-buddy-list-after-pcp-lock-contention.patch
This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches...
This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days
------------------------------------------------------ From: Mel Gorman mgorman@techsingularity.net Subject: mm: page_alloc: free pages to correct buddy list after PCP lock contention Date: Tue, 5 Sep 2023 10:09:22 +0100
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] Link: https://lkml.kernel.org/r/20230905090922.zy7srh33rg5c3zao@techsingularity.ne... Fixes: 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock") Signed-off-by: Mel Gorman mgorman@techsingularity.net Reported-by: Joe Liu joe.liu@mediatek.com Acked-by: Vlastimil Babka vbabka@suse.cz Cc: Johannes Weiner hannes@cmpxchg.org Cc: stable@vger.kernel.org Signed-off-by: Andrew Morton akpm@linux-foundation.org ---
mm/page_alloc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
--- a/mm/page_alloc.c~mm-page_alloc-free-pages-to-correct-buddy-list-after-pcp-lock-contention +++ a/mm/page_alloc.c @@ -2428,7 +2428,13 @@ void free_unref_page(struct page *page, free_unref_page_commit(zone, pcp, page, migratetype, order); pcp_spin_unlock(pcp); } else { - free_one_page(zone, page, pfn, order, migratetype, FPI_NONE); + /* + * The page migratetype may have been clobbered for types + * (type >= MIGRATE_PCPTYPES && !is_migrate_isolate) so + * must be rechecked. + */ + free_one_page(zone, page, pfn, order, + get_pcppage_migratetype(page), FPI_NONE); } pcp_trylock_finish(UP_flags); } _
Patches currently in -mm which might be from mgorman@techsingularity.net are
mm-page_alloc-free-pages-to-correct-buddy-list-after-pcp-lock-contention.patch
On Mon, Sep 11, 2023 at 02:00:52PM -0700, Andrew Morton wrote:
The patch titled Subject: mm: page_alloc: free pages to correct buddy list after PCP lock contention has been added to the -mm mm-hotfixes-unstable branch. Its filename is mm-page_alloc-free-pages-to-correct-buddy-list-after-pcp-lock-contention.patch
This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches...
This patch will later appear in the mm-hotfixes-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days
From: Mel Gorman mgorman@techsingularity.net Subject: mm: page_alloc: free pages to correct buddy list after PCP lock contention Date: Tue, 5 Sep 2023 10:09:22 +0100
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] Link: https://lkml.kernel.org/r/20230905090922.zy7srh33rg5c3zao@techsingularity.ne... Fixes: 4b23a68f9536 ("mm/page_alloc: protect PCP lists with a spinlock") Signed-off-by: Mel Gorman mgorman@techsingularity.net Reported-by: Joe Liu joe.liu@mediatek.com Acked-by: Vlastimil Babka vbabka@suse.cz Cc: Johannes Weiner hannes@cmpxchg.org Cc: stable@vger.kernel.org Signed-off-by: Andrew Morton akpm@linux-foundation.org
This patch is superseded by the following patch you picked up: mm-page_alloc-fix-cma-and-highatomic-landing-on-the-wrong-buddy-list.patch
If you drop this patch here, you can also drop the fixlet to free_unref_page(). The branch in there should look like this:
if (pcp) free_unref_page_commit(..., pcpmigratetype, ...); else free_one_page(..., migratetype, ...);
On Tue, 12 Sep 2023 09:50:29 -0400 Johannes Weiner hannes@cmpxchg.org wrote:
Cc: Johannes Weiner hannes@cmpxchg.org Cc: stable@vger.kernel.org Signed-off-by: Andrew Morton akpm@linux-foundation.org
This patch is superseded by the following patch you picked up: mm-page_alloc-fix-cma-and-highatomic-landing-on-the-wrong-buddy-list.patch
OK.
If you drop this patch here, you can also drop the fixlet to free_unref_page(). The branch in there should look like this:
if (pcp) free_unref_page_commit(..., pcpmigratetype, ...); else free_one_page(..., migratetype, ...);
Well kinda. It's actually
if (pcp) { free_unref_page_commit(zone, pcp, page, migratetype, order); pcp_spin_unlock(pcp); } else { free_one_page(zone, page, pfn, order, migratetype, FPI_NONE); }
On Tue, Sep 12, 2023 at 09:09:38AM -0700, Andrew Morton wrote:
On Tue, 12 Sep 2023 09:50:29 -0400 Johannes Weiner hannes@cmpxchg.org wrote:
Cc: Johannes Weiner hannes@cmpxchg.org Cc: stable@vger.kernel.org Signed-off-by: Andrew Morton akpm@linux-foundation.org
This patch is superseded by the following patch you picked up: mm-page_alloc-fix-cma-and-highatomic-landing-on-the-wrong-buddy-list.patch
OK.
If you drop this patch here, you can also drop the fixlet to free_unref_page(). The branch in there should look like this:
if (pcp) free_unref_page_commit(..., pcpmigratetype, ...); else free_one_page(..., migratetype, ...);
Well kinda. It's actually
if (pcp) { free_unref_page_commit(zone, pcp, page, migratetype, order);
^^ pcpmigratetype
is what I was trying to highlight.
But yes, the pcp_spin_unlock() is needed too!
pcp_spin_unlock(pcp);
} else { free_one_page(zone, page, pfn, order, migratetype, FPI_NONE); }
linux-stable-mirror@lists.linaro.org