From: Sergei Shtylyov <sshtylyov@ru.mvista.com>
To: mingo@elte.hu
Cc: linuxppc-dev@ozlabs.org, johnstul@us.ibm.com,
linux-kernel@vger.kernel.org, dwalker@mvista.com
Subject: [PATCH 2.6.21-rc6-rt0] ns2cyc() result fix
Date: Wed, 25 Apr 2007 22:54:17 +0300 [thread overview]
Message-ID: <200704252354.17404.sshtylyov@ru.mvista.com> (raw)
Fix the dubious use of cycles_t where cycle_t was appropriate. On the machines
with 32-bit cycles_t (like ARM/PPC) it caused these warnings:
In file included from arch/powerpc/kernel/time.c:1045:
include/linux/clocksource.h: In function `ns2cyc':
include/linux/clocksource.h:213: warning: comparison of distinct pointer types lacks a cast
include/linux/clocksource.h:213: warning: right shift count >= width of type
include/linux/clocksource.h:213: warning: passing argument 1 of `__div64_32' from incompatible pointer type
This function and therefore usecs_to_cycles() was unlikely to return a correct
result on such machines because of the shift result truncation.
Signed-off-by: Sergei Shtylyov <sshtylyov@ru.mvista.com>
---
I'm also uncertain about 'preempt_max_latency' and 'preempt_thresh' variables
being declared as 'unsigned long' -- however, looks like those are unlikely to
overflow... yet it's unclear why there's casts to 'cycle_t' (which is always
64-bit) when initializing/comparing them...
Index: linux-2.6/include/linux/clocksource.h
===================================================================
--- linux-2.6.orig/include/linux/clocksource.h
+++ linux-2.6/include/linux/clocksource.h
@@ -206,9 +206,9 @@ static inline s64 cyc2ns(struct clocksou
* @cs: Pointer to clocksource
* @nsecs: Nanoseconds
*/
-static inline cycles_t ns2cyc(struct clocksource *cs, u64 nsecs)
+static inline cycle_t ns2cyc(struct clocksource *cs, u64 nsecs)
{
- cycles_t ret = nsecs << cs->shift;
+ cycle_t ret = nsecs << cs->shift;
do_div(ret, cs->mult + 1);
reply other threads:[~2007-04-25 19:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200704252354.17404.sshtylyov@ru.mvista.com \
--to=sshtylyov@ru.mvista.com \
--cc=dwalker@mvista.com \
--cc=johnstul@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@ozlabs.org \
--cc=mingo@elte.hu \
/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