From owner-svn-src-all@freebsd.org Fri Feb 15 10:37:15 2019 Return-Path: Delivered-To: svn-src-all@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 45E0514D5194; Fri, 15 Feb 2019 10:37:15 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 41D538A506; Fri, 15 Feb 2019 10:37:14 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x1FAakZI035956 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 15 Feb 2019 12:36:49 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x1FAakZI035956 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x1FAaiUg035955; Fri, 15 Feb 2019 12:36:44 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 15 Feb 2019 12:36:44 +0200 From: Konstantin Belousov To: Alexey Dokuchaev Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r344118 - head/sys/i386/include Message-ID: <20190215103644.GN24863@kib.kiev.ua> References: <201902141353.x1EDrB0Z076223@repo.freebsd.org> <20190215071604.GA89653@FreeBSD.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190215071604.GA89653@FreeBSD.org> User-Agent: Mutt/1.11.2 (2019-01-07) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Feb 2019 10:37:15 -0000 On Fri, Feb 15, 2019 at 07:16:04AM +0000, Alexey Dokuchaev wrote: > On Thu, Feb 14, 2019 at 01:53:11PM +0000, Konstantin Belousov wrote: > > New Revision: 344118 > > URL: https://svnweb.freebsd.org/changeset/base/344118 > > > > Log: > > Provide userspace versions of do_cpuid() and cpuid_count() on i386. > > > > Some older compilers, when generating PIC code, cannot handle inline > > asm that clobbers %ebx (because %ebx is used as the GOT offset > > register). Userspace versions avoid clobbering %ebx by saving it to > > stack before executing the CPUID instruction. > > > > ... > > +static __inline void > > +do_cpuid(u_int ax, u_int *p) > > +{ > > + __asm __volatile( > > + "pushl\t%%ebx\n\t" > > + "cpuid\n\t" > > + "movl\t%%ebx,%1\n\t" > > + "popl\t%%ebx" > > Is there a reason to prefer pushl+movl+popl instead of movl+xchgl? > > "movl %%ebx, %1\n\t" > "cpuid\n\t" > "xchgl %%ebx, %1" xchgl seems to be slower even in registers format (where no implicit lock is used). If you can demonstrate that your fragment is better in some microbenchmark, I can change it. But also note that its use is not on the critical path.