Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1227377 > unrolled thread

Re: [PATCH v9 2/5] genalloc:support allocating specific region

Started byScott Wood <scottwood@freescale.com>
First post2015-09-17 22:20 +0200
Last post2015-09-17 22:30 +0200
Articles 2 — 1 participant

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v9 2/5] genalloc:support allocating specific region Scott Wood <scottwood@freescale.com> - 2015-09-17 22:20 +0200
    Re: [PATCH v9 2/5] genalloc:support allocating specific region Scott Wood <scottwood@freescale.com> - 2015-09-17 22:30 +0200

#1227377 — Re: [PATCH v9 2/5] genalloc:support allocating specific region

FromScott Wood <scottwood@freescale.com>
Date2015-09-17 22:20 +0200
SubjectRe: [PATCH v9 2/5] genalloc:support allocating specific region
Message-ID<q9NOV-5WE-3@gated-at.bofh.it>
On Mon, 2015-09-14 at 09:38 +0800, Zhao Qiang wrote:
> Add new algo for genalloc, it reserve a specific region of
> memory matching the size requirement (no alignment constraint)
> 
> Signed-off-by: Zhao Qiang <qiang.zhao@freescale.com>
> ---
> Changes for v9:
>       - reserve a specific region, if the return region
>       - is not during the specific region, return fail.
> 
>  include/linux/genalloc.h | 11 +++++++++++
>  lib/genalloc.c           | 30 ++++++++++++++++++++++++++++++
>  2 files changed, 41 insertions(+)
> 
> diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
> index aaf3dc2..85e3b2f 100644
> --- a/include/linux/genalloc.h
> +++ b/include/linux/genalloc.h
> @@ -82,6 +82,13 @@ struct genpool_data_align {
>       int align;              /* alignment by bytes for starting address */
>  };
>  
> +/*
> + *  gen_pool data descriptor for gen_pool_fixed_fit.
> + */
> +struct genpool_data_fixed {
> +     unsigned long offset;           /* The offset of the specific region */
> +};
> +
>  extern struct gen_pool *gen_pool_create(int, int);
>  extern phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned 
> long);
>  extern int gen_pool_add_virt(struct gen_pool *, unsigned long, phys_addr_t,
> @@ -121,6 +128,10 @@ extern unsigned long gen_pool_first_fit(unsigned long 
> *map, unsigned long size,
>               unsigned long start, unsigned int nr, void *data,
>               struct gen_pool *pool);
>  
> +extern unsigned long gen_pool_fixed_fit(unsigned long *map,
> +             unsigned long size, unsigned long start, unsigned int nr,
> +             void *data, struct gen_pool *pool);
> +

"fixed fit" doesn't make much sense...  How about "fixed_alloc"?

 /**
> + * gen_pool_fixed_fit - reserve a specific region of
> + * matching the size requirement (no alignment constraint)
> + * @map: The address to base the search on
> + * @size: The bitmap size in bits
> + * @start: The bitnumber to start searching at
> + * @nr: The number of zeroed bits we're looking for
> + * @data: data for alignment
> + * @pool: pool to get order from
> + */
> +unsigned long gen_pool_fixed_fit(unsigned long *map, unsigned long size,
> +             unsigned long start, unsigned int nr, void *data,
> +             struct gen_pool *pool)
> +{
> +     struct genpool_data_fixed *fixed_data;
> +     int order;
> +     unsigned long offset_bit;
> +     unsigned long start_bit;
> +
> +     fixed_data = data;
> +     order = pool->min_alloc_order;
> +     offset_bit = fixed_data->offset >> order;
> +     start_bit = bitmap_find_next_zero_area(map, size,
> +                     start + offset_bit, nr, 0);
> +     if (start_bit != offset_bit)
> +             start_bit = size;
> +     return start_bit;
> +}
> +EXPORT_SYMBOL(gen_pool_fixed_fit);

This would be simpler with bitmap_allocate_region().

-Scott

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

[toc] | [next] | [standalone]


#1227379

FromScott Wood <scottwood@freescale.com>
Date2015-09-17 22:30 +0200
Message-ID<q9NYD-68Q-33@gated-at.bofh.it>
In reply to#1227377
On Thu, 2015-09-17 at 15:19 -0500, Scott Wood wrote:
> On Mon, 2015-09-14 at 09:38 +0800, Zhao Qiang wrote:
> > Add new algo for genalloc, it reserve a specific region of
> > memory matching the size requirement (no alignment constraint)
> > 
> > Signed-off-by: Zhao Qiang <qiang.zhao@freescale.com>
> > ---
> > Changes for v9:
> >       - reserve a specific region, if the return region
> >       - is not during the specific region, return fail.
> > 
> >  include/linux/genalloc.h | 11 +++++++++++
> >  lib/genalloc.c           | 30 ++++++++++++++++++++++++++++++
> >  2 files changed, 41 insertions(+)
> > 
> > diff --git a/include/linux/genalloc.h b/include/linux/genalloc.h
> > index aaf3dc2..85e3b2f 100644
> > --- a/include/linux/genalloc.h
> > +++ b/include/linux/genalloc.h
> > @@ -82,6 +82,13 @@ struct genpool_data_align {
> >       int align;              /* alignment by bytes for starting address 
> > */
> >  };
> >  
> > +/*
> > + *  gen_pool data descriptor for gen_pool_fixed_fit.
> > + */
> > +struct genpool_data_fixed {
> > +     unsigned long offset;           /* The offset of the specific 
> > region */
> > +};
> > +
> >  extern struct gen_pool *gen_pool_create(int, int);
> >  extern phys_addr_t gen_pool_virt_to_phys(struct gen_pool *pool, unsigned 
> > long);
> >  extern int gen_pool_add_virt(struct gen_pool *, unsigned long, 
> > phys_addr_t,
> > @@ -121,6 +128,10 @@ extern unsigned long gen_pool_first_fit(unsigned 
> > long 
> > *map, unsigned long size,
> >               unsigned long start, unsigned int nr, void *data,
> >               struct gen_pool *pool);
> >  
> > +extern unsigned long gen_pool_fixed_fit(unsigned long *map,
> > +             unsigned long size, unsigned long start, unsigned int nr,
> > +             void *data, struct gen_pool *pool);
> > +
> 
> "fixed fit" doesn't make much sense...  How about "fixed_alloc"?
> 
>  /**
> > + * gen_pool_fixed_fit - reserve a specific region of
> > + * matching the size requirement (no alignment constraint)
> > + * @map: The address to base the search on
> > + * @size: The bitmap size in bits
> > + * @start: The bitnumber to start searching at
> > + * @nr: The number of zeroed bits we're looking for
> > + * @data: data for alignment
> > + * @pool: pool to get order from
> > + */
> > +unsigned long gen_pool_fixed_fit(unsigned long *map, unsigned long size,
> > +             unsigned long start, unsigned int nr, void *data,
> > +             struct gen_pool *pool)
> > +{
> > +     struct genpool_data_fixed *fixed_data;
> > +     int order;
> > +     unsigned long offset_bit;
> > +     unsigned long start_bit;
> > +
> > +     fixed_data = data;
> > +     order = pool->min_alloc_order;
> > +     offset_bit = fixed_data->offset >> order;
> > +     start_bit = bitmap_find_next_zero_area(map, size,
> > +                     start + offset_bit, nr, 0);
> > +     if (start_bit != offset_bit)
> > +             start_bit = size;
> > +     return start_bit;
> > +}
> > +EXPORT_SYMBOL(gen_pool_fixed_fit);
> 
> This would be simpler with bitmap_allocate_region().

Never mind, that doesn't fit with how the algorithm is used by the caller, 
and unlike genalloc isn't atomic.

-Scott

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web