From: Petr Holasek Date: Tue, 22 Mar 2011 23:33:05 +0000 (-0700) Subject: hugetlbfs: correct handling of negative input to /proc/sys/vm/nr_hugepages X-Git-Tag: v2.6.39-rc1~321 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=c033a93c0d961fc7ec5b0872649143e061d97dd4;p=linux.git hugetlbfs: correct handling of negative input to /proc/sys/vm/nr_hugepages When the user inserts a negative value into /proc/sys/vm/nr_hugepages it will cause the kernel to allocate as many hugepages as possible and to then update /proc/meminfo to reflect this. This changes the behavior so that the negative input will result in nr_hugepages value being unchanged. Signed-off-by: Petr Holasek Signed-off-by: Anton Arapov Reviewed-by: Naoya Horiguchi Acked-by: David Rientjes Acked-by: Mel Gorman Acked-by: Eric B Munson Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/hugetlb.c b/mm/hugetlb.c index bb0b7c128015..06de5aa4d644 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1872,8 +1872,7 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy, unsigned long tmp; int ret; - if (!write) - tmp = h->max_huge_pages; + tmp = h->max_huge_pages; if (write && h->order >= MAX_ORDER) return -EINVAL; @@ -1938,8 +1937,7 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write, unsigned long tmp; int ret; - if (!write) - tmp = h->nr_overcommit_huge_pages; + tmp = h->nr_overcommit_huge_pages; if (write && h->order >= MAX_ORDER) return -EINVAL;