Re: [PATCH] mm: optimize memblock_add_range() for improved performance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Stephen,

On Wed, Feb 05, 2025 at 05:55:50AM +0000, Stephen Eta Zhou wrote:
> Hi Mike Rapoport、Andrew Morton

> I have recently been researching the mm subsystem of the Linux kernel,
> and I came across the memblock_add_range function, which piqued my
> interest. I found the implementation approach quite interesting, so I
> analyzed it and identified some areas for optimization. Starting with
> this part of the code:
>
> if (type->cnt * 2 + 1 <= type->max)
>       insert = true;
> The idea here is good, but it has a certain flaw. The condition is rather
> restrictive, and it cannot be executed initially. Moreover, it is only
> valid when the remaining space is (2/1) + 1. If there is enough memory,
> but it does not satisfy (2/1) + 1, the insertion operation still needs to
> be performed twice.

The code in memblock_add_range() is very fragile, and many attempts to
remove the second pass that looked correct at the first glance failed for
some corner case.

Unfortunately, it's impossible to capture all possible memory
configurations and reservations in the memblock test suite, so even it it
passes, there is a chance the kernel will fail to boot on an actual HW.
 
> - Before the patch:
>   - Average: 1.22%
>   - Max: 1.63%, Min: 0.93%
> 
> - After the patch:
>   - Average: 0.69%
>   - Max: 0.94%, Min: 0.50%
> 

These numbers do not represent what's actually interesting: the boot time
speedup.

-- 
Sincerely yours,
Mike.




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux