fs: yaffs: Use deferable timer for background operations
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.
Change-Id: Ic168525c6b33600ad23017d00ea9723cf8a738d2
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
diff --git a/fs/yaffs2/yaffs_vfs.c b/fs/yaffs2/yaffs_vfs.c
index a4db5cc..f56e12c 100644
--- a/fs/yaffs2/yaffs_vfs.c
+++ b/fs/yaffs2/yaffs_vfs.c
@@ -65,7 +65,7 @@
#define YPROC_ROOT NULL
-#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)
#define WRITE_SIZE_STR "writesize"
#define WRITE_SIZE(mtd) ((mtd)->writesize)
@@ -1674,10 +1674,9 @@
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);