From: Dan Williams <dan.j.williams@intel.com>
To: akpm@linux-foundation.org
Cc: Michal Hocko <mhocko@suse.com>,
linux-nvdimm@ml01.01.org, Logan Gunthorpe <logang@deltatee.com>,
linux-kernel@vger.kernel.org,
Stephen Bates <stephen.bates@microsemi.com>,
linux-mm@kvack.org, Johannes Weiner <hannes@cmpxchg.org>,
Mel Gorman <mgorman@techsingularity.net>,
Vlastimil Babka <vbabka@suse.cz>
Subject: [PATCH v3 05/12] mm: cleanup sparse_init_one_section() return value
Date: Thu, 19 Jan 2017 14:07:08 -0800 [thread overview]
Message-ID: <148486362851.19694.4580553117827074003.stgit@dwillia2-desk3.amr.corp.intel.com> (raw)
In-Reply-To: <148486359570.19694.18265063120757801811.stgit@dwillia2-desk3.amr.corp.intel.com>
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 91e1908db23d..59966a3e8ff0 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
next prev parent reply other threads:[~2017-01-19 22:23 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-19 22:06 [PATCH v3 00/12] mm: sub-section memory hotplug support Dan Williams
2017-01-19 22:06 ` [PATCH v3 01/12] mm: fix type width of section to/from pfn conversion macros Dan Williams
2017-01-19 22:06 ` [PATCH v3 02/12] mm, devm_memremap_pages: use multi-order radix for ZONE_DEVICE lookups Dan Williams
2017-01-19 22:06 ` [PATCH v3 03/12] mm: introduce struct mem_section_usage to track partial population of a section Dan Williams
2017-01-19 22:07 ` [PATCH v3 04/12] mm: introduce common definitions for the size and mask " Dan Williams
2017-01-19 22:07 ` Dan Williams [this message]
2017-01-19 22:07 ` [PATCH v3 06/12] mm: track active portions of a section at boot Dan Williams
2017-01-20 0:05 ` Andrew Morton
2017-01-20 17:56 ` Dan Williams
2017-01-19 22:07 ` [PATCH v3 07/12] mm: fix register_new_memory() zone type detection Dan Williams
2017-01-19 22:07 ` [PATCH v3 08/12] mm: convert kmalloc_section_memmap() to populate_section_memmap() Dan Williams
2017-01-19 22:07 ` [PATCH v3 09/12] mm: prepare for hot-{add, remove} of sub-section ranges Dan Williams
2017-01-19 22:07 ` [PATCH v3 10/12] mm: support section-unaligned ZONE_DEVICE memory ranges Dan Williams
2017-01-19 22:07 ` [PATCH v3 11/12] mm: enable section-unaligned devm_memremap_pages() Dan Williams
2017-01-19 22:07 ` [PATCH v3 12/12] libnvdimm, pfn, dax: stop padding pmem namespaces to section alignment Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=148486362851.19694.4580553117827074003.stgit@dwillia2-desk3.amr.corp.intel.com \
--to=dan.j.williams@intel.com \
--cc=akpm@linux-foundation.org \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nvdimm@ml01.01.org \
--cc=logang@deltatee.com \
--cc=mgorman@techsingularity.net \
--cc=mhocko@suse.com \
--cc=stephen.bates@microsemi.com \
--cc=vbabka@suse.cz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).