x86/mm: Fix compile warning in remove_pagetable()
PATCH 1/1 x86/mm: Fix compile warning in remove_pagetable()
Fix the following compile warning in remove_pagetable():arch/x86/mm/init_64.c: In function ‘remove_pagetable’:arch/x86/mm/init_64.c:996:9: warning: ‘next’ may be used uninitialized in this function [-Wuninitialized]
--- arch/x86/mm/init_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/mm/init_64.c +1 -1
@@ -987,7 +987,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end,static void __meminit remove_pagetable (unsigned long start,unsigned long end,bool direct) { -unsigned long next; +unsigned long next =pgd_addr_end (start, end);pgd_t *pgd;pud_t *pud;bool pgd_changed = false;
Signature · 1 line
1.7.9.5
Quoted 24 lines · Shuah Khan
Fix the following compile warning in
remove_pagetable():arch/x86/mm/init_64.c: In function ‘remove_pagetable’:arch/x86/mm/init_64.c:996:9: warning: ‘next’ may be used uninitialized in this function [-Wuninitialized]Signed-off-by Shuah Khan <[email protected]>--- arch/x86/mm/init_64.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/x86/mm/init_64.c +1
-2@@ -987,7 +987,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end,static void __meminit remove_pagetable (unsigned long start,unsigned long end,bool direct) { -unsigned long next; +unsigned long next =pgd_addr_end (start, end);pgd_t *pgd;pud_t *pud;bool pgd_changed = false; --
Quoted 1 line
1.7.9.5
Andrew already had one fix-fix-...-fix for that.
Quoted 71 lines · Andrew Morton
Quoted 35 lines · On Mon, 4 Feb 2013 15:18:58 -0800 Yinghai Lu <[email protected]> wrote:
Quoted 34 lines · On Mon, Feb 4, 2013 at 3:04 PM, <[email protected]> wrote:
The patch titled
Subject: memory-hotplug-common-apis-to-support-page-tables-hot-remove-fix-fix-fix-fix-fix-fix-fix
has been added to the -mm tree. Its filename is
memory-hotplug-common-apis-to-support-page-tables-hot-remove-fix-fix-fix-fix-fix-fix-fix.patchBefore you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's*** Remember to use
Documentation/SubmitChecklistwhen testing your code ***The -mm tree is included into linux-next and is updated there every 3-4 working days
------------------------------------------------------
From: Andrew Morton <[email protected]>
Subject: memory-hotplug-common-apis-to-support-page-tables-hot-remove-fix-fix-fix-fix-fix-fix-fixfix used-uninitialised bug
Cc Jiang Liu <[email protected]>Cc Jianguo Wu <[email protected]>Cc Kamezawa Hiroyuki <[email protected]>Cc Lai Jiangshan <[email protected]>Cc Tang Chen <[email protected]>Cc Wen Congyang <[email protected]>Cc Yasuaki Ishimatsu <[email protected]>Cc Yinghai Lu <[email protected]>Signed-off-by Andrew Morton <[email protected]>---
Quoted 7 lines
Quoted 5 lines
arch/x86/mm/init_64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)diff -puN
arch/x86/mm/init_64.c~memory-hotplug-common-apis-to-support-page-tables-hot-remove-fix-fix-fix-fix-fix-fix-fixarch/x86/mm/init_64.c--- a/arch/x86/mm/init_64.c~memory-hotplug-common-apis-to-support-page-tables-hot-remove-fix-fix-fix-fix-fix-fix-fixit is hard to count fix now!
Yes, I think that's a world record ;)
Quoted 11 lines
Quoted 11 lines
+++
a/arch/x86/mm/init_64.c(quoted diff) +2
-0@@ -993,12 +993,12 @@ remove_pagetable(unsigned long start, un bool pgd_changed = false; for (; start < end; start = next) { + next = pgd_addr_end(start, end); + pgd = pgd_offset_k(start); if (!pgd_present(*pgd)) continue;Quoted 10 lines
Quoted 6 lines
(quoted diff) +0
-2- next = pgd_addr_end(start, end); - pud = (pud_t *)pgd_page_vaddr(*pgd); remove_pud_table(pud, start, next, direct); if (free_pud_table(pud, pgd))_
It's a real bug fix.
Without this fix, it will get dead loop if there is 512G (and aligned) memory hole in the range.OK, thanks.
arch/x86/mm/init_64.c remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end, · line 993
Quoted 13 lines · Shuah Khan
arch/x86/mm/init_64.c +1
-1@@ -987,7 +987,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end,static void __meminit remove_pagetable (unsigned long start,unsigned long end,bool direct) { -unsigned long next; +unsigned long next =pgd_addr_end (start, end);pgd_t *pgd;pud_t *pud;bool pgd_changed = false;
This isn't enough, there's a potential for an infinite loop if !pgd_present() is ever true in the iteration since "next" remains constant. Theoretical, maybe.
I think it's better to just set next before checking for !pgd_present() in the iteration so it's clear what's happening. Or, even better, change this into the standard do-while loop that everything else uses.
Quoted 20 lines · David Rientjes
arch/x86/mm/init_64.c remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end, · line 993
Quoted 13 lines · Shuah Khan
arch/x86/mm/init_64.c +1
-1@@ -987,7 +987,7 @@ remove_pud_table(pud_t *pud_start, unsigned long addr, unsigned long end,static void __meminit remove_pagetable (unsigned long start,unsigned long end,bool direct) { -unsigned long next; +unsigned long next =pgd_addr_end (start, end);pgd_t *pgd;pud_t *pud;bool pgd_changed = false;This isn't enough, there's a potential for an infinite loop if !pgd_present() is ever true in the iteration since "next" remains constant. Theoretical, maybe.
Quoted 2 lines
I think it's better to just set next before checking for !pgd_present() in the iteration so it's clear what's happening.
Yes, Andrew's patch just fixed it like this. :)
Thanks. :)
Quoted 3 lines
Or, even better, change
this into the standard do-while loop that everything else uses.