All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/sparse: Make sparse_init_one_section void and remove check
@ 2018-07-02 15:43 osalvador
  2018-07-02 16:05 ` Michal Hocko
  2018-07-02 18:47 ` Pavel Tatashin
  0 siblings, 2 replies; 19+ messages in thread
From: osalvador @ 2018-07-02 15:43 UTC (permalink / raw)
  To: akpm
  Cc: pasha.tatashin, mhocko, vbabka, bhe, kirill.shutemov,
	dave.hansen, linux-mm, linux-kernel, Oscar Salvador

From: Oscar Salvador <osalvador@suse.de>

sparse_init_one_section() is being called from two sites:
sparse_init() and sparse_add_one_section().
The former calls it from a for_each_present_section_nr() loop,
and the latter marks the section as present before calling it.
This means that when sparse_init_one_section() gets called, we already know
that the section is present.
So there is no point to double check that in the function.

This removes the check and makes the function void.

Signed-off-by: Oscar Salvador <osalvador@suse.de>
---
 mm/sparse.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/mm/sparse.c b/mm/sparse.c
index b2848cc6e32a..f55e79fda03e 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -264,19 +264,14 @@ struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pn
 	return ((struct page *)coded_mem_map) + section_nr_to_pfn(pnum);
 }
 
-static int __meminit sparse_init_one_section(struct mem_section *ms,
+static void __meminit sparse_init_one_section(struct mem_section *ms,
 		unsigned long pnum, struct page *mem_map,
 		unsigned long *pageblock_bitmap)
 {
-	if (!present_section(ms))
-		return -EINVAL;
-
 	ms->section_mem_map &= ~SECTION_MAP_MASK;
 	ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum) |
 							SECTION_HAS_MEM_MAP;
  	ms->pageblock_flags = pageblock_bitmap;
-
-	return 1;
 }
 
 unsigned long usemap_size(void)
@@ -801,12 +796,11 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat,
 #endif
 
 	section_mark_present(ms);
-
-	ret = sparse_init_one_section(ms, section_nr, memmap, usemap);
+	sparse_init_one_section(ms, section_nr, memmap, usemap);
 
 out:
 	pgdat_resize_unlock(pgdat, &flags);
-	if (ret <= 0) {
+	if (ret < 0) {
 		kfree(usemap);
 		__kfree_section_memmap(memmap, altmap);
 	}
-- 
2.13.6


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2018-07-07  6:02 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-02 15:43 [PATCH] mm/sparse: Make sparse_init_one_section void and remove check osalvador
2018-07-02 16:05 ` Michal Hocko
2018-07-02 18:47 ` Pavel Tatashin
2018-07-06 18:23   ` Ross Zwisler
2018-07-06 18:23     ` Ross Zwisler
2018-07-06 19:06     ` [PATCH] mm/sparse.c: fix error path in sparse_add_one_section Ross Zwisler
2018-07-06 19:06       ` Ross Zwisler
2018-07-06 21:23       ` Oscar Salvador
2018-07-06 21:23         ` Oscar Salvador
2018-07-06 21:54         ` Ross Zwisler
2018-07-06 21:54           ` Ross Zwisler
2018-07-06 21:58           ` Andrew Morton
2018-07-06 21:58             ` Andrew Morton
2018-07-06 21:32       ` Andrew Morton
2018-07-06 21:32         ` Andrew Morton
2018-07-06 22:33       ` [PATCH v2] " Ross Zwisler
2018-07-06 22:33         ` Ross Zwisler
2018-07-07  6:01         ` Oscar Salvador
2018-07-07  6:01           ` Oscar Salvador

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.