Re: [PATCH v3] mm: page_alloc: make defrag_mode retries follow the promoted order

From: Dev Jain

Date: Wed Oct 28 2026 - 03:02:48 EST




On 27/10/26 4:30 pm, Kiryl Shutsemau wrote:
> On Tue, Oct 27, 2026 at 12:42:12PM +0530, Dev Jain wrote:
>>
>>
>> On 23/10/26 8:16 pm, Kiryl Shutsemau wrote:
>>> On Fri, Oct 23, 2026 at 01:12:02PM +0100, Kiryl Shutsemau wrote:
>>>> The diff below replaces the previous one. It needs cleanup and splitting
>>>> before it goes upstream.
>>>
>>> Proper patchset:
>>>
>>> https://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git page_alloc/nofrag-watermark-v1
>>>
>>
>> Thanks! I applied the 3 commits on top and the results improved a lot. Your patches
>> make sense to me.
>
> Thanks for testing.
>
> Can I use your Tested-by?

Sure! Do Cc me whenever you send. I'll try reviewing if I am not on vacation : )


>
>> But still, I see more compact_stalls and a worse compaction success:fail ratio. The
>> limitation must be by definition I believe: we still won't be able to use 64K blocks
>> from non-movable pageblocks.
>
> Right, that is by design.
>
> defrag_mode keeps the free space in unmovable and reclaimable blocks for
> those allocations, so they don't spill into movable blocks. Your 64K
> faults never take it.
>
> The price is that defrag_mode needs more free memory for the same
> workload. In return, the system does not fragment over time: huge page
> availability stays steady instead of decaying under load.

Right.


>
> The benchmark runs right at the edge: it fills 99% of MemAvailable and
> then faults another 20% in 64K. defrag_mode=0 takes the 64K chunks it
> finds in non-movable blocks without compacting. defrag_mode=1 has to
> build them inside movable blocks, and with memory full there is little
> free space there. So more compaction, and more of it fails.
>
> The 64K fault count ends up close anyway: 20.1k vs 20.7k in my runs.

Yep, the issue is that Android folks may complain - they observe increased power
consumption due to reclaim stalls and compaction stalls and would like to
minimize them.

I would really want to see defrag_mode become the default since it attacks
the major cause of fragmentation nicely, but the assumption is that compaction
is a free resource, unfortunately on smaller devices that's not the case.