aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/bitset.h
Commit message (Collapse)AuthorAgeFilesLines
* bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMICRyan Libby2020-12-311-0/+14
| | | | | | | | | | That is, provide wrappers around the atomic_testandclear and atomic_testandset primitives. Submitted by: jeff Reviewed by: cem, kib, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22702
* bitset: expand bit index type to `long`D Scott Phillips2020-09-211-4/+3
| | | | | | | | | | | | | | | | | | | An upcoming patch to use the bitset macros for tracking vm page dump information could conceivably need more than INT_MAX bits. Expand the bit type to long so that the extra range is available on 64-bit platforms where it would most likely be needed. CPUSET_COUNT and DOMAINSET_COUNT are also modified to remain of type `int`. Reviewed by: kib, markj Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26190 Notes: svn path=/head/; revision=365975
* bitset: add BIT_FFS_AT() for finding the first bit set greater than a start bitD Scott Phillips2020-08-261-4/+15
| | | | | | | | | | | Reviewed by: kib Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26128 Notes: svn path=/head/; revision=364796
* Fix undefined behavior: left-shifting into the sign bit.Konstantin Belousov2019-12-231-1/+1
| | | | | | | | | | Reviewed by: dim, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D22898 Notes: svn path=/head/; revision=356039
* bitset: rename confusing macro NAND to ANDNOTRyan Libby2019-12-131-2/+2
| | | | | | | | | | | | | | | | s/BIT_NAND/BIT_ANDNOT/, and for CPU and DOMAINSET too. The actual implementation is "and not" (or "but not"), i.e. A but not B. Fortunately this does appear to be what all existing callers want. Don't supply a NAND (not (A and B)) operation at this time. Discussed with: jeff Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22791 Notes: svn path=/head/; revision=355709
* bitset: avoid pessimized code when bitset size is not constantRyan Libby2019-12-031-2/+9
| | | | | | | | | | | | | | | We have a couple optimizations for when the bitset is known to be just one word. But with dynamically sized bitsets, it was actually more work to determine the size than just to do the necessary computation. Now, only use the optimization when the size is known to be constant. Reviewed by: markj Discussed with: jeff Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22639 Notes: svn path=/head/; revision=355344
* Use a precise bit count for the slab free items in UMA. This significantlyJeff Roberson2019-12-021-2/+3
| | | | | | | | | | shrinks embedded slab structures. Reviewed by: markj, rlibby (prior version) Differential Revision: https://reviews.freebsd.org/D22584 Notes: svn path=/head/; revision=355315
* sys/sys: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326256
* Fix BIT_FLS().Konstantin Belousov2017-07-111-4/+4
| | | | | | | | | | | The iteration index is unsigned, so testing for larger than or equal to zero makes little sense. Submitted by: Sebastian Huber <sebastian.huber@embedded-brains.de> MFC after: 3 days Notes: svn path=/head/; revision=320893
* Add BIT_FLS() analogous to BIT_FFS().Konstantin Belousov2017-07-061-0/+15
| | | | | | | | | | | The benefit of BIT_FLS() is that ffsl() can be implemented with a count leading zeros instruction which is more widespread available. Submitted by: Sebastian Huber <sebastian.huber@embedded-brains.de> MFC after: 1 week Notes: svn path=/head/; revision=320755
* Add BIT_OR2(), BIT_AND2(), BIT_NAND2(), BIT_XOR() and BIT_XOR2().Konstantin Belousov2017-05-241-0/+30
| | | | | | | | Submitted by: Sebastian Huber <sebastian.huber@embedded-brains.de> MFC after: 2 weeks Notes: svn path=/head/; revision=318781
* bitset: introduce helpers to allocate a bitset at runtimeRoger Pau Monné2016-05-061-0/+6
| | | | | | | | | | | | Introduce some new helpers to declare and allocate a dynamic bitset, whose size is not a constant. Sponsored by: Citrix Systems R&D Reviewed by: kib jhb Differential revision: https://reviews.freebsd.org/D6226 Notes: svn path=/head/; revision=299184
* Fix <sys/_bitset.h> and <sys/_cpuset.h> to not require <sys/param.h>.John Baldwin2016-05-051-1/+14
| | | | | | | | | | | | | | - Hardcode '8' instead of NBBY in _BITSET_BITS. - Define a private version of 'howmany' for use in __bitset_words(). - While here, move a few more things out of _bitset.h and _cpuset.h to bitset.h and cpuset.h, respectively. The only things left in _bitset.h and _cpuset.h are the bits needed to define a bitset structure. Reviewed by: bde, kib (ish) Notes: svn path=/head/; revision=299122
* Expand the bitcount* API to support 64-bit integers, plain ints and longsJohn Baldwin2015-03-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | and create a "hidden" API that can be used in other system headers without adding namespace pollution. - If the POPCNT instruction is enabled at compile time, use __builtin_popcount*() to implement __bitcount*(), otherwise fall back to software implementations. - Use the existing bitcount16() and bitcount32() from <sys/systm.h> to implement the non-POPCNT __bitcount16() and __bitcount32() in <sys/types.h>. - For the non-POPCNT __bitcount64(), use a similar SWAR method on 64-bit systems. For 32-bit systems, use two __bitcount32() operations on the two halves. - Use __bitcount32() to provide a __bitcount() that operates on plain ints. - Use either __bitcount32() or __bitcount64() to provide a __bitcountl() that operates on longs. - Add public bitcount*() wrappers for __bitcount*() for use in the kernel in <sys/libkern.h>. - Use __builtinl() instead of __builtin_popcountl() in BIT_COUNT(). Discussed with: bde Notes: svn path=/head/; revision=280279
* Use __builtin_popcountl() instead of __builtin_popcount().John Baldwin2015-02-091-1/+1
| | | | | | | Submitted by: jkim Notes: svn path=/head/; revision=278476
* Use __builtin_popcnt() to implement a BIT_COUNT() operation for bitsets andJohn Baldwin2015-02-091-0/+10
| | | | | | | | | use this to implement CPU_COUNT() to count the number of CPUs in a cpuset. MFC after: 2 weeks Notes: svn path=/head/; revision=278474
* Merge from projects/bhyve_svm all the changes outside vmm.ko or bhyve utilities:Neel Natu2014-10-201-0/+4
| | | | | | | | | | | | | | | | | | | | Add support for AMD's nested page tables in pmap.c: - Provide the correct bit mask for various bit fields in a PTE (e.g. valid bit) for a pmap of type PT_RVI. - Add a function 'pmap_type_guest(pmap)' that returns TRUE if the pmap is of type PT_EPT or PT_RVI. Add CPU_SET_ATOMIC_ACQ(num, cpuset): This is used when activating a vcpu in the nested pmap. Using the 'acquire' variant guarantees that the load of the 'pm_eptgen' will happen only after the vcpu is activated in 'pm_active'. Add defines for various AMD-specific MSRs. Submitted by: Anish Gupta (akgupt3@gmail.com) Notes: svn path=/head/; revision=273338
* Add BIT_AND_ATOMIC() and CPU_AND_ATOMIC().Konstantin Belousov2013-08-301-1/+8
| | | | | | | | | Sponsored by: The FreeBSD Foundation Reviewed by: alc Tested by: pho, bf Notes: svn path=/head/; revision=255059
* - Add a BIT_FFS() macro and use it to replace cpusetffs_obj()Jeff Roberson2013-06-131-0/+15
| | | | | | | | Discussed with: attilio Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=251703
* Generalize the bitset operations, present in cpuset and offer a KPI toAttilio Rao2013-05-091-0/+153
redefine such operations for different consumers. This will be used when NUMA support will be finished and numaset will need to be used. Sponsored by: EMC / Isilon storage division Obtained from: jeff Reviewed by: alc Notes: svn path=/head/; revision=250395