>From 7f468bd7bad2f2fec2e93c89a48008d1cba99001 Mon Sep 17 00:00:00 2001 From: Knut Petersen Date: Wed, 25 Sep 2013 13:34:57 +0200 Subject: [PATCH] Enforce 1 as lower limit for perf_event_max_sample_rate /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 --- kernel/events/core.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/events/core.c b/kernel/events/core.c index dd236b6..350bb53 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -198,6 +198,9 @@ int perf_proc_update_handler(struct ctl_table *table, int write, if (ret || !write) return ret; + if (sysctl_perf_event_sample_rate <= 0) + sysctl_perf_event_sample_rate = 1; + max_samples_per_tick = DIV_ROUND_UP(sysctl_perf_event_sample_rate, HZ); perf_sample_period_ns = NSEC_PER_SEC / sysctl_perf_event_sample_rate; update_perf_cpu_limits(); -- 1.8.1.4