linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
       [not found] <a2itf-5jB-27@gated-at.bofh.it>
@ 2008-02-29 21:09 ` Alan Jenkins
  2008-03-01 12:29   ` Pierre Ossman
  0 siblings, 1 reply; 11+ messages in thread
From: Alan Jenkins @ 2008-02-29 21:09 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: linux-kernel

Pierre Ossman wrote:
> Many devices today are of a less than stellar quality, and singing
> transistors are a common problem. A high-pitch noise is created, caused
> by power fluctuations as the processor enters and leaves deep sleep at
> a high frequency.

Capacitors or transistors?  The subject and the description disagree.

Alan

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-02-29 21:09 ` [RFC][PATCH] cpuidle: avoid singing capacitors Alan Jenkins
@ 2008-03-01 12:29   ` Pierre Ossman
  2008-03-05 17:32     ` Jeremy Fitzhardinge
  0 siblings, 1 reply; 11+ messages in thread
From: Pierre Ossman @ 2008-03-01 12:29 UTC (permalink / raw)
  To: Alan Jenkins; +Cc: linux-kernel

On Fri, 29 Feb 2008 13:09:05 -0800 (PST)
Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:

> Pierre Ossman wrote:
> > Many devices today are of a less than stellar quality, and singing
> > transistors are a common problem. A high-pitch noise is created, caused
> > by power fluctuations as the processor enters and leaves deep sleep at
> > a high frequency.
> 
> Capacitors or transistors?  The subject and the description disagree.
> 

That should teach me to write commit messages when I'm tired... Capacitors is of course the right answer. :)

-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-03-01 12:29   ` Pierre Ossman
@ 2008-03-05 17:32     ` Jeremy Fitzhardinge
  2008-03-05 18:01       ` Pierre Ossman
  0 siblings, 1 reply; 11+ messages in thread
From: Jeremy Fitzhardinge @ 2008-03-05 17:32 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: Alan Jenkins, linux-kernel

Pierre Ossman wrote:
> On Fri, 29 Feb 2008 13:09:05 -0800 (PST)
> Alan Jenkins <alan-jenkins@tuffmail.co.uk> wrote:
>
>   
>> Pierre Ossman wrote:
>>     
>>> Many devices today are of a less than stellar quality, and singing
>>> transistors are a common problem. A high-pitch noise is created, caused
>>> by power fluctuations as the processor enters and leaves deep sleep at
>>> a high frequency.
>>>       
>> Capacitors or transistors?  The subject and the description disagree.
>>
>>     
>
> That should teach me to write commit messages when I'm tired... Capacitors is of course the right answer. :)

More likely inductors, I think.  The coils can vibrate against the coil 
if they haven't been properly potted in something.  Capacitors don't 
really have anything which can "sing".

    J

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-03-05 17:32     ` Jeremy Fitzhardinge
@ 2008-03-05 18:01       ` Pierre Ossman
  0 siblings, 0 replies; 11+ messages in thread
From: Pierre Ossman @ 2008-03-05 18:01 UTC (permalink / raw)
  To: Jeremy Fitzhardinge; +Cc: Alan Jenkins, linux-kernel

On Wed, 05 Mar 2008 09:32:15 -0800
Jeremy Fitzhardinge <jeremy@goop.org> wrote:

> 
> More likely inductors, I think.  The coils can vibrate against the coil 
> if they haven't been properly potted in something.  Capacitors don't 
> really have anything which can "sing".
> 

I have no idea. Previous reports of this behaviour have always been described as "singing" capacitors and explained by some piezoelectric effect.

Rgds
-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-02-29 18:38 Pierre Ossman
                   ` (2 preceding siblings ...)
  2008-03-02  2:27 ` Lee Revell
@ 2008-03-03 12:36 ` Andi Kleen
  3 siblings, 0 replies; 11+ messages in thread
From: Andi Kleen @ 2008-03-03 12:36 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: Venkatesh Pallipadi, Adam Belay, linux-pm, LKML

Pierre Ossman <drzeus-list@drzeus.cx> writes:

> Many devices today are of a less than stellar quality, and singing
> transistors are a common problem. A high-pitch noise is created, caused
> by power fluctuations as the processor enters and leaves deep sleep at
> a high frequency.
>
> Instead of just disabling the deep sleep (which wastes power). This
> patch merely reduces the number of times it is entered so that the
> frequency doesn't exceed 500 Hz. That should make sure the problem is
> inaudible.
>
> Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
> --
>
> The basic idea is above, but the implementation doesn't quite work. It seems jiffies is not a good time source in this scenario. The time spent in C3 takes a much bigger hit than I expect. The fact that powertop says that it has an average residency of 200 ms in C2 tells me that those should have been spent in C3.

I like the patch in principle, although I think the threshold should
be configurable, not hard coded.

I haven't checked in detail if that is the case, but you need to make
sure that you only reference jiffies on idle exit after the clock
source has caught up with lost jiffies after idle. That might be 
the cause of your problem.

-Andi

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-03-02  2:27 ` Lee Revell
@ 2008-03-02 14:17   ` Pierre Ossman
  0 siblings, 0 replies; 11+ messages in thread
From: Pierre Ossman @ 2008-03-02 14:17 UTC (permalink / raw)
  To: Lee Revell; +Cc: Venkatesh Pallipadi, Adam Belay, linux-pm, LKML

On Sat, 1 Mar 2008 21:27:09 -0500
"Lee Revell" <rlrevell@joe-job.com> wrote:

> 
> Should there be a comment stating the motivation for the change?

In the code you mean? Yes, that will be added.

> 
> Thanks for trying to address this problem, I know many users who are afflicted.
> 

As always, the quickest way to get things done is to make sure a kernel developer suffers from the same issue. ;)

-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-02-29 18:38 Pierre Ossman
  2008-02-29 21:44 ` Lennart Sorensen
  2008-03-01 13:40 ` Pierre Ossman
@ 2008-03-02  2:27 ` Lee Revell
  2008-03-02 14:17   ` Pierre Ossman
  2008-03-03 12:36 ` Andi Kleen
  3 siblings, 1 reply; 11+ messages in thread
From: Lee Revell @ 2008-03-02  2:27 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: Venkatesh Pallipadi, Adam Belay, linux-pm, LKML

On Fri, Feb 29, 2008 at 1:38 PM, Pierre Ossman <drzeus-list@drzeus.cx> wrote:
> Many devices today are of a less than stellar quality, and singing
>  transistors are a common problem. A high-pitch noise is created, caused
>  by power fluctuations as the processor enters and leaves deep sleep at
>  a high frequency.
>
>  Instead of just disabling the deep sleep (which wastes power). This
>  patch merely reduces the number of times it is entered so that the
>  frequency doesn't exceed 500 Hz. That should make sure the problem is
>  inaudible.

Should there be a comment stating the motivation for the change?

Thanks for trying to address this problem, I know many users who are afflicted.

Lee

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-02-29 18:38 Pierre Ossman
  2008-02-29 21:44 ` Lennart Sorensen
@ 2008-03-01 13:40 ` Pierre Ossman
  2008-03-02  2:27 ` Lee Revell
  2008-03-03 12:36 ` Andi Kleen
  3 siblings, 0 replies; 11+ messages in thread
From: Pierre Ossman @ 2008-03-01 13:40 UTC (permalink / raw)
  To: Venkatesh Pallipadi, Adam Belay; +Cc: linux-pm, LKML

On Fri, 29 Feb 2008 19:38:12 +0100
Pierre Ossman <drzeus-list@drzeus.cx> wrote:

> @@ -50,9 +58,16 @@ static int menu_select(struct cpuidle_device *dev)
>                         break;
>                 if (s->exit_latency > pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY))
>                         break;
> +               if ((dev->states[i].flags & CPUIDLE_FLAG_DEEP) &&
> +                       time_before_eq(jiffies, data->last_deep_jif + MIN_DEEP_INTERVAL))
> +                       break;
>         }
>  

I guess another approach would be to refuse to enter deep sleep if the sleep time is less than 2 ms. That would mean we would not lose the long sleeps, but if it is just doing short sleeps then we would never enter C3...

Is there a decent way of testing which approach is actually doing the least damage?

Rgds

-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-02-29 21:44 ` Lennart Sorensen
@ 2008-03-01 12:31   ` Pierre Ossman
  0 siblings, 0 replies; 11+ messages in thread
From: Pierre Ossman @ 2008-03-01 12:31 UTC (permalink / raw)
  To: Lennart Sorensen; +Cc: Venkatesh Pallipadi, Adam Belay, linux-pm, LKML

On Fri, 29 Feb 2008 16:44:07 -0500
lsorense@csclub.uwaterloo.ca (Lennart Sorensen) wrote:

> On Fri, Feb 29, 2008 at 07:38:12PM +0100, Pierre Ossman wrote:
> > +/*
> > + * The minimum number of ticks needed to not oscillate faster than
> > + * 500 Hz.
> > + */
> > +#define MIN_DEEP_INTERVAL (HZ / 500)
> 
> What happens here if HZ < 500?  Or does the fact that you have less than
> 500HZ jiffies automatically imply that you can't go to sleep more than
> the jiffy rate times per second?

