Linux-mm Archive on
 help / color / Atom feed
* [patch 084/158] mm/sparse: consistently do not zero memmap
@ 2019-12-01  1:54 akpm
  0 siblings, 0 replies; only message in thread
From: akpm @ 2019-12-01  1:54 UTC (permalink / raw)
  To: akpm, david, linux-mm, mhocko, mm-commits, osalvador,
	pasha.tatashin, torvalds, vincent.whitchurch

From: Vincent Whitchurch <>
Subject: mm/sparse: consistently do not zero memmap

sparsemem without VMEMMAP has two allocation paths to allocate the memory
needed for its memmap (done in sparse_mem_map_populate()).

In one allocation path (sparse_buffer_alloc() succeeds), the memory is not
zeroed (since it was previously allocated with

In the other allocation path (sparse_buffer_alloc() fails and
sparse_mem_map_populate() falls back to memblock_alloc_try_nid()), the
memory is zeroed.

AFAICS this difference does not appear to be on purpose.  If the code is
supposed to work with non-initialized memory (__init_single_page() takes
care of zeroing the struct pages which are actually used), we should
consistently not zero the memory, to avoid masking bugs.

(I noticed this because on my ARM64 platform, with 1 GiB of memory the
 first [and only] section is allocated from the zeroing path while with
 2 GiB of memory the first 1 GiB section is allocated from the
 non-zeroing path.)

Michal: "the main user visible problem is a memory wastage.  The overal
amount of memory should be small.  I wouldn't call it stable material."

Signed-off-by: Vincent Whitchurch <>
Acked-by: Michal Hocko <>
Acked-by: David Hildenbrand <>
Reviewed-by: Oscar Salvador <>
Reviewed-by: Pavel Tatashin <>
Signed-off-by: Andrew Morton <>

 mm/sparse.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/mm/sparse.c~mm-sparse-consistently-do-not-zero-memmap
+++ a/mm/sparse.c
@@ -458,7 +458,7 @@ struct page __init *__populate_section_m
 	if (map)
 		return map;
-	map = memblock_alloc_try_nid(size,
+	map = memblock_alloc_try_nid_raw(size,
 					  PAGE_SIZE, addr,
 	if (!map)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01  1:54 [patch 084/158] mm/sparse: consistently do not zero memmap akpm

Linux-mm Archive on

Archives are clonable:
	git clone --mirror linux-mm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-mm linux-mm/ \
	public-inbox-index linux-mm

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone