4457d98459
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 - Better 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 - Different types of fifos: it is now possible to define a int fifo or any other type. See below for an example. - Smaller footprint for none byte type fifos - No need of creating a second hidden variable, like in the old DEFINE_KFIFO The API was not changed. There are now real in place fifos where the data space is a part of the structure. The fifo needs now 20 byte plus the fifo space. Dynamic assigned or allocated create a little bit more code. Most of the macros code will be optimized away and simple generate a function call. Only the really small one generates inline code. Additionally 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. This macros generates inline code, which is lit bit larger but faster. I know that this kind of macros are very sophisticated and not easy to maintain. But i have all tested and it works as expected. I analyzed the output of the compiler and for the x86 the code is as good as hand written assembler code. For the byte stream fifo the generate code is exact the same as with the current kfifo implementation. For all other types of fifos the code is smaller before, because the interface is easier to use. The main goal was to provide an API which is very intuitive, save and easy to use. So linux will get now a powerful fifo API which provides all what a developer needs. This will save in the future a lot of kernel space, since there is no need to write an own implementation. Most of the device driver developers need a fifo, and also deep kernel development will gain benefit from this API. Here are the results of the text section usage: Example 1: kfifo_put/_get kfifo_in/out current kfifo dynamic allocated 0x000002a8 0x00000291 0x00000299 in place 0x00000291 0x0000026e 0x00000273 kfifo.c new old text section size 0x00000be5 0x000008b2 As you can see, kfifo_put/kfifo_get creates a little bit more code than kfifo_in/kfifo_out, but it is much faster (the code is inline). The code is complete hand crafted and optimized. The text section size is as small as possible. You get all the fifo handling in only 3 kb. This includes type safe fix size records, dynamic records and DMA handling. This should be the final version. All requested features are implemented. Note: Most features of this API doesn't have any users. All functions which are not used in the next 9 months will be removed. So, please adapt your drivers and other sources as soon as possible to the new API and post it. This are the features which are currently not used in the kernel: kfifo_to_user() kfifo_from_user() kfifo_dma_....() macros kfifo_esize() kfifo_recsize() kfifo_put() kfifo_get() The fixed size record elements, exclude "unsigned char" fifo's and the variable size records fifo's This patch: User of the kernel fifo should never bypass the API and directly access the fifo structure. Otherwise it will be very hard to maintain the API. Signed-off-by: Stefani Seibold <stefani@seibold.net> Cc: Greg KH <greg@kroah.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> |
||
---|---|---|
.. | ||
agp | ||
hw_random | ||
ip2 | ||
ipmi | ||
mwave | ||
pcmcia | ||
rio | ||
tpm | ||
xilinx_hwicap | ||
.gitignore | ||
amiserial.c | ||
apm-emulation.c | ||
applicom.c | ||
applicom.h | ||
bfin_jtag_comm.c | ||
bfin-otp.c | ||
briq_panel.c | ||
bsr.c | ||
cd1865.h | ||
consolemap.c | ||
cp437.uni | ||
cs5535_gpio.c | ||
cyclades.c | ||
defkeymap.c_shipped | ||
defkeymap.map | ||
digi1.h | ||
digiFep1.h | ||
digiPCI.h | ||
ds1302.c | ||
ds1620.c | ||
dsp56k.c | ||
dtlk.c | ||
efirtc.c | ||
epca.c | ||
epca.h | ||
epcaconfig.h | ||
generic_nvram.c | ||
generic_serial.c | ||
genrtc.c | ||
hangcheck-timer.c | ||
hpet.c | ||
hvc_beat.c | ||
hvc_console.c | ||
hvc_console.h | ||
hvc_irq.c | ||
hvc_iseries.c | ||
hvc_iucv.c | ||
hvc_rtas.c | ||
hvc_tile.c | ||
hvc_udbg.c | ||
hvc_vio.c | ||
hvc_xen.c | ||
hvcs.c | ||
hvsi.c | ||
i8k.c | ||
isicom.c | ||
istallion.c | ||
Kconfig | ||
keyboard.c | ||
lp.c | ||
Makefile | ||
mbcs.c | ||
mbcs.h | ||
mem.c | ||
misc.c | ||
mmtimer.c | ||
moxa.c | ||
moxa.h | ||
mspec.c | ||
mxser.c | ||
mxser.h | ||
n_gsm.c | ||
n_hdlc.c | ||
n_r3964.c | ||
n_tty.c | ||
nozomi.c | ||
nsc_gpio.c | ||
nvram.c | ||
nwbutton.c | ||
nwbutton.h | ||
nwflash.c | ||
pc8736x_gpio.c | ||
ppdev.c | ||
ps3flash.c | ||
pty.c | ||
ramoops.c | ||
random.c | ||
raw.c | ||
riscom8_reg.h | ||
riscom8.c | ||
riscom8.h | ||
rocket_int.h | ||
rocket.c | ||
rocket.h | ||
rtc.c | ||
scc.h | ||
scx200_gpio.c | ||
selection.c | ||
ser_a2232.c | ||
ser_a2232.h | ||
ser_a2232fw.ax | ||
ser_a2232fw.h | ||
serial167.c | ||
snsc_event.c | ||
snsc.c | ||
snsc.h | ||
sonypi.c | ||
specialix_io8.h | ||
specialix.c | ||
stallion.c | ||
sx.c | ||
sx.h | ||
sxboards.h | ||
sxwindow.h | ||
synclink_gt.c | ||
synclink.c | ||
synclinkmp.c | ||
sysrq.c | ||
tb0219.c | ||
tlclk.c | ||
toshiba.c | ||
tty_audit.c | ||
tty_buffer.c | ||
tty_io.c | ||
tty_ioctl.c | ||
tty_ldisc.c | ||
tty_mutex.c | ||
tty_port.c | ||
uv_mmtimer.c | ||
vc_screen.c | ||
viotape.c | ||
virtio_console.c | ||
vme_scc.c | ||
vt_ioctl.c | ||
vt.c |