That function is the heart of the page allocator inside the Linux kernel [1]. The fundamental building block for every memory allocation on any system (running on Linux). Whether you call malloc() in a C program, kmalloc() inside a kernel driver, the new operator in C++, load a file in python, or almost any other operation, it will ultimately end up in __alloc_pages() (for small objects, multiple units will share a single __alloc_pages(), then there is a fine grain object manager on top of that such as Slab/Slub, jcmalloc, tcmalloc, mimalloc, etc. but you got the point).
[1] https://github.com/torvalds/linux/blob/c3eb11fbb826879be773c...