]> git.baikalelectronics.ru Git - kernel.git/commit
memblock: avoid some repeat when add new range
authorJinyu Tang <tjytimi@163.com>
Wed, 15 Jun 2022 09:40:15 +0000 (17:40 +0800)
committerMike Rapoport <rppt@linux.ibm.com>
Thu, 30 Jun 2022 08:55:00 +0000 (11:55 +0300)
commit68d5c3ed94b00adcc3657e66bfbef839a6c05eef
treec42f476f4b01620d39555d3bb504bedf4750d1b2
parent4f64cb9d4742408196e508a683a5f394c26fe503
memblock: avoid some repeat when add new range

The worst case is that the new memory range overlaps all existing
regions, which requires type->cnt + 1 empty struct memblock_region slots in
the type->regions array.
So if type->cnt + 1 + type->cnt is less than type->max, we can insert
regions directly rather than calculate the needed amount before the
insertion.
And becase of merge operation in the end of function, tpye->cnt will
increase slowly for many cases.

This change allows to avoid unnecessary repeat of memblock ranges traversal
for many cases when adding new memory range.

Signed-off-by: Jinyu Tang <tjytimi@163.com>
[rppt: massaged comment and changelog text]
Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
mm/memblock.c