lkml.org 
[lkml]   [2010]   [May]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 21/25] lmb: Add "start" argument to lmb_find_base()
From
On Mon, May 10, 2010 at 2:38 AM, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> To constraint the search of a region between two boundaries,
> which will be used by the new NUMA aware allocator among others.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  lib/lmb.c |   27 ++++++++++++++++-----------
>  1 files changed, 16 insertions(+), 11 deletions(-)
>
> diff --git a/lib/lmb.c b/lib/lmb.c
> index 84ac3a9..848f908 100644
> --- a/lib/lmb.c
> +++ b/lib/lmb.c
> @@ -117,19 +117,18 @@ static phys_addr_t __init lmb_find_region(phys_addr_t start, phys_addr_t end,
>        return LMB_ERROR;
>  }
>
> -static phys_addr_t __init lmb_find_base(phys_addr_t size, phys_addr_t align, phys_addr_t max_addr)
> +static phys_addr_t __init lmb_find_base(phys_addr_t size, phys_addr_t align,
> +                                       phys_addr_t start, phys_addr_t end)
>  {
>        long i;
> -       phys_addr_t base = 0;
> -       phys_addr_t res_base;
>
>        BUG_ON(0 == size);
>
>        size = lmb_align_up(size, align);
>
>        /* Pump up max_addr */
> -       if (max_addr == LMB_ALLOC_ACCESSIBLE)
> -               max_addr = lmb.current_limit;
> +       if (end == LMB_ALLOC_ACCESSIBLE)
> +               end = lmb.current_limit;
>
>        /* We do a top-down search, this tends to limit memory
>         * fragmentation by keeping early boot allocs near the
> @@ -138,13 +137,19 @@ static phys_addr_t __init lmb_find_base(phys_addr_t size, phys_addr_t align, phy
>        for (i = lmb.memory.cnt - 1; i >= 0; i--) {
>                phys_addr_t lmbbase = lmb.memory.regions[i].base;
>                phys_addr_t lmbsize = lmb.memory.regions[i].size;
> +               phys_addr_t bottom, top, found;
>
>                if (lmbsize < size)
>                        continue;
> -               base = min(lmbbase + lmbsize, max_addr);
> -               res_base = lmb_find_region(lmbbase, base, size, align);
> -               if (res_base != LMB_ERROR)
> -                       return res_base;
> +               if ((lmbbase + lmbsize) <= start)
> +                       break;
> +               bottom = max(lmbbase, start);
> +               top = min(lmbbase + lmbsize, end);
> +               if (bottom >= top)
> +                       continue;
> +               found = lmb_find_region(lmbbase, top, size, align);
^^^^^^^^^
should use bottom here

YH
--
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/

\
 
 \ /
  Last update: 2010-05-12 10:17    [W:0.199 / U:0.268 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site