* [PATCH 0/3] generic hotplug friendly page_is_ram()
@ 2010-01-22 3:21 Wu Fengguang
2010-01-22 3:21 ` [PATCH 1/3] resources: introduce generic page_is_ram() Wu Fengguang
` (2 more replies)
0 siblings, 3 replies; 19+ messages in thread
From: Wu Fengguang @ 2010-01-22 3:21 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin
Cc: Andrew Morton, x86, Wu Fengguang, LKML, Andi Kleen, shaohui.zheng,
KAMEZAWA Hiroyuki
Hi,
This introduces a generic iomem_resource based page_is_ram()
and removes the x86 page_is_ram().
The resource based page_is_ram() is more hotplug friendly, because memory
hotplug only updates resource and leave e820 unchanged.
The first patch changes generic code, however due to tight dependency,
I'd recommend it be included in x86 tree together with the other two.
Thanks,
Fengguang
^ permalink raw reply [flat|nested] 19+ messages in thread* [PATCH 1/3] resources: introduce generic page_is_ram() 2010-01-22 3:21 [PATCH 0/3] generic hotplug friendly page_is_ram() Wu Fengguang @ 2010-01-22 3:21 ` Wu Fengguang 2010-01-22 4:10 ` KAMEZAWA Hiroyuki ` (2 more replies) 2010-01-22 3:21 ` [PATCH 2/3] x86: remove bios data range from e820 Wu Fengguang 2010-01-22 3:21 ` [PATCH 3/3] x86: use the generic page_is_ram() Wu Fengguang 2 siblings, 3 replies; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 3:21 UTC (permalink / raw) To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin Cc: Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips, KAMEZAWA Hiroyuki, Yinghai Lu, Wu Fengguang, x86, LKML, Andi Kleen, shaohui.zheng [-- Warning: decoded text below may be mangled, UTF-8 assumed --] [-- Attachment #1: page-is-ram.patch --] [-- Type: text/plain, Size: 2445 bytes --] It's based on walk_system_ram_range(), for archs that don't have their own page_is_ram(). The static verions in MIPS and SCORE are also made global. CC: Chen Liqin <liqin.chen@sunplusct.com> CC: Lennox Wu <lennox.wu@gmail.com> CC: Ralf Baechle <ralf@linux-mips.org> CC: Américo Wang <xiyou.wangcong@gmail.com> CC: linux-mips@linux-mips.org CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> CC: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- arch/mips/mm/init.c | 2 +- arch/score/mm/init.c | 2 +- include/linux/ioport.h | 2 ++ kernel/resource.c | 11 +++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long #endif +#define PAGE_IS_RAM 24 +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) +{ + return PAGE_IS_RAM; +} +int __attribute__((weak)) page_is_ram(unsigned long pfn) +{ + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); +} +#undef PAGE_IS_RAM + /* * Find empty slot in the resource tree given range and alignment. */ --- linux-mm.orig/include/linux/ioport.h 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/include/linux/ioport.h 2010-01-22 11:20:35.000000000 +0800 @@ -191,5 +191,7 @@ extern int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)); +extern int page_is_ram(unsigned long pfn); + #endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ --- linux-mm.orig/arch/score/mm/init.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/arch/score/mm/init.c 2010-01-22 11:20:35.000000000 +0800 @@ -59,7 +59,7 @@ static unsigned long setup_zero_page(voi } #ifndef CONFIG_NEED_MULTIPLE_NODES -static int __init page_is_ram(unsigned long pagenr) +int page_is_ram(unsigned long pagenr) { if (pagenr >= min_low_pfn && pagenr < max_low_pfn) return 1; --- linux-mm.orig/arch/mips/mm/init.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/arch/mips/mm/init.c 2010-01-22 11:20:35.000000000 +0800 @@ -298,7 +298,7 @@ void __init fixrange_init(unsigned long } #ifndef CONFIG_NEED_MULTIPLE_NODES -static int __init page_is_ram(unsigned long pagenr) +int page_is_ram(unsigned long pagenr) { int i; ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] resources: introduce generic page_is_ram() 2010-01-22 3:21 ` [PATCH 1/3] resources: introduce generic page_is_ram() Wu Fengguang @ 2010-01-22 4:10 ` KAMEZAWA Hiroyuki 2010-01-22 4:20 ` [PATCH 1/3 v3] " Wu Fengguang 2010-01-22 5:15 ` [PATCH 1/3] " Xiaotian Feng 2010-01-22 7:51 ` H. Peter Anvin 2 siblings, 1 reply; 19+ messages in thread From: KAMEZAWA Hiroyuki @ 2010-01-22 4:10 UTC (permalink / raw) To: Wu Fengguang Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips, Yinghai Lu, x86, LKML, Andi Kleen, shaohui.zheng On Fri, 22 Jan 2010 11:21:03 +0800 Wu Fengguang <fengguang.wu@intel.com> wrote: > It's based on walk_system_ram_range(), for archs that don't have > their own page_is_ram(). > > The static verions in MIPS and SCORE are also made global. > > CC: Chen Liqin <liqin.chen@sunplusct.com> > CC: Lennox Wu <lennox.wu@gmail.com> > CC: Ralf Baechle <ralf@linux-mips.org> > CC: Am辿rico Wang <xiyou.wangcong@gmail.com> > CC: linux-mips@linux-mips.org > CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > CC: Yinghai Lu <yinghai@kernel.org> > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Maybe adding comment like this is good for reviewers.. "This page_is_ram() returns true if specified address is registered as System RAM in io_resource list." AFAIK, this "System RAM" information has been used for kdump to grab valid memory area and seems good for the kernel itself. Thanks, -Kame Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > --- > arch/mips/mm/init.c | 2 +- > arch/score/mm/init.c | 2 +- > include/linux/ioport.h | 2 ++ > kernel/resource.c | 11 +++++++++++ > 4 files changed, 15 insertions(+), 2 deletions(-) > > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 > @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long > > #endif > > +#define PAGE_IS_RAM 24 > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) > +{ > + return PAGE_IS_RAM; > +} > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > +{ > + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); > +} > +#undef PAGE_IS_RAM > + > /* > * Find empty slot in the resource tree given range and alignment. > */ > --- linux-mm.orig/include/linux/ioport.h 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/include/linux/ioport.h 2010-01-22 11:20:35.000000000 +0800 > @@ -191,5 +191,7 @@ extern int > walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, > void *arg, int (*func)(unsigned long, unsigned long, void *)); > > +extern int page_is_ram(unsigned long pfn); > + > #endif /* __ASSEMBLY__ */ > #endif /* _LINUX_IOPORT_H */ > --- linux-mm.orig/arch/score/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/arch/score/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > @@ -59,7 +59,7 @@ static unsigned long setup_zero_page(voi > } > > #ifndef CONFIG_NEED_MULTIPLE_NODES > -static int __init page_is_ram(unsigned long pagenr) > +int page_is_ram(unsigned long pagenr) > { > if (pagenr >= min_low_pfn && pagenr < max_low_pfn) > return 1; > --- linux-mm.orig/arch/mips/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/arch/mips/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > @@ -298,7 +298,7 @@ void __init fixrange_init(unsigned long > } > > #ifndef CONFIG_NEED_MULTIPLE_NODES > -static int __init page_is_ram(unsigned long pagenr) > +int page_is_ram(unsigned long pagenr) > { > int i; > > > > ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/3 v3] resources: introduce generic page_is_ram() 2010-01-22 4:10 ` KAMEZAWA Hiroyuki @ 2010-01-22 4:20 ` Wu Fengguang 0 siblings, 0 replies; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 4:20 UTC (permalink / raw) To: KAMEZAWA Hiroyuki Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips@linux-mips.org, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui On Fri, Jan 22, 2010 at 06:10:17AM +0200, KAMEZAWA Hiroyuki wrote: > On Fri, 22 Jan 2010 11:21:03 +0800 > Wu Fengguang <fengguang.wu@intel.com> wrote: > > > It's based on walk_system_ram_range(), for archs that don't have > > their own page_is_ram(). > > > > The static verions in MIPS and SCORE are also made global. > > > > CC: Chen Liqin <liqin.chen@sunplusct.com> > > CC: Lennox Wu <lennox.wu@gmail.com> > > CC: Ralf Baechle <ralf@linux-mips.org> > > CC: Am辿rico Wang <xiyou.wangcong@gmail.com> > > CC: linux-mips@linux-mips.org > > CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > CC: Yinghai Lu <yinghai@kernel.org> > > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> > > Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > Maybe adding comment like this is good for reviewers.. > > "This page_is_ram() returns true if specified address is registered > as System RAM in io_resource list." > > AFAIK, this "System RAM" information has been used for kdump to grab valid > memory area and seems good for the kernel itself. Thanks! Patch updated as follows. --- resources: introduce generic page_is_ram() It's based on walk_system_ram_range(), for archs that don't have their own page_is_ram(). The static verions in MIPS and SCORE are also made global. v3: add comment (KAMEZAWA Hiroyuki) v2: add PAGE_IS_RAM macro (Américo Wang) CC: Chen Liqin <liqin.chen@sunplusct.com> CC: Lennox Wu <lennox.wu@gmail.com> CC: Ralf Baechle <ralf@linux-mips.org> CC: Américo Wang <xiyou.wangcong@gmail.com> CC: linux-mips@linux-mips.org CC: Yinghai Lu <yinghai@kernel.org> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- arch/mips/mm/init.c | 2 +- arch/score/mm/init.c | 2 +- include/linux/ioport.h | 2 ++ kernel/resource.c | 15 +++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/kernel/resource.c 2010-01-22 12:17:50.000000000 +0800 @@ -327,6 +327,21 @@ int walk_system_ram_range(unsigned long #endif +#define PAGE_IS_RAM 24 +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) +{ + return PAGE_IS_RAM; +} +/* + * This generic page_is_ram() returns true if specified address is + * registered as "System RAM" in iomem_resource list. + */ +int __attribute__((weak)) page_is_ram(unsigned long pfn) +{ + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); +} +#undef PAGE_IS_RAM + /* * Find empty slot in the resource tree given range and alignment. */ --- linux-mm.orig/include/linux/ioport.h 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/include/linux/ioport.h 2010-01-22 11:20:35.000000000 +0800 @@ -191,5 +191,7 @@ extern int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)); +extern int page_is_ram(unsigned long pfn); + #endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ --- linux-mm.orig/arch/score/mm/init.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/arch/score/mm/init.c 2010-01-22 11:20:35.000000000 +0800 @@ -59,7 +59,7 @@ static unsigned long setup_zero_page(voi } #ifndef CONFIG_NEED_MULTIPLE_NODES -static int __init page_is_ram(unsigned long pagenr) +int page_is_ram(unsigned long pagenr) { if (pagenr >= min_low_pfn && pagenr < max_low_pfn) return 1; --- linux-mm.orig/arch/mips/mm/init.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/arch/mips/mm/init.c 2010-01-22 11:20:35.000000000 +0800 @@ -298,7 +298,7 @@ void __init fixrange_init(unsigned long } #ifndef CONFIG_NEED_MULTIPLE_NODES -static int __init page_is_ram(unsigned long pagenr) +int page_is_ram(unsigned long pagenr) { int i; ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] resources: introduce generic page_is_ram() 2010-01-22 3:21 ` [PATCH 1/3] resources: introduce generic page_is_ram() Wu Fengguang 2010-01-22 4:10 ` KAMEZAWA Hiroyuki @ 2010-01-22 5:15 ` Xiaotian Feng 2010-01-22 5:37 ` Wu Fengguang 2010-01-22 7:51 ` H. Peter Anvin 2 siblings, 1 reply; 19+ messages in thread From: Xiaotian Feng @ 2010-01-22 5:15 UTC (permalink / raw) To: Wu Fengguang Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips, KAMEZAWA Hiroyuki, Yinghai Lu, x86, LKML, Andi Kleen, shaohui.zheng On Fri, Jan 22, 2010 at 11:21 AM, Wu Fengguang <fengguang.wu@intel.com> wrote: > It's based on walk_system_ram_range(), for archs that don't have > their own page_is_ram(). > > The static verions in MIPS and SCORE are also made global. > > CC: Chen Liqin <liqin.chen@sunplusct.com> > CC: Lennox Wu <lennox.wu@gmail.com> > CC: Ralf Baechle <ralf@linux-mips.org> > CC: Américo Wang <xiyou.wangcong@gmail.com> > CC: linux-mips@linux-mips.org > CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > CC: Yinghai Lu <yinghai@kernel.org> > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> > --- > arch/mips/mm/init.c | 2 +- > arch/score/mm/init.c | 2 +- > include/linux/ioport.h | 2 ++ > kernel/resource.c | 11 +++++++++++ > 4 files changed, 15 insertions(+), 2 deletions(-) > > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 > @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long > > #endif > > +#define PAGE_IS_RAM 24 > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) > +{ > + return PAGE_IS_RAM; > +} > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > +{ > + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); > +} > +#undef PAGE_IS_RAM > + I'm not sure, but any build test for powerpc/mips/score? walk_system_ram_range is defined when CONFIG_ARCH_HAS_WALK_MEMORY is not set. Is it safe when CONFIG_ARCH_HAS_WALK_MEMORY is set for some powerpc archs? > /* > * Find empty slot in the resource tree given range and alignment. > */ > --- linux-mm.orig/include/linux/ioport.h 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/include/linux/ioport.h 2010-01-22 11:20:35.000000000 +0800 > @@ -191,5 +191,7 @@ extern int > walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, > void *arg, int (*func)(unsigned long, unsigned long, void *)); > > +extern int page_is_ram(unsigned long pfn); > + > #endif /* __ASSEMBLY__ */ > #endif /* _LINUX_IOPORT_H */ > --- linux-mm.orig/arch/score/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/arch/score/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > @@ -59,7 +59,7 @@ static unsigned long setup_zero_page(voi > } > > #ifndef CONFIG_NEED_MULTIPLE_NODES > -static int __init page_is_ram(unsigned long pagenr) > +int page_is_ram(unsigned long pagenr) > { > if (pagenr >= min_low_pfn && pagenr < max_low_pfn) > return 1; > --- linux-mm.orig/arch/mips/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/arch/mips/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > @@ -298,7 +298,7 @@ void __init fixrange_init(unsigned long > } > > #ifndef CONFIG_NEED_MULTIPLE_NODES > -static int __init page_is_ram(unsigned long pagenr) > +int page_is_ram(unsigned long pagenr) > { > int i; > > > > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ > ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] resources: introduce generic page_is_ram() 2010-01-22 5:15 ` [PATCH 1/3] " Xiaotian Feng @ 2010-01-22 5:37 ` Wu Fengguang 2010-01-22 5:50 ` Xiaotian Feng 0 siblings, 1 reply; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 5:37 UTC (permalink / raw) To: Xiaotian Feng Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips@linux-mips.org, KAMEZAWA Hiroyuki, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui On Thu, Jan 21, 2010 at 10:15:50PM -0700, Xiaotian Feng wrote: > On Fri, Jan 22, 2010 at 11:21 AM, Wu Fengguang <fengguang.wu@intel.com> wrote: > > It's based on walk_system_ram_range(), for archs that don't have > > their own page_is_ram(). > > > > The static verions in MIPS and SCORE are also made global. > > > > CC: Chen Liqin <liqin.chen@sunplusct.com> > > CC: Lennox Wu <lennox.wu@gmail.com> > > CC: Ralf Baechle <ralf@linux-mips.org> > > CC: Américo Wang <xiyou.wangcong@gmail.com> > > CC: linux-mips@linux-mips.org > > CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > CC: Yinghai Lu <yinghai@kernel.org> > > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> > > --- > > arch/mips/mm/init.c | 2 +- > > arch/score/mm/init.c | 2 +- > > include/linux/ioport.h | 2 ++ > > kernel/resource.c | 11 +++++++++++ > > 4 files changed, 15 insertions(+), 2 deletions(-) > > > > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 > > +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 > > @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long > > > > #endif > > > > +#define PAGE_IS_RAM 24 > > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) > > +{ > > + return PAGE_IS_RAM; > > +} > > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > > +{ > > + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); > > +} > > +#undef PAGE_IS_RAM > > + > > I'm not sure, but any build test for powerpc/mips/score? Sorry, no build tests yet: /bin/sh: score-linux-gcc: command not found I just make the mips/score page_is_ram() non-static and assume that will make it compile. > walk_system_ram_range is defined when CONFIG_ARCH_HAS_WALK_MEMORY is not set. > Is it safe when CONFIG_ARCH_HAS_WALK_MEMORY is set for some powerpc archs? Good question. Grep shows that CONFIG_ARCH_HAS_WALK_MEMORY is only defined for powerpc, and it has its own page_is_ram() as well as walk_system_ram_range(). walk_system_ram_range() must be defined somewhere because it is expected to be generic routine: exported and called from both in-kernel and out-of-tree code. Thanks, Fengguang ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] resources: introduce generic page_is_ram() 2010-01-22 5:37 ` Wu Fengguang @ 2010-01-22 5:50 ` Xiaotian Feng 2010-01-22 5:52 ` Wu Fengguang 0 siblings, 1 reply; 19+ messages in thread From: Xiaotian Feng @ 2010-01-22 5:50 UTC (permalink / raw) To: Wu Fengguang Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips@linux-mips.org, KAMEZAWA Hiroyuki, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui On Fri, Jan 22, 2010 at 1:37 PM, Wu Fengguang <fengguang.wu@intel.com> wrote: > On Thu, Jan 21, 2010 at 10:15:50PM -0700, Xiaotian Feng wrote: >> On Fri, Jan 22, 2010 at 11:21 AM, Wu Fengguang <fengguang.wu@intel.com> wrote: >> > It's based on walk_system_ram_range(), for archs that don't have >> > their own page_is_ram(). >> > >> > The static verions in MIPS and SCORE are also made global. >> > >> > CC: Chen Liqin <liqin.chen@sunplusct.com> >> > CC: Lennox Wu <lennox.wu@gmail.com> >> > CC: Ralf Baechle <ralf@linux-mips.org> >> > CC: Américo Wang <xiyou.wangcong@gmail.com> >> > CC: linux-mips@linux-mips.org >> > CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> >> > CC: Yinghai Lu <yinghai@kernel.org> >> > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> >> > --- >> > arch/mips/mm/init.c | 2 +- >> > arch/score/mm/init.c | 2 +- >> > include/linux/ioport.h | 2 ++ >> > kernel/resource.c | 11 +++++++++++ >> > 4 files changed, 15 insertions(+), 2 deletions(-) >> > >> > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 >> > +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 >> > @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long >> > >> > #endif >> > >> > +#define PAGE_IS_RAM 24 >> > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) >> > +{ >> > + return PAGE_IS_RAM; >> > +} >> > +int __attribute__((weak)) page_is_ram(unsigned long pfn) >> > +{ >> > + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); >> > +} >> > +#undef PAGE_IS_RAM >> > + >> >> I'm not sure, but any build test for powerpc/mips/score? > > Sorry, no build tests yet: > > /bin/sh: score-linux-gcc: command not found > > I just make the mips/score page_is_ram() non-static and assume that > will make it compile. > >> walk_system_ram_range is defined when CONFIG_ARCH_HAS_WALK_MEMORY is not set. >> Is it safe when CONFIG_ARCH_HAS_WALK_MEMORY is set for some powerpc archs? > > Good question. Grep shows that CONFIG_ARCH_HAS_WALK_MEMORY is only > defined for powerpc, and it has its own page_is_ram() as well as > walk_system_ram_range(). > > walk_system_ram_range() must be defined somewhere because it is > expected to be generic routine: exported and called from both > in-kernel and out-of-tree code. > Yes, powerpc has its own walk_system_ram_range() and page_is_ram() ;-) Would it be better if moving the weak attribute page_is_ram() into #if !defined(CONFIG_ARCH_HAS_WALK_MEMORY) ? > Thanks, > Fengguang > ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] resources: introduce generic page_is_ram() 2010-01-22 5:50 ` Xiaotian Feng @ 2010-01-22 5:52 ` Wu Fengguang 0 siblings, 0 replies; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 5:52 UTC (permalink / raw) To: Xiaotian Feng Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips@linux-mips.org, KAMEZAWA Hiroyuki, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui On Thu, Jan 21, 2010 at 09:50:01PM -0800, Xiaotian Feng wrote: > On Fri, Jan 22, 2010 at 1:37 PM, Wu Fengguang <fengguang.wu@intel.com> wrote: > > On Thu, Jan 21, 2010 at 10:15:50PM -0700, Xiaotian Feng wrote: > >> On Fri, Jan 22, 2010 at 11:21 AM, Wu Fengguang <fengguang.wu@intel.com> wrote: > >> > It's based on walk_system_ram_range(), for archs that don't have > >> > their own page_is_ram(). > >> > > >> > The static verions in MIPS and SCORE are also made global. > >> > > >> > CC: Chen Liqin <liqin.chen@sunplusct.com> > >> > CC: Lennox Wu <lennox.wu@gmail.com> > >> > CC: Ralf Baechle <ralf@linux-mips.org> > >> > CC: Américo Wang <xiyou.wangcong@gmail.com> > >> > CC: linux-mips@linux-mips.org > >> > CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > >> > CC: Yinghai Lu <yinghai@kernel.org> > >> > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> > >> > --- > >> > arch/mips/mm/init.c | 2 +- > >> > arch/score/mm/init.c | 2 +- > >> > include/linux/ioport.h | 2 ++ > >> > kernel/resource.c | 11 +++++++++++ > >> > 4 files changed, 15 insertions(+), 2 deletions(-) > >> > > >> > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 > >> > +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 > >> > @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long > >> > > >> > #endif > >> > > >> > +#define PAGE_IS_RAM 24 > >> > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) > >> > +{ > >> > + return PAGE_IS_RAM; > >> > +} > >> > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > >> > +{ > >> > + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); > >> > +} > >> > +#undef PAGE_IS_RAM > >> > + > >> > >> I'm not sure, but any build test for powerpc/mips/score? > > > > Sorry, no build tests yet: > > > > /bin/sh: score-linux-gcc: command not found > > > > I just make the mips/score page_is_ram() non-static and assume that > > will make it compile. > > > >> walk_system_ram_range is defined when CONFIG_ARCH_HAS_WALK_MEMORY is not set. > >> Is it safe when CONFIG_ARCH_HAS_WALK_MEMORY is set for some powerpc archs? > > > > Good question. Grep shows that CONFIG_ARCH_HAS_WALK_MEMORY is only > > defined for powerpc, and it has its own page_is_ram() as well as > > walk_system_ram_range(). > > > > walk_system_ram_range() must be defined somewhere because it is > > expected to be generic routine: exported and called from both > > in-kernel and out-of-tree code. > > > > Yes, powerpc has its own walk_system_ram_range() and page_is_ram() ;-) > > Would it be better if moving the weak attribute page_is_ram() into #if > !defined(CONFIG_ARCH_HAS_WALK_MEMORY) ? Only several archs defined page_is_ram(), so that would not be feasible for doing a _generic_ page_is_ram(). Thanks, Fengguang ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3] resources: introduce generic page_is_ram() 2010-01-22 3:21 ` [PATCH 1/3] resources: introduce generic page_is_ram() Wu Fengguang 2010-01-22 4:10 ` KAMEZAWA Hiroyuki 2010-01-22 5:15 ` [PATCH 1/3] " Xiaotian Feng @ 2010-01-22 7:51 ` H. Peter Anvin 2010-01-22 8:16 ` [PATCH 1/3 v4] " Wu Fengguang 2 siblings, 1 reply; 19+ messages in thread From: H. Peter Anvin @ 2010-01-22 7:51 UTC (permalink / raw) To: Wu Fengguang Cc: Thomas Gleixner, Ingo Molnar, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips, KAMEZAWA Hiroyuki, Yinghai Lu, x86, LKML, Andi Kleen, shaohui.zheng On 01/21/2010 07:21 PM, Wu Fengguang wrote: > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 > @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long > > #endif > > +#define PAGE_IS_RAM 24 > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) > +{ > + return PAGE_IS_RAM; > +} > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > +{ > + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); > +} > +#undef PAGE_IS_RAM > + Stylistic nitpick: The use of the magic number "24" here is pretty ugly; it seems to imply that there is something peculiar with this number and that it is trying to avoid an overlap, whereas in fact any number but 0 and -1 would do. I would rather see just returning 1 and do: return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; (walk_system_ram_range() returning -1 on error, and 0 means continue.) Note also that we don't write "constant == expression"; although some schools teach it as a way to avoid the "=" versus "==" beginner C mistake, it makes the code less intuitive to read. Other than that, the patchset looks good; if Ingo doesn't beat me to it I'll put it in tomorrow (need sleep right now.) -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf. ^ permalink raw reply [flat|nested] 19+ messages in thread
* [PATCH 1/3 v4] resources: introduce generic page_is_ram() 2010-01-22 7:51 ` H. Peter Anvin @ 2010-01-22 8:16 ` Wu Fengguang 2010-01-27 0:30 ` Andrew Morton 0 siblings, 1 reply; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 8:16 UTC (permalink / raw) To: H. Peter Anvin Cc: Thomas Gleixner, Ingo Molnar, Andrew Morton, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips@linux-mips.org, KAMEZAWA Hiroyuki, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui On Fri, Jan 22, 2010 at 12:51:32AM -0700, H. Peter Anvin wrote: > On 01/21/2010 07:21 PM, Wu Fengguang wrote: > > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 > > +++ linux-mm/kernel/resource.c 2010-01-22 11:20:35.000000000 +0800 > > @@ -327,6 +327,17 @@ int walk_system_ram_range(unsigned long > > > > #endif > > > > +#define PAGE_IS_RAM 24 > > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) > > +{ > > + return PAGE_IS_RAM; > > +} > > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > > +{ > > + return PAGE_IS_RAM == walk_system_ram_range(pfn, 1, NULL, __is_ram); > > +} > > +#undef PAGE_IS_RAM > > + > > Stylistic nitpick: > > The use of the magic number "24" here is pretty ugly; it seems to imply > that there is something peculiar with this number and that it is trying > to avoid an overlap, whereas in fact any number but 0 and -1 would do. Yes, exactly. > I would rather see just returning 1 and do: > > return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; > > (walk_system_ram_range() returning -1 on error, and 0 means continue.) Good suggestion. > Note also that we don't write "constant == expression"; although some > schools teach it as a way to avoid the "=" versus "==" beginner C > mistake, it makes the code less intuitive to read. Yeah. > Other than that, the patchset looks good; if Ingo doesn't beat me to it > I'll put it in tomorrow (need sleep right now.) OK, thanks! Here is the updated patch. --- resources: introduce generic page_is_ram() It's based on walk_system_ram_range(), for archs that don't have their own page_is_ram(). The static verions in MIPS and SCORE are also made global. v4: prefer plain 1 instead of PAGE_IS_RAM (H. Peter Anvin) v3: add comment (KAMEZAWA Hiroyuki) "AFAIK, this "System RAM" information has been used for kdump to grab valid memory area and seems good for the kernel itself." v2: add PAGE_IS_RAM macro (Américo Wang) CC: Chen Liqin <liqin.chen@sunplusct.com> CC: Lennox Wu <lennox.wu@gmail.com> CC: Ralf Baechle <ralf@linux-mips.org> CC: Américo Wang <xiyou.wangcong@gmail.com> CC: linux-mips@linux-mips.org CC: Yinghai Lu <yinghai@kernel.org> Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- arch/mips/mm/init.c | 2 +- arch/score/mm/init.c | 2 +- include/linux/ioport.h | 2 ++ kernel/resource.c | 13 +++++++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/kernel/resource.c 2010-01-22 16:12:55.000000000 +0800 @@ -327,6 +327,19 @@ int walk_system_ram_range(unsigned long #endif +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) +{ + return 1; +} +/* + * This generic page_is_ram() returns true if specified address is + * registered as "System RAM" in iomem_resource list. + */ +int __attribute__((weak)) page_is_ram(unsigned long pfn) +{ + return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; +} + /* * Find empty slot in the resource tree given range and alignment. */ --- linux-mm.orig/include/linux/ioport.h 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/include/linux/ioport.h 2010-01-22 11:20:35.000000000 +0800 @@ -191,5 +191,7 @@ extern int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)); +extern int page_is_ram(unsigned long pfn); + #endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ --- linux-mm.orig/arch/score/mm/init.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/arch/score/mm/init.c 2010-01-22 11:20:35.000000000 +0800 @@ -59,7 +59,7 @@ static unsigned long setup_zero_page(voi } #ifndef CONFIG_NEED_MULTIPLE_NODES -static int __init page_is_ram(unsigned long pagenr) +int page_is_ram(unsigned long pagenr) { if (pagenr >= min_low_pfn && pagenr < max_low_pfn) return 1; --- linux-mm.orig/arch/mips/mm/init.c 2010-01-22 11:20:34.000000000 +0800 +++ linux-mm/arch/mips/mm/init.c 2010-01-22 11:20:35.000000000 +0800 @@ -298,7 +298,7 @@ void __init fixrange_init(unsigned long } #ifndef CONFIG_NEED_MULTIPLE_NODES -static int __init page_is_ram(unsigned long pagenr) +int page_is_ram(unsigned long pagenr) { int i; ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3 v4] resources: introduce generic page_is_ram() 2010-01-22 8:16 ` [PATCH 1/3 v4] " Wu Fengguang @ 2010-01-27 0:30 ` Andrew Morton 2010-01-27 3:06 ` Wu Fengguang 0 siblings, 1 reply; 19+ messages in thread From: Andrew Morton @ 2010-01-27 0:30 UTC (permalink / raw) To: Wu Fengguang Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips@linux-mips.org, KAMEZAWA Hiroyuki, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui On Fri, 22 Jan 2010 16:16:19 +0800 Wu Fengguang <fengguang.wu@intel.com> wrote: > > It's based on walk_system_ram_range(), for archs that don't have > their own page_is_ram(). > > The static verions in MIPS and SCORE are also made global. > > v4: prefer plain 1 instead of PAGE_IS_RAM (H. Peter Anvin) > v3: add comment (KAMEZAWA Hiroyuki) > "AFAIK, this "System RAM" information has been used for kdump to > grab valid memory area and seems good for the kernel itself." > v2: add PAGE_IS_RAM macro (Am__rico Wang) > > CC: Chen Liqin <liqin.chen@sunplusct.com> > CC: Lennox Wu <lennox.wu@gmail.com> > CC: Ralf Baechle <ralf@linux-mips.org> > CC: Am__rico Wang <xiyou.wangcong@gmail.com> > CC: linux-mips@linux-mips.org > CC: Yinghai Lu <yinghai@kernel.org> > Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> > --- > arch/mips/mm/init.c | 2 +- > arch/score/mm/init.c | 2 +- > include/linux/ioport.h | 2 ++ > kernel/resource.c | 13 +++++++++++++ > 4 files changed, 17 insertions(+), 2 deletions(-) > > --- linux-mm.orig/kernel/resource.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/kernel/resource.c 2010-01-22 16:12:55.000000000 +0800 > @@ -327,6 +327,19 @@ int walk_system_ram_range(unsigned long > > #endif > > +static int __is_ram(unsigned long pfn, unsigned long nr_pages, void *arg) > +{ > + return 1; > +} > +/* > + * This generic page_is_ram() returns true if specified address is > + * registered as "System RAM" in iomem_resource list. > + */ > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > +{ > + return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; > +} I'll switch this to use __weak. > /* > * Find empty slot in the resource tree given range and alignment. > */ > --- linux-mm.orig/include/linux/ioport.h 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/include/linux/ioport.h 2010-01-22 11:20:35.000000000 +0800 > @@ -191,5 +191,7 @@ extern int > walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, > void *arg, int (*func)(unsigned long, unsigned long, void *)); > > +extern int page_is_ram(unsigned long pfn); Is it appropriate that this function be declared in ioport.h? It's a pretty general function. Dunno. > #endif /* __ASSEMBLY__ */ > #endif /* _LINUX_IOPORT_H */ > --- linux-mm.orig/arch/score/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/arch/score/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > @@ -59,7 +59,7 @@ static unsigned long setup_zero_page(voi > } > > #ifndef CONFIG_NEED_MULTIPLE_NODES > -static int __init page_is_ram(unsigned long pagenr) > +int page_is_ram(unsigned long pagenr) > { > if (pagenr >= min_low_pfn && pagenr < max_low_pfn) > return 1; > --- linux-mm.orig/arch/mips/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > +++ linux-mm/arch/mips/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > @@ -298,7 +298,7 @@ void __init fixrange_init(unsigned long > } > > #ifndef CONFIG_NEED_MULTIPLE_NODES > -static int __init page_is_ram(unsigned long pagenr) > +int page_is_ram(unsigned long pagenr) > { > int i; hm, so we lose the __init. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 1/3 v4] resources: introduce generic page_is_ram() 2010-01-27 0:30 ` Andrew Morton @ 2010-01-27 3:06 ` Wu Fengguang 2010-02-02 1:01 ` [tip:x86/mm] Move page_is_ram() declaration to mm.h tip-bot for Wu Fengguang 0 siblings, 1 reply; 19+ messages in thread From: Wu Fengguang @ 2010-01-27 3:06 UTC (permalink / raw) To: Andrew Morton Cc: H. Peter Anvin, Thomas Gleixner, Ingo Molnar, Chen Liqin, Lennox Wu, Ralf Baechle, Américo Wang, linux-mips@linux-mips.org, KAMEZAWA Hiroyuki, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui On Tue, Jan 26, 2010 at 05:30:58PM -0700, Andrew Morton wrote: > > +int __attribute__((weak)) page_is_ram(unsigned long pfn) > > +{ > > + return walk_system_ram_range(pfn, 1, NULL, __is_ram) == 1; > > +} > > I'll switch this to use __weak. Thanks. > > /* > > * Find empty slot in the resource tree given range and alignment. > > */ > > --- linux-mm.orig/include/linux/ioport.h 2010-01-22 11:20:34.000000000 +0800 > > +++ linux-mm/include/linux/ioport.h 2010-01-22 11:20:35.000000000 +0800 > > @@ -191,5 +191,7 @@ extern int > > walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, > > void *arg, int (*func)(unsigned long, unsigned long, void *)); > > > > +extern int page_is_ram(unsigned long pfn); > > Is it appropriate that this function be declared in ioport.h? It's a > pretty general function. Dunno. Good suggestion. The following patch moves it to mm.h. > > #endif /* __ASSEMBLY__ */ > > #endif /* _LINUX_IOPORT_H */ > > --- linux-mm.orig/arch/score/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > > +++ linux-mm/arch/score/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > > @@ -59,7 +59,7 @@ static unsigned long setup_zero_page(voi > > } > > > > #ifndef CONFIG_NEED_MULTIPLE_NODES > > -static int __init page_is_ram(unsigned long pagenr) > > +int page_is_ram(unsigned long pagenr) > > { > > if (pagenr >= min_low_pfn && pagenr < max_low_pfn) > > return 1; > > --- linux-mm.orig/arch/mips/mm/init.c 2010-01-22 11:20:34.000000000 +0800 > > +++ linux-mm/arch/mips/mm/init.c 2010-01-22 11:20:35.000000000 +0800 > > @@ -298,7 +298,7 @@ void __init fixrange_init(unsigned long > > } > > > > #ifndef CONFIG_NEED_MULTIPLE_NODES > > -static int __init page_is_ram(unsigned long pagenr) > > +int page_is_ram(unsigned long pagenr) > > { > > int i; > > hm, so we lose the __init. Maybe Ralf Baechle knows whether MIPS can switch to the (smaller) generic page_is_ram(). Thanks, Fengguang --- move page_is_ram() declaration to mm.h --- include/linux/ioport.h | 2 -- include/linux/mm.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) --- linux-mm.orig/include/linux/ioport.h 2010-01-27 11:04:22.000000000 +0800 +++ linux-mm/include/linux/ioport.h 2010-01-27 11:04:38.000000000 +0800 @@ -191,7 +191,5 @@ extern int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)); -extern int page_is_ram(unsigned long pfn); - #endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ --- linux-mm.orig/include/linux/mm.h 2010-01-27 11:04:43.000000000 +0800 +++ linux-mm/include/linux/mm.h 2010-01-27 11:05:30.000000000 +0800 @@ -265,6 +265,8 @@ static inline int get_page_unless_zero(s return atomic_inc_not_zero(&page->_count); } +extern int page_is_ram(unsigned long pfn); + /* Support for virtually mapped pages */ struct page *vmalloc_to_page(const void *addr); unsigned long vmalloc_to_pfn(const void *addr); ^ permalink raw reply [flat|nested] 19+ messages in thread
* [tip:x86/mm] Move page_is_ram() declaration to mm.h 2010-01-27 3:06 ` Wu Fengguang @ 2010-02-02 1:01 ` tip-bot for Wu Fengguang 0 siblings, 0 replies; 19+ messages in thread From: tip-bot for Wu Fengguang @ 2010-02-02 1:01 UTC (permalink / raw) To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, tglx, fengguang.wu Commit-ID: 53df8fdc15fb646b0219e43c989c2cdab1ab100c Gitweb: http://git.kernel.org/tip/53df8fdc15fb646b0219e43c989c2cdab1ab100c Author: Wu Fengguang <fengguang.wu@intel.com> AuthorDate: Wed, 27 Jan 2010 11:06:39 +0800 Committer: H. Peter Anvin <hpa@zytor.com> CommitDate: Mon, 1 Feb 2010 16:58:17 -0800 Move page_is_ram() declaration to mm.h Move page_is_ram() declaration to mm.h, it makes no sense in <linux/ioport.h>. Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> LKML-Reference: <20100127030639.GD8132@localhost> Signed-off-by: H. Peter Anvin <hpa@zytor.com> --- include/linux/ioport.h | 2 -- include/linux/mm.h | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/ioport.h b/include/linux/ioport.h index 11ef795..83aa812 100644 --- a/include/linux/ioport.h +++ b/include/linux/ioport.h @@ -188,7 +188,5 @@ extern int walk_system_ram_range(unsigned long start_pfn, unsigned long nr_pages, void *arg, int (*func)(unsigned long, unsigned long, void *)); -extern int page_is_ram(unsigned long pfn); - #endif /* __ASSEMBLY__ */ #endif /* _LINUX_IOPORT_H */ diff --git a/include/linux/mm.h b/include/linux/mm.h index 24c3956..bad433f 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -265,6 +265,8 @@ static inline int get_page_unless_zero(struct page *page) return atomic_inc_not_zero(&page->_count); } +extern int page_is_ram(unsigned long pfn); + /* Support for virtually mapped pages */ struct page *vmalloc_to_page(const void *addr); unsigned long vmalloc_to_pfn(const void *addr); ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 2/3] x86: remove bios data range from e820 2010-01-22 3:21 [PATCH 0/3] generic hotplug friendly page_is_ram() Wu Fengguang 2010-01-22 3:21 ` [PATCH 1/3] resources: introduce generic page_is_ram() Wu Fengguang @ 2010-01-22 3:21 ` Wu Fengguang 2010-01-22 4:06 ` Wu Fengguang ` (2 more replies) 2010-01-22 3:21 ` [PATCH 3/3] x86: use the generic page_is_ram() Wu Fengguang 2 siblings, 3 replies; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 3:21 UTC (permalink / raw) To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin Cc: Andrew Morton, Yinghai Lu, x86, Wu Fengguang, LKML, Andi Kleen, shaohui.zheng, KAMEZAWA Hiroyuki [-- Attachment #1: remove_bios_begin_end.patch --] [-- Type: text/plain, Size: 3024 bytes --] From: Yinghai Lu <yinghai@kernel.org> To prepare move page_is_ram() as generic one. Tested-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Yinghai Lu <yinghai@kernel.org> --- arch/x86/kernel/e820.c | 8 ++++++++ arch/x86/kernel/setup.c | 19 ++++++++++++++++++- arch/x86/mm/ioremap.c | 16 ---------------- 3 files changed, 26 insertions(+), 17 deletions(-) --- linux-mm.orig/arch/x86/kernel/setup.c 2010-01-22 11:20:33.000000000 +0800 +++ linux-mm/arch/x86/kernel/setup.c 2010-01-22 11:20:37.000000000 +0800 @@ -659,6 +659,23 @@ static struct dmi_system_id __initdata b {} }; +static void __init trim_bios_range(void) +{ + /* + * A special case is the first 4Kb of memory; + * This is a BIOS owned area, not kernel ram, but generally + * not listed as such in the E820 table. + */ + e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED); + /* + * special case: Some BIOSen report the PC BIOS + * area (640->1Mb) as ram even though it is not. + * take them out. + */ + e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1); + sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); +} + /* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -822,7 +839,7 @@ void __init setup_arch(char **cmdline_p) insert_resource(&iomem_resource, &data_resource); insert_resource(&iomem_resource, &bss_resource); - + trim_bios_range(); #ifdef CONFIG_X86_32 if (ppro_with_ram_bug()) { e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM, --- linux-mm.orig/arch/x86/kernel/e820.c 2010-01-22 11:20:33.000000000 +0800 +++ linux-mm/arch/x86/kernel/e820.c 2010-01-22 11:20:37.000000000 +0800 @@ -517,11 +517,19 @@ u64 __init e820_remove_range(u64 start, int checktype) { int i; + u64 end; u64 real_removed_size = 0; if (size > (ULLONG_MAX - start)) size = ULLONG_MAX - start; + end = start + size; + printk(KERN_DEBUG "e820 remove range: %016Lx - %016Lx ", + (unsigned long long) start, + (unsigned long long) end); + e820_print_type(old_type); + printk(KERN_CONT "\n"); + for (i = 0; i < e820.nr_map; i++) { struct e820entry *ei = &e820.map[i]; u64 final_start, final_end; --- linux-mm.orig/arch/x86/mm/ioremap.c 2010-01-22 11:20:33.000000000 +0800 +++ linux-mm/arch/x86/mm/ioremap.c 2010-01-22 11:20:37.000000000 +0800 @@ -29,22 +29,6 @@ int page_is_ram(unsigned long pagenr) resource_size_t addr, end; int i; - /* - * A special case is the first 4Kb of memory; - * This is a BIOS owned area, not kernel ram, but generally - * not listed as such in the E820 table. - */ - if (pagenr == 0) - return 0; - - /* - * Second special case: Some BIOSen report the PC BIOS - * area (640->1Mb) as ram even though it is not. - */ - if (pagenr >= (BIOS_BEGIN >> PAGE_SHIFT) && - pagenr < (BIOS_END >> PAGE_SHIFT)) - return 0; - for (i = 0; i < e820.nr_map; i++) { /* * Not usable memory: ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/3] x86: remove bios data range from e820 2010-01-22 3:21 ` [PATCH 2/3] x86: remove bios data range from e820 Wu Fengguang @ 2010-01-22 4:06 ` Wu Fengguang 2010-01-27 0:32 ` Andrew Morton 2010-02-02 1:01 ` [tip:x86/mm] x86: Remove BIOS " tip-bot for Yinghai Lu 2 siblings, 0 replies; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 4:06 UTC (permalink / raw) To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin Cc: Andrew Morton, Yinghai Lu, x86@kernel.org, LKML, Andi Kleen, Zheng, Shaohui, KAMEZAWA Hiroyuki On Thu, Jan 21, 2010 at 07:21:04PM -0800, Wu, Fengguang wrote: > From: Yinghai Lu <yinghai@kernel.org> > > To prepare move page_is_ram() as generic one. Yinghai, The following two chunks cannot apply because the lines they remove don't exist in linux-next. Because this patchset is targeted for 2.6.34, I just remove the chunks. =================================================================== --- linux-2.6.orig/arch/x86/kernel/head32.c +++ linux-2.6/arch/x86/kernel/head32.c @@ -29,8 +29,6 @@ static void __init i386_default_early_se void __init i386_start_kernel(void) { - reserve_early_overlap_ok(0, PAGE_SIZE, "BIOS data page"); - #ifdef CONFIG_X86_TRAMPOLINE /* * But first pinch a few for the stack/trampoline stuff Index: linux-2.6/arch/x86/kernel/head64.c =================================================================== --- linux-2.6.orig/arch/x86/kernel/head64.c +++ linux-2.6/arch/x86/kernel/head64.c @@ -98,8 +98,6 @@ void __init x86_64_start_reservations(ch { copy_bootdata(__va(real_mode_data)); - reserve_early_overlap_ok(0, PAGE_SIZE, "BIOS data page"); - reserve_early(__pa_symbol(&_text), __pa_symbol(&__bss_stop), "TEXT DATA BSS"); #ifdef CONFIG_BLK_DEV_INITRD Thanks, Fengguang ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [PATCH 2/3] x86: remove bios data range from e820 2010-01-22 3:21 ` [PATCH 2/3] x86: remove bios data range from e820 Wu Fengguang 2010-01-22 4:06 ` Wu Fengguang @ 2010-01-27 0:32 ` Andrew Morton 2010-02-02 1:01 ` [tip:x86/mm] x86: Remove BIOS " tip-bot for Yinghai Lu 2 siblings, 0 replies; 19+ messages in thread From: Andrew Morton @ 2010-01-27 0:32 UTC (permalink / raw) To: Wu Fengguang Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, Yinghai Lu, x86, LKML, Andi Kleen, shaohui.zheng, KAMEZAWA Hiroyuki On Fri, 22 Jan 2010 11:21:04 +0800 Wu Fengguang <fengguang.wu@intel.com> wrote: > From: Yinghai Lu <yinghai@kernel.org> > > To prepare move page_is_ram() as generic one. > > Tested-by: Wu Fengguang <fengguang.wu@intel.com> > Signed-off-by: Yinghai Lu <yinghai@kernel.org> This should have included Signed-off-by:you, as you were on the patch delivery path. I shall add that. ^ permalink raw reply [flat|nested] 19+ messages in thread
* [tip:x86/mm] x86: Remove BIOS data range from e820 2010-01-22 3:21 ` [PATCH 2/3] x86: remove bios data range from e820 Wu Fengguang 2010-01-22 4:06 ` Wu Fengguang 2010-01-27 0:32 ` Andrew Morton @ 2010-02-02 1:01 ` tip-bot for Yinghai Lu 2 siblings, 0 replies; 19+ messages in thread From: tip-bot for Yinghai Lu @ 2010-02-02 1:01 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, hpa, mingo, yinghai, akpm, tglx, fengguang.wu Commit-ID: 1b5576e69a5fe168c08a159685ac366316ac9bbc Gitweb: http://git.kernel.org/tip/1b5576e69a5fe168c08a159685ac366316ac9bbc Author: Yinghai Lu <yinghai@kernel.org> AuthorDate: Fri, 22 Jan 2010 11:21:04 +0800 Committer: H. Peter Anvin <hpa@zytor.com> CommitDate: Mon, 1 Feb 2010 16:58:17 -0800 x86: Remove BIOS data range from e820 In preparation for moving to the generic page_is_ram(), make explicit what we expect to be reserved and not reserved. Tested-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Yinghai Lu <yinghai@kernel.org> LKML-Reference: <20100122033004.335813103@intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com> --- arch/x86/kernel/e820.c | 8 ++++++++ arch/x86/kernel/setup.c | 19 ++++++++++++++++++- arch/x86/mm/ioremap.c | 16 ---------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index d17d482..230687b 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -517,11 +517,19 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type, int checktype) { int i; + u64 end; u64 real_removed_size = 0; if (size > (ULLONG_MAX - start)) size = ULLONG_MAX - start; + end = start + size; + printk(KERN_DEBUG "e820 remove range: %016Lx - %016Lx ", + (unsigned long long) start, + (unsigned long long) end); + e820_print_type(old_type); + printk(KERN_CONT "\n"); + for (i = 0; i < e820.nr_map; i++) { struct e820entry *ei = &e820.map[i]; u64 final_start, final_end; diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index cdb6a8a..f9b1f4e 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c @@ -650,6 +650,23 @@ static struct dmi_system_id __initdata bad_bios_dmi_table[] = { {} }; +static void __init trim_bios_range(void) +{ + /* + * A special case is the first 4Kb of memory; + * This is a BIOS owned area, not kernel ram, but generally + * not listed as such in the E820 table. + */ + e820_update_range(0, PAGE_SIZE, E820_RAM, E820_RESERVED); + /* + * special case: Some BIOSen report the PC BIOS + * area (640->1Mb) as ram even though it is not. + * take them out. + */ + e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1); + sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); +} + /* * Determine if we were loaded by an EFI loader. If so, then we have also been * passed the efi memmap, systab, etc., so we should use these data structures @@ -813,7 +830,7 @@ void __init setup_arch(char **cmdline_p) insert_resource(&iomem_resource, &data_resource); insert_resource(&iomem_resource, &bss_resource); - + trim_bios_range(); #ifdef CONFIG_X86_32 if (ppro_with_ram_bug()) { e820_update_range(0x70000000ULL, 0x40000ULL, E820_RAM, diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 334e63c..30e068d 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -29,22 +29,6 @@ int page_is_ram(unsigned long pagenr) resource_size_t addr, end; int i; - /* - * A special case is the first 4Kb of memory; - * This is a BIOS owned area, not kernel ram, but generally - * not listed as such in the E820 table. - */ - if (pagenr == 0) - return 0; - - /* - * Second special case: Some BIOSen report the PC BIOS - * area (640->1Mb) as ram even though it is not. - */ - if (pagenr >= (BIOS_BEGIN >> PAGE_SHIFT) && - pagenr < (BIOS_END >> PAGE_SHIFT)) - return 0; - for (i = 0; i < e820.nr_map; i++) { /* * Not usable memory: ^ permalink raw reply related [flat|nested] 19+ messages in thread
* [PATCH 3/3] x86: use the generic page_is_ram() 2010-01-22 3:21 [PATCH 0/3] generic hotplug friendly page_is_ram() Wu Fengguang 2010-01-22 3:21 ` [PATCH 1/3] resources: introduce generic page_is_ram() Wu Fengguang 2010-01-22 3:21 ` [PATCH 2/3] x86: remove bios data range from e820 Wu Fengguang @ 2010-01-22 3:21 ` Wu Fengguang 2010-02-02 1:01 ` [tip:x86/mm] x86: Use " tip-bot for Wu Fengguang 2 siblings, 1 reply; 19+ messages in thread From: Wu Fengguang @ 2010-01-22 3:21 UTC (permalink / raw) To: Thomas Gleixner, Ingo Molnar, H. Peter Anvin Cc: Andrew Morton, Andi Kleen, KAMEZAWA Hiroyuki, Yinghai Lu, Wu Fengguang, x86, LKML, shaohui.zheng [-- Attachment #1: x86-page-is-ram.patch --] [-- Type: text/plain, Size: 1520 bytes --] The generic resource based page_is_ram() works better with memory hotplug/hotremove. So switch the x86 e820map based code to it. CC: Andi Kleen <andi@firstfloor.org> CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> CC: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> --- arch/x86/include/asm/page_types.h | 1 - arch/x86/mm/ioremap.c | 21 --------------------- 2 files changed, 22 deletions(-) --- linux-mm.orig/arch/x86/include/asm/page_types.h 2010-01-22 11:20:29.000000000 +0800 +++ linux-mm/arch/x86/include/asm/page_types.h 2010-01-22 11:20:39.000000000 +0800 @@ -40,7 +40,6 @@ #ifndef __ASSEMBLY__ -extern int page_is_ram(unsigned long pagenr); extern int devmem_is_allowed(unsigned long pagenr); extern unsigned long max_low_pfn_mapped; --- linux-mm.orig/arch/x86/mm/ioremap.c 2010-01-22 11:20:37.000000000 +0800 +++ linux-mm/arch/x86/mm/ioremap.c 2010-01-22 11:20:39.000000000 +0800 @@ -24,27 +24,6 @@ #include "physaddr.h" -int page_is_ram(unsigned long pagenr) -{ - resource_size_t addr, end; - int i; - - for (i = 0; i < e820.nr_map; i++) { - /* - * Not usable memory: - */ - if (e820.map[i].type != E820_RAM) - continue; - addr = (e820.map[i].addr + PAGE_SIZE-1) >> PAGE_SHIFT; - end = (e820.map[i].addr + e820.map[i].size) >> PAGE_SHIFT; - - - if ((pagenr >= addr) && (pagenr < end)) - return 1; - } - return 0; -} - /* * Fix up the linear direct mapping of the kernel to avoid cache attribute * conflicts. ^ permalink raw reply [flat|nested] 19+ messages in thread
* [tip:x86/mm] x86: Use the generic page_is_ram() 2010-01-22 3:21 ` [PATCH 3/3] x86: use the generic page_is_ram() Wu Fengguang @ 2010-02-02 1:01 ` tip-bot for Wu Fengguang 0 siblings, 0 replies; 19+ messages in thread From: tip-bot for Wu Fengguang @ 2010-02-02 1:01 UTC (permalink / raw) To: linux-tip-commits Cc: linux-kernel, hpa, mingo, yinghai, andi, akpm, tglx, fengguang.wu, kamezawa.hiroyu Commit-ID: 13ca0fcaa33f6b1984c4111b6ec5df42689fea6f Gitweb: http://git.kernel.org/tip/13ca0fcaa33f6b1984c4111b6ec5df42689fea6f Author: Wu Fengguang <fengguang.wu@intel.com> AuthorDate: Fri, 22 Jan 2010 11:21:05 +0800 Committer: H. Peter Anvin <hpa@zytor.com> CommitDate: Mon, 1 Feb 2010 16:58:17 -0800 x86: Use the generic page_is_ram() The generic resource based page_is_ram() works better with memory hotplug/hotremove. So switch the x86 e820map based code to it. CC: Andi Kleen <andi@firstfloor.org> CC: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> CC: Yinghai Lu <yinghai@kernel.org> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> LKML-Reference: <20100122033004.470767217@intel.com> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: H. Peter Anvin <hpa@zytor.com> --- arch/x86/include/asm/page_types.h | 1 - arch/x86/mm/ioremap.c | 21 --------------------- 2 files changed, 0 insertions(+), 22 deletions(-) diff --git a/arch/x86/include/asm/page_types.h b/arch/x86/include/asm/page_types.h index 642fe34..a667f24 100644 --- a/arch/x86/include/asm/page_types.h +++ b/arch/x86/include/asm/page_types.h @@ -40,7 +40,6 @@ #ifndef __ASSEMBLY__ -extern int page_is_ram(unsigned long pagenr); extern int devmem_is_allowed(unsigned long pagenr); extern unsigned long max_low_pfn_mapped; diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c index 30e068d..1bf9e08 100644 --- a/arch/x86/mm/ioremap.c +++ b/arch/x86/mm/ioremap.c @@ -24,27 +24,6 @@ #include "physaddr.h" -int page_is_ram(unsigned long pagenr) -{ - resource_size_t addr, end; - int i; - - for (i = 0; i < e820.nr_map; i++) { - /* - * Not usable memory: - */ - if (e820.map[i].type != E820_RAM) - continue; - addr = (e820.map[i].addr + PAGE_SIZE-1) >> PAGE_SHIFT; - end = (e820.map[i].addr + e820.map[i].size) >> PAGE_SHIFT; - - - if ((pagenr >= addr) && (pagenr < end)) - return 1; - } - return 0; -} - /* * Fix up the linear direct mapping of the kernel to avoid cache attribute * conflicts. ^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2010-02-02 1:02 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-01-22 3:21 [PATCH 0/3] generic hotplug friendly page_is_ram() Wu Fengguang 2010-01-22 3:21 ` [PATCH 1/3] resources: introduce generic page_is_ram() Wu Fengguang 2010-01-22 4:10 ` KAMEZAWA Hiroyuki 2010-01-22 4:20 ` [PATCH 1/3 v3] " Wu Fengguang 2010-01-22 5:15 ` [PATCH 1/3] " Xiaotian Feng 2010-01-22 5:37 ` Wu Fengguang 2010-01-22 5:50 ` Xiaotian Feng 2010-01-22 5:52 ` Wu Fengguang 2010-01-22 7:51 ` H. Peter Anvin 2010-01-22 8:16 ` [PATCH 1/3 v4] " Wu Fengguang 2010-01-27 0:30 ` Andrew Morton 2010-01-27 3:06 ` Wu Fengguang 2010-02-02 1:01 ` [tip:x86/mm] Move page_is_ram() declaration to mm.h tip-bot for Wu Fengguang 2010-01-22 3:21 ` [PATCH 2/3] x86: remove bios data range from e820 Wu Fengguang 2010-01-22 4:06 ` Wu Fengguang 2010-01-27 0:32 ` Andrew Morton 2010-02-02 1:01 ` [tip:x86/mm] x86: Remove BIOS " tip-bot for Yinghai Lu 2010-01-22 3:21 ` [PATCH 3/3] x86: use the generic page_is_ram() Wu Fengguang 2010-02-02 1:01 ` [tip:x86/mm] x86: Use " tip-bot for Wu Fengguang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox