Skip to content

Commit

Permalink
hugetlbfs: correct handling of negative input to /proc/sys/vm/nr_huge…
Browse files Browse the repository at this point in the history
…pages

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 <pholasek@redhat.com>
Signed-off-by: Anton Arapov <anton@redhat.com>
Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Mel Gorman <mel@csn.ul.ie>
Acked-by: Eric B Munson <emunson@mgebm.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Petr Holasek authored and Linus Torvalds committed Mar 23, 2011
1 parent 8afdcec commit c033a93
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions mm/hugetlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit c033a93

Please sign in to comment.