[PATCH] i386: Make the jiffies compares use the 64bit safe macros.
[deliverable/linux.git] / arch / i386 / kernel / cpu / mcheck / therm_throt.c
1 /*
2 * linux/arch/i386/kerne/cpu/mcheck/therm_throt.c
3 *
4 * Thermal throttle event support code.
5 *
6 * Author: Dmitriy Zavin (dmitriyz@google.com)
7 *
8 * Credits: Adapted from Zwane Mwaikambo's original code in mce_intel.c.
9 *
10 */
11
12 #include <linux/percpu.h>
13 #include <linux/cpu.h>
14 #include <asm/cpu.h>
15 #include <linux/notifier.h>
16 #include <asm/therm_throt.h>
17
18 /* How long to wait between reporting thermal events */
19 #define CHECK_INTERVAL (300 * HZ)
20
21 static DEFINE_PER_CPU(__u64, next_check);
22
23 /***
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.
28 *
29 * This function is normally called by the thermal interrupt after the
30 * IRQ has been acknowledged.
31 *
32 * It will take care of rate limiting and printing messages to the syslog.
33 *
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.
38 */
39 int therm_throt_process(int curr)
40 {
41 unsigned int cpu = smp_processor_id();
42 __u64 tmp_jiffs = get_jiffies_64();
43
44 if (time_before64(tmp_jiffs, __get_cpu_var(next_check)))
45 return 0;
46
47 __get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
48
49 /* if we just entered the thermal event */
50 if (curr) {
51 printk(KERN_CRIT "CPU%d: Temperature above threshold, "
52 "cpu clock throttled\n", cpu);
53 add_taint(TAINT_MACHINE_CHECK);
54 } else {
55 printk(KERN_CRIT "CPU%d: Temperature/speed normal\n", cpu);
56 }
57
58 return 1;
59 }
This page took 0.034703 seconds and 5 git commands to generate.