All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcin Slusarz <marcin.slusarz@gmail.com>
To: ngupta@vflare.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Christoph Lameter <cl@linux-foundation.org>,
	Pekka Enberg <penberg@cs.helsinki.fi>, Ed Tomlinson <edt@aei.ca>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/3] xvmalloc memory allocator
Date: Sun, 29 Mar 2009 12:39:54 +0200	[thread overview]
Message-ID: <49CF4FFA.8090904@gmail.com> (raw)
In-Reply-To: <49CEEF30.9060202@vflare.org>

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);
> +

  reply	other threads:[~2009-03-29 10:40 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-29  3:43 [PATCH 0/3] compressed in-memory swapping take4 Nitin Gupta
2009-03-29  3:46 ` [PATCH 1/3] xvmalloc memory allocator Nitin Gupta
2009-03-29 10:39   ` Marcin Slusarz [this message]
2009-03-29 11:23     ` Nitin Gupta
2009-03-29  3:51 ` [PATCH 2/3] ramzswap virtual block device Nitin Gupta
2009-03-29  3:53 ` [PATCH 3/3] ramzswap documentation Nitin Gupta
  -- strict thread matches above, loose matches on Subject: below --
2009-09-22  4:56 [PATCH 0/3] compcache: in-memory compressed swapping v4 Nitin Gupta
2009-09-22  4:56 ` [PATCH 1/3] xvmalloc memory allocator Nitin Gupta
2009-09-22  4:56   ` Nitin Gupta
2009-03-30 14:48 [PATCH 0/3] compressed in-memory swapping take5 Nitin Gupta
2009-03-30 14:50 ` [PATCH 1/3] xvmalloc memory allocator Nitin Gupta
2009-03-24 19:01 [PATCH 0/3] compressed in-memory swapping take3 Nitin Gupta
2009-03-24 19:11 ` [PATCH 1/3] xvmalloc memory allocator Nitin Gupta

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49CF4FFA.8090904@gmail.com \
    --to=marcin.slusarz@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=cl@linux-foundation.org \
    --cc=edt@aei.ca \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ngupta@vflare.org \
    --cc=penberg@cs.helsinki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.