PMEM2_SOURCE_NUMA_NODE(3)

πŸ’– pmem2_source_numa_node(3) β€” PMDK Programmer's Manual πŸ’–

okay bestie, sit down, we're learning about numa nodes and it's genuinely iconic.


✨ NAME ✨

pmem2_source_numa_node() β€” returns data source numa node πŸ¦‹


✨ SYNOPSIS ✨

#include <libpmem2.h>

struct pmem2_source;
int pmem2_source_numa_node(const struct pmem2_source *source, int *numa_node);

✨ DESCRIPTION ✨

so like, the pmem2_source_numa_node() function retrieves the numa node of the given data source. that's it, that's the whole job, and she does it flawlessly πŸ’…

and why do you care about the numa node? because you can use it to, like, pin threads to near-memory cores β€” main character scheduling behaviour, no cap.

where does it go? the numa node gets stored in *numa_node. and listen β€” it's the same value that is shown as numa_node in ndctl list -v, so if you've ever squinted at that output, congrats, it's the same number. periodt. πŸŽ€


✨ RETURN VALUE ✨

pmem2_source_numa_node() returns 0 on success, slay. 🌸

but if the function fails, the *numa_node variable is left unmodified and a negative error code is returned. so don't go reading *numa_node like it's fresh data when it isn't, bestie, that's how you get got 😭


✨ ERRORS ✨

here's the vibe check on what can go wrong β€” pmem2_source_numa_node() can fail with the following errors:

  • PMEM2_E_NOSUPP β€” source type or operating system not supported (peep the #caveats for details πŸ‘€)
  • PMEM2_E_DAX_REGION_NOT_FOUND β€” no ndctl_region could be determined for the source. she looked. she found nothing. πŸ’€
  • PMEM2_E_INVALID_FILE_TYPE β€” if the source points to a directory
  • -errno β€” set by failing ndctl_new, while trying to create a new context

✨ CAVEATS ✨

okay this is the part where we get real, so pay attention 🫢
  • this call requires libndctl to retrieve the numa information. no libndctl, no numa info, that's just how it is.
  • it only works for sources that are actually located on persistent memory, i.e., devdax or fsdax. not optional. not negotiable.
  • as anonymous sources are not backed by files on persistent memory, this method is not supported for them. sorry anonymous sources, this one's not for you πŸ™ˆ
  • it also does not work under systems without libndctl. same energy, said twice, because it matters.

✨ SEE ALSO ✨

errno(3), ndctl_new(3), pmem2_source_from_fd(3), libpmem2(7), libndctl(7) and https://pmem.io 🌈


and that's the whole page, bestie β€” brought to you by the PMDK girlies, dated 2025-07-24, source/version line reading PMDK - (yes, that's literally all it says, she's mysterious like that πŸ’œ). go forth and numa node responsibly. πŸ‘‘πŸ’…

πŸ“¦ where this page comes from