Date: Thu, 20 Sep 2018 13:29:44 +0000 (UTC) From: Mateusz Guzik <mjg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338828 - head/sys/amd64/amd64 Message-ID: <201809201329.w8KDTiab008870@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mjg Date: Thu Sep 20 13:29:43 2018 New Revision: 338828 URL: https://svnweb.freebsd.org/changeset/base/338828 Log: amd64: move fusufault after all users A lot of function have the following check: cmpq %rax,%rdi /* verify address is valid */ ja fusufault The label is present earlier in kernel .text, which means this is a jump backwards. Absent any information in branch predictor, the cpu predicts it as taken. Since it is almost never taken in practice, this results in a completely avoidable misprediction. Move it past all consumers, so that it is predicted as not taken. Approved by: re (kib) Modified: head/sys/amd64/amd64/support.S Modified: head/sys/amd64/amd64/support.S ============================================================================== --- head/sys/amd64/amd64/support.S Thu Sep 20 11:44:36 2018 (r338827) +++ head/sys/amd64/amd64/support.S Thu Sep 20 13:29:43 2018 (r338828) @@ -755,16 +755,6 @@ ENTRY(fubyte_smap) ret END(fubyte_smap) - ALIGN_TEXT - /* Fault entry clears PSL.AC */ -fusufault: - movq PCPU(CURPCB),%rcx - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%rcx) - decq %rax - POP_FRAME_POINTER - ret - /* * Store a 64-bit word, a 32-bit word, a 16-bit word, or an 8-bit byte to * user memory. @@ -915,6 +905,16 @@ ENTRY(subyte_smap) POP_FRAME_POINTER ret END(subyte_smap) + + ALIGN_TEXT + /* Fault entry clears PSL.AC */ +fusufault: + movq PCPU(CURPCB),%rcx + xorl %eax,%eax + movq %rax,PCB_ONFAULT(%rcx) + decq %rax + POP_FRAME_POINTER + ret /* * copyinstr(from, to, maxlen, int *lencopied)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201809201329.w8KDTiab008870>