From owner-svn-src-head@freebsd.org Mon May 7 15:45:46 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 11DF9FB534E; Mon, 7 May 2018 15:45:46 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (br1.CN84in.dnsmgr.net [69.59.192.140]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B9D9F86DC4; Mon, 7 May 2018 15:45:44 +0000 (UTC) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: from pdx.rh.CN85.dnsmgr.net (localhost [127.0.0.1]) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3) with ESMTP id w47FjZWk056521; Mon, 7 May 2018 08:45:35 -0700 (PDT) (envelope-from freebsd@pdx.rh.CN85.dnsmgr.net) Received: (from freebsd@localhost) by pdx.rh.CN85.dnsmgr.net (8.13.3/8.13.3/Submit) id w47FjZYA056520; Mon, 7 May 2018 08:45:35 -0700 (PDT) (envelope-from freebsd) From: "Rodney W. Grimes" Message-Id: <201805071545.w47FjZYA056520@pdx.rh.CN85.dnsmgr.net> Subject: Re: svn commit: r333324 - in head/sys: amd64/amd64 conf In-Reply-To: <201805071507.w47F7SOs035073@repo.freebsd.org> To: Mateusz Guzik Date: Mon, 7 May 2018 08:45:35 -0700 (PDT) CC: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Reply-To: rgrimes@freebsd.org X-Mailer: ELM [version 2.4ME+ PL121h (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 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: Mon, 07 May 2018 15:45:46 -0000 > Author: mjg > Date: Mon May 7 15:07:28 2018 > New Revision: 333324 > URL: https://svnweb.freebsd.org/changeset/base/333324 > > Log: > amd64: replace libkern's memset and memmove with assembly variants > > memmove is repurposed bcopy (arguments swapped, return value added) > The libkern variant is a wrapper around bcopy, so this is a big > improvement. > > memset is repurposed memcpy. The librkern variant is doing fishy stuff, > including branching on 0 and calling bzero. > > Both functions are rather crude and subject to partial depessimization. > > This is a soft prerequisite to adding variants utilizing the > 'Enhanced REP MOVSB/STOSB' bit and let the kernel patch at runtime. > > Modified: > head/sys/amd64/amd64/support.S > head/sys/conf/files.amd64 > > Modified: head/sys/amd64/amd64/support.S > ============================================================================== > --- head/sys/amd64/amd64/support.S Mon May 7 15:07:26 2018 (r333323) > +++ head/sys/amd64/amd64/support.S Mon May 7 15:07:28 2018 (r333324) > @@ -162,6 +162,58 @@ ENTRY(bcopy) > END(bcopy) > > /* > + * memmove(dst, src, cnt) > + * rdi, rsi, rdx > + * Original by: > + * ws@tools.de (Wolfgang Solfrank, TooLs GmbH) +49-228-985800 If the original is by ws@tools.de, who is this version by? Or is this simply copied from some other FreeBSD file? Thanks, > + */ > +ENTRY(memmove) > + PUSH_FRAME_POINTER > + movq %rdi,%r9 > + movq %rdx,%rcx > + > + movq %rdi,%rax > + subq %rsi,%rax > + cmpq %rcx,%rax /* overlapping && src < dst? */ > + jb 1f > + > + shrq $3,%rcx /* copy by 64-bit words */ > + rep > + movsq > + movq %rdx,%rcx > + andq $7,%rcx /* any bytes left? */ > + rep > + movsb > + movq %r9,%rax > + POP_FRAME_POINTER > + ret > + > + /* ALIGN_TEXT */ > +1: > + addq %rcx,%rdi /* copy backwards */ > + addq %rcx,%rsi > + decq %rdi > + decq %rsi > + andq $7,%rcx /* any fractional bytes? */ > + std > + rep > + movsb > + movq %rdx,%rcx /* copy remainder by 32-bit words */ > + shrq $3,%rcx > + subq $7,%rsi > + subq $7,%rdi > + rep > + movsq > + cld > + movq %r9,%rax > + POP_FRAME_POINTER > + ret > +END(memmove) > + > +/* > + * memcpy(dst, src, len) > + * rdi, rsi, rdx > + * > * Note: memcpy does not support overlapping copies > */ > ENTRY(memcpy) > @@ -178,6 +230,27 @@ ENTRY(memcpy) > POP_FRAME_POINTER > ret > END(memcpy) > + > +/* > + * memset(dst, c, len) > + * rdi, rsi, rdx > + */ > +ENTRY(memset) > + PUSH_FRAME_POINTER > + movq %rdi,%r9 > + movq %rdx,%rcx > + movq %rsi,%rax > + shrq $3,%rcx > + rep > + stosq > + movq %rdx,%rcx > + andq $7,%rcx > + rep > + stosb > + movq %r9,%rax > + POP_FRAME_POINTER > + ret > +END(memset) > > /* > * pagecopy(%rdi=from, %rsi=to) > > Modified: head/sys/conf/files.amd64 > ============================================================================== > --- head/sys/conf/files.amd64 Mon May 7 15:07:26 2018 (r333323) > +++ head/sys/conf/files.amd64 Mon May 7 15:07:28 2018 (r333324) > @@ -620,8 +620,6 @@ isa/vga_isa.c optional vga > kern/kern_clocksource.c standard > kern/link_elf_obj.c standard > libkern/x86/crc32_sse42.c standard > -libkern/memmove.c standard > -libkern/memset.c standard > # > # IA32 binary support > # > > -- Rod Grimes rgrimes@freebsd.org