Skip to content

Commit

Permalink
mm/sparse.c: make sparse_init_one_section void and remove check
Browse files Browse the repository at this point in the history
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.

[[email protected]: fix error path in sparse_add_one_section]
  Link: http://lkml.kernel.org/r/[email protected]
[[email protected]: simplification suggested by Oscar]
  Link: http://lkml.kernel.org/r/[email protected]
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Oscar Salvador <[email protected]>
Acked-by: Michal Hocko <[email protected]>
Reviewed-by: Pavel Tatashin <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Pasha Tatashin <[email protected]>
Cc: Oscar Salvador <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
osalvadorvilardaga authored and torvalds committed Aug 17, 2018
1 parent 29ef680 commit 4e40987
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions mm/sparse.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

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)
Expand Down Expand Up @@ -760,6 +755,7 @@ int __meminit sparse_add_one_section(struct pglist_data *pgdat,
ret = sparse_index_init(section_nr, pgdat->node_id);
if (ret < 0 && ret != -EEXIST)
return ret;
ret = 0;
memmap = kmalloc_section_memmap(section_nr, pgdat->node_id, altmap);
if (!memmap)
return -ENOMEM;
Expand All @@ -786,12 +782,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);
}
Expand Down

0 comments on commit 4e40987

Please sign in to comment.