A low HZ will still go to sleep very often (provided NO_HZ is in effect). But a HZ < 500 makes that number up there turn to zero.  But the check further down makes sure that at least 1 tick passes. So that means it will not enter C3 more often than min(HZ, 500) Hz. Another reason to stop using jiffies.

-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org

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

* Re: [RFC][PATCH] cpuidle: avoid singing capacitors
  2008-02-29 18:38 Pierre Ossman
@ 2008-02-29 21:44 ` Lennart Sorensen
  2008-03-01 12:31   ` Pierre Ossman
  2008-03-01 13:40 ` Pierre Ossman
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Lennart Sorensen @ 2008-02-29 21:44 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: Venkatesh Pallipadi, Adam Belay, linux-pm, LKML

On Fri, Feb 29, 2008 at 07:38:12PM +0100, Pierre Ossman wrote:
> +/*
> + * The minimum number of ticks needed to not oscillate faster than
> + * 500 Hz.
> + */
> +#define MIN_DEEP_INTERVAL (HZ / 500)

What happens here if HZ < 500?  Or does the fact that you have less than
500HZ jiffies automatically imply that you can't go to sleep more than
the jiffy rate times per second?

--
Len Sorensen

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

* [RFC][PATCH] cpuidle: avoid singing capacitors
@ 2008-02-29 18:38 Pierre Ossman
  2008-02-29 21:44 ` Lennart Sorensen
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Pierre Ossman @ 2008-02-29 18:38 UTC (permalink / raw)
  To: Venkatesh Pallipadi, Adam Belay; +Cc: linux-pm, LKML

Many devices today are of a less than stellar quality, and singing
transistors are a common problem. A high-pitch noise is created, caused
by power fluctuations as the processor enters and leaves deep sleep at
a high frequency.

Instead of just disabling the deep sleep (which wastes power). This
patch merely reduces the number of times it is entered so that the
frequency doesn't exceed 500 Hz. That should make sure the problem is
inaudible.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
--

The basic idea is above, but the implementation doesn't quite work. It seems jiffies is not a good time source in this scenario. The time spent in C3 takes a much bigger hit than I expect. The fact that powertop says that it has an average residency of 200 ms in C2 tells me that those should have been spent in C3.

So, pointers on what else to do?

(Patch also needs an on/off switch, but that's a later problem)

diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c
index 78d77c5..171d838 100644
--- a/drivers/cpuidle/governors/menu.c
+++ b/drivers/cpuidle/governors/menu.c
@@ -16,6 +16,12 @@
 
 #define BREAK_FUZZ     4       /* 4 us */
 
+/*
+ * The minimum number of ticks needed to not oscillate faster than
+ * 500 Hz.
+ */
+#define MIN_DEEP_INTERVAL (HZ / 500)
+
 struct menu_device {
        int             last_state_idx;
 
@@ -23,6 +29,8 @@ struct menu_device {
        unsigned int    predicted_us;
        unsigned int    last_measured_us;
        unsigned int    elapsed_us;
+
+       unsigned long   last_deep_jif;
 };
 
 static DEFINE_PER_CPU(struct menu_device, menu_devices);
@@ -50,9 +58,16 @@ static int menu_select(struct cpuidle_device *dev)
                        break;
                if (s->exit_latency > pm_qos_requirement(PM_QOS_CPU_DMA_LATENCY))
                        break;
+               if ((dev->states[i].flags & CPUIDLE_FLAG_DEEP) &&
+                       time_before_eq(jiffies, data->last_deep_jif + MIN_DEEP_INTERVAL))
+                       break;
        }
 
        data->last_state_idx = i - 1;
+
+       if (dev->states[i - 1].flags & CPUIDLE_FLAG_DEEP)
+               data->last_deep_jif = jiffies;
+
        return i - 1;
 }
 


-- 
     -- Pierre Ossman

  Linux kernel, MMC maintainer        http://www.kernel.org
  PulseAudio, core developer          http://pulseaudio.org
  rdesktop, core developer          http://www.rdesktop.org

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

end of thread, other threads:[~2008-03-05 18:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <a2itf-5jB-27@gated-at.bofh.it>
2008-02-29 21:09 ` [RFC][PATCH] cpuidle: avoid singing capacitors Alan Jenkins
2008-03-01 12:29   ` Pierre Ossman
2008-03-05 17:32     ` Jeremy Fitzhardinge
2008-03-05 18:01       ` Pierre Ossman
2008-02-29 18:38 Pierre Ossman
2008-02-29 21:44 ` Lennart Sorensen
2008-03-01 12:31   ` Pierre Ossman
2008-03-01 13:40 ` Pierre Ossman
2008-03-02  2:27 ` Lee Revell
2008-03-02 14:17   ` Pierre Ossman
2008-03-03 12:36 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).