All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] n2100: reduce power button timer to 1 Hz
@ 2009-09-26 19:53 Mikael Pettersson
  2009-09-28  8:06 ` Aaro Koskinen
  2009-09-28  9:52 ` Lennert Buytenhek
  0 siblings, 2 replies; 7+ messages in thread
From: Mikael Pettersson @ 2009-09-26 19:53 UTC (permalink / raw)
  To: linux-arm-kernel

The power button on the n2100 apparently does not generate
an interrupt when pressed, so the board support code sets
up a periodic timer to sample it.

This timer operates at 10 Hz, which makes it the third worst
cause of timeouts in my kernel when idle.

10 Hz seems excessive, so this patch adds a compile-time option
to reduce the polling frequency to 1 Hz.

(This change could possibly be handled via a kernel boot option,
or even be made unconditional, but I opted for a compile-time
option for now.)

Signed-off-by: Mikael Pettersson <mikpe@it.uu.se>
---
 arch/arm/mach-iop32x/Kconfig |   12 ++++++++++++
 arch/arm/mach-iop32x/n2100.c |   10 ++++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)

diff -rupN linux-2.6.31.arm-n2100-1-xint1-uart/arch/arm/mach-iop32x/Kconfig linux-2.6.31.arm-n2100-2-pbpt-hz1/arch/arm/mach-iop32x/Kconfig
--- linux-2.6.31.arm-n2100-1-xint1-uart/arch/arm/mach-iop32x/Kconfig	2009-09-26 13:39:20.000000000 +0200
+++ linux-2.6.31.arm-n2100-2-pbpt-hz1/arch/arm/mach-iop32x/Kconfig	2009-09-26 13:56:05.000000000 +0200
@@ -64,4 +64,16 @@ config N2100_XINT1_UART
 
 	  Say Y if tickless operation is important for you.
 
+config N2100_PBPT_HZ1
+	bool "Set Thecus n2100 power button poll timer frequency to 1 Hz"
+	depends on MACH_N2100 && NO_HZ
+	help
+	  The Thecus n2100 power button does not generate an interrupt,
+	  so it is polled by a timer, by default at 10 Hz.
+
+	  This option reduces the polling frequency to 1 Hz, which helps
+	  tickless systems keep the timer interrupt rate low.
+
+	  Say Y if tickless operation is important for you.
+
 endif
diff -rupN linux-2.6.31.arm-n2100-1-xint1-uart/arch/arm/mach-iop32x/n2100.c linux-2.6.31.arm-n2100-2-pbpt-hz1/arch/arm/mach-iop32x/n2100.c
--- linux-2.6.31.arm-n2100-1-xint1-uart/arch/arm/mach-iop32x/n2100.c	2009-09-26 13:49:18.000000000 +0200
+++ linux-2.6.31.arm-n2100-2-pbpt-hz1/arch/arm/mach-iop32x/n2100.c	2009-09-26 13:56:43.000000000 +0200
@@ -307,6 +307,12 @@ static void n2100_power_off(void)
 
 static struct timer_list power_button_poll_timer;
 
+#ifdef CONFIG_N2100_PBPT_HZ1
+#define N2100_PBPT_DELTA	(HZ)
+#else
+#define N2100_PBPT_DELTA	(HZ / 10)
+#endif
+
 static void power_button_poll(unsigned long dummy)
 {
 	if (gpio_line_get(N2100_POWER_BUTTON) == 0) {
@@ -314,7 +320,7 @@ static void power_button_poll(unsigned l
 		return;
 	}
 
-	power_button_poll_timer.expires = jiffies + (HZ / 10);
+	power_button_poll_timer.expires = jiffies + N2100_PBPT_DELTA;
 	add_timer(&power_button_poll_timer);
 }
 
@@ -334,7 +340,7 @@ static void __init n2100_init_machine(vo
 
 	init_timer(&power_button_poll_timer);
 	power_button_poll_timer.function = power_button_poll;
-	power_button_poll_timer.expires = jiffies + (HZ / 10);
+	power_button_poll_timer.expires = jiffies + N2100_PBPT_DELTA;
 	add_timer(&power_button_poll_timer);
 }
 

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

* [PATCH 2/2] n2100: reduce power button timer to 1 Hz
  2009-09-26 19:53 [PATCH 2/2] n2100: reduce power button timer to 1 Hz Mikael Pettersson
@ 2009-09-28  8:06 ` Aaro Koskinen
  2009-09-28 10:30   ` Mikael Pettersson
  2009-09-28  9:52 ` Lennert Buytenhek
  1 sibling, 1 reply; 7+ messages in thread
From: Aaro Koskinen @ 2009-09-28  8:06 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

Mikael Pettersson wrote:
> 10 Hz seems excessive, so this patch adds a compile-time option
> to reduce the polling frequency to 1 Hz.
> 
> (This change could possibly be handled via a kernel boot option,
> or even be made unconditional, but I opted for a compile-time
> option for now.)

I don't think there is need to have an option for this. With HZ also
round_jiffies() could be used, it doesn't need to be exact.

(I also think the code should check that the button is held down for
a while before doing the shutdown, but that's a different issue.)

A.

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

* [PATCH 2/2] n2100: reduce power button timer to 1 Hz
  2009-09-26 19:53 [PATCH 2/2] n2100: reduce power button timer to 1 Hz Mikael Pettersson
  2009-09-28  8:06 ` Aaro Koskinen
@ 2009-09-28  9:52 ` Lennert Buytenhek
  2009-09-28 10:25   ` Mikael Pettersson
  1 sibling, 1 reply; 7+ messages in thread
From: Lennert Buytenhek @ 2009-09-28  9:52 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Sep 26, 2009 at 09:53:55PM +0200, Mikael Pettersson wrote:

> The power button on the n2100 apparently does not generate
> an interrupt when pressed, so the board support code sets
> up a periodic timer to sample it.
> 
> This timer operates at 10 Hz, which makes it the third worst
> cause of timeouts in my kernel when idle.
> 
> 10 Hz seems excessive, so this patch adds a compile-time option
> to reduce the polling frequency to 1 Hz.

How much power does this actually save?

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

* [PATCH 2/2] n2100: reduce power button timer to 1 Hz
  2009-09-28  9:52 ` Lennert Buytenhek
@ 2009-09-28 10:25   ` Mikael Pettersson
  0 siblings, 0 replies; 7+ messages in thread
From: Mikael Pettersson @ 2009-09-28 10:25 UTC (permalink / raw)
  To: linux-arm-kernel

Lennert Buytenhek writes:
 > On Sat, Sep 26, 2009 at 09:53:55PM +0200, Mikael Pettersson wrote:
 > 
 > > The power button on the n2100 apparently does not generate
 > > an interrupt when pressed, so the board support code sets
 > > up a periodic timer to sample it.
 > > 
 > > This timer operates at 10 Hz, which makes it the third worst
 > > cause of timeouts in my kernel when idle.
 > > 
 > > 10 Hz seems excessive, so this patch adds a compile-time option
 > > to reduce the polling frequency to 1 Hz.
 > 
 > How much power does this actually save?

I have no way of measuring that, unfortunately.

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

* [PATCH 2/2] n2100: reduce power button timer to 1 Hz
  2009-09-28  8:06 ` Aaro Koskinen
@ 2009-09-28 10:30   ` Mikael Pettersson
  2009-09-28 10:44     ` Aaro Koskinen
  0 siblings, 1 reply; 7+ messages in thread
From: Mikael Pettersson @ 2009-09-28 10:30 UTC (permalink / raw)
  To: linux-arm-kernel

Aaro Koskinen writes:
 > Hello,
 > 
 > Mikael Pettersson wrote:
 > > 10 Hz seems excessive, so this patch adds a compile-time option
 > > to reduce the polling frequency to 1 Hz.
 > > 
 > > (This change could possibly be handled via a kernel boot option,
 > > or even be made unconditional, but I opted for a compile-time
 > > option for now.)
 > 
 > I don't think there is need to have an option for this. With HZ also
 > round_jiffies() could be used, it doesn't need to be exact.

I don't quite follow you here. Can you elaborate?

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

* [PATCH 2/2] n2100: reduce power button timer to 1 Hz
  2009-09-28 10:30   ` Mikael Pettersson
@ 2009-09-28 10:44     ` Aaro Koskinen
  2009-09-28 11:26       ` Mikael Pettersson
  0 siblings, 1 reply; 7+ messages in thread
From: Aaro Koskinen @ 2009-09-28 10:44 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

Mikael Pettersson wrote:
> Aaro Koskinen writes:
>  > Mikael Pettersson wrote:
>  > > 10 Hz seems excessive, so this patch adds a compile-time option
>  > > to reduce the polling frequency to 1 Hz.
>  > > 
>  > > (This change could possibly be handled via a kernel boot option,
>  > > or even be made unconditional, but I opted for a compile-time
>  > > option for now.)
>  > 
>  > I don't think there is need to have an option for this. With HZ also
>  > round_jiffies() could be used, it doesn't need to be exact.
> 
> I don't quite follow you here. Can you elaborate?

round_jiffies() rounds the time up or down to a full second. It's useful for
timers that expire every N seconds. This way timeouts can be grouped, so there
is less wakeups.

A.

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

* [PATCH 2/2] n2100: reduce power button timer to 1 Hz
  2009-09-28 10:44     ` Aaro Koskinen
@ 2009-09-28 11:26       ` Mikael Pettersson
  0 siblings, 0 replies; 7+ messages in thread
From: Mikael Pettersson @ 2009-09-28 11:26 UTC (permalink / raw)
  To: linux-arm-kernel

Aaro Koskinen writes:
 > Hello,
 > 
 > Mikael Pettersson wrote:
 > > Aaro Koskinen writes:
 > >  > Mikael Pettersson wrote:
 > >  > > 10 Hz seems excessive, so this patch adds a compile-time option
 > >  > > to reduce the polling frequency to 1 Hz.
 > >  > > 
 > >  > > (This change could possibly be handled via a kernel boot option,
 > >  > > or even be made unconditional, but I opted for a compile-time
 > >  > > option for now.)
 > >  > 
 > >  > I don't think there is need to have an option for this. With HZ also
 > >  > round_jiffies() could be used, it doesn't need to be exact.
 > > 
 > > I don't quite follow you here. Can you elaborate?
 > 
 > round_jiffies() rounds the time up or down to a full second. It's useful for
 > timers that expire every N seconds. This way timeouts can be grouped, so there
 > is less wakeups.

Ah, the two sentences were not to be taken as a group:
1) no need for an option, i.e. reduce to 1 Hz unconditionally, and
2) with a 1 Hz timer, use round_jiffies() in the hope of grouping
   with other whole-Hz timers that also use round_jiffies().

I'll look into using round_jiffies().

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

end of thread, other threads:[~2009-09-28 11:26 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-26 19:53 [PATCH 2/2] n2100: reduce power button timer to 1 Hz Mikael Pettersson
2009-09-28  8:06 ` Aaro Koskinen
2009-09-28 10:30   ` Mikael Pettersson
2009-09-28 10:44     ` Aaro Koskinen
2009-09-28 11:26       ` Mikael Pettersson
2009-09-28  9:52 ` Lennert Buytenhek
2009-09-28 10:25   ` Mikael Pettersson

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.