Commit 4e40987f authored by Oscar Salvador's avatar Oscar Salvador Committed by Linus Torvalds

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.netSigned-off-by: default avatarOscar Salvador <osalvador@suse.de>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Reviewed-by: default avatarPavel Tatashin <pasha.tatashin@oracle.com>
Reviewed-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Cc: Pasha Tatashin <Pavel.Tatashin@microsoft.com>
Cc: Oscar Salvador <osalvador@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 29ef680a
...@@ -257,19 +257,14 @@ struct page *sparse_decode_mem_map(unsigned long coded_mem_map, unsigned long pn ...@@ -257,19 +257,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); 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 pnum, struct page *mem_map,
unsigned long *pageblock_bitmap) unsigned long *pageblock_bitmap)
{ {
if (!present_section(ms))
return -EINVAL;
ms->section_mem_map &= ~SECTION_MAP_MASK; ms->section_mem_map &= ~SECTION_MAP_MASK;
ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum) | ms->section_mem_map |= sparse_encode_mem_map(mem_map, pnum) |
SECTION_HAS_MEM_MAP; SECTION_HAS_MEM_MAP;
ms->pageblock_flags = pageblock_bitmap; ms->pageblock_flags = pageblock_bitmap;
return 1;
} }
unsigned long usemap_size(void) unsigned long usemap_size(void)
...@@ -760,6 +755,7 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, ...@@ -760,6 +755,7 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat,
ret = sparse_index_init(section_nr, pgdat->node_id); ret = sparse_index_init(section_nr, pgdat->node_id);
if (ret < 0 && ret != -EEXIST) if (ret < 0 && ret != -EEXIST)
return ret; return ret;
ret = 0;
memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, altmap); memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, altmap);
if (!memmap) if (!memmap)
return -ENOMEM; return -ENOMEM;
...@@ -786,12 +782,11 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat, ...@@ -786,12 +782,11 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat,
#endif #endif
section_mark_present(ms); section_mark_present(ms);
sparse_init_one_section(ms, section_nr, memmap, usemap);
ret = sparse_init_one_section(ms, section_nr, memmap, usemap);
out: out:
pgdat_resize_unlock(pgdat, &flags); pgdat_resize_unlock(pgdat, &flags);
if (ret <= 0) { if (ret < 0) {
kfree(usemap); kfree(usemap);
__kfree_section_memmap(memmap, altmap); __kfree_section_memmap(memmap, altmap);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment