Skip to contentSkip to conversation

block core: use round_jiffies on timer to reduce wakeups

PATCH In review Randy Dunlap 2 participants 2 messages Nov 11, 2009 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block core: use round_jiffies on timer to reduce wakeups

From: Randy Dunlap <[email protected]>

Use round_jiffies() variant to schedule the timer along with other timer wakeups on the same CPU.

Source file also needs to include jiffies.h since it uses functions or macros from it.

---
 block/blk-core.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-core.c +3 -1
@@ -17,6 +17,7 @@
 #include <linux/bio.h>
 #include <linux/blkdev.h>
 #include <linux/highmem.h>
+#include <linux/jiffies.h>
 #include <linux/mm.h>
 #include <linux/kernel_stat.h>
 #include <linux/string.h>
@@ -212,7 +213,8 @@ void blk_plug_device(struct request_queu
 		return;
 
 	if (!queue_flag_test_and_set(QUEUE_FLAG_PLUGGED, q)) {
-		mod_timer(&q->unplug_timer, jiffies + q->unplug_delay);
+		mod_timer(&q->unplug_timer,
+			round_jiffies_up(jiffies + q->unplug_delay));
 		trace_block_plug(q);
 	}
 }
#1 lore raw
Quoted 7 lines · Randy Dunlap

From: Randy Dunlap <[email protected]>

Use round_jiffies() variant to schedule the timer along with other timer wakeups on the same CPU.

Source file also needs to include jiffies.h since it uses functions or macros from it.

round_jiffies() rounds to the next second, that's way too far away for an event that should trigger within msecs.

Signature · 1 line
Jens Axboe