mm/sparse: move buffer init/fini to the common place
authorPavel Tatashin <[email protected]>
Fri, 17 Aug 2018 22:49:30 +0000 (15:49 -0700)
committerLinus Torvalds <[email protected]>
Fri, 17 Aug 2018 23:20:32 +0000 (16:20 -0700)
Now that both variants of sparse memory use the same buffers to populate
memory map, we can move sparse_buffer_init()/sparse_buffer_fini() to the
common place.

Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Pavel Tatashin <[email protected]>
Tested-by: Michael Ellerman <[email protected]> [powerpc]
Tested-by: Oscar Salvador <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Pasha Tatashin <[email protected]>
Cc: Abdul Haleem <[email protected]>
Cc: Baoquan He <[email protected]>
Cc: Daniel Jordan <[email protected]>
Cc: Dan Williams <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: David Rientjes <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: Jérôme Glisse <[email protected]>
Cc: "Kirill A. Shutemov" <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Souptick Joarder <[email protected]>
Cc: Steven Sistare <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Wei Yang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
include/linux/mm.h
mm/sparse-vmemmap.c
mm/sparse.c

index 4ace5d50a89206602535a6e047d2b58738d25b97..48040510df05ce721438ddac1a1f161adfe6f114 100644 (file)
@@ -2671,9 +2671,6 @@ void sparse_mem_maps_populate_node(struct page **map_map,
                                   unsigned long map_count,
                                   int nodeid);
 
-unsigned long __init section_map_size(void);
-void sparse_buffer_init(unsigned long size, int nid);
-void sparse_buffer_fini(void);
 void *sparse_buffer_alloc(unsigned long size);
 struct page *sparse_mem_map_populate(unsigned long pnum, int nid,
                struct vmem_altmap *altmap);
index b05c7663c6401d4aa4841a853d12cf7cd8147000..cd15f3d252c37fac7f2a81ec649e2e0cd3d67d1a 100644 (file)
@@ -270,7 +270,6 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
        unsigned long pnum;
        int nr_consumed_maps = 0;
 
-       sparse_buffer_init(section_map_size() * map_count, nodeid);
        for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
                if (!present_section_nr(pnum))
                        continue;
@@ -282,5 +281,4 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
                pr_err("%s: sparsemem memory map backing failed some memory will not be available\n",
                       __func__);
        }
-       sparse_buffer_fini();
 }
index db4867b62fff67c36372944ca7a29f94f5634ca9..20ca292d8f11dd3c4283fd31dd9586c122d9c8ad 100644 (file)
@@ -401,14 +401,14 @@ static void __init sparse_early_usemaps_alloc_node(void *data,
 }
 
 #ifdef CONFIG_SPARSEMEM_VMEMMAP
-unsigned long __init section_map_size(void)
+static unsigned long __init section_map_size(void)
 
 {
        return ALIGN(sizeof(struct page) * PAGES_PER_SECTION, PMD_SIZE);
 }
 
 #else
-unsigned long __init section_map_size(void)
+static unsigned long __init section_map_size(void)
 {
        return PAGE_ALIGN(sizeof(struct page) * PAGES_PER_SECTION);
 }
@@ -433,10 +433,8 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
                                          unsigned long map_count, int nodeid)
 {
        unsigned long pnum;
-       unsigned long size = section_map_size();
        int nr_consumed_maps = 0;
 
-       sparse_buffer_init(size * map_count, nodeid);
        for (pnum = pnum_begin; pnum < pnum_end; pnum++) {
                if (!present_section_nr(pnum))
                        continue;
@@ -447,14 +445,13 @@ void __init sparse_mem_maps_populate_node(struct page **map_map,
                pr_err("%s: sparsemem memory map backing failed some memory will not be available\n",
                       __func__);
        }
-       sparse_buffer_fini();
 }
 #endif /* !CONFIG_SPARSEMEM_VMEMMAP */
 
 static void *sparsemap_buf __meminitdata;
 static void *sparsemap_buf_end __meminitdata;
 
-void __init sparse_buffer_init(unsigned long size, int nid)
+static void __init sparse_buffer_init(unsigned long size, int nid)
 {
        WARN_ON(sparsemap_buf); /* forgot to call sparse_buffer_fini()? */
        sparsemap_buf =
@@ -464,7 +461,7 @@ void __init sparse_buffer_init(unsigned long size, int nid)
        sparsemap_buf_end = sparsemap_buf + size;
 }
 
-void __init sparse_buffer_fini(void)
+static void __init sparse_buffer_fini(void)
 {
        unsigned long size = sparsemap_buf_end - sparsemap_buf;
 
@@ -494,8 +491,11 @@ static void __init sparse_early_mem_maps_alloc_node(void *data,
                                 unsigned long map_count, int nodeid)
 {
        struct page **map_map = (struct page **)data;
+
+       sparse_buffer_init(section_map_size() * map_count, nodeid);
        sparse_mem_maps_populate_node(map_map, pnum_begin, pnum_end,
                                         map_count, nodeid);
+       sparse_buffer_fini();
 }
 #else
 static struct page __init *sparse_early_mem_map_alloc(unsigned long pnum)