From: tip-bot for Yang Yingliang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: tglx@linutronix.de, mingo@kernel.org, yangyingliang@huawei.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, hpa@zytor.com
Subject: [tip:timers/core] clocksource: Make clocksource validation work for all clocksources
Date: Sat, 19 Dec 2015 07:03:33 -0800 [thread overview]
Message-ID: <tip-1f45f1f33c8c8b96722dbc5e6b7acf74eaa721f7@git.kernel.org> (raw)
In-Reply-To: <56349607.6070708@huawei.com>
Commit-ID: 1f45f1f33c8c8b96722dbc5e6b7acf74eaa721f7
Gitweb: http://git.kernel.org/tip/1f45f1f33c8c8b96722dbc5e6b7acf74eaa721f7
Author: Yang Yingliang <yangyingliang@huawei.com>
AuthorDate: Sat, 31 Oct 2015 18:20:55 +0800
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitDate: Sat, 19 Dec 2015 15:59:57 +0100
clocksource: Make clocksource validation work for all clocksources
The clocksource validation which makes sure that the newly read value
is not smaller than the last value only works if the clocksource mask
is 64bit, i.e. the counter is 64bit wide. But we want to use that
mechanism also for clocksources which are less than 64bit wide.
So instead of checking whether bit 63 is set, we check whether the
most significant bit of the clocksource mask is set in the delta
result. If it is set, we return 0.
[ tglx: Simplified the implementation, added a comment and massaged
the commit message ]
Suggested-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Cc: <linux-arm-kernel@lists.infradead.org>
Link: http://lkml.kernel.org/r/56349607.6070708@huawei.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
kernel/time/timekeeping_internal.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/kernel/time/timekeeping_internal.h b/kernel/time/timekeeping_internal.h
index e20466f..5be7627 100644
--- a/kernel/time/timekeeping_internal.h
+++ b/kernel/time/timekeeping_internal.h
@@ -17,7 +17,11 @@ static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask)
{
cycle_t ret = (now - last) & mask;
- return (s64) ret > 0 ? ret : 0;
+ /*
+ * Prevent time going backwards by checking the MSB of mask in
+ * the result. If set, return 0.
+ */
+ return ret & ~(mask >> 1) ? 0 : ret;
}
#else
static inline cycle_t clocksource_delta(cycle_t now, cycle_t last, cycle_t mask)
next prev parent reply other threads:[~2015-12-19 15:04 UTC|newest]
Thread overview: 12+ 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 ` [PATCH resend] clocksource: modify the cycle_last validation to fit for non-64bit clocksourece mask Yang Yingliang
2015-12-19 15:03 ` tip-bot for Yang Yingliang [this message]
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=tip-1f45f1f33c8c8b96722dbc5e6b7acf74eaa721f7@git.kernel.org \
--to=tipbot@zytor.com \
--cc=hpa@zytor.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=yangyingliang@huawei.com \
/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
Powered by JetHome