LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 08/14] mm/: Use time_* macros
@ 2008-02-14 15:36 S.Çağlar Onur
  0 siblings, 0 replies; only message in thread
From: S.Çağlar Onur @ 2008-02-14 15:36 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-mm, S.Çağlar Onur

The functions time_before, time_before_eq, time_after, and time_after_eq are more robust for comparing jiffies against other values.

So following patch implements usage of the time_after() macro, defined at linux/jiffies.h, which deals with wrapping correctly

Cc: linux-mm@kvack.org
Signed-off-by: S.Çağlar Onur <caglar@pardus.org.tr>
---
 mm/page_alloc.c |    3 ++-
 mm/pdflush.c    |    5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 75b9793..1a0c9cc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -14,6 +14,7 @@
  *          (lots of bits borrowed from Ingo Molnar & Andrew Morton)
  */
 
+#include <linux/jiffies.h>
 #include <linux/stddef.h>
 #include <linux/mm.h>
 #include <linux/swap.h>
@@ -1276,7 +1277,7 @@ static nodemask_t *zlc_setup(struct zonelist *zonelist, int alloc_flags)
 	if (!zlc)
 		return NULL;
 
-	if (jiffies - zlc->last_full_zap > 1 * HZ) {
+	if (time_after(jiffies, zlc->last_full_zap + HZ)) {
 		bitmap_zero(zlc->fullzones, MAX_ZONES_PER_ZONELIST);
 		zlc->last_full_zap = jiffies;
 	}
diff --git a/mm/pdflush.c b/mm/pdflush.c
index 8f6ee07..5d736d5 100644
--- a/mm/pdflush.c
+++ b/mm/pdflush.c
@@ -10,6 +10,7 @@
  *		up stack space with nested calls to kernel_thread.
  */
 
+#include <linux/jiffies.h>
 #include <linux/sched.h>
 #include <linux/list.h>
 #include <linux/signal.h>
@@ -130,7 +131,7 @@ static int __pdflush(struct pdflush_work *my_work)
 		 * Thread creation: For how long have there been zero
 		 * available threads?
 		 */
-		if (jiffies - last_empty_jifs > 1 * HZ) {
+		if (time_after(jiffies, last_empty_jifs + HZ)) {
 			/* unlocked list_empty() test is OK here */
 			if (list_empty(&pdflush_list)) {
 				/* unlocked test is OK here */
@@ -151,7 +152,7 @@ static int __pdflush(struct pdflush_work *my_work)
 		if (nr_pdflush_threads <= MIN_PDFLUSH_THREADS)
 			continue;
 		pdf = list_entry(pdflush_list.prev, struct pdflush_work, list);
-		if (jiffies - pdf->when_i_went_to_sleep > 1 * HZ) {
+		if (time_after(jiffies, pdf->when_i_went_to_sleep + HZ)) {
 			/* Limit exit rate */
 			pdf->when_i_went_to_sleep = jiffies;
 			break;					/* exeunt */
-- 
1.5.3.7


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-02-14 15:44 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-14 15:36 [PATCH 08/14] mm/: Use time_* macros S.Çağlar Onur

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).