GETHUGEPAGESIZES(3)

πŸ’– GETHUGEPAGESIZES πŸ’–

okay bestie, so this one is from the Library Functions Manual, section 3, and it's called gethugepagesizes β€” yes, it's giving "how big are the huge pages around here" energy and honestly? iconic. πŸŽ€


✨ NAME ✨

gethugepagesizes β€” Get the system supported huge page sizes πŸ¦‹


🌸 SYNOPSIS 🌸

#include <hugetlbfs.h>

int gethugepagesizes(long pagesizes[], int n_elem);

like. that's the whole vibe. two args, one dream. πŸ’…


πŸ’œ DESCRIPTION πŸ’œ

So here's the tea, bestie: gethugepagesizes() does one of two things, and it's very much a "pick your own adventure" moment.

  • It returns the number of huge page sizes your system supports, OR
  • It returns the sizes themselves. ✨

Which one you get depends entirely on what you pass in:

  • If pagesizes is NULL and n_elem is 0, then the number of huge pages the system supports is returned. (just the count, no numbers, no drama)
  • Otherwise, pagesizes gets filled with at most n_elem page sizes. no more than that, bestie, we respect the boundary. 🫢

πŸ”₯ RETURN VALUE πŸ”₯

On success, you get back either:

  • the number of huge page sizes supported by the system, or
  • the number of huge page sizes stored in pagesizes

(whichever one applies to your little call, iykyk)

On failure? -1 is returned and errno is set appropriately. 😭 that's the sad path, we don't go there.


πŸ’€ ERRORS πŸ’€

  • EINVAL β€” n_elem is less than zero, or n_elem is greater than zero and pagesizes is NULL.

Also, go peek at opendir(3) for other possible values for errno. This error occurs when the sysfs directory exists but cannot be opened. (so close yet so far πŸ₯²)


πŸ‘‘ NOTES πŸ‘‘

This call will return all huge page sizes as reported by the kernel. Not all of these sizes may be usable by the programmer, since mount points may not be available for all sizes. ⚠️

So if you wanna test whether a size will actually be usable by libhugetlbfs, you can call hugetlbfs_find_path_for_size() on a specific size to see if a mount point is configured. main character move, honestly. ⭐


🌈 SEE ALSO 🌈


🧚 AUTHORS 🧚

libhugetlbfs was written by various people on the libhugetlbfs-devel mailing list. πŸ’Œ (a whole group chat of legends, fr fr)


and that's the whole page bestie!! this one's dated October 10, 2008, from the GETHUGEPAGESIZES(3) crew πŸ’– slay, go read a huge page, you got this πŸŽ€βœ¨