lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Fri, 20 Jan 2017 21:15:02 +0000
From:   Long Li <longli@...rosoft.com>
To:     Dexuan Cui <decui@...rosoft.com>,
        KY Srinivasan <kys@...rosoft.com>,
        Haiyang Zhang <haiyangz@...rosoft.com>
CC:     "devel@...uxdriverproject.org" <devel@...uxdriverproject.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] hv: use substraction to update ring buffer index



> -----Original Message-----
> From: Dexuan Cui
> Sent: Sunday, January 15, 2017 7:12 PM
> To: Long Li <longli@...rosoft.com>; KY Srinivasan <kys@...rosoft.com>;
> Haiyang Zhang <haiyangz@...rosoft.com>
> Cc: devel@...uxdriverproject.org; linux-kernel@...r.kernel.org
> Subject: RE: [PATCH] hv: use substraction to update ring buffer index
> 
> > From: devel [mailto:driverdev-devel-bounces@...uxdriverproject.org] On
> > Behalf Of Long Li
> > Sent: Thursday, January 5, 2017 12:08
> > To: KY Srinivasan <kys@...rosoft.com>; Haiyang Zhang
> > <haiyangz@...rosoft.com>
> > Cc: devel@...uxdriverproject.org; linux-kernel@...r.kernel.org
> > Subject: [PATCH] hv: use substraction to update ring buffer index
> >
> > From: Long Li <longli@...rosoft.com>
> >
> > The ring buffer code uses %= to calculate index. For x86/64, %=
> > compiles to div, more than 10 times slower than sub.
> >
> > Replace div with sub for this data heavy code path.
> >
> > Signed-off-by: Long Li <longli@...rosoft.com>
> > ---
> >  drivers/hv/ring_buffer.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index
> > cd49cb1..f8eee6e 100644
> > --- a/drivers/hv/ring_buffer.c
> > +++ b/drivers/hv/ring_buffer.c
> > @@ -135,7 +135,8 @@ hv_get_next_readlocation_withoffset(struct
> > hv_ring_buffer_info *ring_info,
> >         u32 next = ring_info->ring_buffer->read_index;
> >
> >         next += offset;
> > -       next %= ring_info->ring_datasize;
> > +       if (next >= ring_info->ring_datasize)
> > +               next -= ring_info->ring_datasize;
> >
> >         return next;
> >  }
> > @@ -179,7 +180,8 @@ static u32 hv_copyfrom_ringbuffer(
> >         memcpy(dest, ring_buffer + start_read_offset, destlen);
> >
> >         start_read_offset += destlen;
> > -       start_read_offset %= ring_buffer_size;
> > +       if (start_read_offset >= ring_buffer_size)
> > +               start_read_offset -= ring_buffer_size;
> >
> >         return start_read_offset;
> >  }
> > @@ -201,7 +203,8 @@ static u32 hv_copyto_ringbuffer(
> >         memcpy(ring_buffer + start_write_offset, src, srclen);
> >
> >         start_write_offset += srclen;
> > -       start_write_offset %= ring_buffer_size;
> > +       if (start_write_offset >= ring_buffer_size)
> > +               start_write_offset -= ring_buffer_size;
> >
> >         return start_write_offset;
> >  }
> 
> Hi Long,
> I guess you want to fix put_pkt_raw() too. :-)

Good point. I will send an updated patch.

> 
> Thanks,
> -- Dexuan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