From: Roland Dreier <rdreier@cisco.com>
To: "Robert P. J. Day" <rpjday@crashcourse.ca>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: kfifo: possible weird violation of what should be invariant
Date: Tue, 16 Mar 2010 15:25:17 -0700 [thread overview]
Message-ID: <adamxy79a5u.fsf@roland-alpha.cisco.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1003151702040.3329@localhost> (Robert P. J. Day's message of "Mon, 15 Mar 2010 17:22:49 -0400 (EDT)")
> sure, the code seems to work, but allowing the internal values of a
> kfifo to contain invalid values on a regular basis would seem to make
> a mess of, say, tracing or debugging. making sure that offset values
> actually lie within their valid range would seem to be one of those
> ASSERT() things that should always be true, should it not? is there a
> reason the design is like this?
Actually I believe having the values be free-running without clamping
them makes the code much simpler -- the reason being that you preserve
the invariant of "in" always being ahead of "out". If you reduce the
pointers modulo the size, then you end up having a lot of code that has
two cases: one to handle "in > out", and one to handle "in < out because
in has wrapped and out hasn't yet".
- R.
--
Roland Dreier <rolandd@cisco.com>
For corporate legal information go to:
http://www.cisco.com/web/about/doing_business/legal/cri/index.html
next prev parent reply other threads:[~2010-03-16 22:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-15 21:22 Robert P. J. Day
2010-03-16 22:25 ` Roland Dreier [this message]
2010-03-17 11:22 ` Robert P. J. Day
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=adamxy79a5u.fsf@roland-alpha.cisco.com \
--to=rdreier@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rpjday@crashcourse.ca \
/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
Powered by JetHome