public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: yangyingliang@huawei•com (Yang Yingliang)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH resend] clocksource: modify the cycle_last validation to fit for non-64bit clocksourece mask
Date: Sat, 31 Oct 2015 18:20:55 +0800	[thread overview]
Message-ID: <56349607.6070708@huawei.com> (raw)
In-Reply-To: <alpine.DEB.2.11.1510301533310.4032@nanos>

From: Yang Yingliang <yangyingliang@huawei•com>

Check the delta of now and last to make sure it's not
negative while the clocksource mask is not 64-bits.

Suggested-by: Thomas Gleixner <tglx@linutronix•de>
Signed-off-by: Yang Yingliang <yangyingliang@huawei•com>
---
  kernel/time/timekeeping_internal.h | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/time/timekeeping_internal.h 
b/kernel/time/timekeeping_internal.h
index 4ea005a..cbfcd2d 100644
--- a/kernel/time/timekeeping_internal.h
+++ b/kernel/time/timekeeping_internal.h
@@ -16,8 +16,9 @@ extern void tk_debug_account_sleep_time(struct 
timespec64 *t);
  static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, 
cycle_t mask)
  {
  	cycle_t ret = (now - last) & mask;
+	cycle_t negative = ret & ~(mask >> 1);

-	return (s64) ret > 0 ? ret : 0;
+	return negative ? 0 : ret;
  }
  #else
  static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, 
cycle_t mask)
-- 
2.5.0

  parent reply	other threads:[~2015-10-31 10:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-27 13:21 [PATCH 0/2] validate the delta of cycle_now and cycle_last on arm64 Yang Yingliang
2015-10-27 13:21 ` [PATCH 1/2] clocksource: replace cycle_last validation with an equal way Yang Yingliang
2015-10-30 14:56   ` Thomas Gleixner
2015-10-31 10:07     ` Yang Yingliang
2015-10-31 10:20     ` Yang Yingliang [this message]
     [not found]       ` <tip-1f45f1f33c8c8b96722dbc5e6b7acf74eaa721f7@git.kernel.org>
2016-01-04 17:13         ` [tip:timers/core] clocksource: Make clocksource validation work for all clocksources John Stultz
2015-10-27 13:21 ` [PATCH 2/2] arm64: validate the delta of cycle_now and cycle_last Yang Yingliang
2015-10-27 14:03   ` Mark Rutland
2015-10-28  1:33     ` Ding Tianhong
2015-10-29  7:36     ` Yang Yingliang
2015-10-29  8:31       ` Yang Yingliang

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=56349607.6070708@huawei.com \
    --to=yangyingliang@huawei$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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