public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Gu Zheng <guz.fnst@cn.fujitsu.com>
Cc: bpm@sgi.com, elder@kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>,
	xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: simplify kmem_{zone_}zalloc
Date: Sat, 2 Nov 2013 07:58:03 +1100	[thread overview]
Message-ID: <20131101205803.GQ4446@dastard> (raw)
In-Reply-To: <52738187.1000807@cn.fujitsu.com>

On Fri, Nov 01, 2013 at 06:25:11PM +0800, Gu Zheng wrote:
> Introduce flag KM_ZERO which is used to alloc zeroed entry, and convert
> kmem_{zone_}zalloc to call kmem_{zone_}alloc() with KM_ZERO directly,
> in order to avoid the setting to zero step.
> 
> 
> Signed-off-by: Gu Zheng <guz.fnst@cn.fujitsu.com>
> ---
>  fs/xfs/kmem.c |   14 ++------------
>  fs/xfs/kmem.h |    7 ++++++-
>  2 files changed, 8 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/xfs/kmem.c b/fs/xfs/kmem.c
> index a02cfb9..d56fcc9 100644
> --- a/fs/xfs/kmem.c
> +++ b/fs/xfs/kmem.c
> @@ -65,12 +65,7 @@ kmem_alloc(size_t size, xfs_km_flags_t flags)
>  void *
>  kmem_zalloc(size_t size, xfs_km_flags_t flags)
>  {
> -	void	*ptr;
> -
> -	ptr = kmem_alloc(size, flags);
> -	if (ptr)
> -		memset((char *)ptr, 0, (int)size);
> -	return ptr;
> +	return kmem_alloc(size, flags | KM_ZERO);
>  }
>  
>  void *
> @@ -132,10 +127,5 @@ kmem_zone_alloc(kmem_zone_t *zone, xfs_km_flags_t flags)
>  void *
>  kmem_zone_zalloc(kmem_zone_t *zone, xfs_km_flags_t flags)
>  {
> -	void	*ptr;
> -
> -	ptr = kmem_zone_alloc(zone, flags);
> -	if (ptr)
> -		memset((char *)ptr, 0, kmem_cache_size(zone));
> -	return ptr;
> +	return kmem_zone_alloc(zone, flags | KM_ZERO);
>  }

These functions should be made static inline functions in kmem.h
seeing as they are now just a simple wrapper.

Otherwise it's a nice cleanup.

Cheers,

Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2013-11-01 20:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-01 10:25 [PATCH] xfs: simplify kmem_{zone_}zalloc Gu Zheng
2013-11-01 20:58 ` Dave Chinner [this message]
2013-11-04  2:26   ` Gu Zheng

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=20131101205803.GQ4446@dastard \
    --to=david@fromorbit.com \
    --cc=bpm@sgi.com \
    --cc=elder@kernel.org \
    --cc=guz.fnst@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox