Re: [PATCH v5] mm: add overcommit_kbytes sysctl variable
From: Olof Johansson
Date: Thu Dec 19 2013 - 02:36:09 EST
Hi,
On Tue, Dec 3, 2013 at 5:33 AM, Jerome Marchand <jmarchan@xxxxxxxxxx> wrote:
[...]
> diff --git a/kernel/sysctl.c b/kernel/sysctl.c
> index 34a6047..7877929 100644
> --- a/kernel/sysctl.c
> +++ b/kernel/sysctl.c
> @@ -97,6 +97,7 @@
> /* External variables not in a header file. */
> extern int sysctl_overcommit_memory;
> extern int sysctl_overcommit_ratio;
> +extern unsigned long sysctl_overcommit_kbytes;
> extern int max_threads;
> extern int suid_dumpable;
> #ifdef CONFIG_COREDUMP
> @@ -1128,7 +1129,14 @@ static struct ctl_table vm_table[] = {
> .data = &sysctl_overcommit_ratio,
> .maxlen = sizeof(sysctl_overcommit_ratio),
> .mode = 0644,
> - .proc_handler = proc_dointvec,
> + .proc_handler = overcommit_ratio_handler,
> + },
> + {
> + .procname = "overcommit_kbytes",
> + .data = &sysctl_overcommit_kbytes,
> + .maxlen = sizeof(sysctl_overcommit_kbytes),
> + .mode = 0644,
> + .proc_handler = overcommit_kbytes_handler,
> },
> {
> .procname = "page-cluster",
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 834b2d7..b25167d 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -86,6 +86,7 @@ EXPORT_SYMBOL(vm_get_page_prot);
>
> int sysctl_overcommit_memory __read_mostly = OVERCOMMIT_GUESS; /* heuristic overcommit */
> int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
> +unsigned long sysctl_overcommit_kbytes __read_mostly = 0;
> int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
> unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
> unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
> @@ -95,6 +96,30 @@ unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
> */
> struct percpu_counter vm_committed_as ____cacheline_aligned_in_smp;
>
> +int overcommit_ratio_handler(struct ctl_table *table, int write,
> + void __user *buffer, size_t *lenp,
> + loff_t *ppos)
> +{
> + int ret;
> +
> + ret = proc_dointvec(table, write, buffer, lenp, ppos);
> + if (ret == 0 && write)
> + sysctl_overcommit_kbytes = 0;
> + return ret;
> +}
> +
> +int overcommit_kbytes_handler(struct ctl_table *table, int write,
> + void __user *buffer, size_t *lenp,
> + loff_t *ppos)
> +{
> + int ret;
> +
> + ret = proc_doulongvec_minmax(table, write, buffer, lenp, ppos);
> + if (ret == 0 && write)
> + sysctl_overcommit_ratio = 0;
> + return ret;
> +}
> +
> /*
> * The global memory commitment made in the system can be a metric
> * that can be used to drive ballooning decisions when Linux is hosted
> diff --git a/mm/nommu.c b/mm/nommu.c
> index fec093a..319ab8f 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -60,6 +60,7 @@ unsigned long highest_memmap_pfn;
> struct percpu_counter vm_committed_as;
> int sysctl_overcommit_memory = OVERCOMMIT_GUESS; /* heuristic overcommit */
> int sysctl_overcommit_ratio = 50; /* default is 50% */
> +unsigned long sysctl_overcommit_kbytes __read_mostly = 0;
> int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
> int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
> unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
You add the variable on the nommu side, but not the functions to
handle the sysctl. So things fail to compile on !MMU builds with:
kernel/built-in.o:(.data+0x4e0): undefined reference to
`overcommit_ratio_handler'
kernel/built-in.o:(.data+0x504): undefined reference to
`overcommit_kbytes_handler'
I don't know mm well enough to tell if copying and pasting the code
over verbatim is the right thing to do, or if there's a preferred
other location (that is shared) to move it to?
-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/