From: Li Zefan <lizf@cn.fujitsu.com>
To: Stefani Seibold <stefani@seibold.net>
Cc: linux-kernel <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Arnd Bergmann <arnd@arndb.de>, Andi Kleen <andi@firstfloor.org>,
Amerigo Wang <xiyou.wangcong@gmail.com>,
Joe Perches <joe@perches.com>,
Roger Quadros <quadros.roger@gmail.com>,
Greg Kroah-Hartman <gregkh@suse.de>,
Mauro Carvalho Chehab <mchehab@redhat.com>,
Shargorodsky Atal <ext-atal.shargorodsky@nokia.com>
Subject: Re: [PATCH] new kfifo API v.08 (fixed)
Date: Mon, 21 Dec 2009 09:10:24 +0800 [thread overview]
Message-ID: <4B2ECB00.4060907@cn.fujitsu.com> (raw)
In-Reply-To: <1261303696.18283.22.camel@wall-e>
Stefani Seibold wrote:
> This is a complete rewrite of the new kfifo API, which is now really
> generic. The API is still stable.
>
> There are different types of a fifo which can not handled in C without a
> lot of overhead. So i decided to write the API as a set of macros, which
> is the only way to do a kind of template meta programming without c++.
> This macros handles the different types of fifos in a transparent way.
>
> There are a lot of benefits:
>
> - Compile time handling of the different fifo types
> - Performance (a save put or get of an integer does only generate 9 assembly
> instructions on a x86)
> - Type save
> - Cleaner interface, the additional kfifo_..._rec() functions are gone
> - Easier to use
> - Less error prone
> - Smaller footprint
> - Different types of fifos: it is now possible to define a int fifo or
> any other type. See below for an example.
> - The size of the record field will be now detected at compile time
> - No need of creating a hidden variable, like in DEFINE_KFIFO
>
> The API has not been change, but there are now real in place fifos
> where the data space is a part of the structure. There is no need for an
> extra indirection to the access the data and also no size field, because
> the size of the fifo can be determinate with sizeof. This kind of fifo
> does only need 8 bytes plus the fifo space.
>
> The dynamic assigned or allocated fifos still needs 16 byte plus the
> fifo space and does also creates more code.
>
> Most of the macros code will be optimized away and does only generate a
> function call. Only the really the small ones generates inline code. The
> overall size is half of the size of the previous implementation.
>
> Additional you can now create fifos for any data type, not only the
> "unsigned char" byte streamed fifos.
>
> There is also a new kfifo_put and kfifo_get function, to handle a single
> element in a fifo.
>
> Here is a small example how to use it:
>
> Example 1: an integer fifo
>
Why don't you put those examples into samples/kfifo/ ?
prev parent reply other threads:[~2009-12-21 1:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-20 10:08 [PATCH] new kfifo API v.08 (fixed) Stefani Seibold
2009-12-21 1:10 ` Li Zefan [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=4B2ECB00.4060907@cn.fujitsu.com \
--to=lizf@cn.fujitsu.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=arnd@arndb.de \
--cc=ext-atal.shargorodsky@nokia.com \
--cc=gregkh@suse.de \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=quadros.roger@gmail.com \
--cc=stefani@seibold.net \
--cc=xiyou.wangcong@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox