All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86, mce: therm_throt - change when we print messages
@ 2009-08-10  4:44 Dmitry Torokhov
  2009-08-10  5:26 ` Hidetoshi Seto
  2009-08-11  7:57 ` [tip:x86/urgent] " tip-bot for Dmitry Torokhov
  0 siblings, 2 replies; 6+ messages in thread
From: Dmitry Torokhov @ 2009-08-10  4:44 UTC (permalink / raw)
  To: LKML; +Cc: H. Peter Anvin

My Latitude d630 seems to be handling thermal events in SMI by lowering
the max frequency of the CPU till it cools down but still leaks the
"everything is normal" events. Adjust therm_throt driver to only print
messages about the fact that temperatire returned back to normal when
leaving the throttling state.

Also lower the severity of "back to normal" message from KERN_CRIT to
KERN_INFO.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 arch/x86/kernel/cpu/mcheck/therm_throt.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)


diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index bff8dd1..8bc64cf 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -36,6 +36,7 @@
 
 static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
 static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
+static DEFINE_PER_CPU(bool, thermal_throttle_active);
 
 static atomic_t therm_throt_en		= ATOMIC_INIT(0);
 
@@ -96,24 +97,27 @@ static int therm_throt_process(int curr)
 {
 	unsigned int cpu = smp_processor_id();
 	__u64 tmp_jiffs = get_jiffies_64();
+	bool was_throttled = __get_cpu_var(thermal_throttle_active);
+	bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;
 
-	if (curr)
+	if (is_throttled)
 		__get_cpu_var(thermal_throttle_count)++;
 
-	if (time_before64(tmp_jiffs, __get_cpu_var(next_check)))
+	if (!(was_throttled ^ is_throttled) &&
+	    time_before64(tmp_jiffs, __get_cpu_var(next_check)))
 		return 0;
 
 	__get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
 
 	/* if we just entered the thermal event */
-	if (curr) {
+	if (is_throttled) {
 		printk(KERN_CRIT "CPU%d: Temperature above threshold, "
-		       "cpu clock throttled (total events = %lu)\n", cpu,
-		       __get_cpu_var(thermal_throttle_count));
+		       "cpu clock throttled (total events = %lu)\n",
+		       cpu, __get_cpu_var(thermal_throttle_count));
 
 		add_taint(TAINT_MACHINE_CHECK);
-	} else {
-		printk(KERN_CRIT "CPU%d: Temperature/speed normal\n", cpu);
+	} else if (was_throttled) {
+		printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
 	}
 
 	return 1;
-- 
Dmitry

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] x86, mce: therm_throt - change when we print messages
  2009-08-10  4:44 [PATCH] x86, mce: therm_throt - change when we print messages Dmitry Torokhov
@ 2009-08-10  5:26 ` Hidetoshi Seto
  2009-08-11  7:57 ` [tip:x86/urgent] " tip-bot for Dmitry Torokhov
  1 sibling, 0 replies; 6+ messages in thread
From: Hidetoshi Seto @ 2009-08-10  5:26 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: LKML, H. Peter Anvin

Dmitry Torokhov wrote:
> My Latitude d630 seems to be handling thermal events in SMI by lowering
> the max frequency of the CPU till it cools down but still leaks the
> "everything is normal" events. Adjust therm_throt driver to only print
> messages about the fact that temperatire returned back to normal when
> leaving the throttling state.
> 
> Also lower the severity of "back to normal" message from KERN_CRIT to
> KERN_INFO.
> 
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> ---

Looks good.  Thank you for providing nicer logic!

