static atomic_t nr_comm_counters __read_mostly;
/*
- * 0 - not paranoid
- * 1 - disallow cpu counters to unpriv
- * 2 - disallow kernel profiling to unpriv
+ * perf counter paranoia level:
+ * 0 - not paranoid
+ * 1 - disallow cpu counters to unpriv
+ * 2 - disallow kernel profiling to unpriv
*/
-int sysctl_perf_counter_paranoid __read_mostly; /* do we need to be privileged */
+int sysctl_perf_counter_paranoid __read_mostly;
static inline bool perf_paranoid_cpu(void)
{
}
int sysctl_perf_counter_mlock __read_mostly = 512; /* 'free' kb per user */
-int sysctl_perf_counter_limit __read_mostly = 100000; /* max NMIs per second */
+
+/*
+ * max perf counter sample rate
+ */
+int sysctl_perf_counter_sample_rate __read_mostly = 100000;
static atomic64_t perf_counter_id;
if (interrupts == MAX_INTERRUPTS) {
perf_log_throttle(counter, 1);
counter->pmu->unthrottle(counter);
- interrupts = 2*sysctl_perf_counter_limit/HZ;
+ interrupts = 2*sysctl_perf_counter_sample_rate/HZ;
}
if (!counter->attr.freq || !counter->attr.sample_freq)
spin_lock_irq(&ctx->lock);
if (counter->attr.freq) {
- if (value > sysctl_perf_counter_limit) {
+ if (value > sysctl_perf_counter_sample_rate) {
ret = -EINVAL;
goto unlock;
}
} else {
if (hwc->interrupts != MAX_INTERRUPTS) {
hwc->interrupts++;
- if (HZ * hwc->interrupts > (u64)sysctl_perf_counter_limit) {
+ if (HZ * hwc->interrupts >
+ (u64)sysctl_perf_counter_sample_rate) {
hwc->interrupts = MAX_INTERRUPTS;
perf_log_throttle(counter, 0);
ret = 1;
return -EACCES;
}
+ if (attr.freq) {
+ if (attr.sample_freq > sysctl_perf_counter_sample_rate)
+ return -EINVAL;
+ }
+
/*
* Get the target context (task or percpu):
*/
},
{
.ctl_name = CTL_UNNUMBERED,
- .procname = "perf_counter_int_limit",
- .data = &sysctl_perf_counter_limit,
- .maxlen = sizeof(sysctl_perf_counter_limit),
+ .procname = "perf_counter_max_sample_rate",
+ .data = &sysctl_perf_counter_sample_rate,
+ .maxlen = sizeof(sysctl_perf_counter_sample_rate),
.mode = 0644,
.proc_handler = &proc_dointvec,
},