BUS_GET_CPUS(9)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… BUS_GET_CPUS(9) πŸ’…

okay so bestie, welcome to BUS_GET_CPUS(9) β€” that's the Kernel Developer's Manual section 9, aka the deep kernel lore zone. sit down, hydrate, and let me tell you about requesting a set of device-specific CPUs 🫢


✨ NAME ✨

BUS_GET_CPUS, bus_get_cpus β€” request a set of device-specific CPUs πŸ’»πŸŒΈ


πŸŽ€ SYNOPSIS πŸŽ€

like, here's the part you actually copy-paste, no cap:

#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpuset.h>

int
BUS_GET_CPUS(device_t dev, device_t child, enum cpu_sets op,
    size_t setsize, cpuset_t *cpuset);

int
bus_get_cpus(device_t dev, enum cpu_sets op, size_t setsize,
    cpuset_t *cpuset);

πŸ¦‹ DESCRIPTION πŸ¦‹

so the BUS_GET_CPUS() method is literally the main character here πŸ‘‘ β€” it goes and asks the parent bus device for a set of device-specific CPUs.

The op argument is the vibe check: it says which set of CPUs you want. If it all works out (success era ✨), the requested set of CPUs comes back to you in cpuset. And setsize is the size in bytes of the set you passed in cpuset β€” yes, bytes, keep track of your units bestie πŸ’€

BUS_GET_CPUS() supports querying different types of CPU sets via the op argument. But ngl, not every set type is supported for every device πŸ™ˆ. If a set type isn't supported, BUS_GET_CPUS() fails with EINVAL. These set types are the supported ones, periodt:

  • LOCAL_CPUS β€” the set of CPUs that are local to the device. If a device is closer to a specific memory domain in a non-uniform memory architecture system (NUMA), this will return the set of CPUs in that memory domain. proximity slay 🧚
  • INTR_CPUS β€” the preferred set of CPUs that this device should use for device interrupts. This set type must be supported by all bus drivers. no skipping this one πŸ”₯

The bus_get_cpus() function is a simple wrapper around BUS_GET_CPUS() β€” little icon, just handing things off πŸ’…


⭐ RETURN VALUES ⭐

Zero is returned on success πŸŽ‰ otherwise an appropriate error is returned. that's it, that's the rule 😭


🌈 SEE ALSO 🌈

go read these next, iykyk:


πŸ’œ HISTORY πŸ’œ

The BUS_GET_CPUS() method and bus_get_cpus() function first appeared in FreeBSD 11.0. vintage ✨


and that's the whole page, bestie πŸ’– this edition dropped from Debian and it's dated March 1, 2016 β€” mwah, go forth and query those CPU sets πŸŽ€πŸ¦‹πŸ“

πŸ“¦ where this page comes from