public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Denis Vlasenko <vda@ilport.com.ua>
To: Christoph Lameter <clameter@engr.sgi.com>
Cc: akpm@osdl.org, Nick Piggin <nickpiggin@yahoo.com.au>,
	"David S. Miller" <davem@davemloft.net>,
	ioe-lkml@rameria.dem, linux-kernel@vger.kernel.org
Subject: Re: Make kzalloc a macro
Date: Sat, 24 Sep 2005 13:52:54 +0300	[thread overview]
Message-ID: <200509241352.54426.vda@ilport.com.ua> (raw)
In-Reply-To: <Pine.LNX.4.62.0509230857190.22086@schroedinger.engr.sgi.com>

On Friday 23 September 2005 18:58, Christoph Lameter wrote:
> How about this patch making kzalloc a macro?
> 
> ---
> 
> Make kzalloc a macro and use __GFP_ZERO for zeroed slab allocations
> 
> kzalloc is right now a function call. The optimization that the kmalloc macro
> provides does not work for kzalloc invocations. kmalloc also determines the
> slab to use at compile time and fails the compilation if the size is too big.
> kzalloc cannot do not.
> 
>  
> -extern void *kzalloc(size_t, unsigned int __nocast);
> +#define kzalloc(__size, __flags) kmalloc(__size, (__flags) | __GFP_ZERO)

Why macro and not an inline function?

> +static inline void *obj_checkout(kmem_cache_t *cachep, unsigned int __nocast flags, void *objp)
> +{
> +	if (likely(objp)) {
> +		objp = cache_alloc_debugcheck_after(cachep, flags, objp,
> +					__builtin_return_address(0));
> +		if (unlikely(flags & __GFP_ZERO))

Why unlikely?

> +			memset(objp, 0, obj_reallen(cachep));
> +		else
> +			prefetchw(objp);
> +	}
> +	return objp;
> +}
--
vda

      parent reply	other threads:[~2005-09-24 10:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-23  6:14 making kmalloc BUG() might not be a good idea David S. Miller
2005-09-23  6:30 ` Nick Piggin
2005-09-23  6:54   ` David S. Miller
2005-09-23  7:09   ` Ingo Oeser
2005-09-23  7:58     ` Nick Piggin
2005-09-23  8:09       ` David S. Miller
2005-09-23  9:03         ` Nick Piggin
2005-09-23  9:17           ` Coywolf Qi Hunt
2005-09-23 15:58             ` Make kzalloc a macro Christoph Lameter
2005-09-23 17:50               ` Christoph Lameter
2005-09-23 22:37                 ` Andrew Morton
2005-09-26 17:38                   ` Christoph Lameter
2005-09-24 10:52               ` Denis Vlasenko [this message]

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=200509241352.54426.vda@ilport.com.ua \
    --to=vda@ilport.com.ua \
    --cc=akpm@osdl.org \
    --cc=clameter@engr.sgi.com \
    --cc=davem@davemloft.net \
    --cc=ioe-lkml@rameria.dem \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nickpiggin@yahoo.com.au \
    /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