When writing to /proc/sys/vm/nr_huge_pages, it indicates global number of huge pages of the default hstate. But when reading from it, it indicates the current number of "persistent" huge pages in the kernel's huge page pool. There are currently four interfaces used to export the number of huge pages: - /proc/meminfo - /proc/sys/vm/*hugepages* - /sys/devices/system/node/node0/hugepages/hugepages-2048kB/* - /sys/kernel/mm/hugepages/hugepages-2048kB/* But only the /proc/sys/vm/nr_huge_pages provides the 'persistent' semantics when reading from it. This inconsistency is very subtle and can be easily misunderstood. Signed-off-by: Xueshi Hu <xueshi.hu@xxxxxxxxxx> --- mm/hugetlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index e327a5a7602c..76af189053f0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -4606,7 +4606,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy, void *buffer, size_t *length, loff_t *ppos) { struct hstate *h = &default_hstate; - unsigned long tmp = h->max_huge_pages; + unsigned long tmp = h->nr_huge_pages; int ret; if (!hugepages_supported()) -- 2.40.1