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]
Date:   Tue, 12 Apr 2022 00:39:32 +0530
From:   Faiyaz Mohammed <quic_faiyazm@...cinc.com>
To:     <quic_vjitta@...cinc.com>, <karahmed@...zon.de>,
        <qperret@...gle.com>, <robh@...nel.org>, <rppt@...nel.org>,
        <akpm@...ux-foundation.org>, <linux-mm@...ck.org>,
        <linux-kernel@...r.kernel.org>
CC:     Faiyaz Mohammed <quic_faiyazm@...cinc.com>
Subject: [PATCH] mm: memblock: avoid to create memmap for memblock nomap regions

This 'commit 86588296acbf ("fdt: Properly handle "no-map" field in the
memory region")' is keeping the no-map regions in memblock.memory with
MEMBLOCK_NOMAP flag set to use no-map memory for EFI using memblock api's,
but during the initialization sparse_init mark all memblock.memory as
present using for_each_mem_pfn_range, which is creating the memmap for
no-map memblock regions. To avoid it skiping the memblock.memory regions
set with MEMBLOCK_NOMAP set and with this change we will be able to save
~11MB memory for ~612MB carve out.

With change:
[    0.000000] memblock_alloc_exact_nid_raw: 115343360 bytes align=0x200000 nid=0 from=0x0000000080000000 max_addr=0x0000000000000000 sparse_buffer_init+0x60/0x8c
[    0.000000] memblock_reserve: [0x0000000932c00000-0x00000009399fffff] memblock_alloc_range_nid+0xbc/0x1a0
[    0.000000] On node 0 totalpages: 1627824
[    0.000000] DMA32 zone: 5383 pages used for memmap
[    0.000000] Normal zone: 20052 pages used for memmap

Without change:
[    0.000000] memblock_alloc_exact_nid_raw: 117440512 bytes align=0x200000 nid=0 from=0x0000000080000000 max_addr=0x0000000000000000 sparse_buffer_init+0x60/0x8c
[    0.000000] memblock_reserve: [0x0000000932a00000-0x00000009399fffff] memblock_alloc_range_nid+0xbc/0x1a0
[    0.000000] On node 0 totalpages: 1788416
[    0.000000] DMA32 zone: 8192 pages used for memmap
[    0.000000] Normal zone: 20052 pages used for memmap.

Signed-off-by: Faiyaz Mohammed <quic_faiyazm@...cinc.com>
---
 mm/memblock.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/mm/memblock.c b/mm/memblock.c
index 2270e3c..a4fde9d 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -1175,8 +1175,13 @@ void __init_memblock __next_mem_pfn_range(int *idx, int nid,
 		r = &type->regions[*idx];
 		r_nid = memblock_get_region_node(r);
 
+		/* If memblock region is nomap then skip the region. */
+		if (memblock_is_nomap(r))
+			continue;
+
 		if (PFN_UP(r->base) >= PFN_DOWN(r->base + r->size))
 			continue;
+
 		if (nid == MAX_NUMNODES || nid == r_nid)
 			break;
 	}
-- 
2.7.4

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