public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Zach Brown <zach.brown@oracle.com>
Cc: Ken Chen <kenchen@google.com>,
	linux-aio@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [patch] convert aio event reap to use atomic-op instead of spin_lock
Date: Wed, 11 Apr 2007 12:11:46 -0700	[thread overview]
Message-ID: <20070411121146.47ca5b4d.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070411180038.GN28322@mami.zabbo.net>

On Wed, 11 Apr 2007 11:00:38 -0700
Zach Brown <zach.brown@oracle.com> wrote:

> > -	/* Compensate for the ring buffer's head/tail overlap entry */
> > -	nr_events += 2;	/* 1 is required, 2 for good luck */
> > +	/* round nr_event to next power of 2 */
> > +	nr_events = roundup_pow_of_two(nr_events);
> 
> Is that buggy?  How will the code tell if head == tail means a full ring
> or an empty ring?  The old code added that extra event to let it tell
> the ring was full before head == tail and it would think it's empty
> again, I think.  I'm guessing roundup(nr_events + 1) is needed.

Ken uses the other (superior!) way of implementing ringbuffers: the head
and tail pointers (the naming of which AIO appears to have reversed) are
not constrained to the ringsize - they are simply allowed to wrap through
0xfffffff.  Consequently:

ring full:		(head-tail == size)
ring empty:		head==tail
numer-of-items-in-ring:	head-tail
add to ring:		ring[head++]=item
remove from ring: 	item=ring[tail++]

(adjust the above for AIO naming assbackwardness)
(requires that size be a power of 2)

Many net drivers do it this way for their DMA rings.


  reply	other threads:[~2007-04-11 19:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-10 23:53 [patch] convert aio event reap to use atomic-op instead of spin_lock Ken Chen
2007-04-11  5:18 ` Andrew Morton
2007-04-11 16:54   ` Ken Chen
2007-04-11 18:15     ` Zach Brown
2007-04-11 18:29       ` Ken Chen
2007-04-11 18:00 ` Zach Brown
2007-04-11 19:11   ` Andrew Morton [this message]
2007-04-11 19:34     ` Zach Brown
2007-04-11 19:28   ` Ken Chen
2007-04-11 19:44     ` Zach Brown
2007-04-11 19:45     ` Benjamin LaHaise
2007-04-11 19:52       ` Zach Brown
2007-04-11 20:03         ` Benjamin LaHaise
2007-04-12  7:29     ` Ken Chen
2007-04-12 12:06       ` Jeff Moyer
2007-04-13  0:57         ` Ken Chen
2007-04-13  1:08           ` Ken Chen
2007-04-12  7:50   ` Ken Chen
2007-04-12 14:31     ` Benjamin LaHaise
2007-04-12 15:13       ` Benjamin LaHaise

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=20070411121146.47ca5b4d.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=kenchen@google.com \
    --cc=linux-aio@kvack.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=zach.brown@oracle.com \
    /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