public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Kirill Korotaev <dev@sw.ru>
To: rae l <crquan@gmail.com>
Cc: trivial@kernel.org, Denis <cr_quan@163.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] replace kmem_cache_alloc with kmem_cache_zalloc to remove some following zero initializations.
Date: Fri, 13 Jul 2007 13:10:43 +0400	[thread overview]
Message-ID: <46974193.2020302@sw.ru> (raw)
In-Reply-To: <91b13c310707130138p6cffd0b4va34eec320d66ab44@mail.gmail.com>

Look, until you have any numbers in hands it's impossible to say
which one is faster.

Please measure N d_alloc()'s on i686 and some other archs w/o string operations
and compare whether your patch improves something or not.

Kirill

rae l wrote:
> On 7/13/07, Kirill Korotaev <dev@sw.ru> wrote:
> 
>>This doesn't look worth zeroing half of the struct
>>when it is initialized to non-zeros then.
> 
> But why?
> 
> My reason to think it's better and faster is that:
> 1. the code will be shorter if it calls zalloc and then removes the
> NULL and zero initilization;
> 2. in the assembly code objdumped, many mov operations reduced, such as:
>     movl $0,0x40(%ebp)
>     ...
>     this style of zero initialization occupies 7 bytes per line
> (i386), and then multiply 7 lines,
> 
> 3. the only change is that calls to kmem_cache_zalloc other than
> kmem_cache_alloc, it's just an extra memset is called, as we all know
> the memset implimentation is string operation, that's rather fast.
> 
> 
>>Denis Cheng wrote:
>>
>>>>From 4d87e14b67890f06885a76b5792ca034de2e9d06 Mon Sep 17 00:00:00 2001
>>>From: Denis Cheng <crquan@gmail.com>
>>>Date: Thu, 12 Jul 2007 11:53:58 +0800
>>>Subject: [PATCH] replace kmem_cache_alloc with kmem_cache_zalloc to
>>>remove some following zero initializations.
>>>
>>>Signed-off-by: Denis Cheng <crquan@gmail.com>
>>>---
>>> fs/dcache.c |   12 ++----------
>>> 1 files changed, 2 insertions(+), 10 deletions(-)
>>>
>>>diff --git a/fs/dcache.c b/fs/dcache.c
>>>index 0e73aa0..8c559b2 100644
>>>--- a/fs/dcache.c
>>>+++ b/fs/dcache.c
>>>@@ -898,7 +898,7 @@ struct dentry *d_alloc(struct dentry * parent, const
>>>struct qstr *name)
>>>      struct dentry *dentry;
>>>      char *dname;
>>>
>>>-     dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL);
>>>+     dentry = kmem_cache_zalloc(dentry_cache, GFP_KERNEL);
>>>      if (!dentry)
>>>              return NULL;
>>>
>>>@@ -921,15 +921,7 @@ struct dentry *d_alloc(struct dentry * parent,
>>>const struct qstr *name)
>>>      atomic_set(&dentry->d_count, 1);
>>>      dentry->d_flags = DCACHE_UNHASHED;
>>>      spin_lock_init(&dentry->d_lock);
>>>-     dentry->d_inode = NULL;
>>>-     dentry->d_parent = NULL;
>>>-     dentry->d_sb = NULL;
>>>-     dentry->d_op = NULL;
>>>-     dentry->d_fsdata = NULL;
>>>-     dentry->d_mounted = 0;
>>>-#ifdef CONFIG_PROFILING
>>>-     dentry->d_cookie = NULL;
>>>-#endif
>>>+
>>>      INIT_HLIST_NODE(&dentry->d_hash);
>>>      INIT_LIST_HEAD(&dentry->d_lru);
>>>      INIT_LIST_HEAD(&dentry->d_subdirs);
>>
>>
> 
> 


  reply	other threads:[~2007-07-13  9:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-13  1:41 [PATCH] replace kmem_cache_alloc with kmem_cache_zalloc to remove some following zero initializations Denis Cheng
2007-07-13  8:19 ` Kirill Korotaev
2007-07-13  8:38   ` rae l
2007-07-13  9:10     ` Kirill Korotaev [this message]
2007-07-13 13:21       ` Pekka Enberg

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=46974193.2020302@sw.ru \
    --to=dev@sw.ru \
    --cc=cr_quan@163.com \
    --cc=crquan@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=trivial@kernel.org \
    /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