2 * linux/arch/i386/kerne/cpu/mcheck/therm_throt.c
4 * Thermal throttle event support code.
6 * Author: Dmitriy Zavin (dmitriyz@google.com)
8 * Credits: Adapted from Zwane Mwaikambo's original code in mce_intel.c.
12 #include <linux/percpu.h>
13 #include <linux/cpu.h>
15 #include <linux/notifier.h>
16 #include <asm/therm_throt.h>
18 /* How long to wait between reporting thermal events */
19 #define CHECK_INTERVAL (300 * HZ)
21 static DEFINE_PER_CPU(unsigned long, next_check);
24 * therm_throt_process - Process thermal throttling event
25 * @curr: Whether the condition is current or not (boolean), since the
26 * thermal interrupt normally gets called both when the thermal
27 * event begins and once the event has ended.
29 * This function is normally called by the thermal interrupt after the
30 * IRQ has been acknowledged.
32 * It will take care of rate limiting and printing messages to the syslog.
34 * Returns: 0 : Event should NOT be further logged, i.e. still in
35 * "timeout" from previous log message.
36 * 1 : Event should be logged further, and a message has been
37 * printed to the syslog.
39 int therm_throt_process(int curr)
41 unsigned int cpu = smp_processor_id();
43 if (time_before(jiffies, __get_cpu_var(next_check)))
46 __get_cpu_var(next_check) = jiffies + CHECK_INTERVAL;
48 /* if we just entered the thermal event */
50 printk(KERN_CRIT "CPU%d: Temperature above threshold, "
51 "cpu clock throttled\n", cpu);
52 add_taint(TAINT_MACHINE_CHECK);
54 printk(KERN_CRIT "CPU%d: Temperature/speed normal\n", cpu);