Re: [RFC][PATCH 2/3] find a contiguous range.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, 17 Oct 2010 12:18:48 +0900
Minchan Kim <minchan.kim@xxxxxxxxx> wrote:

> Hi Kame,
> Sorry for the late review.
> 
> On Wed, Oct 13, 2010 at 12:17 PM, KAMEZAWA Hiroyuki
> <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:
> > From: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> >
> > Unlike memory hotplug, at an allocation of contigous memory range, address
> > may not be a problem. IOW, if a requester of memory wants to allocate 100M of
> > of contigous memory, placement of allocated memory may not be a problem.
> > So, "finding a range of memory which seems to be MOVABLE" is required.
> >
> > This patch adds a functon to isolate a length of memory within [start, end).
> 
> Typo
> function
> 
> > This function returns a pfn which is 1st page of isolated contigous chunk
> 
> Typo
> contiguous
> 
I'll use aspell...


> > of given length within [start, end).
> >
> > If no_search=true is passed as argument, start address is always same to
> 
> I don't like no_search argument name. It would be better to show not
> the implement but context.
> How about "bool strict" or "ALLOC_FIXED"?

Hmm, ok. 

> > the specified "base" addresss.
> Typo
> address,
> Let's add following description.
> "Some devices want to bind memory to some memory bank. In this case,
> no_search and base address fix
> can be helpful."

Then, do you need "end" address for search ?


> 
> >
> > After isolation, free memory within this area will never be allocated.
> > But some pages will remain as "Used/LRU" pages. They should be dropped by
> > page reclaim or migration.
> 
> At first I saw the above description, I got confused. How about this?

> After it isolates some pages in the range, the part of some pages are
> freed but others could be used processes now.
> Next patch[3/3] try to move or reclaim used pages by page
> migration/reclaim for obtaining big contiguous page.
> 

will consider some.


> >
> >
> > Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx>
> > ---
> > Âmm/page_isolation.c | Â130 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > Â1 file changed, 130 insertions(+)
> >
> > Index: mmotm-1008/mm/page_isolation.c
> > ===================================================================
> > --- mmotm-1008.orig/mm/page_isolation.c
> > +++ mmotm-1008/mm/page_isolation.c
> > @@ -9,6 +9,7 @@
> > Â#include <linux/pageblock-flags.h>
> > Â#include <linux/memcontrol.h>
> > Â#include <linux/migrate.h>
> > +#include <linux/memory_hotplug.h>
> > Â#include <linux/mm_inline.h>
> > Â#include "internal.h"
> >
> > @@ -254,3 +255,132 @@ out:
> > Â Â Â Âreturn ret;
> > Â}
> >
> > +/*
> > + * Functions for getting contiguous MOVABLE pages in a zone.
> > + */
> > +struct page_range {
> > + Â Â Â unsigned long base; /* Base address of searching contigouous block */
> 
> Typo contiguous.
> Please, specify that it's a pfn number.
> 
ok.

> > + Â Â Â unsigned long end;
> > + Â Â Â unsigned long pages;/* Length of contiguous block */
> > +};
> > +
> > +static inline unsigned long ÂMAX_ORDER_ALIGN(unsigned long x)
> > +{
> > + Â Â Â return ALIGN(x, MAX_ORDER_NR_PAGES);
> > +}
> > +
> > +static inline unsigned long MAX_ORDER_BASE(unsigned long x)
> > +{
> > + Â Â Â return x & ~(MAX_ORDER_NR_PAGES - 1);
> > +}
> > +
> > +int __get_contig_block(unsigned long pfn, unsigned long nr_pages, void *arg)
> > +{
> > + Â Â Â struct page_range *blockinfo = arg;
> > + Â Â Â unsigned long end;
> > +
> > + Â Â Â end = pfn + nr_pages;
> > + Â Â Â pfn = MAX_ORDER_ALIGN(pfn);
> > + Â Â Â end = MAX_ORDER_BASE(end);
> > +
> > + Â Â Â if (end < pfn)
> > + Â Â Â Â Â Â Â return 0;
> > + Â Â Â if (end - pfn >= blockinfo->pages) {
> > + Â Â Â Â Â Â Â blockinfo->base = pfn;
> > + Â Â Â Â Â Â Â blockinfo->end = end;
> > + Â Â Â Â Â Â Â return 1;
> > + Â Â Â }
> > + Â Â Â return 0;
> > +}
> > +
> > +static void __trim_zone(struct page_range *range)
> 
> Hmm..
> I think this function name can't present enough meaning.
> Let's move description in body of function to the head.
> 
> /*
>  * In most case, each zone's [start_pfn, end_pfn) has no
>  * overlap between each other. But some arch allows it and
>  * we need to check it here. If it happens, range end is changed
>  * to only include pfns in a zone.
>  */

