ratelimit performance counter interrupts
PATCH 1/1 ratelimit performance counter interrupts
While fiddling around with kerneltop, I found that an unwary user can lock his box up quite thoroughly if he does something really clever like starting kerneltop with -c 100.
Ratelimit performance counter interrupts to 100KHz per CPU.
--- arch/x86/kernel/apic.c | 2 + arch/x86/kernel/cpu/perf_counter.c | 43 ++++++++++++++++++++++++++++++------- include/linux/perf_counter.h | 2 + 3 files changed, 40 insertions(+), 7 deletions(-)
arch/x86/kernel/apic.c +2 -0
@@ -781,6 +781,8 @@ static void local_apic_timer_interrupt(vinc_irq_stat (apic_timer_irqs); evt->event_handler (evt); + +perf_counter_unthrottle (); }/*
arch/x86/kernel/cpu/perf_counter.c +36 -7
74 lines not on this page · raw message
include/linux/perf_counter.h +2 -0
@@ -254,6 +254,7 @@ extern void perf_counter_init_task(strucextern void perf_counter_exit_task (struct task_struct *child);extern void perf_counter_notify (struct pt_regs *regs);extern void perf_counter_print_debug (void ); +extern void perf_counter_unthrottle (void );extern u64 hw_perf_save_disable (void );extern void hw_perf_restore (u64 ctrl);extern int perf_counter_task_disable (void );
@@ -281,6 +282,7 @@ static inline void perf_counter_init_tasstatic inline void perf_counter_exit_task (struct task_struct *child) { }static inline void perf_counter_notify (struct pt_regs *regs) { }static inline void perf_counter_print_debug (void ) { } +static inline void perf_counter_unthrottle (void ) { }static inline void hw_perf_restore (u64 ctrl) { }static inline u64 hw_perf_save_disable (void ) {return 0 ; }static inline int perf_counter_task_disable (void ) {return -EINVAL ; }
Quoted 2 lines · Mike Galbraith
+ * Mamimum interrupt frequency of 100KHz per CPU
+ */
Hi Mike, I think you misspelled the word Maximum here.
Thanks,
Rakib
Quoted 6 lines · Rakib Mullick
Quoted 2 lines · Mike Galbraith
+ * Mamimum interrupt frequency of 100KHz per CPU
+ */Hi Mike, I think you misspelled the word Maximum here.
Yup, thanks.
Ratelimit performance counter interrupts to 100KHz per CPU.
--- arch/x86/kernel/apic.c | 2 + arch/x86/kernel/cpu/perf_counter.c | 43 ++++++++++++++++++++++++++++++------- include/linux/perf_counter.h | 2 + 3 files changed, 40 insertions(+), 7 deletions(-)
arch/x86/kernel/apic.c +2 -0
@@ -781,6 +781,8 @@ static void local_apic_timer_interrupt(vinc_irq_stat (apic_timer_irqs); evt->event_handler (evt); + +perf_counter_unthrottle (); }/*
arch/x86/kernel/cpu/perf_counter.c +36 -7
74 lines not on this page · raw message
include/linux/perf_counter.h +2 -0
@@ -254,6 +254,7 @@ extern void perf_counter_init_task(strucextern void perf_counter_exit_task (struct task_struct *child);extern void perf_counter_notify (struct pt_regs *regs);extern void perf_counter_print_debug (void ); +extern void perf_counter_unthrottle (void );extern u64 hw_perf_save_disable (void );extern void hw_perf_restore (u64 ctrl);extern int perf_counter_task_disable (void );
@@ -281,6 +282,7 @@ static inline void perf_counter_init_tasstatic inline void perf_counter_exit_task (struct task_struct *child) { }static inline void perf_counter_notify (struct pt_regs *regs) { }static inline void perf_counter_print_debug (void ) { } +static inline void perf_counter_unthrottle (void ) { }static inline void hw_perf_restore (u64 ctrl) { }static inline u64 hw_perf_save_disable (void ) {return 0 ; }static inline int perf_counter_task_disable (void ) {return -EINVAL ; }
Ingo Molnar
AppliedQuoted 12 lines · Mike Galbraith
Quoted 6 lines · Rakib Mullick
Quoted 2 lines · Mike Galbraith
+ * Mamimum interrupt frequency of 100KHz per CPU
+ */Hi Mike, I think you misspelled the word Maximum here.
Yup, thanks.
Ratelimit performance counter interrupts to 100KHz per CPU.
Quoted 7 lines
Signed-off-by Mike Galbraith <[email protected]>--- arch/x86/kernel/apic.c | 2 + arch/x86/kernel/cpu/perf_counter.c | 43 ++++++++++++++++++++++++++++++------- include/linux/perf_counter.h | 2 + 3 files changed, 40 insertions(+), 7 deletions(-)
Applied to tip/perfcounters/core, thanks Mike!
Ingo