Reviewed-by: Hidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [tip:x86/urgent] x86, mce: therm_throt - change when we print messages
  2009-08-10  4:44 [PATCH] x86, mce: therm_throt - change when we print messages Dmitry Torokhov
  2009-08-10  5:26 ` Hidetoshi Seto
@ 2009-08-11  7:57 ` tip-bot for Dmitry Torokhov
  2009-08-11 12:31   ` Kevin Winchester
  1 sibling, 1 reply; 6+ messages in thread
From: tip-bot for Dmitry Torokhov @ 2009-08-11  7:57 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, dmitry.torokhov, dtor, tglx, mingo

Commit-ID:  0d01f31439c1e4d602bf9fdc924ab66f407f5e38
Gitweb:     http://git.kernel.org/tip/0d01f31439c1e4d602bf9fdc924ab66f407f5e38
Author:     Dmitry Torokhov <dmitry.torokhov@gmail.com>
AuthorDate: Sun, 9 Aug 2009 21:44:49 -0700
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Tue, 11 Aug 2009 09:54:17 +0200

x86, mce: therm_throt - change when we print messages

My Latitude d630 seems to be handling thermal events in SMI by
lowering the max frequency of the CPU till it cools down but
still leaks the "everything is normal" events.

This spams the console and with high priority printks.

Adjust therm_throt driver to only print messages about the fact
that temperatire returned back to normal when leaving the
throttling state.

Also lower the severity of "back to normal" message from
KERN_CRIT to KERN_INFO.

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Acked-by: H. Peter Anvin <hpa@zytor.com>
LKML-Reference: <20090810051513.0558F526EC9@mailhub.coreip.homeip.net>
Signed-off-by: Ingo Molnar <mingo@elte.hu>


---
 arch/x86/kernel/cpu/mcheck/therm_throt.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
index bff8dd1..8bc64cf 100644
--- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
+++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
@@ -36,6 +36,7 @@
 
 static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
 static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
+static DEFINE_PER_CPU(bool, thermal_throttle_active);
 
 static atomic_t therm_throt_en		= ATOMIC_INIT(0);
 
@@ -96,24 +97,27 @@ static int therm_throt_process(int curr)
 {
 	unsigned int cpu = smp_processor_id();
 	__u64 tmp_jiffs = get_jiffies_64();
+	bool was_throttled = __get_cpu_var(thermal_throttle_active);
+	bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;
 
-	if (curr)
+	if (is_throttled)
 		__get_cpu_var(thermal_throttle_count)++;
 
-	if (time_before64(tmp_jiffs, __get_cpu_var(next_check)))
+	if (!(was_throttled ^ is_throttled) &&
+	    time_before64(tmp_jiffs, __get_cpu_var(next_check)))
 		return 0;
 
 	__get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
 
 	/* if we just entered the thermal event */
-	if (curr) {
+	if (is_throttled) {
 		printk(KERN_CRIT "CPU%d: Temperature above threshold, "
-		       "cpu clock throttled (total events = %lu)\n", cpu,
-		       __get_cpu_var(thermal_throttle_count));
+		       "cpu clock throttled (total events = %lu)\n",
+		       cpu, __get_cpu_var(thermal_throttle_count));
 
 		add_taint(TAINT_MACHINE_CHECK);
-	} else {
-		printk(KERN_CRIT "CPU%d: Temperature/speed normal\n", cpu);
+	} else if (was_throttled) {
+		printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
 	}
 
 	return 1;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [tip:x86/urgent] x86, mce: therm_throt - change when we print  messages
  2009-08-11  7:57 ` [tip:x86/urgent] " tip-bot for Dmitry Torokhov
@ 2009-08-11 12:31   ` Kevin Winchester
  2009-08-12  2:15     ` Dmitry Torokhov
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Winchester @ 2009-08-11 12:31 UTC (permalink / raw)
  To: mingo, hpa, linux-kernel, dmitry.torokhov, dtor, tglx, mingo
  Cc: linux-tip-commits

