Date: Wed, 12 Feb 2020 18:46:14 +0100 From: Mateusz Guzik <mjguzik@gmail.com> To: Gleb Smirnoff <glebius@freebsd.org> Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r357805 - head/sys/amd64/include Message-ID: <CAGudoHEmDKWMRnjw%2Bge6Z-eVZT=%2B2rVczK7ca_F0cP_sTrPHBQ@mail.gmail.com> In-Reply-To: <20200212172608.GD1253@FreeBSD.org> References: <202002121112.01CBCExs085630@repo.freebsd.org> <20200212172608.GD1253@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2/12/20, Gleb Smirnoff <glebius@freebsd.org> 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 > <numfullpathfail4> > M> sub 0x808ff6(%rip),%rax # 0xffffffff80f1a698 <__pcpu> > M> addq $0x1,%gs:(%rax) > M> > M> after: > M> mov 0x4f02fd(%rip),%rax # 0xffffffff80c01788 > <numfullpathfail4> > 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 <mjguzik gmail.com>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGudoHEmDKWMRnjw%2Bge6Z-eVZT=%2B2rVczK7ca_F0cP_sTrPHBQ>