On Fri, Sep 16, 2011 at 3:02 AM, Arnaud Lacombe <lacom...@gmail.com> wrote: > Hi, > > On Wed, Sep 14, 2011 at 10:53 PM, Arnaud Lacombe <lacom...@gmail.com> wrote: >> Hi Kip, >> >> I've got a few question about the buf_ring(9) API. >> >> 1) what means the 'drbr_' prefix. I can guess the two last letter, 'b' >> and 'r', for Buffer Ring, but what about 'd' and 'r' ? >> >> 2) in `sys/sys/buf_ring.h', you defined 'struct buf_ring' as: >> >> struct buf_ring { >> volatile uint32_t br_prod_head; >> volatile uint32_t br_prod_tail; >> int br_prod_size; >> int br_prod_mask; >> uint64_t br_drops; >> uint64_t br_prod_bufs; >> uint64_t br_prod_bytes; > shouldn't those 3 fields be updated atomically, especially on 32bits > platforms ? That might pose a problem as, AFAIK, FreeBSD do not have > MI 64bits atomics operations...
Between the point at which br_prod_tail == prod_head and when we update br_prod_tail to point to prod_next we are the exclusive owners of the fields in buf_ring. That is why we wait for any other enqueueing threads to update br_prod_tail to point to prod_head before continuing. Cheers /* * If there are other enqueues in progress * that preceeded us, we need to wait for them * to complete */ while (br->br_prod_tail != prod_head) cpu_spinwait(); br->br_prod_bufs++; br->br_prod_bytes += nbytes; br->br_prod_tail = prod_next; critical_exit(); _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"