]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
hugetlb: add locking for overcommit sysctl
authorNishanth Aravamudan <nacc@us.ibm.com>
Fri, 8 Feb 2008 12:18:18 +0000 (04:18 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Tue, 26 Feb 2008 00:18:32 +0000 (16:18 -0800)
patch a3d0c6aa1bb342b9b2c7b123b52ac2f48a4d4d0a in mainline.

When I replaced hugetlb_dynamic_pool with nr_overcommit_hugepages I used
proc_doulongvec_minmax() directly.  However, hugetlb.c's locking rules
require that all counter modifications occur under the hugetlb_lock.  Add a
callback into the hugetlb code similar to the one for nr_hugepages.  Grab
the lock around the manipulation of nr_overcommit_hugepages in
proc_doulongvec_minmax().

Signed-off-by: Nishanth Aravamudan <nacc@us.ibm.com>
Acked-by: Adam Litke <agl@us.ibm.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: William Lee Irwin III <wli@holomorphy.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
include/linux/hugetlb.h
kernel/sysctl.c
mm/hugetlb.c

index 30d606afcafe98c9f22cce117082cc3cb2af83ed..7ca198b379afb59b1cc1d6a653926a03b35123cd 100644 (file)
@@ -17,6 +17,7 @@ static inline int is_vm_hugetlb_page(struct vm_area_struct *vma)
 }
 
 int hugetlb_sysctl_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
+int hugetlb_overcommit_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
 int hugetlb_treat_movable_handler(struct ctl_table *, int, struct file *, void __user *, size_t *, loff_t *);
 int copy_hugetlb_page_range(struct mm_struct *, struct mm_struct *, struct vm_area_struct *);
 int follow_hugetlb_page(struct mm_struct *, struct vm_area_struct *, struct page **, struct vm_area_struct **, unsigned long *, int *, int, int);
index c68f68dcc605052c9bcc81d1719b343acb482e5b..e3e0ee388857a2bbd7518ff11b6e0747c9d28a12 100644 (file)
@@ -910,7 +910,7 @@ static struct ctl_table vm_table[] = {
                .data           = &nr_overcommit_huge_pages,
                .maxlen         = sizeof(nr_overcommit_huge_pages),
                .mode           = 0644,
-               .proc_handler   = &proc_doulongvec_minmax,
+               .proc_handler   = &hugetlb_overcommit_handler,
        },
 #endif
        {
index db861d8b6c2824f460cc177f0d4008fd8850cc3e..9c746cbb436ace88543f3a4e0cbc010aaf828cb7 100644 (file)
@@ -605,6 +605,16 @@ int hugetlb_treat_movable_handler(struct ctl_table *table, int write,
        return 0;
 }
 
+int hugetlb_overcommit_handler(struct ctl_table *table, int write,
+                       struct file *file, void __user *buffer,
+                       size_t *length, loff_t *ppos)
+{
+       spin_lock(&hugetlb_lock);
+       proc_doulongvec_minmax(table, write, file, buffer, length, ppos);
+       spin_unlock(&hugetlb_lock);
+       return 0;
+}
+
 #endif /* CONFIG_SYSCTL */
 
 int hugetlb_report_meminfo(char *buf)