Page MenuHomeFreeBSD

bitset: Add ORNOT macros
ClosedPublic

Authored by jfree on Apr 26 2024, 4:12 PM.
Tags
None
Referenced Files
Unknown Object (File)
Oct 1 2024, 7:56 PM
Unknown Object (File)
Sep 30 2024, 6:29 AM
Unknown Object (File)
Sep 29 2024, 4:44 AM
Unknown Object (File)
Sep 28 2024, 9:12 AM
Unknown Object (File)
Sep 17 2024, 2:58 AM
Unknown Object (File)
Sep 3 2024, 9:27 PM
Unknown Object (File)
Jul 28 2024, 8:52 AM
Unknown Object (File)
Jul 8 2024, 12:06 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.Apr 26 2024, 4:12 PM

What do you plan to use this for?

This revision is now accepted and ready to land.Apr 27 2024, 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.