From owner-svn-src-head@freebsd.org Fri Nov 25 16:00:16 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 72FF0C54732; Fri, 25 Nov 2016 16:00:16 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wj0-x242.google.com (mail-wj0-x242.google.com [IPv6:2a00:1450:400c:c01::242]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 08965755; Fri, 25 Nov 2016 16:00:16 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wj0-x242.google.com with SMTP id kp2so6074934wjc.0; Fri, 25 Nov 2016 08:00:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=lBJg3Yd0WaOtG5TBkeDJzzHcKY95kDUbDtLissso0e4=; b=zHNQNGkHu334LIwKuDlB9u/tzC4adqSYyCBBRg9qN4sdfCc6DCt6QCxTe6Y+7qHKu5 WTfk6wSM3DuPAJBkKdwiQF9j5UCxpf1VhCAkwc9EM4GJcAJ5ZLq9qRgxfz3GEFJ6Hda/ eS/On86NJZ00Kt4AbWZkHqYfY0m17eOmoE8PA7tZW7HKCI5fpnup/pQgWCIEMR3sPW7O DDO+R+oVVTEqQcbiCNCzgFh33MWt2Xp+1qfpmbEinhrkaTexdv5NlO66oZS1HEoPdJDs MKBPj8d6bXT8tgnpgSVSJZe48wVE6uRNZB++m4VFLubTdBaUwwn/E3E0rLDZnHWUL1EU r2mQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=lBJg3Yd0WaOtG5TBkeDJzzHcKY95kDUbDtLissso0e4=; b=dPtPBEo64v1aipKgEatvoqT7K0RrmK1snmcczSu/QGMn5H3Ho4zAp5TPgSId9k8dqq XbuIvmtcw+CMzMbYzWXvPKS1i8H6HpAXqhmgsn4MWzp6yMlkGe8iPj/R8ClYwW3qJkM8 40ORsQ1Re3SHcQtZE5kD5wQIlIBvpNbVctPSaT3bYglrlJDB8cQ2H4p9txpBeN9l4H5A MjMb4xVjmNctnwm/2tIrqKg4Rrppu00wCZwwcDhMzFn4mpE8vAVprVy2WnS+5Pcs2vPH vq6PUoF7FU6AwiJfEh9eMSoMhSv3VCQHe0ZU2Lbbpl08qOaWFesiejMQQuwmbcIMQ1Qx yynQ== X-Gm-Message-State: AKaTC00bWj+VPPXadSSUw7MyNLqG+YcnLbx8bj2sbL3eK3z/r+5O+NJ0ZJnoH61Ue54tQQ== X-Received: by 10.194.71.69 with SMTP id s5mr8137316wju.197.1480089613565; Fri, 25 Nov 2016 08:00:13 -0800 (PST) Received: from dft-labs.eu (n1x0n-1-pt.tunnel.tserv5.lon1.ipv6.he.net. [2001:470:1f08:1f7::2]) by smtp.gmail.com with ESMTPSA id kp5sm47684621wjb.8.2016.11.25.08.00.12 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Fri, 25 Nov 2016 08:00:12 -0800 (PST) Date: Fri, 25 Nov 2016 17:00:10 +0100 From: Mateusz Guzik To: Fabien Thomas 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> References: <201611251349.uAPDnX09042110@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <201611251349.uAPDnX09042110@repo.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 25 Nov 2016 16:00:16 -0000 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