diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2022-08-09 09:48:30 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2022-08-09 09:48:30 -0700 |
commit | b8dcef877ab5f2637fccd3efb6fe169c8211961a (patch) | |
tree | ce4911c5bfca8a3189a5c2d64bf6f5dd551b1c03 /mm | |
parent | 15886321a426c7f4f1a0ff788f5b48e49230c0f3 (diff) | |
parent | 04d9490986d1e04a38db88276115e6b3c9ec3faa (diff) | |
download | linux-stable-b8dcef877ab5f2637fccd3efb6fe169c8211961a.tar.gz linux-stable-b8dcef877ab5f2637fccd3efb6fe169c8211961a.tar.bz2 linux-stable-b8dcef877ab5f2637fccd3efb6fe169c8211961a.zip |
Merge tag 'memblock-v5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
Pull memblock updates from Mike Rapoport:
- An optimization in memblock_add_range() to reduce array traversals
- Improvements to the memblock test suite
* tag 'memblock-v5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
memblock test: Modify the obsolete description in README
memblock tests: fix compilation errors
memblock tests: change build options to run-time options
memblock tests: remove completed TODO items
memblock tests: set memblock_debug to enable memblock_dbg() messages
memblock tests: add verbose output to memblock tests
memblock tests: Makefile: add arguments to control verbosity
memblock: avoid some repeat when add new range
Diffstat (limited to 'mm')
-rw-r--r-- | mm/memblock.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/mm/memblock.c b/mm/memblock.c index c0894c137954..b5d3026979fc 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -597,6 +597,17 @@ static int __init_memblock memblock_add_range(struct memblock_type *type, type->total_size = size; return 0; } + + /* + * The worst case is when new range overlaps all existing regions, + * then we'll need type->cnt + 1 empty regions in @type. So if + * type->cnt * 2 + 1 is less than type->max, we know + * that there is enough empty regions in @type, and we can insert + * regions directly. + */ + if (type->cnt * 2 + 1 < type->max) + insert = true; + repeat: /* * The following is executed twice. Once with %false @insert and |