From owner-svn-src-head@freebsd.org Sat Jun 2 20:14:44 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D117CFE1473; Sat, 2 Jun 2018 20:14:44 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7F81475893; Sat, 2 Jun 2018 20:14:44 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 44176148CB; Sat, 2 Jun 2018 20:14:44 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w52KEiwC065186; Sat, 2 Jun 2018 20:14:44 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w52KEiga065185; Sat, 2 Jun 2018 20:14:44 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201806022014.w52KEiga065185@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Sat, 2 Jun 2018 20:14:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334537 - head/sys/amd64/amd64 X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: head/sys/amd64/amd64 X-SVN-Commit-Revision: 334537 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 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: Sat, 02 Jun 2018 20:14:45 -0000 Author: mjg Date: Sat Jun 2 20:14:43 2018 New Revision: 334537 URL: https://svnweb.freebsd.org/changeset/base/334537 Log: amd64: add a mild depessimization to rep mov/stos users Currently all the primitives are waiting for a rewrite, tidy them up in the meantime. Vast majority of cases pass sizes which are multiple of 8. Which means the following rep stosb/movb has nothing to do. Turns out testing first if there is anything to do is a big win across the board (cpus with and without ERMS, Intel and AMD) while not pessimizing the case where there is work to do. Sample results for zeroing 64 bytes (ops/second): Ryzen Threadripper 1950X 91433212 -> 147265741 Intel(R) Xeon(R) CPU X5675 @ 3.07GHz 90714044 -> 121992888 bzero and bcopy are on their way out and were not modified. Nothing in the tree uses them. Modified: head/sys/amd64/amd64/support.S Modified: head/sys/amd64/amd64/support.S ============================================================================== --- head/sys/amd64/amd64/support.S Sat Jun 2 20:11:28 2018 (r334536) +++ head/sys/amd64/amd64/support.S Sat Jun 2 20:14:43 2018 (r334537) @@ -205,6 +205,11 @@ ENTRY(memmove) movsq movq %rdx,%rcx andq $7,%rcx /* any bytes left? */ + jne 2f + movq %r9,%rax + POP_FRAME_POINTER + ret +2: rep movsb movq %r9,%rax @@ -248,6 +253,10 @@ ENTRY(memcpy) movsq movq %rdx,%rcx andq $7,%rcx /* any bytes left? */ + jne 1f + POP_FRAME_POINTER + ret +1: rep movsb POP_FRAME_POINTER @@ -269,6 +278,11 @@ ENTRY(memset) stosq movq %rdx,%rcx andq $7,%rcx + jne 1f + movq %r9,%rax + POP_FRAME_POINTER + ret +1: rep stosb movq %r9,%rax @@ -358,6 +372,7 @@ ENTRY(copyout) movsq movb %dl,%cl andb $7,%cl + je done_copyout rep movsb @@ -406,6 +421,7 @@ ENTRY(copyin) movsq movb %al,%cl andb $7,%cl /* copy remaining bytes */ + je done_copyin rep movsb