All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Robert P. J. Day" <rpjday@crashcourse.ca>
To: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: kfifo has temporarily invalid in pointer?
Date: Mon, 15 Mar 2010 13:17:49 -0400 (EDT)	[thread overview]
Message-ID: <alpine.LFD.2.00.1003151315580.11348@localhost> (raw)
In-Reply-To: <413a6a951003150906ve38d1dy95ed07f026accf09@mail.gmail.com>

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1855 bytes --]

On Mon, 15 Mar 2010, Daniel Baluta wrote:

> Hi Robert,
>
> On Mon, Mar 15, 2010 at 4:58 PM, Robert P. J. Day <rpjday@crashcourse.ca> wrote:
> >
> >  (i am not trying to be annoyingly obsessive about the kernel kfifo,
> > i am merely succeeding.)
> :P
> >  what appears to be a bit of an oddity WRT kfifo:  since a kfifo is
> > defined with a fixed buffer size, it obviously enqueues and dequeues
> > in a circular fashion.  so, the code to add some data to a kfifo (from
> > kernel/kfifo.c):
> >
> > =====
> > unsigned int kfifo_in(struct kfifo *fifo, const void *from,
> >                                unsigned int len)
> > {
> >        len = min(kfifo_avail(fifo), len);
> >
> >        __kfifo_in_data(fifo, from, len, 0);
> >        __kfifo_add_in(fifo, len);
> >        return len;
> > }
> > =====
> >
> >  fair enough -- that first routine adds the data itself, while the
> > second one correspondingly bumps up the pointer, which could
> > conceivably wrap around to follow the data, correct?  but from
> > include/linux.kfifo.h:len = min(kfifo_avail(fifo), len);
>
> Wrong :). If you notice len is truncated using:
> len = min(kfifo_avail(fifo), len);

  kfifo_avail() is defined as returning the number of available bytes
left in the buffer ready to accept incoming data, even if that
incorporates wraparound.  that is not relevant to the point i was
making.

rday
--

========================================================================
Robert P. J. Day                               Waterloo, Ontario, CANADA

            Linux Consulting, Training and Kernel Pedantry.

Web page:                                          http://crashcourse.ca
Twitter:                                       http://twitter.com/rpjday
========================================================================

      reply	other threads:[~2010-03-15 17:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-15 14:58 kfifo has temporarily invalid in pointer? Robert P. J. Day
2010-03-15 16:06 ` Daniel Baluta
2010-03-15 17:17   ` Robert P. J. Day [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=alpine.LFD.2.00.1003151315580.11348@localhost \
    --to=rpjday@crashcourse.ca \
    --cc=daniel.baluta@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.