public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: yi.y.yang@intel.com
Cc: linux-kernel@vger.kernel.org, dbrownell@users.sourceforge.net,
	gregkh@suse.de, linux-usb@vger.kernel.org
Subject: Re: [PATCH] USB: improve ehci_watchdog's side effect in CPU power management
Date: Thu, 2 Oct 2008 16:56:49 -0700	[thread overview]
Message-ID: <20081002165649.00d021db.akpm@linux-foundation.org> (raw)
In-Reply-To: <1222334744.9267.41.camel@yangyi-dev>

On Thu, 25 Sep 2008 17:25:44 +0800
Yi Yang <yi.y.yang@intel.com> wrote:

> ehci_watchdog will wake up CPU very frequently so that CPU
> stays at C3 very short, average residence time is about 50
> ms on Aspire One, but we expect it should be about 1 second
> or more, so this kind of periodic timer is very bad for power
> saving.
> 
> We can't remove this timer because of some bad USB controller
> chipset, but at least we should reduce its side effect to as
> possible as low.
> 
> This patch can make CPU stay at C3 longer, average residence time
> is about twice as long as original. 
> 
> Please consider to apply it, thanks
> 
> Signed-off-by: Yi Yang <yi.y.yang@intel.com>
> ---
>  ehci.h |   12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/usb/host/ehci.h b/drivers/usb/host/ehci.h
> index 5799298..9d530d9 100644
> --- a/drivers/usb/host/ehci.h
> +++ b/drivers/usb/host/ehci.h
> @@ -181,14 +181,16 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
>  	 * the async ring; just the I/O watchdog.  Note that if a
>  	 * SHRINK were pending, OFF would never be requested.
>  	 */
> -	if (timer_pending(&ehci->watchdog)
> -			&& ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
> -				& ehci->actions))
> -		return;
> +	enum ehci_timer_action oldactions = ehci->actions;
>  
>  	if (!test_and_set_bit (action, &ehci->actions)) {
>  		unsigned long t;
>  
> +		if (timer_pending(&ehci->watchdog)
> +			&& ((BIT(TIMER_ASYNC_SHRINK) | BIT(TIMER_ASYNC_OFF))
> +				& oldactions))
> +			return;
> +
>  		switch (action) {
>  		case TIMER_IO_WATCHDOG:
>  			t = EHCI_IO_JIFFIES;
> @@ -204,7 +206,7 @@ timer_action (struct ehci_hcd *ehci, enum ehci_timer_action action)
>  			t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;
>  			break;
>  		}
> -		mod_timer(&ehci->watchdog, t + jiffies);
> +		mod_timer(&ehci->watchdog, round_jiffies(t + jiffies));
>  	}
>  }
>  

<looks>

<regrets it>


Why does this:

	t = DIV_ROUND_UP(EHCI_SHRINK_FRAMES * HZ, 1000) + 1;

add "1000" to a jiffies value when it doesn't know what HZ is?  It'll
be adding anywhere from one second up to ten seconds to the timeout
interval depending upon compile-time options.

I suspect s/1000/HZ/ would improve things here.  Or just delete it -
doesn't the subsequent round_jiffies() do the same thing, only better? 
This code needs help, I suspect.


Also, do we really need to inline this large function into at least
five callsites?


  reply	other threads:[~2008-10-02 23:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-25  9:25 [PATCH] USB: improve ehci_watchdog's side effect in CPU power management Yi Yang
2008-10-02 23:56 ` Andrew Morton [this message]
2008-10-03 14:51   ` Alan Stern
2008-10-08 10:40   ` Yi Yang
2008-10-08 10:51   ` Yi Yang
2008-10-08 14:11     ` Alan Stern
2008-11-20 20:11 ` David Brownell
2008-11-21 14:55   ` Yi Yang
2008-11-21 18:56     ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081002165649.00d021db.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=dbrownell@users.sourceforge.net \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=yi.y.yang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox