1alloc_hugepages(2) System Calls Manual alloc_hugepages(2)
2
3
4
6 alloc_hugepages, free_hugepages - allocate or free huge pages
7
9 void *syscall(SYS_alloc_hugepages, int key, void addr[.len], size_t len,
10 int prot, int flag);
11 int syscall(SYS_free_hugepages, void *addr);
12
13 Note: glibc provides no wrappers for these system calls, necessitating
14 the use of syscall(2).
15
17 The system calls alloc_hugepages() and free_hugepages() were introduced
18 in Linux 2.5.36 and removed again in Linux 2.5.54. They existed only
19 on i386 and ia64 (when built with CONFIG_HUGETLB_PAGE). In Linux
20 2.4.20, the syscall numbers exist, but the calls fail with the error
21 ENOSYS.
22
23 On i386 the memory management hardware knows about ordinary pages
24 (4 KiB) and huge pages (2 or 4 MiB). Similarly ia64 knows about huge
25 pages of several sizes. These system calls serve to map huge pages
26 into the process's memory or to free them again. Huge pages are locked
27 into memory, and are not swapped.
28
29 The key argument is an identifier. When zero the pages are private,
30 and not inherited by children. When positive the pages are shared with
31 other applications using the same key, and inherited by child pro‐
32 cesses.
33
34 The addr argument of free_hugepages() tells which page is being freed:
35 it was the return value of a call to alloc_hugepages(). (The memory is
36 first actually freed when all users have released it.) The addr argu‐
37 ment of alloc_hugepages() is a hint, that the kernel may or may not
38 follow. Addresses must be properly aligned.
39
40 The len argument is the length of the required segment. It must be a
41 multiple of the huge page size.
42
43 The prot argument specifies the memory protection of the segment. It
44 is one of PROT_READ, PROT_WRITE, PROT_EXEC.
45
46 The flag argument is ignored, unless key is positive. In that case, if
47 flag is IPC_CREAT, then a new huge page segment is created when none
48 with the given key existed. If this flag is not set, then ENOENT is
49 returned when no segment with the given key exists.
50
52 On success, alloc_hugepages() returns the allocated virtual address,
53 and free_hugepages() returns zero. On error, -1 is returned, and errno
54 is set to indicate the error.
55
57 ENOSYS The system call is not supported on this kernel.
58
60 /proc/sys/vm/nr_hugepages
61 Number of configured hugetlb pages. This can be read and writ‐
62 ten.
63
64 /proc/meminfo
65 Gives info on the number of configured hugetlb pages and on
66 their size in the three variables HugePages_Total,
67 HugePages_Free, Hugepagesize.
68
70 Linux on Intel processors.
71
73 These system calls are gone; they existed only in Linux 2.5.36 through
74 to Linux 2.5.54.
75
77 Now the hugetlbfs filesystem can be used instead. Memory backed by
78 huge pages (if the CPU supports them) is obtained by using mmap(2) to
79 map files in this virtual filesystem.
80
81 The maximal number of huge pages can be specified using the hugepages=
82 boot parameter.
83
84
85
86Linux man-pages 6.05 2023-03-30 alloc_hugepages(2)