* [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped:q
@ 2013-05-10 9:01 Zhang Yanfei
2013-05-10 9:27 ` Yinghai Lu
0 siblings, 1 reply; 6+ messages in thread
From: Zhang Yanfei @ 2013-05-10 9:01 UTC (permalink / raw)
To: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Andrew Morton
Cc: yinghai, linux-kernel@vger.kernel.org
init_memory_mapping will set max_pfn_mapped:
int_memory_mapping
--> add_pfn_range_mapped
--> max_pfn_mapped = max(max_pfn_mapped, end_pfn)
In init_mem_mapping, before we set max_pfn_mapped to 0, we
have already called init_memory_mapping to setup pagetable
for [0, ISA_END_ADDRESS], and that sets max_pfn_mapped. So
the assignment to 0 is not necessary, remove it.
Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Yinghai Lu <yinghai@kernel.org>
---
arch/x86/mm/init.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index fdc5dca..404c889 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -416,7 +416,6 @@ void __init init_mem_mapping(void)
/* step_size need to be small so pgt_buf from BRK could cover it */
step_size = PMD_SIZE;
- max_pfn_mapped = 0; /* will get exact value next */
min_pfn_mapped = real_end >> PAGE_SHIFT;
last_start = start = real_end;
while (last_start > ISA_END_ADDRESS) {
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped:q 2013-05-10 9:01 [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped:q Zhang Yanfei @ 2013-05-10 9:27 ` Yinghai Lu 2013-05-10 10:28 ` Zhang Yanfei 0 siblings, 1 reply; 6+ messages in thread From: Yinghai Lu @ 2013-05-10 9:27 UTC (permalink / raw) To: Zhang Yanfei Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Andrew Morton, linux-kernel@vger.kernel.org On Fri, May 10, 2013 at 2:01 AM, Zhang Yanfei <zhangyanfei@cn.fujitsu.com> wrote: > init_memory_mapping will set max_pfn_mapped: > int_memory_mapping > --> add_pfn_range_mapped > --> max_pfn_mapped = max(max_pfn_mapped, end_pfn) > > In init_mem_mapping, before we set max_pfn_mapped to 0, we > have already called init_memory_mapping to setup pagetable > for [0, ISA_END_ADDRESS], and that sets max_pfn_mapped. So > the assignment to 0 is not necessary, remove it. NAK. for 32bit or Xen, max_pfn_mapped is set way before in head_32.S and xen-enlighen. Yinghai ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped:q 2013-05-10 9:27 ` Yinghai Lu @ 2013-05-10 10:28 ` Zhang Yanfei 2013-05-10 14:57 ` Yinghai Lu 0 siblings, 1 reply; 6+ messages in thread From: Zhang Yanfei @ 2013-05-10 10:28 UTC (permalink / raw) To: Yinghai Lu Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Andrew Morton, linux-kernel@vger.kernel.org 于 2013年05月10日 17:27, Yinghai Lu 写道: > On Fri, May 10, 2013 at 2:01 AM, Zhang Yanfei > <zhangyanfei@cn.fujitsu.com> wrote: >> init_memory_mapping will set max_pfn_mapped: >> int_memory_mapping >> --> add_pfn_range_mapped >> --> max_pfn_mapped = max(max_pfn_mapped, end_pfn) >> >> In init_mem_mapping, before we set max_pfn_mapped to 0, we >> have already called init_memory_mapping to setup pagetable >> for [0, ISA_END_ADDRESS], and that sets max_pfn_mapped. So >> the assignment to 0 is not necessary, remove it. > > NAK. > > for 32bit or Xen, max_pfn_mapped is set way before in head_32.S and > xen-enlighen. Hi Yinghai I might be wrong, but just from the code in init_mem_mapping only: 410 /* the ISA range is always mapped regardless of memory holes */ 411 init_memory_mapping(0, ISA_END_ADDRESS); 412 413 /* xen has big range in reserved near end of ram, skip it at first.*/ 414 addr = memblock_find_in_range(ISA_END_ADDRESS, end, PMD_SIZE, PMD_SIZE); 415 real_end = addr + PMD_SIZE; 416 417 /* step_size need to be small so pgt_buf from BRK could cover it */ 418 step_size = PMD_SIZE; 419 max_pfn_mapped = 0; /* will get exact value next */ Line 411 set max_pfn_mapped, and then line 419 set it to zero again, so why keep the later assignment? Thanks Zhang ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped:q 2013-05-10 10:28 ` Zhang Yanfei @ 2013-05-10 14:57 ` Yinghai Lu 2013-05-11 7:36 ` Ingo Molnar 2013-05-15 4:44 ` [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped Zhang Yanfei 0 siblings, 2 replies; 6+ messages in thread From: Yinghai Lu @ 2013-05-10 14:57 UTC (permalink / raw) To: Zhang Yanfei Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Andrew Morton, linux-kernel@vger.kernel.org On Fri, May 10, 2013 at 3:28 AM, Zhang Yanfei <zhangyanfei@cn.fujitsu.com> wrote: > 于 2013年05月10日 17:27, Yinghai Lu 写道: >> On Fri, May 10, 2013 at 2:01 AM, Zhang Yanfei >> <zhangyanfei@cn.fujitsu.com> wrote: >>> init_memory_mapping will set max_pfn_mapped: >>> int_memory_mapping >>> --> add_pfn_range_mapped >>> --> max_pfn_mapped = max(max_pfn_mapped, end_pfn) >>> >>> In init_mem_mapping, before we set max_pfn_mapped to 0, we >>> have already called init_memory_mapping to setup pagetable >>> for [0, ISA_END_ADDRESS], and that sets max_pfn_mapped. So >>> the assignment to 0 is not necessary, remove it. >> >> NAK. >> >> for 32bit or Xen, max_pfn_mapped is set way before in head_32.S and >> xen-enlighen. > > Hi Yinghai > > I might be wrong, but just from the code in init_mem_mapping only: > > 410 /* the ISA range is always mapped regardless of memory holes */ > 411 init_memory_mapping(0, ISA_END_ADDRESS); > 412 > 413 /* xen has big range in reserved near end of ram, skip it at first.*/ > 414 addr = memblock_find_in_range(ISA_END_ADDRESS, end, PMD_SIZE, PMD_SIZE); > 415 real_end = addr + PMD_SIZE; > 416 > 417 /* step_size need to be small so pgt_buf from BRK could cover it */ > 418 step_size = PMD_SIZE; > 419 max_pfn_mapped = 0; /* will get exact value next */ > > Line 411 set max_pfn_mapped, and then line 419 set it to zero again, so > why keep the later assignment? the comment says: /* will get exact value next */ For x86 32bit path, and xen set bigger max_pfn_mapped before. Yinghai ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped:q 2013-05-10 14:57 ` Yinghai Lu @ 2013-05-11 7:36 ` Ingo Molnar 2013-05-15 4:44 ` [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped Zhang Yanfei 1 sibling, 0 replies; 6+ messages in thread From: Ingo Molnar @ 2013-05-11 7:36 UTC (permalink / raw) To: Yinghai Lu Cc: Zhang Yanfei, H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Andrew Morton, linux-kernel@vger.kernel.org * Yinghai Lu <yinghai@kernel.org> wrote: > On Fri, May 10, 2013 at 3:28 AM, Zhang Yanfei > <zhangyanfei@cn.fujitsu.com> wrote: > > ?? 2013??05??10?? 17:27, Yinghai Lu ????: > >> On Fri, May 10, 2013 at 2:01 AM, Zhang Yanfei > >> <zhangyanfei@cn.fujitsu.com> wrote: > >>> init_memory_mapping will set max_pfn_mapped: > >>> int_memory_mapping > >>> --> add_pfn_range_mapped > >>> --> max_pfn_mapped = max(max_pfn_mapped, end_pfn) > >>> > >>> In init_mem_mapping, before we set max_pfn_mapped to 0, we > >>> have already called init_memory_mapping to setup pagetable > >>> for [0, ISA_END_ADDRESS], and that sets max_pfn_mapped. So > >>> the assignment to 0 is not necessary, remove it. > >> > >> NAK. > >> > >> for 32bit or Xen, max_pfn_mapped is set way before in head_32.S and > >> xen-enlighen. > > > > Hi Yinghai > > > > I might be wrong, but just from the code in init_mem_mapping only: > > > > 410 /* the ISA range is always mapped regardless of memory holes */ > > 411 init_memory_mapping(0, ISA_END_ADDRESS); > > 412 > > 413 /* xen has big range in reserved near end of ram, skip it at first.*/ > > 414 addr = memblock_find_in_range(ISA_END_ADDRESS, end, PMD_SIZE, PMD_SIZE); > > 415 real_end = addr + PMD_SIZE; > > 416 > > 417 /* step_size need to be small so pgt_buf from BRK could cover it */ > > 418 step_size = PMD_SIZE; > > 419 max_pfn_mapped = 0; /* will get exact value next */ > > > > Line 411 set max_pfn_mapped, and then line 419 set it to zero again, so > > why keep the later assignment? > > the comment says: /* will get exact value next */ And what does that comment mean?? next where? Which call? How? What's the logic? Where is it described accurately so that people who haven't seen the code (for a while) can understand it? > For x86 32bit path, and xen set bigger max_pfn_mapped before. and what does this mean? Perhaps: "32-bit x86 and Xen set a bigger value for max_pfn_mapped before this call." ? And where and why does it matter that we set a bigger max_pfn_mapped before? The dependencies in this code are incestous. Thanks, Ingo ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped 2013-05-10 14:57 ` Yinghai Lu 2013-05-11 7:36 ` Ingo Molnar @ 2013-05-15 4:44 ` Zhang Yanfei 1 sibling, 0 replies; 6+ messages in thread From: Zhang Yanfei @ 2013-05-15 4:44 UTC (permalink / raw) To: Yinghai Lu Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Andrew Morton, linux-kernel@vger.kernel.org 于 2013年05月10日 22:57, Yinghai Lu 写道: > On Fri, May 10, 2013 at 3:28 AM, Zhang Yanfei > <zhangyanfei@cn.fujitsu.com> wrote: >> 于 2013年05月10日 17:27, Yinghai Lu 写道: >>> On Fri, May 10, 2013 at 2:01 AM, Zhang Yanfei >>> <zhangyanfei@cn.fujitsu.com> wrote: >>>> init_memory_mapping will set max_pfn_mapped: >>>> int_memory_mapping >>>> --> add_pfn_range_mapped >>>> --> max_pfn_mapped = max(max_pfn_mapped, end_pfn) >>>> >>>> In init_mem_mapping, before we set max_pfn_mapped to 0, we >>>> have already called init_memory_mapping to setup pagetable >>>> for [0, ISA_END_ADDRESS], and that sets max_pfn_mapped. So >>>> the assignment to 0 is not necessary, remove it. >>> >>> NAK. >>> >>> for 32bit or Xen, max_pfn_mapped is set way before in head_32.S and >>> xen-enlighen. >> >> Hi Yinghai >> >> I might be wrong, but just from the code in init_mem_mapping only: >> >> 410 /* the ISA range is always mapped regardless of memory holes */ >> 411 init_memory_mapping(0, ISA_END_ADDRESS); >> 412 >> 413 /* xen has big range in reserved near end of ram, skip it at first.*/ >> 414 addr = memblock_find_in_range(ISA_END_ADDRESS, end, PMD_SIZE, PMD_SIZE); >> 415 real_end = addr + PMD_SIZE; >> 416 >> 417 /* step_size need to be small so pgt_buf from BRK could cover it */ >> 418 step_size = PMD_SIZE; >> 419 max_pfn_mapped = 0; /* will get exact value next */ >> >> Line 411 set max_pfn_mapped, and then line 419 set it to zero again, so >> why keep the later assignment? > > the comment says: /* will get exact value next */ > > For x86 32bit path, and xen set bigger max_pfn_mapped before. > Hello Yinghai, I kindly understand what you mean now. But I think we can put the reset of max_pfn_mapped at the beginning of init_mem_mapping. That looks more logical. See patch below, please. Thanks Zhang ------ >From dbd213301d800299d256c5da65a1d598902ed826 Mon Sep 17 00:00:00 2001 From: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> Date: Wed, 15 May 2013 11:48:19 +0800 Subject: [PATCH] x86, mm: Reset max_pfn_mapped before we create direct mappings We use init_mem_mapping to create direct mappings from scratch. But in 32bit or xen, we may have already set max_pfn_mapped before in head_32.S and or xen-enlighten. So put the reset at beginning not in the middle of init_mem_mapping seems more logical. Also add comments to explain the reset. Signed-off-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com> --- arch/x86/mm/init.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index fdc5dca..f2e5d28 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c @@ -407,6 +407,14 @@ void __init init_mem_mapping(void) end = max_low_pfn << PAGE_SHIFT; #endif + /* + * In 32bit or xen, max_pfn_mapped has been set way before in + * head_32.S or xen-enlighten. So here we reset it since we will + * create direct mappings from scratch. And it will get its finally + * exact value after we finish the direct mapping in this function. + */ + max_pfn_mapped = 0; + /* the ISA range is always mapped regardless of memory holes */ init_memory_mapping(0, ISA_END_ADDRESS); @@ -416,7 +424,6 @@ void __init init_mem_mapping(void) /* step_size need to be small so pgt_buf from BRK could cover it */ step_size = PMD_SIZE; - max_pfn_mapped = 0; /* will get exact value next */ min_pfn_mapped = real_end >> PAGE_SHIFT; last_start = start = real_end; while (last_start > ISA_END_ADDRESS) { -- 1.7.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-15 4:46 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2013-05-10 9:01 [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped:q Zhang Yanfei 2013-05-10 9:27 ` Yinghai Lu 2013-05-10 10:28 ` Zhang Yanfei 2013-05-10 14:57 ` Yinghai Lu 2013-05-11 7:36 ` Ingo Molnar 2013-05-15 4:44 ` [PATCH] x86: mm: Remove unnecessary assignment for max_pfn_mapped Zhang Yanfei
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox