public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Remove initialization of page_table in one_page_table_init()
@ 2009-07-14  8:57 Zhaolei
  2009-07-14 10:18 ` David Rientjes
  2009-07-18 14:11 ` Ingo Molnar
  0 siblings, 2 replies; 5+ messages in thread
From: Zhaolei @ 2009-07-14  8:57 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: linux-kernel

Only judge if (!page_table) when CONFIG_DEBUG_PAGEALLOC or CONFIG_KMEMCHECK
are defined, then we don't need to set init value for page_table.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
 arch/x86/mm/init_32.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index 3cd7711..55da09b 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -108,13 +108,13 @@ static pmd_t * __init one_md_table_init(pgd_t *pgd)
 static pte_t * __init one_page_table_init(pmd_t *pmd)
 {
     if (!(pmd_val(*pmd) & _PAGE_PRESENT)) {
-        pte_t *page_table = NULL;
+        pte_t *page_table;
 
         if (after_bootmem) {
 #if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
             page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
-#endif
             if (!page_table)
+#endif
                 page_table =
                 (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
         } else
-- 
1.5.5.3



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

* Re: [PATCH] Remove initialization of page_table in one_page_table_init()
  2009-07-14  8:57 [PATCH] Remove initialization of page_table in one_page_table_init() Zhaolei
@ 2009-07-14 10:18 ` David Rientjes
  2009-07-18 14:11 ` Ingo Molnar
  1 sibling, 0 replies; 5+ messages in thread
From: David Rientjes @ 2009-07-14 10:18 UTC (permalink / raw)
  To: Zhaolei; +Cc: Ingo Molnar, linux-kernel

On Tue, 14 Jul 2009, Zhaolei wrote:

> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index 3cd7711..55da09b 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -108,13 +108,13 @@ static pmd_t * __init one_md_table_init(pgd_t *pgd)
> static pte_t * __init one_page_table_init(pmd_t *pmd)
> {
>     if (!(pmd_val(*pmd) & _PAGE_PRESENT)) {
> -        pte_t *page_table = NULL;
> +        pte_t *page_table;
> 
>         if (after_bootmem) {
> #if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
>             page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
> -#endif
>             if (!page_table)
> +#endif
>                 page_table =
>                 (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
>         } else

Nack, gcc will already optimize the branch out for configs without 
CONFIG_DEBUG_PAGEALLOC and CONFIG_KMEMCHECK.  The only thing this change 
does is make the code less readable.

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

* Re: [PATCH] Remove initialization of page_table in one_page_table_init()
  2009-07-14  8:57 [PATCH] Remove initialization of page_table in one_page_table_init() Zhaolei
  2009-07-14 10:18 ` David Rientjes
@ 2009-07-18 14:11 ` Ingo Molnar
  2009-07-20  3:07   ` Zhaolei
  1 sibling, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2009-07-18 14:11 UTC (permalink / raw)
  To: Zhaolei, Thomas Gleixner, H. Peter Anvin, Vegard Nossum; +Cc: linux-kernel


* Zhaolei <zhaolei@cn.fujitsu.com> wrote:

> Only judge if (!page_table) when CONFIG_DEBUG_PAGEALLOC or CONFIG_KMEMCHECK
> are defined, then we don't need to set init value for page_table.
>
> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
> ---
> arch/x86/mm/init_32.c |    4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> index 3cd7711..55da09b 100644
> --- a/arch/x86/mm/init_32.c
> +++ b/arch/x86/mm/init_32.c
> @@ -108,13 +108,13 @@ static pmd_t * __init one_md_table_init(pgd_t *pgd)
> static pte_t * __init one_page_table_init(pmd_t *pmd)
> {
>     if (!(pmd_val(*pmd) & _PAGE_PRESENT)) {
> -        pte_t *page_table = NULL;
> +        pte_t *page_table;
>
>         if (after_bootmem) {
> #if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
>             page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
> -#endif
>             if (!page_table)
> +#endif
>                 page_table =
>                 (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);

I think the original code was cleaner - putting an #ifdef straight 
into the middle of a control block is quite fragile.

	Ingo

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

* Re: Re: [PATCH] Remove initialization of page_table in one_page_table_init()
  2009-07-18 14:11 ` Ingo Molnar
@ 2009-07-20  3:07   ` Zhaolei
  2009-07-20 11:50     ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Zhaolei @ 2009-07-20  3:07 UTC (permalink / raw)
  To: Ingo Molnar, David Rientjes
  Cc: Thomas Gleixner, H. Peter Anvin, Vegard Nossum, linux-kernel

Ingo Molnar wrote:
> * Zhaolei <zhaolei@cn.fujitsu.com> wrote:
> 
>> Only judge if (!page_table) when CONFIG_DEBUG_PAGEALLOC or CONFIG_KMEMCHECK
>> are defined, then we don't need to set init value for page_table.
>>
>> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
>> ---
>> arch/x86/mm/init_32.c |    4 ++--
>> 1 files changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
>> index 3cd7711..55da09b 100644
>> --- a/arch/x86/mm/init_32.c
>> +++ b/arch/x86/mm/init_32.c
>> @@ -108,13 +108,13 @@ static pmd_t * __init one_md_table_init(pgd_t *pgd)
>> static pte_t * __init one_page_table_init(pmd_t *pmd)
>> {
>>     if (!(pmd_val(*pmd) & _PAGE_PRESENT)) {
>> -        pte_t *page_table = NULL;
>> +        pte_t *page_table;
>>
>>         if (after_bootmem) {
>> #if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
>>             page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
>> -#endif
>>             if (!page_table)
>> +#endif
>>                 page_table =
>>                 (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
> 
> I think the original code was cleaner - putting an #ifdef straight 
> into the middle of a control block is quite fragile.
> 
> 	Ingo
> 

Hello, Ingo

David Rientjes said that:
Nack, gcc will already optimize the branch out for configs without 
CONFIG_DEBUG_PAGEALLOC and CONFIG_KMEMCHECK.  The only thing this change 
does is make the code less readable.

I tested it with gcc -O2, and proved that David is correct.
Initialization of page_table and additional "if (!page_table)" was removed by optimization.
Please ignore this patch.

Thanks
Zhaolei


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

* Re: Re: [PATCH] Remove initialization of page_table in one_page_table_init()
  2009-07-20  3:07   ` Zhaolei
@ 2009-07-20 11:50     ` Ingo Molnar
  0 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2009-07-20 11:50 UTC (permalink / raw)
  To: Zhaolei
  Cc: David Rientjes, Thomas Gleixner, H. Peter Anvin, Vegard Nossum,
	linux-kernel


* Zhaolei <zhaolei@cn.fujitsu.com> wrote:

> Ingo Molnar wrote:
> > * Zhaolei <zhaolei@cn.fujitsu.com> wrote:
> > 
> >> Only judge if (!page_table) when CONFIG_DEBUG_PAGEALLOC or CONFIG_KMEMCHECK
> >> are defined, then we don't need to set init value for page_table.
> >>
> >> Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
> >> ---
> >> arch/x86/mm/init_32.c |    4 ++--
> >> 1 files changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
> >> index 3cd7711..55da09b 100644
> >> --- a/arch/x86/mm/init_32.c
> >> +++ b/arch/x86/mm/init_32.c
> >> @@ -108,13 +108,13 @@ static pmd_t * __init one_md_table_init(pgd_t *pgd)
> >> static pte_t * __init one_page_table_init(pmd_t *pmd)
> >> {
> >>     if (!(pmd_val(*pmd) & _PAGE_PRESENT)) {
> >> -        pte_t *page_table = NULL;
> >> +        pte_t *page_table;
> >>
> >>         if (after_bootmem) {
> >> #if defined(CONFIG_DEBUG_PAGEALLOC) || defined(CONFIG_KMEMCHECK)
> >>             page_table = (pte_t *) alloc_bootmem_pages(PAGE_SIZE);
> >> -#endif
> >>             if (!page_table)
> >> +#endif
> >>                 page_table =
> >>                 (pte_t *)alloc_bootmem_low_pages(PAGE_SIZE);
> > 
> > I think the original code was cleaner - putting an #ifdef straight 
> > into the middle of a control block is quite fragile.
> > 
> > 	Ingo
> > 
> 
> Hello, Ingo
> 
> David Rientjes said that:
> Nack, gcc will already optimize the branch out for configs without 
> CONFIG_DEBUG_PAGEALLOC and CONFIG_KMEMCHECK.  The only thing this change 
> does is make the code less readable.
> 
> I tested it with gcc -O2, and proved that David is correct.
> Initialization of page_table and additional "if (!page_table)" was 
> removed by optimization. Please ignore this patch.

Yeah - and note that even if GCC _didnt_ optimize it out, the patch 
was not acceptable in this form.

	Ingo

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

end of thread, other threads:[~2009-07-20 11:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-14  8:57 [PATCH] Remove initialization of page_table in one_page_table_init() Zhaolei
2009-07-14 10:18 ` David Rientjes
2009-07-18 14:11 ` Ingo Molnar
2009-07-20  3:07   ` Zhaolei
2009-07-20 11:50     ` Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox