Huge TLB File system (hugetlbfs) is a pseudo file system, implemented in fs/hugetlbfs/inode.c.
The basic idea behind the implementation is that large pages are being used to back up any file that exists in
the file system.
During initialization, init_hugetlbfs_fs() registers the file system and mounts it as an internal file
system with kern_mount().
There are two ways that a process can access huge pages. The first is by using shmget() to set up a shared
region backed by huge pages, and the second is the mmap() call on a file opened in the huge page file
system.
When a shared memory region should be backed by huge pages, the process should call shmget() and pass
SHM_HUGETLB as one of the flags. This results in hugetlb_zero_setup() being called, which creates
a new file in the root of the internal hugetlbfs. A file is created in the root of the internal file system. The
name of the file is determined by an atomic counter called hugetlbfs_counter, which is incremented
every time a shared region is set up.
To create a file backed by huge pages, the system administrator must first mount a hugetlbfs type of file
system. Instructions on how to perform this task are detailed in
Documentation/vm/hugetlbpage.txt on SLES systems. After the file system is mounted, files can
be created as normal with the system call open(). When mmap() is called on the open file, the
file_operations struct hugetlbfs_file_operations ensures that hugetlbfs_file_ mmap()
is called to set up the region properly.
Huge TLB pages have their own function for the management of page tables, address space operations, and
file system operations. The names of the functions for page table management can all be seen in
linux/hugetlb.h, and they are named very similarly to their normal page equivalents. The
implementation of the hugetlbfs functions are located near their normal page equivalents, so they are easy to
find.
126
Figure 5-66: TLB Operation