Re: [PATCH v4 0/3] mm: Free contiguous order-0 pages efficiently

From: Muhammad Usama Anjum

Date: Mon Mar 30 2026 - 07:36:31 EST


Hi Andrew,

Thank you for reviewing.

On 27/03/2026 7:42 pm, Andrew Morton wrote:
> On Fri, 27 Mar 2026 12:57:12 +0000 Muhammad Usama Anjum <usama.anjum@xxxxxxx> wrote:
>
>> A recent change to vmalloc caused some performance benchmark regressions (see
>> [1]). I'm attempting to fix that (and at the same time significantly improve
>> beyond the baseline) by freeing a contiguous set of order-0 pages as a batch.
>>
>> At the same time I observed that free_contig_range() was essentially doing the
>> same thing as vfree() so I've fixed it there too. While at it, optimize the
>> __free_contig_frozen_range() as well.
>>
>> Check that the contiguous range falls in the same section. If they aren't enabled,
>> the if conditions get optimized out by the compiler as memdesc_section() returns 0.
>> See num_pages_contiguous() for more details about it.
>
> Thanks. I'm seeing impressive speedups for microbenchmarks. The
> speedup in [3/3] may be a bit more real-worldy.
Yeah, we are getting natural speedup as the vmalloc() allocated higher order
page blocks and vfree() starts freeing into higher order blocks instead
of order-0 blocks.

>
> Do you have a feeling for how much difference these changes will make
> for any real-world workload?
I've not run any real world benchmarks. Considering these benchmarks
we'll surely get speedups.

>
> Also, AI review said things:
> https://sashiko.dev/#/patchset/20260327125720.2270651-1-usama.anjum@xxxxxxx
>
> The can_free one (at least) seems legit. I suggest that can_free be
> made local to that for() loop - this would clear things up a bit.
Other than unrelated things in the AI's review, this is the only real
problem highlighted. I'll fix it.

Thanks,
Usama