Messages in this thread | | | Date | Wed, 22 Jul 2009 15:22:38 +0900 | From | KAMEZAWA Hiroyuki <> | Subject | Re: [PATCH 4/4] kcore: remove noise from walk_memory_resource |
| |
On Wed, 22 Jul 2009 14:21:03 +0800 Amerigo Wang <xiyou.wangcong@gmail.com> wrote:
> On Wed, Jul 22, 2009 at 02:12:27PM +0900, KAMEZAWA Hiroyuki wrote: > >From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > > > >Originally, walk_memory_resource() was introduced to traverse all memory > >of "System RAM" for detecting memory hotplug/unplug range. > >For doing so, flags of IORESOUCE_MEM|IORESOURCE_BUSY was used and this > >was enough for memory hotplug because scanning range was controlled properly. > > > >But for using other purpose, /proc/kcore, this may includes some firmware > >area marked as IORESOURCE_BUSY | IORESOUCE_MEM. This patch makes the check > >strict to find out busy "System RAM". > > > >Note: PPC64 keeps their own walk_memory_resouce(), which walk through > >ppc64's lmb informaton. Because old kclist_add() is called per lmb, > >this patch makes no difference in behavior, finally. > > > >Changelog v2: > > - new patch from v2. > > > >Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> > >--- > > kernel/resource.c | 18 ++++++++++++++---- > > 1 file changed, 14 insertions(+), 4 deletions(-) > > > >Index: mmotm-2.6.31-Jul16/kernel/resource.c > >=================================================================== > >--- mmotm-2.6.31-Jul16.orig/kernel/resource.c > >+++ mmotm-2.6.31-Jul16/kernel/resource.c > >@@ -237,10 +237,10 @@ EXPORT_SYMBOL(release_resource); > > #if !defined(CONFIG_ARCH_HAS_WALK_MEMORY) > > /* > > * Finds the lowest memory reosurce exists within [res->start.res->end) > >- * the caller must specify res->start, res->end, res->flags. > >+ * the caller must specify res->start, res->end, res->flags and "name". > > * If found, returns 0, res is overwritten, if not found, returns -1. > > */ > >-static int find_next_system_ram(struct resource *res) > >+static int find_next_system_ram(struct resource *res, char *name) > > { > > resource_size_t start, end; > > struct resource *p; > >@@ -256,6 +256,8 @@ static int find_next_system_ram(struct r > > /* system ram is just marked as IORESOURCE_MEM */ > > if (p->flags != res->flags) > > continue; > >+ if (name && strcmp(p->name, name)) > >+ continue; > > if (p->start > end) { > > p = NULL; > > break; > >@@ -273,19 +275,27 @@ static int find_next_system_ram(struct r > > res->end = p->end; > > return 0; > > } > >+ > >+/* > >+ * This function calls callback against all memory range of "System RAM" > >+ * which are marked as IORESOURCE_MEM and IORESOUCE_BUSY. > >+ * Now, this function is only for "System RAM". > > > Then we should change its name, shouldn't we? :) > I tried, but not changed in this version bacause the usage/purpose is not changed.
Hmm, How about walk_system_ram_range() ?
> >+ */ > > int > > walk_memory_resource(unsigned long start_pfn, unsigned long nr_pages, void *arg, > >- int (*func)(unsigned long, unsigned long, void *)) > >+ int (*func)(unsigned long, unsigned long, void *)) > > > This line is a trivial change, I don't want to see it mixed with > the rest... Sorry, this was from a trial I tried to change the name ;) I'll remove this.
I'll post v3 but wait for a day to hear other comments.
Thank you for review.
Regards, -Kame
> > > > { > > struct resource res; > > unsigned long pfn, len; > > u64 orig_end; > > int ret = -1; > >+ > > res.start = (u64) start_pfn << PAGE_SHIFT; > > res.end = ((u64)(start_pfn + nr_pages) << PAGE_SHIFT) - 1; > > res.flags = IORESOURCE_MEM | IORESOURCE_BUSY; > > orig_end = res.end; > >- while ((res.start < res.end) && (find_next_system_ram(&res) >= 0)) { > >+ while ((res.start < res.end) && > >+ (find_next_system_ram(&res, "System RAM") >= 0)) { > > pfn = (unsigned long)(res.start >> PAGE_SHIFT); > > len = (unsigned long)((res.end + 1 - res.start) >> PAGE_SHIFT); > > ret = (*func)(pfn, len, arg); > > > >-- > >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/ >
| |