Discussion:
[patch] use round_jiffies for commsqual timer
Richard Kennedy
2008-03-24 17:48:17 UTC
Permalink
using round_jiffies for the comms quality timer may help the kernel save
power

the comment in timer.c says :-

* __round_jiffies_relative() rounds a time delta in the future (in jiffies)
* up or down to (approximately) full seconds. This is useful for timers
* for which the exact time they fire does not matter too much, as long as
* they fire approximately every X seconds.
*
* By rounding these timers to whole seconds, all such timers will fire
* at the same time, rather than at various times spread out. The goal
* of this is to have the CPU wake up less, which saves power.

I think round_jiffies got added in 2.6.20 ( if I've driven git correctly ;) )

So I also added an empty #define into wlan_campat.h for older kernels.

I don't see much difference in powertop, but it may help on new
processors. I guess slowing this down to every 5s would have more
difference though.

Cheers
Richard


diff --git a/src/include/wlan/wlan_compat.h b/src/include/wlan/wlan_compat.h
index 55f86fb..428e1cf 100644
--- a/src/include/wlan/wlan_compat.h
+++ b/src/include/wlan/wlan_compat.h
@@ -704,6 +704,10 @@ typedef u32 pm_message_t;
CardServices(ReportError, handle, err)
#endif

+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20))
+#define round_jiffies(a) (a)
+#endif
+
#endif /* __KERNEL__ */

/*=============================================================*/
diff --git a/src/prism2/driver/prism2sta.c b/src/prism2/driver/prism2sta.c
index 68de522..3aea69d 100644
--- a/src/prism2/driver/prism2sta.c
+++ b/src/prism2/driver/prism2sta.c
@@ -2484,7 +2484,7 @@ void prism2sta_commsqual_defer(struct work_struct *data)


/* Reschedule timer */
- mod_timer(&hw->commsqual_timer, jiffies + HZ);
+ mod_timer(&hw->commsqual_timer, round_jiffies(jiffies + HZ));

done:
DBFEXIT;

Loading...