From: YASUAKI ISHIMATSU <yasu.isimatu@gmail.com>
To: linux-mm@kvack.org
Cc: Michal Hocko <mhocko@suse.com>,
LKML <linux-kernel@vger.kernel.org>,
qiuxishi@huawei.com, arbab@linux.vnet.ibm.com,
Vlastimil Babka <vbabka@suse.cz>Reza Arbab
<arbab@linux.vnet.ibm.com>
Subject: [PATCH] mm/memory_hotplug: fix wrong casting for __remove_section()
Date: Fri, 8 Sep 2017 16:43:04 -0400 [thread overview]
Message-ID: <51a59ec3-e7ba-2562-1917-036b8181092c@gmail.com> (raw)
__remove_section() calls __remove_zone() to shrink zone and pgdat.
But due to wrong castings, __remvoe_zone() cannot shrink zone
and pgdat correctly if pfn is over 0xffffffff.
So the patch fixes the following 3 wrong castings.
1. find_smallest_section_pfn() returns 0 or start_pfn which defined
as unsigned long. But the function always returns 32bit value
since the function is defined as int.
2. find_biggest_section_pfn() returns 0 or pfn which defined as
unsigned long. the function always returns 32bit value
since the function is defined as int.
3. __remove_section() calculates start_pfn using section_nr_to_pfn()
and scn_nr. section_nr_to_pfn() just shifts scn_nr by
PFN_SECTION_SHIFT bit. But since scn_nr is defined as int,
section_nr_to_pfn() always return 32 bit value.
The patch fixes the wrong castings.
Signed-off-by: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
---
mm/memory_hotplug.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 73bf17d..3514ef2 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -331,7 +331,7 @@ int __ref __add_pages(int nid, unsigned long phys_start_pfn,
#ifdef CONFIG_MEMORY_HOTREMOVE
/* find the smallest valid pfn in the range [start_pfn, end_pfn) */
-static int find_smallest_section_pfn(int nid, struct zone *zone,
+static unsigned long find_smallest_section_pfn(int nid, struct zone *zone,
unsigned long start_pfn,
unsigned long end_pfn)
{
@@ -356,7 +356,7 @@ static int find_smallest_section_pfn(int nid, struct zone *zone,
}
/* find the biggest valid pfn in the range [start_pfn, end_pfn). */
-static int find_biggest_section_pfn(int nid, struct zone *zone,
+static unsigned long find_biggest_section_pfn(int nid, struct zone *zone,
unsigned long start_pfn,
unsigned long end_pfn)
{
@@ -544,7 +544,7 @@ static int __remove_section(struct zone *zone, struct mem_section *ms,
return ret;
scn_nr = __section_nr(ms);
- start_pfn = section_nr_to_pfn(scn_nr);
+ start_pfn = section_nr_to_pfn((unsigned long)scn_nr);
__remove_zone(zone, start_pfn);
sparse_remove_one_section(zone, ms, map_offset);
--
1.8.3.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next reply other threads:[~2017-09-08 20:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-08 20:43 YASUAKI ISHIMATSU [this message]
2017-09-12 12:49 ` [PATCH] mm/memory_hotplug: fix wrong casting for __remove_section() Michal Hocko
2017-09-12 17:05 ` YASUAKI ISHIMATSU
2017-09-13 5:59 ` Michal Hocko
2017-09-14 15:43 ` YASUAKI ISHIMATSU
2017-09-15 9:36 ` Michal Hocko
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=51a59ec3-e7ba-2562-1917-036b8181092c@gmail.com \
--to=yasu.isimatu@gmail.com \
--cc=arbab@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=qiuxishi@huawei.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).