mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: <mingo@redhat.com>, <peterz@infradead.org>
Cc: <linux-kernel@vger.kernel.org>,
	Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Subject: [PATCH] sched/clock: cleanup, remove wrap_{max|min}().
Date: Wed, 7 May 2014 20:48:58 +0900	[thread overview]
Message-ID: <1399463338-15507-1-git-send-email-yangds.fnst@cn.fujitsu.com> (raw)

I am not sure why we need the wrap_{max|min}() in kernel/sched/clock.c.
But I checked the implementation of max() and min() in linux/kernel.h, I think
we can reuse them here rather than introduce a new function named
wrap_{max|min}().

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 kernel/sched/clock.c | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/kernel/sched/clock.c b/kernel/sched/clock.c
index 3ef6451..36c03a8 100644
--- a/kernel/sched/clock.c
+++ b/kernel/sched/clock.c
@@ -173,20 +173,6 @@ void sched_clock_init(void)
 }
 
 /*
- * min, max except they take wrapping into account
- */
-
-static inline u64 wrap_min(u64 x, u64 y)
-{
-	return (s64)(x - y) < 0 ? x : y;
-}
-
-static inline u64 wrap_max(u64 x, u64 y)
-{
-	return (s64)(x - y) > 0 ? x : y;
-}
-
-/*
  * update the percpu scd from the raw @now value
  *
  *  - filter out backward motion
@@ -212,11 +198,11 @@ again:
 	 */
 
 	clock = scd->tick_gtod + delta;
-	min_clock = wrap_max(scd->tick_gtod, old_clock);
-	max_clock = wrap_max(old_clock, scd->tick_gtod + TICK_NSEC);
+	min_clock = max(scd->tick_gtod, old_clock);
+	max_clock = max(old_clock, scd->tick_gtod + TICK_NSEC);
 
-	clock = wrap_max(clock, min_clock);
-	clock = wrap_min(clock, max_clock);
+	clock = max(clock, min_clock);
+	clock = min(clock, max_clock);
 
 	if (cmpxchg64(&scd->clock, old_clock, clock) != old_clock)
 		goto again;
-- 
1.8.2.1


             reply	other threads:[~2014-05-07 12:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-07 11:48 Dongsheng Yang [this message]
2014-05-07 12:55 ` Peter Zijlstra
2014-05-07 12:04   ` Dongsheng Yang
2014-05-07 13:38     ` Peter Zijlstra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399463338-15507-1-git-send-email-yangds.fnst@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®