Skip to content

Commit 4e40987

Browse files
osalvadorvilardagatorvalds
authored andcommitted
mm/sparse.c: make sparse_init_one_section void and remove check
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. [ross.zwisler@linux.intel.com: fix error path in sparse_add_one_section] Link: http://lkml.kernel.org/r/20180706190658.6873-1-ross.zwisler@linux.intel.com [ross.zwisler@linux.intel.com: simplification suggested by Oscar] Link: http://lkml.kernel.org/r/20180706223358.742-1-ross.zwisler@linux.intel.com Link: http://lkml.kernel.org/r/20180702154325.12196-1-osalvador@techadventures.net Signed-off-by: Oscar Salvador <osalvador@suse.de> Acked-by: Michal Hocko <mhocko@suse.com> Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com> Reviewed-by: Andrew Morton <akpm@linux-foundation.org> Cc: Pasha Tatashin <Pavel.Tatashin@microsoft.com> Cc: Oscar Salvador <osalvador@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 29ef680 commit 4e40987

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

‎mm/sparse.c‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -257,19 +257,14 @@ struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pn
257257
return ((struct page *)coded_mem_map) + section_nr_to_pfn(pnum);
258258
}
259259

260-
static int __meminit sparse_init_one_section(struct mem_section *ms,
260+
static void __meminit sparse_init_one_section(struct mem_section *ms,
261261
unsigned long pnum, struct page *mem_map,
262262
unsigned long *pageblock_bitmap)
263263
{
264-
if (!present_section(ms))
265-
return -EINVAL;
266-
267264
ms->section_mem_map &= ~SECTION_MAP_MASK;
268265
ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum) |
269266
SECTION_HAS_MEM_MAP;
270267
ms->pageblock_flags = pageblock_bitmap;
271-
272-
return 1;
273268
}
274269

275270
unsigned long usemap_size(void)
@@ -760,6 +755,7 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat,
760755
ret = sparse_index_init(section_nr, pgdat->node_id);
761756
if (ret < 0 && ret != -EEXIST)
762757
return ret;
758+
ret = 0;
763759
memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, altmap);
764760
if (!memmap)
765761
return -ENOMEM;
@@ -786,12 +782,11 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat,
786782
#endif
787783

788784
section_mark_present(ms);
789-
790-
ret = sparse_init_one_section(ms, section_nr, memmap, usemap);
785+
sparse_init_one_section(ms, section_nr, memmap, usemap);
791786

792787
out:
793788
pgdat_resize_unlock(pgdat, &flags);
794-
if (ret <= 0) {
789+
if (ret < 0) {
795790
kfree(usemap);
796791
__kfree_section_memmap(memmap, altmap);
797792
}

0 commit comments

Comments
 (0)