[PATCH 2/5] vmbus: implement lock-less ring buffer

Stephen Hemminger stephen at networkplumber.org
Mon May 22 18:33:25 UTC 2017


On Mon, 22 May 2017 11:28:18 -0700
Stephen Hemminger <stephen at networkplumber.org> wrote:

> On Sun, 21 May 2017 18:09:59 +0000
> KY Srinivasan <kys at microsoft.com> wrote:
> 
> > > -----Original Message-----
> > > From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> > > Sent: Thursday, May 18, 2017 9:25 AM
> > > To: KY Srinivasan <kys at microsoft.com>; gregkh at linuxfoundation.org
> > > Cc: devel at linuxdriverproject.org; Stephen Hemminger
> > > <sthemmin at microsoft.com>
> > > Subject: [PATCH 2/5] vmbus: implement lock-less ring buffer
> > > 
> > > Use a reservation similar to ftrace to make vmbus ring buffer writes
> > > lock free.
> > > 
> > > The algorithm uses cmpxchg to atomically reserve an area in the ring
> > > buffer. Then the data is copied into the ring, and the updates to the
> > > head of the ring are ordered.
> > > 
> > > Other similar implementions are FreeBSD buf_ring, and DPDK rte_ring.
> > > 
> > > Signed-off-by: Stephen Hemminger <sthemmin at microsoft.com>  
> 
> 
> I did some detailed measurements. The locked version takes 89.8ns average to write to
> ring buffer, and the cmpxchg version takes 94.7ns.  The difference is that the locked
> version has longer tail of distribution. Some most common for both cases is 80ns.
> 
> Let's skip this patch.

I will make a new version with locks, but uses the simplified memcpy code.


More information about the devel mailing list