[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <49CF4FFA.8090904@gmail.com>
Date: Sun, 29 Mar 2009 12:39:54 +0200
From: Marcin Slusarz <marcin.slusarz@...il.com>
To: ngupta@...are.org
CC: Andrew Morton <akpm@...ux-foundation.org>,
Christoph Lameter <cl@...ux-foundation.org>,
Pekka Enberg <penberg@...helsinki.fi>,
Ed Tomlinson <edt@....ca>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/3] xvmalloc memory allocator
Nitin Gupta wrote:
> +static void stat_inc(u64 *value)
> +{
> + (*value)++;
> +}
> +
> +static void stat_dec(u64 *value)
> +{
> + (*value)--;
> +}
Why not open code it?
> +
> +static u32 test_flag(struct block_header *block, enum blockflags flag)
> +{
> + return block->prev & (1 << flag);
> +}
> +
> +static void set_flag(struct block_header *block, enum blockflags flag)
> +{
> + block->prev |= (1 << flag);
> +}
> +
> +static void clear_flag(struct block_header *block, enum blockflags flag)
> +{
> + block->prev &= ~(1 << flag);
> +}
Why don't you use test_bit / __set_bit / __clear_bit directly?
> +struct xv_pool *xv_create_pool(void)
> +{
> + int i;
> + u32 ovhd_size;
> + struct xv_pool *pool;
> +
> + ovhd_size = roundup(sizeof(*pool), PAGE_SIZE);
> + pool = kmalloc(ovhd_size, GFP_KERNEL);
> + if (!pool)
> + return NULL;
> +
> + memset(pool, 0, ovhd_size);
Please use kzalloc.
> +
> + for (i = 0; i < NUM_FREE_LISTS; i++) {
> + pool->freelist[i].pagenum = 0;
> + pool->freelist[i].offset = 0;
> + }
It was already zeroed by memset.
> +
> + spin_lock_init(&pool->lock);
> +
> + return pool;
> +}
> +EXPORT_SYMBOL_GPL(xv_create_pool);
> +
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists