svn commit: r278474 - head/sys/sys

Jung-uk Kim jkim at FreeBSD.org
Mon Feb 9 23:17:38 UTC 2015


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

On 02/09/2015 18:08, John Baldwin wrote:
> On Monday, February 09, 2015 05:27:45 PM Jung-uk Kim wrote:
>> On 02/09/2015 17:12, John Baldwin wrote:
>>> 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).
>> 
>> I think you should back it out for now and move the discussion to
>> arch or hackers.  I gave it up at the time but you may have
>> better luck. :-)
>> 
>> FYI, the following was the last version of my patch at the time.
>> 
>> https://people.freebsd.org/~jkim/bitcount5.diff
> 
> I could also just make it userland only for now?  Rui wants to use
> it in userland.  However, I can back it out if that is preferred.

I am fine with "#if defined(__clang__) || !define(_KERNEL)" case.

> To be honest, I'm not sure how valuable it is at this point to
> expend a lot of effort to support GCC older than 3.4 (i.e. the
> non-builtin popcount approach).

No, I don't care about GCC 3.x any more.

Jung-uk Kim
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQEcBAEBCAAGBQJU2UALAAoJEHyflib82/FGy8wH/jviXO8fcvprc1y4DGkc87rD
ylBjoHimjsDt6Wr9MixYNZKbTXhd4BIgQVvFphgCshGjBbmkvII9DH/OleSTa/p8
/YJk87dZHE336An+GkXGTshESvLHw3l8hACR5FcussDLswJArBcDMuzbIW9Q7ASY
dJsWTajP3r4rBqAtQQGxAmNfIvWC6iUP7mELSIoP8vBbUfO4HVZZWh7u5gqXxXnk
dDX4kc7XuGweOtMydIY8bYiQYWb+IqMjnCEuucpJ4yktj3kUr8v9To+xAW6AmX7V
OZQjMRzFbVKHPB6gs5fSaNZBD/D6MUpeDAXRQCy52xQB7vCQE1UNrR850upvxxY=
=NARs
-----END PGP SIGNATURE-----


More information about the svn-src-head mailing list