* [PATCH] yaffs: Use deferable timer for background operations
@ 2012-01-20 3:02 Sujit Reddy Thumma
2012-01-20 16:52 ` David Brown
0 siblings, 1 reply; 2+ messages in thread
From: Sujit Reddy Thumma @ 2012-01-20 3:02 UTC (permalink / raw)
To: yaffs; +Cc: linux-arm-msm, Sujit Reddy Thumma
Use deferable timer in background operations thread,
so that it won't cause unnecessary wakeups. Typically,
wakeups are seen in the range 60ms to 2secs (for HZ=100)
after the thread is scheduled out. In general, during this
delay the processor can go into sleep, if there is no other
activity. Since, the work done in this background operation
is not critical and can be handled as soon as when timer
expires and processor wakes up for other critical events,
we mark the timer responsible for wakeup of this thread
as deferable timer. Otherwise, the processor wakesup
unnecessarily to handle the background operations causing
higher power consumption in idle state.
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
---
yaffs_vfs_multi.c | 9 ++++-----
yaffs_vfs_single.c | 5 ++---
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c
index b8e5124..2132ae3 100644
--- a/yaffs_vfs_multi.c
+++ b/yaffs_vfs_multi.c
@@ -129,9 +129,9 @@
#endif
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26))
-#define Y_INIT_TIMER(a) init_timer(a)
+#define Y_INIT_TIMER(a, b, c) setup_timer(a, b, c)
#else
-#define Y_INIT_TIMER(a) init_timer_on_stack(a)
+#define Y_INIT_TIMER(a, b, c) setup_deferrable_timer_on_stack(a, b, c)
#endif
#if (LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 17))
@@ -2300,10 +2300,9 @@ static int yaffs_bg_thread_fn(void *data)
if (time_before(expires, now))
expires = now + HZ;
- Y_INIT_TIMER(&timer);
+ Y_INIT_TIMER(&timer, yaffs_background_waker,
+ (unsigned long)current);
timer.expires = expires + 1;
- timer.data = (unsigned long)current;
- timer.function = yaffs_background_waker;
set_current_state(TASK_INTERRUPTIBLE);
add_timer(&timer);
diff --git a/yaffs_vfs_single.c b/yaffs_vfs_single.c
index f822845..1ddc03e 100644
--- a/yaffs_vfs_single.c
+++ b/yaffs_vfs_single.c
@@ -1636,10 +1636,9 @@ static int yaffs_bg_thread_fn(void *data)
if (time_before(expires, now))
expires = now + HZ;
- init_timer_on_stack(&timer);
+ setup_deferrable_timer_on_stack(&timer, yaffs_background_waker,
+ (unsigned long)current);
timer.expires = expires + 1;
- timer.data = (unsigned long)current;
- timer.function = yaffs_background_waker;
set_current_state(TASK_INTERRUPTIBLE);
add_timer(&timer);
--
Sent by a consultant of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] yaffs: Use deferable timer for background operations
2012-01-20 3:02 [PATCH] yaffs: Use deferable timer for background operations Sujit Reddy Thumma
@ 2012-01-20 16:52 ` David Brown
0 siblings, 0 replies; 2+ messages in thread
From: David Brown @ 2012-01-20 16:52 UTC (permalink / raw)
To: Sujit Reddy Thumma; +Cc: yaffs, linux-arm-msm
On Fri, Jan 20, 2012 at 08:32:45AM +0530, Sujit Reddy Thumma wrote:
> diff --git a/yaffs_vfs_multi.c b/yaffs_vfs_multi.c
> index b8e5124..2132ae3 100644
> --- a/yaffs_vfs_multi.c
> +++ b/yaffs_vfs_multi.c
> @@ -129,9 +129,9 @@
> #endif
>
> #if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26))
> -#define Y_INIT_TIMER(a) init_timer(a)
> +#define Y_INIT_TIMER(a, b, c) setup_timer(a, b, c)
> #else
> -#define Y_INIT_TIMER(a) init_timer_on_stack(a)
> +#define Y_INIT_TIMER(a, b, c) setup_deferrable_timer_on_stack(a, b, c)
> #endif
setup_timer() was added in 2.6.15, so I'm not sure that this will
quite work as is.
David
--
Sent by an employee of the Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-01-20 16:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-20 3:02 [PATCH] yaffs: Use deferable timer for background operations Sujit Reddy Thumma
2012-01-20 16:52 ` David Brown
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.