On Thu, 8 Feb 2007 20:16:55 +0800 "Cong WANG" <xiyou.wangcong@xxxxxxxxx> wrote:
> 2007/2/8, Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>:
> > On Thu, 8 Feb 2007 17:07:28 +0800 "Cong WANG" <xiyou.wangcong@xxxxxxxxx> wrote:
> >
> > > Kfifo is a ring-buffer in kernel which can be used as a lock-free way
> > > for concurrent read/write when there are only one producer and one
> > > consumer. Details of its design can be found in kernel/kfifo.c and
> > > include/linux/kfifo.h.
> > >
> > > You will find that the 'in' and 'out' fields of 'struct kfifo' are
> > > both represented as 'unsigned int' and in most cases 'in' is larger
> > > than 'out' and their difference will NOT be over 'size'.
> > >
> > > Now the problem is that 'in' will be *smaller* than 'out' when 'in'
> > > overflows and 'out' doesn't (Yes, this may occur quietly.). This is
> > > NOT what we expect, though it may not cause any serious problems if we
> > > carefully use kfifo*() functions. And this is really a bug.
> >
> > You seem to be saying that it's not a bug, but it's a bug.
> >
> > Exactly what goes wrong?
>
> I wrote a module on my machine to test this bug. And when the overflow
> occurs, I cann't put any data into the fifo even though it is not
> full.
Why did you remove the mailing list? Please don't do that.
I can't find any bug.
I converted the code so that it'll run in userspace:
http://userweb.kernel.org/~akpm/kfifo.c
http://userweb.kernel.org/~akpm/kfifo.h
Please see if you can reproduce the problem with that setup and then let's
see if we can understand what's going on, and fix it.