2009/8/11 tip-bot for Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> Commit-ID:  0d01f31439c1e4d602bf9fdc924ab66f407f5e38
> Gitweb:     http://git.kernel.org/tip/0d01f31439c1e4d602bf9fdc924ab66f407f5e38
> Author:     Dmitry Torokhov <dmitry.torokhov@gmail.com>
> AuthorDate: Sun, 9 Aug 2009 21:44:49 -0700
> Committer:  Ingo Molnar <mingo@elte.hu>
> CommitDate: Tue, 11 Aug 2009 09:54:17 +0200
>
> x86, mce: therm_throt - change when we print messages
>
> My Latitude d630 seems to be handling thermal events in SMI by
> lowering the max frequency of the CPU till it cools down but
> still leaks the "everything is normal" events.
>
> This spams the console and with high priority printks.
>
> Adjust therm_throt driver to only print messages about the fact
> that temperatire returned back to normal when leaving the
> throttling state.
>
> Also lower the severity of "back to normal" message from
> KERN_CRIT to KERN_INFO.
>
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> Acked-by: H. Peter Anvin <hpa@zytor.com>
> LKML-Reference: <20090810051513.0558F526EC9@mailhub.coreip.homeip.net>
> Signed-off-by: Ingo Molnar <mingo@elte.hu>
>
>
> ---
>  arch/x86/kernel/cpu/mcheck/therm_throt.c |   18 +++++++++++-------
>  1 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
> index bff8dd1..8bc64cf 100644
> --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
> +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
> @@ -36,6 +36,7 @@
>
>  static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
>  static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
> +static DEFINE_PER_CPU(bool, thermal_throttle_active);
>
>  static atomic_t therm_throt_en         = ATOMIC_INIT(0);
>
> @@ -96,24 +97,27 @@ static int therm_throt_process(int curr)
>  {
>        unsigned int cpu = smp_processor_id();
>        __u64 tmp_jiffs = get_jiffies_64();
> +       bool was_throttled = __get_cpu_var(thermal_throttle_active);
> +       bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;

This seems a little odd (or perhaps my lack of experience is
showing...) - should it be:

bool is_throttled = __get_cpu_var(thermal_throttle_active) == curr;

?

>
> -       if (curr)
> +       if (is_throttled)
>                __get_cpu_var(thermal_throttle_count)++;
>
> -       if (time_before64(tmp_jiffs, __get_cpu_var(next_check)))
> +       if (!(was_throttled ^ is_throttled) &&
> +           time_before64(tmp_jiffs, __get_cpu_var(next_check)))
>                return 0;
>
>        __get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
>
>        /* if we just entered the thermal event */
> -       if (curr) {
> +       if (is_throttled) {
>                printk(KERN_CRIT "CPU%d: Temperature above threshold, "
> -                      "cpu clock throttled (total events = %lu)\n", cpu,
> -                      __get_cpu_var(thermal_throttle_count));
> +                      "cpu clock throttled (total events = %lu)\n",
> +                      cpu, __get_cpu_var(thermal_throttle_count));
>
>                add_taint(TAINT_MACHINE_CHECK);
> -       } else {
> -               printk(KERN_CRIT "CPU%d: Temperature/speed normal\n", cpu);
> +       } else if (was_throttled) {
> +               printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
>        }
>
>        return 1;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
>
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [tip:x86/urgent] x86, mce: therm_throt - change when we print messages
  2009-08-11 12:31   ` Kevin Winchester
@ 2009-08-12  2:15     ` Dmitry Torokhov
  2009-08-12 12:34       ` Kevin Winchester
  0 siblings, 1 reply; 6+ messages in thread
From: Dmitry Torokhov @ 2009-08-12  2:15 UTC (permalink / raw)
  To: Kevin Winchester; +Cc: mingo, hpa, linux-kernel, tglx, mingo, linux-tip-commits

On Tue, Aug 11, 2009 at 09:31:14AM -0300, Kevin Winchester wrote:
> 2009/8/11 tip-bot for Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> >  static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
> >  static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
> > +static DEFINE_PER_CPU(bool, thermal_throttle_active);
> >
> >  static atomic_t therm_throt_en         = ATOMIC_INIT(0);
> >
> > @@ -96,24 +97,27 @@ static int therm_throt_process(int curr)
> >  {
> >        unsigned int cpu = smp_processor_id();
> >        __u64 tmp_jiffs = get_jiffies_64();
> > +       bool was_throttled = __get_cpu_var(thermal_throttle_active);
> > +       bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;
> 
> This seems a little odd (or perhaps my lack of experience is
> showing...) - should it be:
> 
> bool is_throttled = __get_cpu_var(thermal_throttle_active) == curr;
> 
> ?

No, you still want to assign the value to thermal_throttle_active.
is_throttled is just a temp so you don't need to invoke
__get_cpu_var(thermal_throttle_active) all over the function.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [tip:x86/urgent] x86, mce: therm_throt - change when we print  messages
  2009-08-12  2:15     ` Dmitry Torokhov
@ 2009-08-12 12:34       ` Kevin Winchester
  0 siblings, 0 replies; 6+ messages in thread
From: Kevin Winchester @ 2009-08-12 12:34 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: mingo, hpa, linux-kernel, tglx, mingo, linux-tip-commits

2009/8/11 Dmitry Torokhov <dmitry.torokhov@gmail.com>:
> On Tue, Aug 11, 2009 at 09:31:14AM -0300, Kevin Winchester wrote:
>> 2009/8/11 tip-bot for Dmitry Torokhov <dmitry.torokhov@gmail.com>:
>> >  static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES;
>> >  static DEFINE_PER_CPU(unsigned long, thermal_throttle_count);
>> > +static DEFINE_PER_CPU(bool, thermal_throttle_active);
>> >
>> >  static atomic_t therm_throt_en         = ATOMIC_INIT(0);
>> >
>> > @@ -96,24 +97,27 @@ static int therm_throt_process(int curr)
>> >  {
>> >        unsigned int cpu = smp_processor_id();
>> >        __u64 tmp_jiffs = get_jiffies_64();
>> > +       bool was_throttled = __get_cpu_var(thermal_throttle_active);
>> > +       bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;
>>
>> This seems a little odd (or perhaps my lack of experience is
>> showing...) - should it be:
>>
>> bool is_throttled = __get_cpu_var(thermal_throttle_active) == curr;
>>
>> ?
>
> No, you still want to assign the value to thermal_throttle_active.
> is_throttled is just a temp so you don't need to invoke
> __get_cpu_var(thermal_throttle_active) all over the function.
>

Thanks - now I understand.  I guess I'm used to seeing:

bool a = b == c;

So it jumped out at me.

-- 
Kevin Winchester

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-08-12 12:34 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-10  4:44 [PATCH] x86, mce: therm_throt - change when we print messages Dmitry Torokhov
2009-08-10  5:26 ` Hidetoshi Seto
2009-08-11  7:57 ` [tip:x86/urgent] " tip-bot for Dmitry Torokhov
2009-08-11 12:31   ` Kevin Winchester
2009-08-12  2:15     ` Dmitry Torokhov
2009-08-12 12:34       ` Kevin Winchester

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.