All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Stefani Seibold <stefani@seibold.net>
Cc: Yuanhan Liu <yliu.null@gmail.com>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Wei Yang <weiyang@linux.vnet.ibm.com>,
	Fengguang Wu <fengguang.wu@intel.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: Re: [PATCH] kfifo: remove unnecessary type check
Date: Fri, 26 Oct 2012 21:04:08 +0800	[thread overview]
Message-ID: <20121026130408.GH2778@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1351243591.8719.2.camel@wall-e>

On Fri, Oct 26, 2012 at 11:26:31AM +0200, Stefani Seibold wrote:
> Am Freitag, den 26.10.2012, 15:17 +0800 schrieb Yuanhan Liu:
> > On Fri, Oct 26, 2012 at 08:51:06AM +0200, Stefani Seibold wrote:
> > > Am Freitag, den 26.10.2012, 14:11 +0800 schrieb Yuanhan Liu:
> > > > On Fri, Oct 26, 2012 at 07:38:31AM +0200, Stefani Seibold wrote:
> > > > > Am Freitag, den 26.10.2012, 09:46 +0800 schrieb Yuanhan Liu:
> > > > > > From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > > > > > 
> > > > > > Firstly, this kind of type check doesn't work. It does something similay
> > > > > > like following:
> > > > > > 	void * __dummy = NULL;
> > > > > > 	__buf = __dummy;
> > > > > > 
> > > > > > __dummy is defined as void *. Thus it will not trigger warnings as
> > > > > > expected.
> > > > > > 
> > > > > > Second, we don't need that kind of check. Since the prototype
> > > > > > of __kfifo_out is:
> > > > > > 	unsigned int __kfifo_out(struct __kfifo *fifo,  void *buf, unsigned int len)
> > > > > > 
> > > > > > buf is defined as void *, so we don't need do the type check. Remove it.
> > > > > > 
> > > > > > LINK: https://lkml.org/lkml/2012/10/25/386
> > > > > > LINK: https://lkml.org/lkml/2012/10/25/584
> > > > > > 
> > > > > > Cc: Andrew Morton <akpm@linux-foundation.org>
> > > > > > Cc: Wei Yang <weiyang@linux.vnet.ibm.com>
> > > > > > Cc: Stefani Seibold <stefani@seibold.net>
> > > > > > Cc: Fengguang Wu <fengguang.wu@intel.com>
> > > > > > Cc: Stephen Rothwell <sfr@canb.auug.org.au>
> > > > > > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > > > > > ---
> > > 

[snip]...

> > > 
> > > Also you have to build the kfifo samples, since this example code use
> > > all features of the kfifo API.
> > > 
> > > And again: The kfifo is designed to do the many things at compile time,
> > > not at runtime. If you modify the code, you have to check the compiler
> > > assembler output for no degradation, especially in kfifo_put, kfifo_get,
> > > kfifo_in, kfifo_out, __kfifo_in and __kfifo_out. Prevent runtime checks
> > > if you can do it at compile time. This is the basic reasons to do it in
> > > macros.
> > 
> > Is it enought to check kernel/kfifo.o only? I build that file with
> > and without this patch. And then  dump it by objdump -D kernel/fifo.o to
> > /tmp/kfifo.dump.with and /tmp/kfifo.dump.without, respectively. And the
> > two dump file are exactly same.
> > 
> 
> No, since most of the code is inlined due performace reasons, you have
> to hack the kfifo examples output code for regressions and code
> increase.

In my test, this patch doesn't change anything. Here are some data to
prove that:

$ make samples/kfifo/
$ cp samples/kfifo/*.o /tmp/before/

$ git am this-patch
$ make samples/kfifo/
$ cp samples/kfifo/*.o /tmp/after/

$ for i in /tmp/before/*.o; do size $i /tmp/after/`basename $i`; done
   text    data     bss     dec     hex filename
   1939     464     456    2859     b2b /tmp/before/bytestream-example.o
   1939     464     456    2859     b2b /tmp/after/bytestream-example.o
   text    data     bss     dec     hex filename
   1423     112     296    1831     727 /tmp/before/dma-example.o
   1423     112     296    1831     727 /tmp/after/dma-example.o
   text    data     bss     dec     hex filename
   1864     624     376    2864     b30 /tmp/before/inttype-example.o
   1864     624     376    2864     b30 /tmp/after/inttype-example.o
   text    data     bss     dec     hex filename
   1916     464     472    2852     b24 /tmp/before/record-example.o
   1916     464     472    2852     b24 /tmp/after/record-example.o
# You will see that it changed nothing.


$ objdump -d /tmp/before/bytestream-example.o >/tmp/bytestream-example.before
$ objdump -d /tmp/after/bytestream-example.o >/tmp/bytestream-example.after
$ diff /tmp/bytestream.before /tmp/bytestream.after -urN
--- bytestream.before   2012-10-26 20:55:33.645578668 +0800
+++ bytestream.after    2012-10-26 20:55:26.520578669 +0800
@@ -1,5 +1,5 @@

-/tmp/bytestream-example.o:     file format elf64-x86-64
+/tmp/bytestream-example.o:     file format elf64-x86-64

# So, as you can see, expect the filename, they are same.


So, Stefani, is it what you want? Does this looks OK to you?

Thanks,
Yuanhan Liu



  reply	other threads:[~2012-10-26 13:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26  1:46 [PATCH] kfifo: remove unnecessary type check Yuanhan Liu
2012-10-26  5:38 ` Stefani Seibold
2012-10-26  6:11   ` Yuanhan Liu
2012-10-26  6:51     ` Stefani Seibold
2012-10-26  7:17       ` Yuanhan Liu
2012-10-26  7:33         ` Yuanhan Liu
2012-10-26  9:26         ` Stefani Seibold
2012-10-26 13:04           ` Yuanhan Liu [this message]
2012-10-26 13:42             ` Stefani Seibold
2012-10-27  8:43               ` Yuanhan Liu
     [not found]     ` <20121026095244.GA815@richard.(null)>
2012-10-26 12:31       ` Yuanhan Liu
     [not found]         ` <20121027015558.GA3983@richard.(null)>
2012-10-27  8:48           ` Yuanhan Liu

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=20121026130408.GH2778@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sfr@canb.auug.org.au \
    --cc=stefani@seibold.net \
    --cc=weiyang@linux.vnet.ibm.com \
    --cc=yliu.null@gmail.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 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.