GET_HUGE_PAGES(3)

πŸ’– GET_HUGE_PAGES(3) πŸ’–

okay bestie, welcome to the GET_HUGE_PAGES(3) manual page, aka the Library Functions Manual glow-up you didn't know you needed ✨


🌸 NAME 🌸

get_huge_pages, free_huge_pages β€” Allocate and free hugepages 🫢


✨ SYNOPSIS ✨

#include <hugetlbfs.h>

void *get_huge_pages(size_t len, ghp_t flags);
void free_huge_pages(void *ptr);

πŸ’… DESCRIPTION πŸ’…

so like, get_huge_pages() allocates a memory region len bytes in size backed by hugepages. no cap. πŸ¦‹

hugepages may be of benefit to applications that use large amounts of address space and suffer a performance hit due to TLB misses. lowkey iconic. Wall-clock time or oprofile can be used to determine if there is a performance benefit from using hugepages or not. like, do your research bestie πŸ”

the len parameter must be hugepage-aligned, fr fr. and in the current implementation, only the default hugepage size may be allocated via this function πŸ‘‘ use gethugepagesize to discover what the alignment should be.

the flags argument changes the behaviour of the function. flags may be or'd together πŸŽ€

  • GHP_DEFAULT β€” Allocate a region of memory of the requested length backed by hugepages of the default hugepage size. Return NULL if sufficient pages are not available 😭

free_huge_pages() frees a region of memory allocated by get_huge_pages(). πŸ’–

⚠️ bestie the behaviour of the function if another pointer is used, valid or otherwise, is undefined. undefined behaviour is not the vibe. do not do it. periodt πŸ’€

🌈 RETURN VALUE 🌈

On success, a pointer is returned to the allocated memory πŸŽ‰ On error, NULL is returned. errno will be set based on what the failure of mmap() was due to. yeah she's giving "blame the syscall" energy πŸ™ˆ


πŸ¦‹ SEE ALSO πŸ¦‹


πŸŽ€ AUTHORS πŸŽ€

libhugetlbfs was written by various people on the libhugetlbfs-devel mailing list. shoutout to the whole group chat πŸ’œ


and that's the whole page, bestie β€” this one dropped way back on October 8, 2008, and it lives in the GET_HUGE_PAGES(3) section of the manual. slay πŸ’…βœ¨