diff options
author | Knut Petersen <Knut_Petersen@t-online.de> | 2013-09-25 14:29:37 +0200 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2014-02-26 10:24:22 +0100 |
commit | 2b183ff24e726b97e2eeef5a54f88d4a8ac4f7d8 (patch) | |
tree | bae5e7e05392cd58c4e14ecd42cbdaa12d962828 /kernel | |
parent | 454d0fc5cdf56444ef17e7f56d6c047734c86a0e (diff) | |
download | lwn-2b183ff24e726b97e2eeef5a54f88d4a8ac4f7d8.tar.gz lwn-2b183ff24e726b97e2eeef5a54f88d4a8ac4f7d8.zip |
perf: Enforce 1 as lower limit for perf_event_max_sample_rate
commit 723478c8a471403c53cf144999701f6e0c4bbd11 upstream.
/proc/sys/kernel/perf_event_max_sample_rate will accept
negative values as well as 0.
Negative values are unreasonable, and 0 causes a
divide by zero exception in perf_proc_update_handler.
This patch enforces a lower limit of 1.
Signed-off-by: Knut Petersen <Knut_Petersen@t-online.de>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/5242DB0C.4070005@t-online.de
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/core.c | 2 | ||||
-rw-r--r-- | kernel/sysctl.c | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/kernel/events/core.c b/kernel/events/core.c index 953c14348375..7c8e4fcfa822 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -193,7 +193,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) { - int ret = proc_dointvec(table, write, buffer, lenp, ppos); + int ret = proc_dointvec_minmax(table, write, buffer, lenp, ppos); if (ret || !write) return ret; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b2f06f3c6a3f..2a9db916c3f5 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -1049,6 +1049,7 @@ static struct ctl_table kern_table[] = { .maxlen = sizeof(sysctl_perf_event_sample_rate), .mode = 0644, .proc_handler = perf_proc_update_handler, + .extra1 = &one, }, { .procname = "perf_cpu_time_max_percent", |