From owner-svn-src-head@FreeBSD.ORG Mon Feb 9 22:12:37 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BEE416B4; Mon, 9 Feb 2015 22:12:37 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 976128A5; Mon, 9 Feb 2015 22:12:37 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id B358AB93B; Mon, 9 Feb 2015 17:12:35 -0500 (EST) From: John Baldwin To: Jung-uk Kim Subject: Re: svn commit: r278474 - head/sys/sys Date: Mon, 09 Feb 2015 17:12:02 -0500 Message-ID: <3501684.yzo0NMkRZd@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <54D92CE8.1030803@FreeBSD.org> References: <201502092103.t19L3OAn013792@svn.freebsd.org> <1698688.fEq0HxqPxg@ralph.baldwin.cx> <54D92CE8.1030803@FreeBSD.org> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 09 Feb 2015 17:12:35 -0500 (EST) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 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, 09 Feb 2015 22:12:37 -0000 On Monday, February 09, 2015 04:55:52 PM Jung-uk Kim wrote: > On 02/09/2015 16:08, John Baldwin wrote: > > On Monday, February 09, 2015 09:03:24 PM John Baldwin wrote: > >> Author: jhb Date: Mon Feb 9 21:03:23 2015 New Revision: 278474 > >> URL: https://svnweb.freebsd.org/changeset/base/278474 > >> > >> Log: Use __builtin_popcnt() to implement a BIT_COUNT() operation > >> for bitsets and use this to implement CPU_COUNT() to count the > >> number of CPUs in a cpuset. > >> > >> MFC after: 2 weeks > > > > Yes, __builtin_popcnt() works with GCC 4.2. It should also allow > > the compiler to DTRT in userland uses of this if -msse4.2 is > > enabled. > > Back in 2012, when I submitted a similar patch, bde noted > __builtin_popcount*() cannot be used with GCC 4.2 for *kernel* because > it emits a library call. > > http://docs.freebsd.org/cgi/mid.cgi?20121116171923.L1135 > > FYI... Weird, I though I built a kernel with this in a tree that uses it in the igb(4) driver. We need a CPU_COUNT() no matter what, but if this emits a library call under GCC I will need to add the call. We could also adopt your bitcount header, though I think it is more consistent to keep the loop in BIT_COUNT() and use something that emulates popcountl() rather than directly using bitcount() in BIT_COUNT() (primarily because the rest of sys/bitset.h is structured that way: explicit loops in sys/bitset.h itself). -- John Baldwin