Re: [PATCH] change gen_pool allocator to not touch managed memory

From: Jesper Juhl
Date: Wed Apr 26 2006 - 06:27:46 EST


On 4/25/06, Dean Nelson <dcn@xxxxxxx> wrote:
> The following patch modifies the gen_pool allocator (lib/genalloc.c) to
> utilize a bitmap scheme instead of the buddy scheme. The purpose of this
> change is to eliminate the touching of the actual memory being allocated.
>
> Since the change modifies the interface, a change to the uncached
> allocator (arch/ia64/kernel/uncached.c) is also required.
>
[snip]

A few small comments below.

> -unsigned long gen_pool_alloc(struct gen_pool *poolp, int size)
> +int gen_pool_add(struct gen_pool *pool, unsigned long addr, size_t size,
> + int nid)
> {
> - int j, i, s, max_chunk_size;
> - unsigned long a, flags;
> - struct gen_pool_link *h = poolp->h;
> + struct gen_pool_chunk *chunk;
> + int nbits = size >> pool->min_alloc_order;
> + int nbytes = sizeof(struct gen_pool_chunk) +
> + (nbits + BITS_PER_BYTE - 1) / BITS_PER_BYTE;
> +
> + if (nbytes > PAGE_SIZE) {
> + chunk = vmalloc_node(nbytes, nid);
> + } else {
> + chunk = kmalloc_node(nbytes, GFP_KERNEL, nid);
> + }

No curly braces when not needed is usually prefered.

if (nbytes > PAGE_SIZE)
chunk = vmalloc_node(nbytes, nid);
else
chunk = kmalloc_node(nbytes, GFP_KERNEL, nid);


> +static int
> +uncached_add_chunk(struct gen_pool *pool, int nid)

Why not

+static int uncached_add_chunk(struct gen_pool *pool, int nid)

There's room for it on one line and other functions in that file use
just one line (more grep'able)...


> void
> -uncached_free_page(unsigned long maddr)
> +uncached_free_page(unsigned long uc_addr)

Move this to a single line perhaps?

+void uncached_free_page(unsigned long uc_addr)


> +static int __init
> +uncached_init(void)

One line ?


--
Jesper Juhl <jesper.juhl@xxxxxxxxx>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/