[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4B2ECB00.4060907@cn.fujitsu.com>
Date: Mon, 21 Dec 2009 09:10:24 +0800
From: Li Zefan <lizf@...fujitsu.com>
To: Stefani Seibold <stefani@...bold.net>
CC: linux-kernel <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Arnd Bergmann <arnd@...db.de>,
Andi Kleen <andi@...stfloor.org>,
Amerigo Wang <xiyou.wangcong@...il.com>,
Joe Perches <joe@...ches.com>,
Roger Quadros <quadros.roger@...il.com>,
Greg Kroah-Hartman <gregkh@...e.de>,
Mauro Carvalho Chehab <mchehab@...hat.com>,
Shargorodsky Atal <ext-atal.shargorodsky@...ia.com>
Subject: Re: [PATCH] new kfifo API v.08 (fixed)
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/ ?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists