linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH linux-next] x86/mm: Fix compile warning in remove_pagetable()
@ 2013-02-06  2:52 Shuah Khan
  2013-02-06  4:24 ` Yinghai Lu
  2013-02-06  8:27 ` David Rientjes
  0 siblings, 2 replies; 4+ messages in thread
From: Shuah Khan @ 2013-02-06  2:52 UTC (permalink / raw)
  To: Andrew Morton, tglx, hpa, mingo, yinghai, tangchen, wency
  Cc: LKML, x86, shuahkhan

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 <shuah.khan@hp.com>
---
 arch/x86/mm/init_64.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 67bad4b..ed78400 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -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;
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH linux-next] x86/mm: Fix compile warning in remove_pagetable()
  2013-02-06  2:52 [PATCH linux-next] x86/mm: Fix compile warning in remove_pagetable() Shuah Khan
@ 2013-02-06  4:24 ` Yinghai Lu
  2013-02-06  8:27 ` David Rientjes
  1 sibling, 0 replies; 4+ messages in thread
From: Yinghai Lu @ 2013-02-06  4:24 UTC (permalink / raw)
  To: shuah.khan
  Cc: Andrew Morton, tglx, hpa, mingo, tangchen, wency, LKML, x86, shuahkhan

On Tue, Feb 5, 2013 at 6:52 PM, Shuah Khan <shuah.khan@hp.com> wrote:
> 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 <shuah.khan@hp.com>
> ---
>  arch/x86/mm/init_64.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 67bad4b..ed78400 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -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;
> --
> 1.7.9.5

Andrew already had one fix-fix-...-fix for that.



On Mon, Feb 4, 2013 at 3:28 PM, Andrew Morton <akpm@linux-foundation.org> wrote:
> On Mon, 4 Feb 2013 15:18:58 -0800
> Yinghai Lu <yinghai@kernel.org> wrote:
>
>> On Mon, Feb 4, 2013 at 3:04 PM,  <akpm@linux-foundation.org> 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.patch
>> >
>> > Before 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/SubmitChecklist when testing your code ***
>> >
>> > The -mm tree is included into linux-next and is updated
>> > there every 3-4 working days
>> >
>> > ------------------------------------------------------
>> > From: Andrew Morton <akpm@linux-foundation.org>
>> > Subject: memory-hotplug-common-apis-to-support-page-tables-hot-remove-fix-fix-fix-fix-fix-fix-fix
>> >
>> > fix used-uninitialised bug
>> >
>> > Cc: Jiang Liu <jiang.liu@huawei.com>
>> > Cc: Jianguo Wu <wujianguo@huawei.com>
>> > Cc: Kamezawa Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
>> > Cc: Lai Jiangshan <laijs@cn.fujitsu.com>
>> > Cc: Tang Chen <tangchen@cn.fujitsu.com>
>> > Cc: Wen Congyang <wency@cn.fujitsu.com>
>> > Cc: Yasuaki Ishimatsu <isimatu.yasuaki@jp.fujitsu.com>
>> > Cc: Yinghai Lu <yinghai@kernel.org>
>> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
>> > ---
>> >
>> >  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-fix arch/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-fix
>>
>> it is hard to count fix now!
>
> Yes, I think that's a world record ;)
>
>> > +++ a/arch/x86/mm/init_64.c
>> > @@ -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;
>> >
>> > -               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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH linux-next] x86/mm: Fix compile warning in remove_pagetable()
  2013-02-06  2:52 [PATCH linux-next] x86/mm: Fix compile warning in remove_pagetable() Shuah Khan
  2013-02-06  4:24 ` Yinghai Lu
@ 2013-02-06  8:27 ` David Rientjes
  2013-02-06  8:30   ` Tang Chen
  1 sibling, 1 reply; 4+ messages in thread
From: David Rientjes @ 2013-02-06  8:27 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Andrew Morton, tglx, H. Peter Anvin, Ingo Molnar, yinghai,
	tangchen, wency, linux-kernel, x86, shuahkhan

On Tue, 5 Feb 2013, Shuah Khan wrote:

> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
> index 67bad4b..ed78400 100644
> --- a/arch/x86/mm/init_64.c
> +++ b/arch/x86/mm/init_64.c
> @@ -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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH linux-next] x86/mm: Fix compile warning in remove_pagetable()
  2013-02-06  8:27 ` David Rientjes
@ 2013-02-06  8:30   ` Tang Chen
  0 siblings, 0 replies; 4+ messages in thread
From: Tang Chen @ 2013-02-06  8:30 UTC (permalink / raw)
  To: David Rientjes
  Cc: Shuah Khan, Andrew Morton, tglx, H. Peter Anvin, Ingo Molnar,
	yinghai, wency, linux-kernel, x86, shuahkhan

On 02/06/2013 04:27 PM, David Rientjes wrote:
> On Tue, 5 Feb 2013, Shuah Khan wrote:
>
>> diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
>> index 67bad4b..ed78400 100644
>> --- a/arch/x86/mm/init_64.c
>> +++ b/arch/x86/mm/init_64.c
>> @@ -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.

Yes, Andrew's patch just fixed it like this. :)

Thanks. :)

> Or, even better, change
> this into the standard do-while loop that everything else uses.
>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-06  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-02-06  2:52 [PATCH linux-next] x86/mm: Fix compile warning in remove_pagetable() Shuah Khan
2013-02-06  4:24 ` Yinghai Lu
2013-02-06  8:27 ` David Rientjes
2013-02-06  8:30   ` Tang Chen

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).