From: Stefani Seibold <stefani@seibold.net>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel <linux-kernel@vger.kernel.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>
Subject: Re: [PATCH 7/7] kfifo: add record handling functions
Date: Tue, 24 Nov 2009 07:52:06 +0100 [thread overview]
Message-ID: <1259045526.14668.1.camel@wall-e> (raw)
In-Reply-To: <20091123141914.e320c341.akpm@linux-foundation.org>
Am Montag, den 23.11.2009, 14:19 -0800 schrieb Andrew Morton:
> On Fri, 20 Nov 2009 09:33:08 +0100
> Stefani Seibold <stefani@seibold.net> wrote:
>
> > Add kfifo_in_rec() - puts some record data into the FIFO
> > Add kfifo_out_rec() - gets some record data from the FIFO
> > Add kfifo_from_user_rec() - puts some data from user space into the FIFO
> > Add kfifo_to_user_rec() - gets data from the FIFO and write it to user space
> > Add kfifo_peek_rec() - gets the size of the next FIFO record field
> > Add kfifo_skip_rec() - skip the next fifo out record
> > Add kfifo_avail_rec() - determinate the number of bytes available in a record FIFO
> >
> > 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>
> > ---
> > include/linux/kfifo.h | 328 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > kernel/kfifo.c | 286 +++++++++++++++++++++++++++++--------------
> > 2 files changed, 521 insertions(+), 93 deletions(-)
> >
> > diff -u -N -r -p kfifo6/include/linux/kfifo.h kfifo7/include/linux/kfifo.h
> > --- kfifo6/include/linux/kfifo.h 2009-11-19 20:54:56.275420767 +0100
> > +++ kfifo7/include/linux/kfifo.h 2009-11-19 20:55:16.596339811 +0100
> > @@ -275,4 +275,332 @@ static inline unsigned int __kfifo_off(s
> > return off & (fifo->size - 1);
> > }
> >
> > +/**
> > + * __kfifo_peek_n internal helper function for determinate the length of
> > + * the next record in the fifo
> > + */
> > +static inline unsigned int __kfifo_peek_n(struct kfifo *fifo,
> > + unsigned int recsize)
> > +{
> > +#define __KFIFO_GET(fifo, off, shift) \
> > + ((fifo)->buffer[__kfifo_off((fifo), (fifo)->out+(off))] << (shift))
> > +
> > + unsigned int l;
> > +
> > + l = __KFIFO_GET(fifo, 0, 0);
> > +
> > + if (--recsize)
> > + l |= __KFIFO_GET(fifo, 1, 8);
> > +
> > + return l;
> > +}
> > +
> > +/**
> > + * __kfifo_poke_n internal helper function for storing the length of
> > + * the next record into the fifo
> > + */
> > +static inline void __kfifo_poke_n(struct kfifo *fifo,
> > + unsigned int recsize, unsigned int n)
> > +{
> > +#define __KFIFO_PUT(fifo, off, val, shift) \
> > + ( \
> > + (fifo)->buffer[__kfifo_off((fifo), (fifo)->in+(off))] = \
> > + (unsigned char)((val) >> (shift)) \
> > + )
> > +
> > + __KFIFO_PUT(fifo, 0, n, 0);
> > +
> > + if (--recsize)
> > + __KFIFO_PUT(fifo, 1, n, 8);
> > +}
>
> This will leave the __KFIFO_GET and __KFIFO_PUT macros defined in the
> .c files which use this header file. That's messy and undesired, to it
> would be better to #undef these macros as early as possible.
>
> but...
Will be fixed ...
>
> > +static inline unsigned int __kfifo_out_rec(struct kfifo *fifo,
> > + void *to, unsigned int n, unsigned int recsize,
> > + unsigned int *total)
> > +{
> > + unsigned int l;
> > +
> > + if (!recsize) {
> > + l = n;
> > + if (total)
> > + *total = l;
> > + } else {
> > + l = __kfifo_peek_n(fifo, recsize);
> > + if (total)
> > + *total = l;
> > + if (n < l)
> > + return l;
> > + }
> > +
> > + return __kfifo_out_n(fifo, to, l, recsize);
> > +}
>
> The amount of inlining in this header is pretty wild. These are large
> functions! Inlining them will create a large kernel and most likely a
> slower one, due to the increased instruction cache footprint.
>
> So please, let's see a "kfifo: uninline everything" patch?
>
> but...
>
> > +/**
> > + * kfifo_out_rec - gets some record data from the FIFO
> > + * @fifo: the fifo to be used.
> > + * @to: where the data must be copied.
> > + * @n: the size of the destination buffer.
> > + * @recsize: size of record field
> > + * @total: pointer where the total number of to copied bytes should stored
> > + *
> > + * This function copies at most @n bytes from the FIFO to @to and returns the
> > + * number of bytes which cannot be copied.
> > + * A returned value greater than the @n value means that the record doesn't
> > + * fit into the @to buffer.
> > + *
> > + * Note that with only one concurrent reader and one concurrent
> > + * writer, you don't need extra locking to use these functions.
> > + */
> > +static inline __must_check unsigned int kfifo_out_rec(struct kfifo *fifo,
> > + void *to, unsigned int n, unsigned int recsize,
> > + unsigned int *total)
> > +
> > +{
> > + if (!__builtin_constant_p(recsize))
> > + return __kfifo_out_generic(fifo, to, n, recsize, total);
> > + return __kfifo_out_rec(fifo, to, n, recsize, total);
> > +}
>
> OK, so I see that some attention has been paid to the text footprint issue.
>
> But how much, and was it successful?
>
I will think about it.
next prev parent reply other threads:[~2009-11-24 6:52 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 8:15 [PATCH 0/7] kfifo: new API v0.7 Stefani Seibold
2009-11-20 8:18 ` [PATCH 1/7] kfifo: move struct kfifo in place Stefani Seibold
2009-11-20 8:20 ` [PATCH 2/7] kfifo: move out spinlock Stefani Seibold
2009-11-20 8:22 ` [PATCH 3/7] kfifo: cleanup namespace Stefani Seibold
2009-11-20 8:25 ` [PATCH 4/7] kfifo: rename kfifo_put... into kfifo_in... and kfifo_get... into kfifo_out Stefani Seibold
2009-11-20 8:27 ` [PATCH 5/7] kfifo: add DEFINE_KFIFO and friends, add very tiny functions Stefani Seibold
2009-11-23 22:19 ` Andrew Morton
2009-11-24 6:52 ` Stefani Seibold
2009-11-24 23:29 ` Andrew Morton
2009-11-20 8:29 ` [PATCH 6/7] kfifo: add kfifo_skip, kfifo_from_user and kfifo_to_user Stefani Seibold
2009-11-20 8:33 ` [PATCH 7/7] kfifo: add record handling functions Stefani Seibold
2009-11-23 22:19 ` Andrew Morton
2009-11-24 6:52 ` Stefani Seibold [this message]
2009-11-26 16:07 ` Stefani Seibold
2009-11-26 16:44 ` Andi Kleen
2009-11-29 16:17 ` [PATCH 0/7] kfifo: new API v0.7 Thiago Farina
-- strict thread matches above, loose matches on Subject: below --
2009-11-16 11:50 [PATCH 0/7] kfifo: new API v0.6 Stefani Seibold
2009-11-16 12:07 ` [PATCH 7/7] kfifo: add record handling functions Stefani Seibold
2009-08-19 20:49 [PATCH 0/7] kfifo: new API v0.5 Stefani Seibold
2009-08-19 21:06 ` [PATCH 7/7] kfifo: add record handling functions Stefani Seibold
2009-08-16 20:39 [PATCH 0/7] kfifo: new API v0.4 Stefani Seibold
2009-08-16 21:04 ` [PATCH 7/7] kfifo: add record handling functions Stefani Seibold
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=1259045526.14668.1.camel@wall-e \
--to=stefani@seibold.net \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=arnd@arndb.de \
--cc=gregkh@suse.de \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@redhat.com \
--cc=quadros.roger@gmail.com \
--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