Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1601972

[PATCH v4 05/13] mm: cleanup sparse_init_one_section() return value

From Dan Williams <dan.j.williams@intel.com>
Newsgroups linux.kernel
Subject [PATCH v4 05/13] mm: cleanup sparse_init_one_section() return value
Date 2017-03-16 07:20 +0100
Message-ID <tlwVs-2BJ-15@gated-at.bofh.it> (permalink)
References <tlwVr-2BJ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


We mark and check that the section is present under a spin_lock() in
sparse_add_one_section(), so the lock ensures it will not change between
those 2 events. Also, we do not check the -EBUSY return value in
sparse_init(). Just make sparse_init_one_section() return void and clean
up the error handling.

Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Logan Gunthorpe <logang@deltatee.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Stephen Bates <stephen.bates@microsemi.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
 mm/sparse.c |   21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/mm/sparse.c b/mm/sparse.c
index d0d4c005dc60..886f666ebe35 100644
--- a/mm/sparse.c
+++ b/mm/sparse.c
@@ -231,19 +231,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,
 		struct mem_section_usage *usage)
 {
-	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->usage = usage;
-
-	return 1;
 }
 
 unsigned long usemap_size(void)
@@ -690,11 +685,6 @@ static void free_map_bootmem(struct page *memmap)
 #endif /* CONFIG_MEMORY_HOTREMOVE */
 #endif /* CONFIG_SPARSEMEM_VMEMMAP */
 
-/*
- * returns the number of sections whose mem_maps were properly
- * set.  If this is <=0, then that means that the passed-in
- * map was not consumed and must be freed.
- */
 int __meminit sparse_add_one_section(struct zone *zone, unsigned long start_pfn)
 {
 	unsigned long section_nr = pfn_to_section_nr(start_pfn);
@@ -725,7 +715,7 @@ int __meminit sparse_add_one_section(struct zone *zone, unsigned long start_pfn)
 
 	ms = __pfn_to_section(start_pfn);
 	if (ms->section_mem_map & SECTION_MARKED_PRESENT) {
-		ret = -EEXIST;
+		ret = -EBUSY;
 		goto out;
 	}
 
@@ -733,15 +723,16 @@ int __meminit sparse_add_one_section(struct zone *zone, unsigned long start_pfn)
 
 	ms->section_mem_map |= SECTION_MARKED_PRESENT;
 
-	ret = sparse_init_one_section(ms, section_nr, memmap, usage);
+	sparse_init_one_section(ms, section_nr, memmap, usage);
 
 out:
 	pgdat_resize_unlock(pgdat, &flags);
-	if (ret <= 0) {
+	if (ret < 0 && ret != -EEXIST) {
 		kfree(usage);
 		__kfree_section_memmap(memmap);
+		return ret;
 	}
-	return ret;
+	return 0;
 }
 
 #ifdef CONFIG_MEMORY_HOTREMOVE

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v4 00/13] mm: sub-section memory hotplug support Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 07/13] mm: fix register_new_memory() zone type detection Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 10/13] mm: prepare for hot-{add,  remove} of sub-section ranges Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 06/13] mm: track active portions of a section at boot Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 12/13] mm: enable section-unaligned devm_memremap_pages() Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 11/13] mm: support section-unaligned ZONE_DEVICE memory  ranges Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 05/13] mm: cleanup sparse_init_one_section() return value Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 01/13] mm: fix type width of section to/from pfn  conversion macros Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 09/13] mm: convert kmalloc_section_memmap() to  populate_section_memmap() Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 02/13] mm,  devm_memremap_pages: use multi-order radix for ZONE_DEVICE lookups Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 03/13] mm: introduce struct mem_section_usage to track  partial population of a section Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 04/13] mm: introduce common definitions for the size and  mask of a section Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 13/13] libnvdimm, pfn,  dax: stop padding pmem namespaces to section alignment Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  [PATCH v4 08/13] x86,  kasan: clarify kasan's dependency on vmemmap_populate_hugepages() Dan Williams <dan.j.williams@intel.com> - 2017-03-16 07:20 +0100
  Re: [PATCH v4 00/13] mm: sub-section memory hotplug support Michal Hocko <mhocko@kernel.org> - 2017-03-16 18:50 +0100
    Re: [PATCH v4 00/13] mm: sub-section memory hotplug support Dan Williams <dan.j.williams@intel.com> - 2017-03-16 20:10 +0100
      Re: [PATCH v4 00/13] mm: sub-section memory hotplug support Michal Hocko <mhocko@kernel.org> - 2017-03-19 18:00 +0100

csiph-web