* Re: [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop
2026-11-16 12:57 [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Kiryl Shutsemau (Meta)
@ 2026-11-17 1:37 ` SJ Park
2026-11-17 10:29 ` Kiryl Shutsemau (Meta)
2026-11-17 5:34 ` Dev Jain
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: SJ Park @ 2026-11-17 1:37 UTC (permalink / raw)
To: Kiryl Shutsemau (Meta)
Cc: SJ Park, Andrew Morton, Vlastimil Babka, Johannes Weiner,
David Hildenbrand, Mel Gorman, Suren Baghdasaryan, Michal Hocko,
Brendan Jackman, Zi Yan, Dev Jain, linux-mm, linux-kernel,
kernel-team
On Mon, 16 Nov 2026 12:57:45 +0000 "Kiryl Shutsemau (Meta)" <kas@kernel.org> wrote:
> isolate_freepages_block() drops zone->lock, checks for a fatal signal
> and calls cond_resched() at every pfn that is a multiple of
> COMPACT_CLUSTER_MAX.
>
> With a stride above one, the scan steps over a compound page, or over a
> high-order free page it has just isolated, to a pfn that is not a
> multiple of the stride. From there it never reaches a multiple of
> COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
> check, possibly with zone->lock held and interrupts off.
>
> Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
Makes sense to me.
>
> Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
I understand you intentionally not Cc-ing stable@, buecase the user impact is
not that bad. I think that makes sense. I just wanted to call out this for a
case that it was not intentional.
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> ---
> mm/compaction.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index f1b2060eb201..4465c1551406 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -579,7 +579,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> unsigned int stride,
> bool strict)
> {
> - int nr_scanned = 0, total_isolated = 0;
> + int nr_scanned = 0, nr_probes = 0, total_isolated = 0;
> struct page *page;
> unsigned long flags = 0;
> bool locked = false;
> @@ -599,13 +599,15 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> /*
> * Periodically drop the lock (if held) regardless of its
> * contention, to give chance to IRQs. Abort if fatal signal
> - * pending.
> + * pending. Count probes rather than pfns, as the scan does not
> + * always land on a multiple of COMPACT_CLUSTER_MAX.
> */
> - if (!(blockpfn % COMPACT_CLUSTER_MAX)
> - && compact_unlock_should_abort(&cc->zone->lock, flags,
> - &locked, cc))
> + if (!(nr_probes % COMPACT_CLUSTER_MAX) &&
> + compact_unlock_should_abort(&cc->zone->lock, flags,
> + &locked, cc))
Why don't you let the later two lines unchanged? No strong opinion, no
blocker.
Reviewed-by: SJ Park <sj@kernel.org>
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop
2026-11-17 1:37 ` SJ Park
@ 2026-11-17 10:29 ` Kiryl Shutsemau (Meta)
0 siblings, 0 replies; 9+ messages in thread
From: Kiryl Shutsemau (Meta) @ 2026-11-17 10:29 UTC (permalink / raw)
To: SJ Park
Cc: Andrew Morton, Vlastimil Babka, Johannes Weiner,
David Hildenbrand, Mel Gorman, Suren Baghdasaryan, Michal Hocko,
Brendan Jackman, Zi Yan, Dev Jain, linux-mm, linux-kernel,
kernel-team
On Mon, Nov 16, 2026 at 05:37:02PM -0800, SJ Park wrote:
> On Mon, 16 Nov 2026 12:57:45 +0000 "Kiryl Shutsemau (Meta)" <kas@kernel.org> wrote:
>
> > isolate_freepages_block() drops zone->lock, checks for a fatal signal
> > and calls cond_resched() at every pfn that is a multiple of
> > COMPACT_CLUSTER_MAX.
> >
> > With a stride above one, the scan steps over a compound page, or over a
> > high-order free page it has just isolated, to a pfn that is not a
> > multiple of the stride. From there it never reaches a multiple of
> > COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
> > check, possibly with zone->lock held and interrupts off.
> >
> > Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
>
> Makes sense to me.
>
> >
> > Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
>
> I understand you intentionally not Cc-ing stable@, buecase the user impact is
> not that bad. I think that makes sense. I just wanted to call out this for a
> case that it was not intentional.
Right, I have not see the actual user effect of the bug.
> > Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> > ---
> > mm/compaction.c | 12 +++++++-----
> > 1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/mm/compaction.c b/mm/compaction.c
> > index f1b2060eb201..4465c1551406 100644
> > --- a/mm/compaction.c
> > +++ b/mm/compaction.c
> > @@ -579,7 +579,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> > unsigned int stride,
> > bool strict)
> > {
> > - int nr_scanned = 0, total_isolated = 0;
> > + int nr_scanned = 0, nr_probes = 0, total_isolated = 0;
> > struct page *page;
> > unsigned long flags = 0;
> > bool locked = false;
> > @@ -599,13 +599,15 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> > /*
> > * Periodically drop the lock (if held) regardless of its
> > * contention, to give chance to IRQs. Abort if fatal signal
> > - * pending.
> > + * pending. Count probes rather than pfns, as the scan does not
> > + * always land on a multiple of COMPACT_CLUSTER_MAX.
> > */
> > - if (!(blockpfn % COMPACT_CLUSTER_MAX)
> > - && compact_unlock_should_abort(&cc->zone->lock, flags,
> > - &locked, cc))
> > + if (!(nr_probes % COMPACT_CLUSTER_MAX) &&
> > + compact_unlock_should_abort(&cc->zone->lock, flags,
> > + &locked, cc))
>
> Why don't you let the later two lines unchanged? No strong opinion, no
> blocker.
&& on the new line is odd to me.
> Reviewed-by: SJ Park <sj@kernel.org>
Thanks!
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop
2026-11-16 12:57 [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Kiryl Shutsemau (Meta)
2026-11-17 1:37 ` SJ Park
@ 2026-11-17 5:34 ` Dev Jain
2026-11-17 10:28 ` Kiryl Shutsemau (Meta)
2026-11-17 17:29 ` Zi Yan
` (3 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Dev Jain @ 2026-11-17 5:34 UTC (permalink / raw)
To: Kiryl Shutsemau (Meta), Andrew Morton, Vlastimil Babka,
Johannes Weiner, David Hildenbrand
Cc: Mel Gorman, Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
Zi Yan, linux-mm, linux-kernel, kernel-team
On 16/11/26 6:27 pm, Kiryl Shutsemau (Meta) wrote:
> isolate_freepages_block() drops zone->lock, checks for a fatal signal
> and calls cond_resched() at every pfn that is a multiple of
> COMPACT_CLUSTER_MAX.
>
> With a stride above one, the scan steps over a compound page, or over a
> high-order free page it has just isolated, to a pfn that is not a
> multiple of the stride. From there it never reaches a multiple of
> COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
> check, possibly with zone->lock held and interrupts off.
>
> Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
>
> Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> ---
Cc stable?
Reviewed-by: Dev Jain <dev.jain@arm.com>
> mm/compaction.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index f1b2060eb201..4465c1551406 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -579,7 +579,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> unsigned int stride,
> bool strict)
> {
> - int nr_scanned = 0, total_isolated = 0;
> + int nr_scanned = 0, nr_probes = 0, total_isolated = 0;
> struct page *page;
> unsigned long flags = 0;
> bool locked = false;
> @@ -599,13 +599,15 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> /*
> * Periodically drop the lock (if held) regardless of its
> * contention, to give chance to IRQs. Abort if fatal signal
> - * pending.
> + * pending. Count probes rather than pfns, as the scan does not
> + * always land on a multiple of COMPACT_CLUSTER_MAX.
> */
> - if (!(blockpfn % COMPACT_CLUSTER_MAX)
> - && compact_unlock_should_abort(&cc->zone->lock, flags,
> - &locked, cc))
> + if (!(nr_probes % COMPACT_CLUSTER_MAX) &&
> + compact_unlock_should_abort(&cc->zone->lock, flags,
> + &locked, cc))
I see this is an unrelated change but I don't mind.
> break;
>
> + nr_probes++;
> nr_scanned++;
>
> /*
>
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop
2026-11-17 5:34 ` Dev Jain
@ 2026-11-17 10:28 ` Kiryl Shutsemau (Meta)
0 siblings, 0 replies; 9+ messages in thread
From: Kiryl Shutsemau (Meta) @ 2026-11-17 10:28 UTC (permalink / raw)
To: Dev Jain
Cc: Andrew Morton, Vlastimil Babka, Johannes Weiner,
David Hildenbrand, Mel Gorman, Suren Baghdasaryan, Michal Hocko,
Brendan Jackman, Zi Yan, linux-mm, linux-kernel, kernel-team
On Tue, Nov 17, 2026 at 11:04:25AM +0530, Dev Jain wrote:
>
>
> On 16/11/26 6:27 pm, Kiryl Shutsemau (Meta) wrote:
> > isolate_freepages_block() drops zone->lock, checks for a fatal signal
> > and calls cond_resched() at every pfn that is a multiple of
> > COMPACT_CLUSTER_MAX.
> >
> > With a stride above one, the scan steps over a compound page, or over a
> > high-order free page it has just isolated, to a pfn that is not a
> > multiple of the stride. From there it never reaches a multiple of
> > COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
> > check, possibly with zone->lock held and interrupts off.
> >
> > Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
> >
> > Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
> > Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> > ---
>
> Cc stable?
I have not seen real world problem triggered by the bug. I don't think
it is needed.
>
> Reviewed-by: Dev Jain <dev.jain@arm.com>
Thanks!
> > mm/compaction.c | 12 +++++++-----
> > 1 file changed, 7 insertions(+), 5 deletions(-)
> >
> > diff --git a/mm/compaction.c b/mm/compaction.c
> > index f1b2060eb201..4465c1551406 100644
> > --- a/mm/compaction.c
> > +++ b/mm/compaction.c
> > @@ -579,7 +579,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> > unsigned int stride,
> > bool strict)
> > {
> > - int nr_scanned = 0, total_isolated = 0;
> > + int nr_scanned = 0, nr_probes = 0, total_isolated = 0;
> > struct page *page;
> > unsigned long flags = 0;
> > bool locked = false;
> > @@ -599,13 +599,15 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> > /*
> > * Periodically drop the lock (if held) regardless of its
> > * contention, to give chance to IRQs. Abort if fatal signal
> > - * pending.
> > + * pending. Count probes rather than pfns, as the scan does not
> > + * always land on a multiple of COMPACT_CLUSTER_MAX.
> > */
> > - if (!(blockpfn % COMPACT_CLUSTER_MAX)
> > - && compact_unlock_should_abort(&cc->zone->lock, flags,
> > - &locked, cc))
> > + if (!(nr_probes % COMPACT_CLUSTER_MAX) &&
> > + compact_unlock_should_abort(&cc->zone->lock, flags,
> > + &locked, cc))
>
> I see this is an unrelated change but I don't mind.
&& on the new line looks odd to me, it belongs to the first line.
--
Kiryl Shutsemau / Kirill A. Shutemov
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop
2026-11-16 12:57 [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Kiryl Shutsemau (Meta)
2026-11-17 1:37 ` SJ Park
2026-11-17 5:34 ` Dev Jain
@ 2026-11-17 17:29 ` Zi Yan
2026-12-02 2:18 ` + mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch added to mm-new branch Andrew Morton
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Zi Yan @ 2026-11-17 17:29 UTC (permalink / raw)
To: Kiryl Shutsemau (Meta)
Cc: Andrew Morton, Vlastimil Babka, Johannes Weiner,
David Hildenbrand, Mel Gorman, Suren Baghdasaryan, Michal Hocko,
Brendan Jackman, Dev Jain, linux-mm, linux-kernel, kernel-team
On 16 Nov 2026, at 7:57, Kiryl Shutsemau (Meta) wrote:
> isolate_freepages_block() drops zone->lock, checks for a fatal signal
> and calls cond_resched() at every pfn that is a multiple of
> COMPACT_CLUSTER_MAX.
>
> With a stride above one, the scan steps over a compound page, or over a
> high-order free page it has just isolated, to a pfn that is not a
> multiple of the stride. From there it never reaches a multiple of
> COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
> check, possibly with zone->lock held and interrupts off.
>
> Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
Makes sense. The loop is working on one page (regardless of its order)
at a time.
>
> Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> ---
> mm/compaction.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Best Regards,
Yan, Zi
^ permalink raw reply [flat|nested] 9+ messages in thread* + mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch added to mm-new branch
2026-11-16 12:57 [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Kiryl Shutsemau (Meta)
` (2 preceding siblings ...)
2026-11-17 17:29 ` Zi Yan
@ 2026-12-02 2:18 ` Andrew Morton
2026-12-02 9:12 ` [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Vlastimil Babka (SUSE)
2026-12-02 16:19 ` [merged _alloc/for-7.5/misc] mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch removed from -mm tree Andrew Morton
5 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-12-02 2:18 UTC (permalink / raw)
To: mm-commits, ziy, vbabka, surenb, sj, mhocko, mgorman, hannes,
dev.jain, david, brendan.jackman, kas, akpm
The patch titled
Subject: mm/compaction: do not skip the free scanner's periodic lock drop
has been added to the -mm mm-new branch. Its filename is
mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
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 various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: "Kiryl Shutsemau (Meta)" <kas@kernel.org>
Subject: mm/compaction: do not skip the free scanner's periodic lock drop
Date: Mon, 16 Nov 2026 12:57:45 +0000
isolate_freepages_block() drops zone->lock, checks for a fatal signal
and calls cond_resched() at every pfn that is a multiple of
COMPACT_CLUSTER_MAX.
With a stride above one, the scan steps over a compound page, or over a
high-order free page it has just isolated, to a pfn that is not a
multiple of the stride. From there it never reaches a multiple of
COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
check, possibly with zone->lock held and interrupts off.
Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
Link: https://patch.msgid.link/20261116125746.2897395-1-kas@kernel.org
Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
mm/compaction.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--- a/mm/compaction.c~mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop
+++ a/mm/compaction.c
@@ -579,7 +579,7 @@ static unsigned long isolate_freepages_b
unsigned int stride,
bool strict)
{
- int nr_scanned = 0, total_isolated = 0;
+ int nr_scanned = 0, nr_probes = 0, total_isolated = 0;
struct page *page;
unsigned long flags = 0;
bool locked = false;
@@ -599,13 +599,15 @@ static unsigned long isolate_freepages_b
/*
* Periodically drop the lock (if held) regardless of its
* contention, to give chance to IRQs. Abort if fatal signal
- * pending.
+ * pending. Count probes rather than pfns, as the scan does not
+ * always land on a multiple of COMPACT_CLUSTER_MAX.
*/
- if (!(blockpfn % COMPACT_CLUSTER_MAX)
- && compact_unlock_should_abort(&cc->zone->lock, flags,
- &locked, cc))
+ if (!(nr_probes % COMPACT_CLUSTER_MAX) &&
+ compact_unlock_should_abort(&cc->zone->lock, flags,
+ &locked, cc))
break;
+ nr_probes++;
nr_scanned++;
/*
_
Patches currently in -mm which might be from kas@kernel.org are
mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop
2026-11-16 12:57 [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Kiryl Shutsemau (Meta)
` (3 preceding siblings ...)
2026-12-02 2:18 ` + mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch added to mm-new branch Andrew Morton
@ 2026-12-02 9:12 ` Vlastimil Babka (SUSE)
2026-12-02 16:19 ` [merged _alloc/for-7.5/misc] mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch removed from -mm tree Andrew Morton
5 siblings, 0 replies; 9+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-12-02 9:12 UTC (permalink / raw)
To: Kiryl Shutsemau (Meta), Andrew Morton, Johannes Weiner,
David Hildenbrand
Cc: Mel Gorman, Suren Baghdasaryan, Michal Hocko, Brendan Jackman,
Zi Yan, Dev Jain, linux-mm, linux-kernel, kernel-team, Harry Yoo
On 11/16/26 13:57, Kiryl Shutsemau (Meta) wrote:
> isolate_freepages_block() drops zone->lock, checks for a fatal signal
> and calls cond_resched() at every pfn that is a multiple of
> COMPACT_CLUSTER_MAX.
>
> With a stride above one, the scan steps over a compound page, or over a
> high-order free page it has just isolated, to a pfn that is not a
> multiple of the stride. From there it never reaches a multiple of
> COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
> check, possibly with zone->lock held and interrupts off.
I'm adding this paragraph here:
On the other hand, the lock drops can become more frequent than intended
and thus making scanning progress slower with a stride above one or in
the presence of high-order pages.
> Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
>
> Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
> Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Applied to page_alloc/for-7.5/misc, thanks!
> ---
> mm/compaction.c | 12 +++++++-----
> 1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/mm/compaction.c b/mm/compaction.c
> index f1b2060eb201..4465c1551406 100644
> --- a/mm/compaction.c
> +++ b/mm/compaction.c
> @@ -579,7 +579,7 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> unsigned int stride,
> bool strict)
> {
> - int nr_scanned = 0, total_isolated = 0;
> + int nr_scanned = 0, nr_probes = 0, total_isolated = 0;
> struct page *page;
> unsigned long flags = 0;
> bool locked = false;
> @@ -599,13 +599,15 @@ static unsigned long isolate_freepages_block(struct compact_control *cc,
> /*
> * Periodically drop the lock (if held) regardless of its
> * contention, to give chance to IRQs. Abort if fatal signal
> - * pending.
> + * pending. Count probes rather than pfns, as the scan does not
> + * always land on a multiple of COMPACT_CLUSTER_MAX.
> */
> - if (!(blockpfn % COMPACT_CLUSTER_MAX)
> - && compact_unlock_should_abort(&cc->zone->lock, flags,
> - &locked, cc))
> + if (!(nr_probes % COMPACT_CLUSTER_MAX) &&
> + compact_unlock_should_abort(&cc->zone->lock, flags,
> + &locked, cc))
> break;
>
> + nr_probes++;
> nr_scanned++;
>
> /*
>
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
^ permalink raw reply [flat|nested] 9+ messages in thread* [merged _alloc/for-7.5/misc] mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch removed from -mm tree
2026-11-16 12:57 [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Kiryl Shutsemau (Meta)
` (4 preceding siblings ...)
2026-12-02 9:12 ` [PATCH] mm/compaction: do not skip the free scanner's periodic lock drop Vlastimil Babka (SUSE)
@ 2026-12-02 16:19 ` Andrew Morton
5 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-12-02 16:19 UTC (permalink / raw)
To: mm-commits, ziy, vbabka, surenb, sj, mhocko, mgorman, hannes,
dev.jain, david, brendan.jackman, kas, akpm
The quilt patch titled
Subject: mm/compaction: do not skip the free scanner's periodic lock drop
has been removed from the -mm tree. Its filename was
mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop.patch
This patch was dropped because it was merged into _alloc/for-7.5/misc
------------------------------------------------------
From: "Kiryl Shutsemau (Meta)" <kas@kernel.org>
Subject: mm/compaction: do not skip the free scanner's periodic lock drop
Date: Mon, 16 Nov 2026 12:57:45 +0000
isolate_freepages_block() drops zone->lock, checks for a fatal signal
and calls cond_resched() at every pfn that is a multiple of
COMPACT_CLUSTER_MAX.
With a stride above one, the scan steps over a compound page, or over a
high-order free page it has just isolated, to a pfn that is not a
multiple of the stride. From there it never reaches a multiple of
COMPACT_CLUSTER_MAX, so the rest of the pageblock is scanned without the
check, possibly with zone->lock held and interrupts off.
Count probes instead, and check every COMPACT_CLUSTER_MAX of them.
Link: https://patch.msgid.link/20261116125746.2897395-1-kas@kernel.org
Fixes: 4fca9730c51d ("mm, compaction: sample pageblocks for free pages")
Signed-off-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: SJ Park <sj@kernel.org>
Reviewed-by: Dev Jain <dev.jain@arm.com>
Reviewed-by: Zi Yan <ziy@nvidia.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: David Hildenbrand <david@kernel.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Brendan Jackman <brendan.jackman@linux.dev>
mm/compaction.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
--- a/mm/compaction.c~mm-compaction-do-not-skip-the-free-scanners-periodic-lock-drop
+++ a/mm/compaction.c
@@ -579,7 +579,7 @@ static unsigned long isolate_freepages_b
unsigned int stride,
bool strict)
{
- int nr_scanned = 0, total_isolated = 0;
+ int nr_scanned = 0, nr_probes = 0, total_isolated = 0;
struct page *page;
unsigned long flags = 0;
bool locked = false;
@@ -599,13 +599,15 @@ static unsigned long isolate_freepages_b
/*
* Periodically drop the lock (if held) regardless of its
* contention, to give chance to IRQs. Abort if fatal signal
- * pending.
+ * pending. Count probes rather than pfns, as the scan does not
+ * always land on a multiple of COMPACT_CLUSTER_MAX.
*/
- if (!(blockpfn % COMPACT_CLUSTER_MAX)
- && compact_unlock_should_abort(&cc->zone->lock, flags,
- &locked, cc))
+ if (!(nr_probes % COMPACT_CLUSTER_MAX) &&
+ compact_unlock_should_abort(&cc->zone->lock, flags,
+ &locked, cc))
break;
+ nr_probes++;
nr_scanned++;
/*
_
Patches currently in -mm which might be from kas@kernel.org are
^ permalink raw reply [flat|nested] 9+ messages in thread