kfifo: move struct kfifo in place
This is a new generic kernel FIFO implementation. The current kernel fifo API is not very widely used, because it has to many constrains. Only 17 files in the current 2.6.31-rc5 used it. FIFO's are like list's a very basic thing and a kfifo API which handles the most use case would save a lot of development time and memory resources. I think this are the reasons why kfifo is not in use: - The API is to simple, important functions are missing - A fifo can be only allocated dynamically - There is a requirement of a spinlock whether you need it or not - There is no support for data records inside a fifo So I decided to extend the kfifo in a more generic way without blowing up the API to much. The new API has the following benefits: - Generic usage: For kernel internal use and/or device driver. - Provide an API for the most use case. - Slim API: The whole API provides 25 functions. - Linux style habit. - DECLARE_KFIFO, DEFINE_KFIFO and INIT_KFIFO Macros - Direct copy_to_user from the fifo and copy_from_user into the fifo. - The kfifo itself is an in place member of the using data structure, this save an indirection access and does not waste the kernel allocator. - Lockless access: if only one reader and one writer is active on the fifo, which is the common use case, no additional locking is necessary. - Remove spinlock - give the user the freedom of choice what kind of locking to use if one is required. - Ability to handle records. Three type of records are supported: - Variable length records between 0-255 bytes, with a record size field of 1 bytes. - Variable length records between 0-65535 bytes, with a record size field of 2 bytes. - Fixed size records, which no record size field. - Preserve memory resource. - Performance! - Easy to use! This patch: Since most users want to have the kfifo as part of another object, reorganize the code to allow including struct kfifo in another data structure. This requires changing the kfifo_alloc and kfifo_init prototypes so that we pass an existing kfifo pointer into them. This patch changes the implementation and all existing users. [akpm@linux-foundation.org: fix warning] Signed-off-by:Stefani Seibold <stefani@seibold.net> Acked-by:
Greg Kroah-Hartman <gregkh@suse.de> Acked-by:
Mauro Carvalho Chehab <mchehab@redhat.com> Acked-by:
Andi Kleen <ak@linux.intel.com> Acked-by:
Arnd Bergmann <arnd@arndb.de> Signed-off-by:
Andrew Morton <akpm@linux-foundation.org> Signed-off-by:
Linus Torvalds <torvalds@linux-foundation.org>
Showing
- drivers/char/nozomi.c 10 additions, 11 deletionsdrivers/char/nozomi.c
- drivers/char/sonypi.c 19 additions, 21 deletionsdrivers/char/sonypi.c
- drivers/infiniband/hw/cxgb3/cxio_hal.h 5 additions, 4 deletionsdrivers/infiniband/hw/cxgb3/cxio_hal.h
- drivers/infiniband/hw/cxgb3/cxio_resource.c 29 additions, 31 deletionsdrivers/infiniband/hw/cxgb3/cxio_resource.c
- drivers/media/video/meye.c 23 additions, 25 deletionsdrivers/media/video/meye.c
- drivers/media/video/meye.h 2 additions, 2 deletionsdrivers/media/video/meye.h
- drivers/net/wireless/libertas/cmd.c 2 additions, 2 deletionsdrivers/net/wireless/libertas/cmd.c
- drivers/net/wireless/libertas/dev.h 2 additions, 2 deletionsdrivers/net/wireless/libertas/dev.h
- drivers/net/wireless/libertas/main.c 7 additions, 9 deletionsdrivers/net/wireless/libertas/main.c
- drivers/platform/x86/fujitsu-laptop.c 8 additions, 10 deletionsdrivers/platform/x86/fujitsu-laptop.c
- drivers/platform/x86/sony-laptop.c 23 additions, 23 deletionsdrivers/platform/x86/sony-laptop.c
- drivers/scsi/libiscsi.c 8 additions, 14 deletionsdrivers/scsi/libiscsi.c
- drivers/scsi/libiscsi_tcp.c 14 additions, 15 deletionsdrivers/scsi/libiscsi_tcp.c
- drivers/scsi/libsrp.c 5 additions, 8 deletionsdrivers/scsi/libsrp.c
- drivers/usb/host/fhci-sched.c 5 additions, 5 deletionsdrivers/usb/host/fhci-sched.c
- drivers/usb/host/fhci-tds.c 17 additions, 18 deletionsdrivers/usb/host/fhci-tds.c
- drivers/usb/host/fhci.h 5 additions, 5 deletionsdrivers/usb/host/fhci.h
- drivers/usb/serial/usb-serial.c 2 additions, 3 deletionsdrivers/usb/serial/usb-serial.c
- include/linux/kfifo.h 6 additions, 5 deletionsinclude/linux/kfifo.h
- include/scsi/libiscsi.h 2 additions, 1 deletioninclude/scsi/libiscsi.h
Loading
Please register or sign in to comment