[openib-general] [PATCH v3 3/3] ofed_1_2 Provide generic allocator backport to 2.6.20.
Michael S. Tsirkin
mst at mellanox.co.il
Sat Jan 13 13:13:57 PST 2007
> Quoting Steve Wise <swise at opengridcomputing.com>:
> Subject: [PATCH v3 3/3] ofed_1_2 Provide generic allocator backport to 2.6.20.
>
>
> This is needed even on kernels that might have genalloc because it
> may not be configured into the running kernel. Right now the only
> subsystem that turns on the generic allocator config option is IA64.
> So chances are good that 2.6.20 kernels will _not_ have this compiled in.
> So we just backport it to all supported kernels.
>
> To avoid collisions with kernels that _do_ have this compiled in,
> change the names of the exported symbols in the backport.
>
> Changes to genalloc.c:
>
> - Change exported symbol names by prepending ib_
> EG: gen_pool_alloc() becomes ib_gen_pool_alloc()
>
> Changes to genalloc.h:
>
> - Change exported symbol names by prepending ib_
> - added #defines for original exported symbol names to new names. Thus
> code calling the allocator doesn't need to change.
>
> EG: #define gen_pool_alloc ib_gen_pool alloc
>
> Signed-off-by: Steve Wise <swise at opengridcomputing.com>
> ---
>
> .../backport/2.6.20/include/linux/genalloc.h | 42 +++++
> .../backport/2.6.20/include/src/genalloc.c | 198 +++++++++++++++++++++++
> .../backport/2.6.20/linux_genalloc_to_2.6.20.patch | 18 ++
> 3 files changed, 258 insertions(+), 0 deletions(-)
>
> diff --git a/kernel_addons/backport/2.6.20/include/linux/genalloc.h b/kernel_addons/backport/2.6.20/include/linux/genalloc.h
> new file mode 100644
> index 0000000..3c23c68
> --- /dev/null
> +++ b/kernel_addons/backport/2.6.20/include/linux/genalloc.h
> @@ -0,0 +1,42 @@
> +/*
> + * Basic general purpose allocator for managing special purpose memory
> + * not managed by the regular kmalloc/kfree interface.
> + * Uses for this includes on-device special memory, uncached memory
> + * etc.
> + *
> + * This source code is licensed under the GNU General Public License,
> + * Version 2. See the file COPYING for more details.
> + */
> +
> +
> +/*
> + * General purpose special memory pool descriptor.
> + */
> +struct gen_pool {
> + rwlock_t lock;
> + struct list_head chunks; /* list of chunks in this pool */
> + int min_alloc_order; /* minimum allocation order */
> +};
> +
> +/*
> + * General purpose special memory pool chunk descriptor.
> + */
> +struct gen_pool_chunk {
> + spinlock_t lock;
> + struct list_head next_chunk; /* next chunk in pool */
> + unsigned long start_addr; /* starting address of memory chunk */
> + unsigned long end_addr; /* ending address of memory chunk */
> + unsigned long bits[0]; /* bitmap for allocating memory chunk */
> +};
> +
> +extern struct gen_pool *ib_gen_pool_create(int, int);
If you think about it, by virtue of the defines above, genalloc.c
can be included without change. Correct?
--
MST
More information about the general
mailing list