[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20140827161854.0619a04653b336d3adc755f3@linux-foundation.org>
Date: Wed, 27 Aug 2014 16:18:54 -0700
From: Andrew Morton <akpm@...ux-foundation.org>
To: Mike Travis <travis@....com>
Cc: mingo@...hat.com, tglx@...utronix.de, hpa@...or.com,
msalter@...hat.com, dyoung@...hat.com, riel@...hat.com,
peterz@...radead.org, mgorman@...e.de,
linux-kernel@...r.kernel.org, x86@...nel.org, linux-mm@...ck.org,
Alex Thorlton <athorlton@....com>
Subject: Re: [PATCH 1/2] x86: Optimize resource lookups for ioremap
On Wed, 27 Aug 2014 16:09:09 -0700 Mike Travis <travis@....com> wrote:
>
> >>
> >> ...
> >>
> >> --- linux.orig/kernel/resource.c
> >> +++ linux/kernel/resource.c
> >> @@ -494,6 +494,43 @@ int __weak page_is_ram(unsigned long pfn
> >> }
> >> EXPORT_SYMBOL_GPL(page_is_ram);
> >>
> >> +/*
> >> + * Search for a resouce entry that fully contains the specified region.
> >> + * If found, return 1 if it is RAM, 0 if not.
> >> + * If not found, or region is not fully contained, return -1
> >> + *
> >> + * Used by the ioremap functions to insure user not remapping RAM and is as
> >> + * vast speed up over walking through the resource table page by page.
> >> + */
> >> +int __weak region_is_ram(resource_size_t start, unsigned long size)
> >> +{
> >> + struct resource *p;
> >> + resource_size_t end = start + size - 1;
> >> + int flags = IORESOURCE_MEM | IORESOURCE_BUSY;
> >> + const char *name = "System RAM";
> >> + int ret = -1;
> >> +
> >> + read_lock(&resource_lock);
> >> + for (p = iomem_resource.child; p ; p = p->sibling) {
> >> + if (end < p->start)
> >> + continue;
> >> +
> >> + if (p->start <= start && end <= p->end) {
> >> + /* resource fully contains region */
> >> + if ((p->flags != flags) || strcmp(p->name, name))
> >> + ret = 0;
> >> + else
> >> + ret = 1;
> >> + break;
> >> + }
> >> + if (p->end < start)
> >> + break; /* not found */
> >> + }
> >> + read_unlock(&resource_lock);
> >> + return ret;
> >> +}
> >> +EXPORT_SYMBOL_GPL(region_is_ram);
> >
> > Exporting a __weak symbol is strange. I guess it works, but neither
> > the __weak nor the export are actually needed?
> >
>
> I mainly used 'weak' and export because that was what the page_is_ram
> function was using. Most likely this won't be used anywhere else but
> I wasn't sure. I can certainly remove the weak and export, at least
> until it's actually needed?
Several architectures implement custom page_is_ram(), so they need the
__weak. region_is_ram() needs neither so yes, they should be removed.
<looks at the code>
Doing strcmp("System RAM") is rather a hack. Is there nothing in
resource.flags which can be used? Or added otherwise?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists