Page MenuHomeFreeBSD

bitset: Add ORNOT macros
ClosedPublic

Authored by jfree on Fri, Apr 26, 4:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, May 1, 9:03 AM
Unknown Object (File)
Tue, Apr 30, 3:19 PM
Unknown Object (File)
Tue, Apr 30, 3:12 PM
Unknown Object (File)
Tue, Apr 30, 2:18 PM
Unknown Object (File)
Sun, Apr 28, 8:42 PM
Unknown Object (File)
Sun, Apr 28, 12:22 AM
Unknown Object (File)
Sat, Apr 27, 12:16 AM
Unknown Object (File)
Sat, Apr 27, 12:14 AM
Subscribers

Details

Summary

Macros to ANDNOT a bitset currently exist, but there are no ORNOT
equivalents. Introduce ORNOT macros for bitset(9), cpuset(9), and
domainset(9).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jfree requested review of this revision.Fri, Apr 26, 4:12 PM

What do you plan to use this for?

This revision is now accepted and ready to land.Sat, Apr 27, 11:36 PM

What do you plan to use this for?

I have a cpuset that represents the cpus used by a set of programs. Each 1 in the cpuset represents a taken cpu, each 0 represents an open cpu.

I want some programs to reserve cpus in a certain numa domain, so I use cpuset_getaffinity() with CPU_WHICH_DOMAIN to get the cpus in a certain domain.

I then use BIT_ORNOT2(CPU_SETSIZE, &domain_set, &master_set, &domain_set) which:

  • finds all cpus that are not in the numa domain: ~domain_set.
  • ORs it with the master set
  • places the result in the domain_set.

This gives me a cpuset with 1s representing either taken cpus or cpus that are not in the numa domain and 0s representing open cpus.

I then loop over this bitset and find the first 0, which is my cpu to take.

This revision was automatically updated to reflect the committed changes.