Re: [RFC -v2] kfifo writer side lock-less support

From: Huang Ying
Date: Tue Aug 24 2010 - 20:38:56 EST


On Wed, 2010-08-25 at 03:13 +0800, Stefani Seibold wrote:
> > > > The patch adds only 1 field (unsigned int) to struct __kfifo. I think
> > > > that should be acceptable. Because sizeof(struct __kfifo) should be much
> > > > smaller that __kfifo->mask + 1 in most cases.
> > >
> > > I don't know what you mean with "because sizeof(struct __kfifo) should
> > > be much smaller that __kfifo->mask + 1 in most cases". I am convinced
> > > that you did not really understand the kfifo code. sizeof(struct
> > > __kfifo) is constant and __kfifo->mask + 1 is the fifo size in elements,
> > > which is not constant. Before you answering study the code first!
> > >
> > > And is not acceptable to bload the struct __kfifo, because it will never
> > > need by the most users.
> >
> > I mean, for most user, __kfifo->mask + 1 > sizeof(struct __kfifo), so
> > another 4 bytes for each user is relatively small.
> >
>
> You have no idea. As i wrote you should study the code before answering!
>
> sizeof(struct __kfifo) is always 20 bytes on a 32 bit cpu, and
> kfifo->mask +1 depends on the size of the number of fifo elements and it
> is an initialization parameter.

After my changing, sizeof(struct __kfifo) should be 24 on 32 bit CPU,
that is 4 bytes more. But I think for most users, kfifo->mask + 1 should
be hundreds or thousands. If the average(kfifo->mask + 1) = 256, the
increment percentage for each user is about:

4 / (256 + 20) = 1.45%

So I think the changes to the size of struct __kfifo should be
acceptable.

Best Regards,
Huang Ying


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/