From: Arnd Bergmann <arnd@arndb.de>
To: Stefani Seibold <stefani@seibold.net>
Cc: "linux-kernel" <linux-kernel@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [RFC 0/2] new kfifo API
Date: Mon, 3 Aug 2009 21:00:35 +0200 [thread overview]
Message-ID: <200908032100.35892.arnd@arndb.de> (raw)
In-Reply-To: <1249306755.8358.8.camel@wall-e>
Going through your list again:
On Monday 03 August 2009, Stefani Seibold wrote:
> - Generic usage: For kernel internal use or device driver
no change here, right?
> - Linux style habit: DECLARE_KFIFO, DEFINE_KFIFO and INIT_KFIFO Macros
DEFINE_KFIFO looks useful, but I probably wouldn't expose
the other macros, so you could define them as __KFIFO_* or
integrate them into a larger DEFINE_KFIFO.
> - Ability to handle variable length records. Three type of records are
> supported:
> - Records between 0-255 bytes, with a record size field of 1 bytes
> - Records between 0-65535 bytes, with a record size field of 2 bytes
> - Byte stream, which no record size field
> Inside a fifo this record types it is not a good idea to mix them together.
Not sure if having both 1 and 2 byte record lengths really helps.
If you want to avoid mixing the two, maybe just leave the existing
API for byte streams in a compatible, and provide extra functions
for records with a definite length.
> - Direct copy_to_user from the fifo and copy_from_user into the fifo.
Sounds useful, as mentioned.
> - Single structure: The fifo structure contains the management variables and
> the buffer. No extra indirection is needed to access the fifo buffer.
I see two problems here:
1. you can no longer use preallocated buffers, which limits the possible
users to those that are unrestricted to the type of allocation.
2. The size of the buffer is no longer power-of-two. In fact, it's guaranteed
to be non-power-of-two because kmalloc gives you a power-of-two allocation
but now you also put the struct kfifo in there.
Users that need a power-of-two buffer (the common case) now waste almost
50% of the space.
The requirement for power-of-two also meant a much faster __kfifo_off
function on certain embedded platforms that don't have an integer division
instruction in hardware.
> - Lockless access: if only one reader and one writer is active on the fifo,
> which is the common use case, there is no additional locking necessary.
The existing API already provides this, you can simply call __kfifo_put()
and __kfifo_get() directly, rather than their wrappers, which are just
helpers to make the code more robust. Half the existing users do that
already.
Arnd <><
next prev parent reply other threads:[~2009-08-03 19:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-03 13:39 [RFC 0/2] new kfifo API Stefani Seibold
2009-08-03 14:42 ` Arnd Bergmann
2009-08-03 15:14 ` Stefani Seibold
2009-08-03 18:23 ` Arnd Bergmann
2009-08-03 18:45 ` Stefani Seibold
2009-08-03 16:41 ` Mike Christie
2009-08-03 18:27 ` Andi Kleen
2009-08-03 18:35 ` Arnd Bergmann
2009-08-03 18:48 ` Stefani Seibold
2009-08-03 19:00 ` Arnd Bergmann [this message]
2009-08-03 19:48 ` Stefani Seibold
2009-08-04 12:24 ` Arnd Bergmann
2009-08-04 12:44 ` Stefani Seibold
2009-08-04 13:45 ` Arnd Bergmann
2009-08-04 14:57 ` Stefani Seibold
2009-08-04 18:00 ` Arnd Bergmann
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=200908032100.35892.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stefani@seibold.net \
/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