ok.

> 
> > +{
> > + Â Â Â struct zone *zone;
> > + Â Â Â unsigned long pfn;
> > + Â Â Â /*
> > + Â Â Â Â* In most case, each zone's [start_pfn, end_pfn) has no
> > + Â Â Â Â* overlap between each other. But some arch allows it and
> > + Â Â Â Â* we need to check it here.
> > + Â Â Â Â*/
> > + Â Â Â for (pfn = range->base, zone = page_zone(pfn_to_page(pfn));
> > + Â Â Â Â Â Âpfn < range->end;
> > + Â Â Â Â Â Âpfn += MAX_ORDER_NR_PAGES) {
> > +
> > + Â Â Â Â Â Â Â if (zone != page_zone(pfn_to_page(pfn)))
> > + Â Â Â Â Â Â Â Â Â Â Â break;
> > + Â Â Â }
> > + Â Â Â range->end = min(pfn, range->end);
> > + Â Â Â return;
> 
> Unnecessary return.
> 
will remove.

> > +}
> > +
> > +/*
> > + * This function is for finding a contiguous memory block which has length
> > + * of pages and MOVABLE. If it finds, make the range of pages as ISOLATED
> > + * and return the first page's pfn.
> > + * If no_search==true, this function doesn't scan the range but tries to
> > + * isolate the range of memory.
> > + */
> > +
> > +static unsigned long find_contig_block(unsigned long base,
> > + Â Â Â Â Â Â Â unsigned long end, unsigned long pages, bool no_search)
> > +{
> > + Â Â Â unsigned long pfn, pos;
> > + Â Â Â struct page_range blockinfo;
> > + Â Â Â int ret;
> > +
> > + Â Â Â pages = MAX_ORDER_ALIGN(pages);
> > +retry:
> > + Â Â Â blockinfo.base = base;
> > + Â Â Â blockinfo.end = end;
> > + Â Â Â blockinfo.pages = pages;
> > + Â Â Â /*
> > + Â Â Â Â* At first, check physical page layout and skip memory holes.
> > + Â Â Â Â*/
> > + Â Â Â ret = walk_system_ram_range(base, end - base, &blockinfo,
> > + Â Â Â Â Â Â Â __get_contig_block);
> > + Â Â Â if (!ret)
> > + Â Â Â Â Â Â Â return 0;
> > + Â Â Â /* check contiguous pages in a zone */
> > + Â Â Â __trim_zone(&blockinfo);
> > +
> > +
> > + Â Â Â /* Ok, we found contiguous memory chunk of size. Isolate it.*/
> > + Â Â Â for (pfn = blockinfo.base; pfn + pages < blockinfo.end;
> > + Â Â Â Â Â Âpfn += MAX_ORDER_NR_PAGES) {
> > + Â Â Â Â Â Â Â /* If no_search==true, base addess should be same to 'base' */
> > + Â Â Â Â Â Â Â if (no_search && pfn != base)
> > + Â Â Â Â Â Â Â Â Â Â Â break;
> > + Â Â Â Â Â Â Â /* Better code is necessary here.. */
> > + Â Â Â Â Â Â Â for (pos = pfn; pos < pfn + pages; pos++) {
> > + Â Â Â Â Â Â Â Â Â Â Â struct page *p;
> > +
> > + Â Â Â Â Â Â Â Â Â Â Â if (!pfn_valid_within(pos))
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
> > + Â Â Â Â Â Â Â Â Â Â Â p = pfn_to_page(pos);
> > + Â Â Â Â Â Â Â Â Â Â Â if (PageReserved(p))
> > + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â break;
> > + Â Â Â Â Â Â Â Â Â Â Â /* This may hit a page on per-cpu queue. */
> 
> Couldn't we drain per-cpu queue before this function?
> 
We can't guarantee it on SMP systems because we don't ISOLATE the range
at this point.


Thanks,
-Kame

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]