Inspect hugepage config in /sys/kernel/mm
In this final step, we will explore another location where hugepage configuration information is available: the /sys
filesystem. The /sys
filesystem provides an interface to kernel data structures, allowing us to inspect and sometimes modify kernel objects.
Hugepage-related information can be found under /sys/kernel/mm/transparent_hugepage
. Transparent Hugepages (THP) is a feature that attempts to automatically use hugepages without requiring explicit configuration from applications.
Let's navigate to this directory using the cd
command. cd
stands for "change directory".
Type the following command and press Enter:
cd /sys/kernel/mm/transparent_hugepage
Now that we are in the /sys/kernel/mm/transparent_hugepage
directory, let's list the files in this directory using the ls
command. The ls
command lists the contents of a directory.
Type the following command and press Enter:
ls
You should see output similar to this:
defrag enabled khugepaged numa_defrag shmem_enabled split_huge_pmd_size split_huge_pte_size
These files represent different configuration options and status indicators for Transparent Hugepages.
Let's look at the content of the enabled
file using the cat
command. This file shows whether Transparent Hugepages are enabled, disabled, or in a 'madvise' mode (where applications can advise the kernel on hugepage usage).
Type the following command and press Enter:
cat enabled
You should see output similar to this:
[always] madvise never
The output indicates the current setting. [always]
means THP is currently enabled for all mappings.
Now let's look at the defrag
file. This file controls whether the kernel should attempt to defragment memory to make hugepages available.
Type the following command and press Enter:
cat defrag
You should see output similar to this:
[always] defer defer+madvise madvise never
Again, [always]
indicates the current setting for memory defragmentation related to THP.
The /sys
filesystem is a valuable resource for understanding the kernel's internal state and configuration. Exploring directories like /sys/kernel/mm
can provide deep insights into memory management.
You have now successfully explored hugepage information using three different methods: /proc/meminfo
, sysctl
, and the /sys
filesystem.
Click Continue to complete the lab.