lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220609024122.6679-1-tjytimi@163.com>
Date:   Thu,  9 Jun 2022 10:41:22 +0800
From:   tjytimi <tjytimi@....com>
To:     rppt@...nel.org, akpm@...ux-foundation.org
Cc:     linux-mm@...ck.org, linux-kernel@...r.kernel.org,
        tjytimi <tjytimi@....com>
Subject: [PATCH] memblock: avoid some repeat when add new range

The worst case is that the new memory range overlaps all existing
regions,which need type->cnt + 1 free area of struct memblock_region.
So if type->cnt + 1 + type->cnt is less than type->max,we can insert
regions directly.And becase of merge operation in the end of function,
tpye->cnt increase slowly for many cases.So this patch can avoid
unnecessary repeat for many cases when add new memory range.

Signed-off-by: tjytimi <tjytimi@....com>
---
 mm/memblock.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/memblock.c b/mm/memblock.c
index e4f03a6e8..243cd7de5 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -602,6 +602,9 @@ static int __init_memblock memblock_add_range(struct memblock_type *type,
 	base = obase;
 	nr_new = 0;
 
+	if (type->cnt<<1 < type->max - 1)
+		insert = true;
+
 	for_each_memblock_type(idx, type, rgn) {
 		phys_addr_t rbase = rgn->base;
 		phys_addr_t rend = rbase + rgn->size;
-- 
2.32.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