Date: Fri, 25 Nov 2016 17:00:10 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Fabien Thomas <fabient@FreeBSD.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r309143 - head/sys/libkern Message-ID: <20161125160010.GA3307@dft-labs.eu> In-Reply-To: <201611251349.uAPDnX09042110@repo.freebsd.org> References: <201611251349.uAPDnX09042110@repo.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Nov 25, 2016 at 01:49:33PM +0000, Fabien Thomas wrote: > Author: fabient > Date: Fri Nov 25 13:49:33 2016 > New Revision: 309143 > URL: https://svnweb.freebsd.org/changeset/base/309143 > > Log: > In a dual processor system (2*6 cores) during IPSec throughput tests, > we see a lot of contention on the arc4 lock, used to generate the IV > of the ESP output packets. > > The idea of this patch is to split this mutex in order to reduce the > contention on this lock. > > +MALLOC_DEFINE(M_ARC4RANDOM, "arc4random", "arc4random structures"); > > -static u_int8_t arc4_randbyte(void); > +struct arc4_s { > + u_int8_t i, j; > + int numruns; > + u_int8_t sbox[256]; > + time_t t_reseed; > + > + struct mtx mtx; > +}; > + Why is the lock at the end? Right now you got false sharing with the next entry. That said, I suggest: 1. moving thelock to the beginning 2. annotating the struct with __aligned(CACHE_LINE_SIZE) -- Mateusz Guzik <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20161125160010.GA3307>