Skip to contentSkip to conversation

perf: Optimize throttling code

tip:perf/core tip-bot for Peter Zijlstra 1 participant 1 message Feb 16, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Commit-ID:  163ec4354a5135c6c38c3f4a9b46a31900ebdf48
Gitweb:     http://git.kernel.org/tip/163ec4354a5135c6c38c3f4a9b46a31900ebdf48
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Wed, 16 Feb 2011 11:22:34 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Wed, 16 Feb 2011 13:30:55 +0100

perf: Optimize throttling code

By pre-computing the maximum number of samples per tick we can avoid a multiplication and a conditional since MAX_INTERRUPTS > max_samples_per_tick.

LKML-Reference: <new-submission>

---
 include/linux/perf_event.h |    4 ++++
 kernel/perf_event.c        |   43 ++++++++++++++++++++++++-------------------
 kernel/sysctl.c            |    2 +-
 3 files changed, 29 insertions(+), 20 deletions(-)
include/linux/perf_event.h +4 -0
index 38c8b25..8ceb5a6 100644
@@ -1110,6 +1110,10 @@ extern int sysctl_perf_event_paranoid;
 extern int sysctl_perf_event_mlock;
 extern int sysctl_perf_event_sample_rate;
 
+extern int perf_proc_update_handler(struct ctl_table *table, int write,
+		void __user *buffer, size_t *lenp,
+		loff_t *ppos);
+
 static inline bool perf_paranoid_tracepoint_raw(void)
 {
 	return sysctl_perf_event_paranoid > -1;
kernel/perf_event.c +24 -19

57 lines not on this page · raw message

kernel/sysctl.c +1 -1
index 0f1bd83..daef911 100644
@@ -948,7 +948,7 @@ static struct ctl_table kern_table[] = {
 		.data		= &sysctl_perf_event_sample_rate,
 		.maxlen		= sizeof(sysctl_perf_event_sample_rate),
 		.mode		= 0644,
-		.proc_handler	= proc_dointvec,
+		.proc_handler	= perf_proc_update_handler,
 	},
 #endif
 #ifdef CONFIG_KMEMCHECK