io_uring_register_iowq_aff(3)

πŸ“¦
version 2.15 Β· 2 versions
  • 2.15 Β· alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking (latest)
  • 2.5 Β· debian bookworm, ubuntu noble
, in alpine 3.22, alpine 3.23, alpine 3.24, arch rolling, centos-stream 10, centos-stream 9, debian trixie, fedora 43, fedora 44, nixpkgs unstable, opensuse-leap 16.0, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– io_uring_register_iowq_aff(3) β€” the liburing manual πŸ’–

okay bestie, gather round, because this one is about telling your async workers exactly which CPUs they're allowed to vibe on. it lives in the liburing manual, and yes, the whole page is basically "here's how to pin your workers, here's how to unpin them, go off." ✨


🌸 NAME 🌸

io_uring_register_iowq_aff β€” register async worker CPU affinities


πŸŽ€ SYNOPSIS πŸŽ€

#include <sched.h>
#include <liburing.h>

int io_uring_register_iowq_aff(struct io_uring *ring,
                               size_t cpusz,
                               const cpu_set_t *mask);

void io_uring_unregister_iowq_aff(struct io_uring *ring);

πŸ¦‹ DESCRIPTION πŸ¦‹

so, the io_uring_prep_register_iowq_aff(3) function registers a set of CPU affinities that your io_uring async workers are gonna use. by default, io_uring async workers are allowed to run on any CPU in the system β€” like, total free spirits, no rules, no cap. πŸ•ŠοΈ

but if you call this function with ring set to the ring in question, mask set to a pointer to a cpu_set_t value, and cpusz set to the size of the CPU set? then your async workers will only be allowed to run on the CPUs specified in the mask. glow-up complete. πŸ’…

one lil heads up though: existing workers may need to hit a schedule point before they are migrated. so like, they don't teleport instantly, they gotta get to a checkpoint first. patience, babe. 🫢

for unregistration, io_uring_unregister_iowq_aff(3) may be called to restore CPU affinities to the default. back to chaos, we love to see it. 🌈

⚠️ okay this part matters: applications must define _GNU_SOURCE to obtain the definition of this helper, as cpu_set_t will not be defined without it. no _GNU_SOURCE, no cpu_set_t, no function. it's giving locked door and you forgot the key. πŸ”‘

πŸ’œ RETURN VALUE πŸ’œ

returns 0 on success, or any of the following values in case of error. 😭

  • -EFAULT β€” the kernel was unable to copy the memory pointer to by mask as it was invalid.
  • -ENOMEM β€” the kernel was unable to allocate memory for the new CPU mask.
  • -EINVAL β€” cpusz or mask was NULL/0, or any other value specified was invalid.

πŸ‘‘ SEE ALSO πŸ‘‘

io_uring_queue_init(3), io_uring_register(2)


and that's the whole page, bestie, you ate that. πŸ“ this was brought to you by liburing-2.2, dated March 13, 2022 β€” iconic since day one, fr fr. πŸ’–βœ¨

πŸ“¦ where this page comes from