LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: "Cong WANG" <xiyou.wangcong@gmail.com>
To: "Andrew Morton" <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] kfifo: overflow of unsigned integer
Date: Sat, 10 Feb 2007 09:56:24 +0800	[thread overview]
Message-ID: <2375c9f90702091756l4cddfc63r68b5a318457f13d8@mail.gmail.com> (raw)
In-Reply-To: <20070209003732.03012671.akpm@linux-foundation.org>

2007/2/9, Andrew Morton <akpm@linux-foundation.org>:
> On Thu, 8 Feb 2007 20:16:55 +0800 "Cong WANG" <xiyou.wangcong@gmail.com> wrote:
>
> > 2007/2/8, Andrew Morton <akpm@linux-foundation.org>:
> > > On Thu, 8 Feb 2007 17:07:28 +0800 "Cong WANG" <xiyou.wangcong@gmail.com> 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.

Sorry. I used the poor 'reply'.

>
> 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.
>
>

Thanks for your work. And you are right.

I think the OLD /proc API which I used in my module confused my eyes.
I got completely lost by that. OLD /proc API is very bad, isn't it?

BTW, can you tell me which way do you use to exchange information
between user-space and kernel-space when debugging the kernel?

Thanks again! And have a nice day!

      parent reply	other threads:[~2007-02-10  1:56 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-08  9:07 Cong WANG
2007-02-08  9:38 ` Andrew Morton
     [not found]   ` <2375c9f90702080416s54664351q3df54e80459c63af@mail.gmail.com>
     [not found]     ` <20070209003732.03012671.akpm@linux-foundation.org>
2007-02-10  1:56       ` Cong WANG [this message]

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=2375c9f90702091756l4cddfc63r68b5a318457f13d8@mail.gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH] kfifo: overflow of unsigned integer' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).