@@ -80,6 +80,8 @@ struct hugepage_subpool *hugepage_new_subpool(struct hstate *h, long max_hpages,
void reset_vma_resv_huge_pages(struct vm_area_struct *vma);
int hugetlb_sysctl_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
int hugetlb_overcommit_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
+int hugetlb_charge_surplus_handler(struct ctl_table *, int, void __user *,
+ size_t *, loff_t *);
int hugetlb_treat_movable_handler(struct ctl_table *, int, void __user *, size_t *, loff_t *);
#ifdef CONFIG_NUMA
@@ -1394,6 +1394,13 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write,
.mode = 0644,
.proc_handler = hugetlb_overcommit_handler,
},
+ {
+ .procname = "charge_surplus_hugepages",
+ .data = NULL,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = hugetlb_charge_surplus_handler,
+ },
#endif
{
.procname = "lowmem_reserve_ratio",
@@ -3069,6 +3069,27 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
return ret;
}
+int hugetlb_charge_surplus_handler(struct ctl_table *table, int write,
+ void __user *buffer, size_t *length, loff_t *ppos)
+{
+ struct hstate *h = &default_hstate;
+ int tmp, ret;
+
+ if (!hugepages_supported())
+ return -EOPNOTSUPP;
+
+ tmp = h->charge_surplus_huge_pages ? 1 : 0;
+ table->data = &tmp;
+ table->maxlen = sizeof(int);
+ ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
+ if (ret)
+ goto out;
+
+ if (write)
+ h->charge_surplus_huge_pages = tmp ? true : false;
+out:
+ return ret;
+}
#endif /* CONFIG_SYSCTL */
void hugetlb_report_meminfo(struct seq_file *m)
Make the default hugetlb surplus hugepage controlable by /proc/sys/vm/charge_surplus_hugepages. Signed-off-by: TSUKADA Koutaro <tsukada@ascade.co.jp> --- include/linux/hugetlb.h | 2 ++ kernel/sysctl.c | 7 +++++++ mm/hugetlb.c | 21 +++++++++++++++++++++ 3 files changed, 30 insertions(+) -- Tsukada