[lkml]   [2007]   [Apr]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [patch] convert aio event reap to use atomic-op instead of spin_lock
    On Wed, 11 Apr 2007 11:00:38 -0700
    Zach Brown <> 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.

    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2007-04-11 21:17    [W:0.046 / U:67.092 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site