BUS_GET_CPUS(9)

πŸ’– BUS_GET_CPUS πŸ’–

okay bestie, gather round, because this is the manual page for BUS_GET_CPUS and bus_get_cpus from the Kernel Developer's Manual (section 9, we're fancy like that). It's the vibe where you ask a bus for a lil set of device-specific CPUs. Let's get into it ✨


🌸 NAME 🌸

BUS_GET_CPUS, bus_get_cpus β€” request a set of device-specific CPUs 🧚


✨ SYNOPSIS ✨

#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 BUS_GET_CPUS() is the method that goes and queries the parent bus device for a set of CPUs that are specific to a device. Iconic behaviour, honestly.

The op argument is the one that tells it which set of CPUs you want to retrieve. If everything goes right, the set you asked for gets returned in cpuset. And the setsize argument? That's the size in bytes of the set you passed in via cpuset. No cap πŸ“

BUS_GET_CPUS() supports querying different types of CPU sets through that op argument. But here's the tea: not all set types are supported for every device πŸ™ˆ. If a set type isn't supported, BUS_GET_CPUS() just fails with EINVAL. So rude of it. The set types that are supported are:

  • LOCAL_CPUS β€” the set of CPUs that are local to the device. So if a device is closer to a specific memory domain in a non-uniform memory architecture system (NUMA), this returns the set of CPUs in that memory domain. It's giving "geography matters" πŸ—ΊοΈ
  • INTR_CPUS β€” the preferred set of CPUs that this device should use for device interrupts. And bestie, listen: this set type must be supported by all bus drivers. Non-negotiable. periodt πŸ‘‘

And the bus_get_cpus() function? She's just a simple wrapper around BUS_GET_CPUS(). Low-key a shortcut, high-key useful 🫢


⭐ RETURN VALUES ⭐

Zero comes back on success πŸŽ€. Otherwise, an appropriate error is returned. That's it, that's the rule.


πŸ‘€ SEE ALSO πŸ‘€

Go read them, iykyk πŸ’…


🌈 HISTORY 🌈

The BUS_GET_CPUS() method and the bus_get_cpus() function first appeared in FreeBSD 11.0. A little origin story for you, bestie 🌸


and that's the whole page, fr fr πŸ’œ this one came from the Debian gang and it's dated March 1, 2016 β€” so go forth and query your CPU sets, main character πŸŽ€βœ¨

πŸ“¦ where this page comes from