From owner-svn-src-head@freebsd.org Wed Feb 12 17:46:17 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id C2FCA23EA54; Wed, 12 Feb 2020 17:46:17 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48HnBK4mv8z3DQH; Wed, 12 Feb 2020 17:46:17 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x344.google.com with SMTP id t14so3557744wmi.5; Wed, 12 Feb 2020 09:46:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=VgEVR/ZyetrrwaJ9lZY2hyTLolr+7uQwgHVJzc9Yyw4=; b=hm6LQGCZMC5A8ix1Q5YnMk2I3dbWWTAp+IRBEVb2lY+q7wgbMtL6riW1H5SRi5+O2N rTyifDCaKK/4WG5XyGjMC/Znrh6EAVLwAexAm05RjVdKoa5e9zjs803fwqcyeL5jygNN 1KynlW33sgrPQj+6Vtn1o4WtWm5ZV83Bh1H6tsjAnczgEo3jqDstgvaCKjLz3iYGqnbr pzTHR4qqxGAL4mBiFN5FYIu8J3stbjhwxp0cOUDj96hhDxsW6X5pnxD579534TBpVwZE 2LwRk3Orcje9WdtaBNDDRWd192MslGQ1+QANn1xaHnztGeQtnIQJyA7BWuXF8Mk4siFF 2OwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=VgEVR/ZyetrrwaJ9lZY2hyTLolr+7uQwgHVJzc9Yyw4=; b=jTqDQY8j7Hm8gt2aEEC8QQiOZkJB2gu+fT8WShIxtKSlUpx/k03x3MJDuKCJkGaYAj JhT0Q4Hd7Hi3pY8yifFyhLYp27W3auv0cIimgIrasYySDCmuKHIbIDTT5NUDRkpqVE2s 5/Nw45Bof2Ai0xnDMFMd0OA9Ml0SD3Fhc94cVA+CJJ9gBf2dZyaF1JYhTzPZbSkTPlhC NNIKcmoCXp9r8MJaaKhn2tLyH1F2rMgGBXaGeC/e6eNWsUytvl0MJvYKOr/kr0K243mz BPNRtwfa0bAaRv82rzapE3H0BCJ+psS6x3bI+vUWdKXXuu/5F5sahKmA2GseXNAMrT3q SkcQ== X-Gm-Message-State: APjAAAW3FL6moYELY7FM/GobqoJzqd8u/WT959cH+ReqwxEgQlWDGqmi yj2l8d+c5wW8EF9CUED+r095xL8c5IVmOBLxQ9qqVg== X-Google-Smtp-Source: APXvYqxYUS++NF/HRU+gQUDzkpKPzxlVgaDSjvrNiZMtLSwg73aOHz2BIjrCQnMoFSpE48yl4i6CsO1oDlZNVQ+nvNk= X-Received: by 2002:a1c:8055:: with SMTP id b82mr179420wmd.127.1581529575491; Wed, 12 Feb 2020 09:46:15 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:6b02:0:0:0:0:0 with HTTP; Wed, 12 Feb 2020 09:46:14 -0800 (PST) In-Reply-To: <20200212172608.GD1253@FreeBSD.org> References: <202002121112.01CBCExs085630@repo.freebsd.org> <20200212172608.GD1253@FreeBSD.org> From: Mateusz Guzik Date: Wed, 12 Feb 2020 18:46:14 +0100 Message-ID: Subject: Re: svn commit: r357805 - head/sys/amd64/include To: Gleb Smirnoff Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 48HnBK4mv8z3DQH X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-6.00 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-0.998,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; REPLY(-4.00)[] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 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: Wed, 12 Feb 2020 17:46:17 -0000 On 2/12/20, Gleb Smirnoff wrote: > On Wed, Feb 12, 2020 at 11:12:14AM +0000, Mateusz Guzik wrote: > M> Author: mjg > M> Date: Wed Feb 12 11:12:13 2020 > M> New Revision: 357805 > M> URL: https://svnweb.freebsd.org/changeset/base/357805 > M> > M> Log: > M> amd64: store per-cpu allocations subtracted by __pcpu > M> > M> This eliminates a runtime subtraction from counter_u64_add. > M> > M> before: > M> mov 0x4f00ed(%rip),%rax # 0xffffffff80c01788 > > M> sub 0x808ff6(%rip),%rax # 0xffffffff80f1a698 <__pcpu> > M> addq $0x1,%gs:(%rax) > M> > M> after: > M> mov 0x4f02fd(%rip),%rax # 0xffffffff80c01788 > > M> addq $0x1,%gs:(%rax) > M> > M> Reviewed by: jeff > M> Differential Revision: https://reviews.freebsd.org/D23570 > > Neat optimization! Thanks. Why didn't we do it back when created counter? > Don't look at me, I did not work on it. You can top it for counters like the above -- most actual counters are known to be there at compilatin time and they never disappear. Meaning that in the simplest case they can just be a part of one big array in struct pcpu. Then assembly could resort to addq $0x1,%gs:(someoffset) removing the mov loading the address -- faster single threaded and less cache use. I'm confident I noted this at least few times. -- Mateusz Guzik