Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-25 Thread David Howells
Roman Zippel <[EMAIL PROTECTED]> wrote:

> I would actually prefer to introduce an explicit API for signed 64 
> divides to get rid of the temps completely

Yeah, that's a better plan.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-25 Thread Roman Zippel
Hi,

On Thu, 21 Feb 2008, David Howells wrote:

> The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make 
> it
> instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

I would actually prefer to introduce an explicit API for signed 64 
divides to get rid of the temps completely, something like below.
Right now it uses do_div as fallback. When all archs are converted, do_div 
can be single compatibility define and perhaps we can get rid of it
completely.
Bonus feature: implement the x86 version without the asm casts allowing 
gcc to generate better code.

bye, Roman

---
 include/asm-generic/div64.h |   14 ++
 include/asm-i386/div64.h|   20 
 include/linux/calc64.h  |   28 
 kernel/time.c   |   26 +++---
 kernel/time/ntp.c   |   21 +
 lib/div64.c |   21 -
 6 files changed, 94 insertions(+), 36 deletions(-)

Index: linux-2.6/include/asm-generic/div64.h
===
--- linux-2.6.orig/include/asm-generic/div64.h
+++ linux-2.6/include/asm-generic/div64.h
@@ -35,6 +35,20 @@ static inline uint64_t div64_64(uint64_t
return dividend / divisor;
 }
 
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+   *remainder = dividend % divisor;
+   return dividend / divisor;
+}
+#define div_u64_remdiv_u64_rem
+
+static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
+{
+   *remainder = dividend % divisor;
+   return dividend / divisor;
+}
+#define div_s64_remdiv_s64_rem
+
 #elif BITS_PER_LONG == 32
 
 extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
Index: linux-2.6/include/asm-i386/div64.h
===
--- linux-2.6.orig/include/asm-i386/div64.h
+++ linux-2.6/include/asm-i386/div64.h
@@ -48,5 +48,25 @@ div_ll_X_l_rem(long long divs, long div,
 
 }
 
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+   union {
+   u64 v64;
+   u32 v32[2];
+   } d = { dividend };
+   u32 upper;
+
+   upper = d.v32[1];
+   if (upper) {
+   upper = d.v32[1] % divisor;
+   d.v32[1] = d.v32[1] / divisor;
+   }
+   asm ("divl %2" : "=a" (d.v32[0]), "=d" (*remainder) :
+   "rm" (divisor), "0" (d.v32[0]), "1" (upper));
+   return d.v64;
+}
+#define div_u64_remdiv_u64_rem
+
 extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
+
 #endif
Index: linux-2.6/include/linux/calc64.h
===
--- linux-2.6.orig/include/linux/calc64.h
+++ linux-2.6/include/linux/calc64.h
@@ -46,4 +46,32 @@ static inline long div_long_long_rem_sig
return res;
 }
 
+#ifndef div_u64_rem
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+   *remainder = do_div(dividend, divisor);
+   return dividend;
+}
+#endif
+
+#ifndef div_u64
+static inline u64 div_u64(u64 dividend, u32 divisor)
+{
+   u32 remainder;
+   return div_u64_rem(dividend, divisor, );
+}
+#endif
+
+#ifndef div_s64_rem
+extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
+#endif
+
+#ifndef div_s64
+static inline s64 div_s64(s64 dividend, s32 divisor)
+{
+   s32 remainder;
+   return div_s64_rem(dividend, divisor, );
+}
+#endif
+
 #endif
Index: linux-2.6/kernel/time.c
===
--- linux-2.6.orig/kernel/time.c
+++ linux-2.6/kernel/time.c
@@ -661,9 +661,7 @@ clock_t jiffies_to_clock_t(long x)
 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
return x / (HZ / USER_HZ);
 #else
-   u64 tmp = (u64)x * TICK_NSEC;
-   do_div(tmp, (NSEC_PER_SEC / USER_HZ));
-   return (long)tmp;
+   return div_u64((u64)x * TICK_NSEC, NSEC_PER_SEC / USER_HZ);
 #endif
 }
 EXPORT_SYMBOL(jiffies_to_clock_t);
@@ -675,16 +673,12 @@ unsigned long clock_t_to_jiffies(unsigne
return ~0UL;
return x * (HZ / USER_HZ);
 #else
-   u64 jif;
-
/* Don't worry about loss of precision here .. */
if (x >= ~0UL / HZ * USER_HZ)
return ~0UL;
 
/* .. but do try to contain it here */
-   jif = x * (u64) HZ;
-   do_div(jif, USER_HZ);
-   return jif;
+   return div_u64((u64)x * HZ, USER_HZ);
 #endif
 }
 EXPORT_SYMBOL(clock_t_to_jiffies);
@@ -692,17 +686,15 @@ EXPORT_SYMBOL(clock_t_to_jiffies);
 u64 jiffies_64_to_clock_t(u64 x)
 {
 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
-   do_div(x, HZ / USER_HZ);
+   return div_u64(x, HZ / USER_HZ);
 #else
/*
 * There are better ways that don't overflow early,
 * but even this doesn't overflow in hundreds of years
 * in 64 bits, so..
 */
-   x *= 

Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-25 Thread Roman Zippel
Hi,

On Thu, 21 Feb 2008, David Howells wrote:

 The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make 
 it
 instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

I would actually prefer to introduce an explicit API for signed 64 
divides to get rid of the temps completely, something like below.
Right now it uses do_div as fallback. When all archs are converted, do_div 
can be single compatibility define and perhaps we can get rid of it
completely.
Bonus feature: implement the x86 version without the asm casts allowing 
gcc to generate better code.

bye, Roman

---
 include/asm-generic/div64.h |   14 ++
 include/asm-i386/div64.h|   20 
 include/linux/calc64.h  |   28 
 kernel/time.c   |   26 +++---
 kernel/time/ntp.c   |   21 +
 lib/div64.c |   21 -
 6 files changed, 94 insertions(+), 36 deletions(-)

Index: linux-2.6/include/asm-generic/div64.h
===
--- linux-2.6.orig/include/asm-generic/div64.h
+++ linux-2.6/include/asm-generic/div64.h
@@ -35,6 +35,20 @@ static inline uint64_t div64_64(uint64_t
return dividend / divisor;
 }
 
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+   *remainder = dividend % divisor;
+   return dividend / divisor;
+}
+#define div_u64_remdiv_u64_rem
+
+static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
+{
+   *remainder = dividend % divisor;
+   return dividend / divisor;
+}
+#define div_s64_remdiv_s64_rem
+
 #elif BITS_PER_LONG == 32
 
 extern uint32_t __div64_32(uint64_t *dividend, uint32_t divisor);
Index: linux-2.6/include/asm-i386/div64.h
===
--- linux-2.6.orig/include/asm-i386/div64.h
+++ linux-2.6/include/asm-i386/div64.h
@@ -48,5 +48,25 @@ div_ll_X_l_rem(long long divs, long div,
 
 }
 
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+   union {
+   u64 v64;
+   u32 v32[2];
+   } d = { dividend };
+   u32 upper;
+
+   upper = d.v32[1];
+   if (upper) {
+   upper = d.v32[1] % divisor;
+   d.v32[1] = d.v32[1] / divisor;
+   }
+   asm (divl %2 : =a (d.v32[0]), =d (*remainder) :
+   rm (divisor), 0 (d.v32[0]), 1 (upper));
+   return d.v64;
+}
+#define div_u64_remdiv_u64_rem
+
 extern uint64_t div64_64(uint64_t dividend, uint64_t divisor);
+
 #endif
Index: linux-2.6/include/linux/calc64.h
===
--- linux-2.6.orig/include/linux/calc64.h
+++ linux-2.6/include/linux/calc64.h
@@ -46,4 +46,32 @@ static inline long div_long_long_rem_sig
return res;
 }
 
+#ifndef div_u64_rem
+static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
+{
+   *remainder = do_div(dividend, divisor);
+   return dividend;
+}
+#endif
+
+#ifndef div_u64
+static inline u64 div_u64(u64 dividend, u32 divisor)
+{
+   u32 remainder;
+   return div_u64_rem(dividend, divisor, remainder);
+}
+#endif
+
+#ifndef div_s64_rem
+extern s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder);
+#endif
+
+#ifndef div_s64
+static inline s64 div_s64(s64 dividend, s32 divisor)
+{
+   s32 remainder;
+   return div_s64_rem(dividend, divisor, remainder);
+}
+#endif
+
 #endif
Index: linux-2.6/kernel/time.c
===
--- linux-2.6.orig/kernel/time.c
+++ linux-2.6/kernel/time.c
@@ -661,9 +661,7 @@ clock_t jiffies_to_clock_t(long x)
 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
return x / (HZ / USER_HZ);
 #else
-   u64 tmp = (u64)x * TICK_NSEC;
-   do_div(tmp, (NSEC_PER_SEC / USER_HZ));
-   return (long)tmp;
+   return div_u64((u64)x * TICK_NSEC, NSEC_PER_SEC / USER_HZ);
 #endif
 }
 EXPORT_SYMBOL(jiffies_to_clock_t);
@@ -675,16 +673,12 @@ unsigned long clock_t_to_jiffies(unsigne
return ~0UL;
return x * (HZ / USER_HZ);
 #else
-   u64 jif;
-
/* Don't worry about loss of precision here .. */
if (x = ~0UL / HZ * USER_HZ)
return ~0UL;
 
/* .. but do try to contain it here */
-   jif = x * (u64) HZ;
-   do_div(jif, USER_HZ);
-   return jif;
+   return div_u64((u64)x * HZ, USER_HZ);
 #endif
 }
 EXPORT_SYMBOL(clock_t_to_jiffies);
@@ -692,17 +686,15 @@ EXPORT_SYMBOL(clock_t_to_jiffies);
 u64 jiffies_64_to_clock_t(u64 x)
 {
 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
-   do_div(x, HZ / USER_HZ);
+   return div_u64(x, HZ / USER_HZ);
 #else
/*
 * There are better ways that don't overflow early,
 * but even this doesn't overflow in hundreds of years
 * in 64 bits, so..
 */
-   x 

Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-25 Thread David Howells
Roman Zippel [EMAIL PROTECTED] wrote:

 I would actually prefer to introduce an explicit API for signed 64 
 divides to get rid of the temps completely

Yeah, that's a better plan.

David
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Thomas Gleixner
On Sat, 23 Feb 2008, Andrew Morton wrote:
> > > Thomas, do you consider ntp to fall under git-hrt?
> > 
> > I'll pick it up.
> > 
> OK.  And this is still
> git+ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt.git#mm,
> yes?

Yes
 
> Can we please define the scope of that tree?

Primary scope is hrtimer, posixtimer, clockevents & Co.

In the last month I fed a lot of timekeeping/ntp stuff via -hrt as
well. If there is no objection, I'm happy to provide the sink for
those.

> Please review
> 
> fix-shadowed-variables-in-kernel-posix-cpu-timersc.patch
> timers-simplify-lockdep-stuff.patch
> hrtimers-simplify-lockdep-stuff.patch
> kill-double_spin_lock.patch
> ntp-make-the-kernel-ntp-code-hand-64-bit-unsigned-values-to-do_div.patch
> 
> from http://userweb.kernel.org/~akpm/mmotm/broken-out/.  I think they're
> all probably git-hrt material.

Will do tomorrow, when I'm more awake.

> Can we get that tree into linux-next too please?

Will contact Stephen.

Thanks,

tglx

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Andrew Morton
On Sat, 23 Feb 2008 22:01:55 +0100 (CET) Thomas Gleixner <[EMAIL PROTECTED]> 
wrote:

> On Sat, 23 Feb 2008, Andrew Morton wrote:
> 
> > On Thu, 21 Feb 2008 16:50:35 + David Howells <[EMAIL PROTECTED]> wrote:
> > 
> > > From: David Howells <[EMAIL PROTECTED]>
> > > 
> > > The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  
> > > Make it
> > > instead hand 64-bit unsigned values.  This gets rid of a couple of 
> > > warnings.
> > 
> > On certain architectures.  It would have bene nice to mention what those
> > architectures are, and to quote the warnings.  Next time, please ;)
> > 
> > > Signed-off-by: David Howells <[EMAIL PROTECTED]>
> > > ---
> > > 
> > >  kernel/time/ntp.c |   12 +++-
> > 
> > Thomas, do you consider ntp to fall under git-hrt?
> 
> I'll pick it up.
> 


OK.  And this is still
git+ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt.git#mm,
yes?

Can we please define the scope of that tree?

Please review

fix-shadowed-variables-in-kernel-posix-cpu-timersc.patch
timers-simplify-lockdep-stuff.patch
hrtimers-simplify-lockdep-stuff.patch
kill-double_spin_lock.patch
ntp-make-the-kernel-ntp-code-hand-64-bit-unsigned-values-to-do_div.patch

from http://userweb.kernel.org/~akpm/mmotm/broken-out/.  I think they're
all probably git-hrt material.

Can we get that tree into linux-next too please?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Thomas Gleixner
On Sat, 23 Feb 2008, Andrew Morton wrote:

> On Thu, 21 Feb 2008 16:50:35 + David Howells <[EMAIL PROTECTED]> wrote:
> 
> > From: David Howells <[EMAIL PROTECTED]>
> > 
> > The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  
> > Make it
> > instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.
> 
> On certain architectures.  It would have bene nice to mention what those
> architectures are, and to quote the warnings.  Next time, please ;)
> 
> > Signed-off-by: David Howells <[EMAIL PROTECTED]>
> > ---
> > 
> >  kernel/time/ntp.c |   12 +++-
> 
> Thomas, do you consider ntp to fall under git-hrt?

I'll pick it up.

Thanks,

tglx

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Andrew Morton
On Thu, 21 Feb 2008 16:50:35 + David Howells <[EMAIL PROTECTED]> wrote:

> From: David Howells <[EMAIL PROTECTED]>
> 
> The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make 
> it
> instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

On certain architectures.  It would have bene nice to mention what those
architectures are, and to quote the warnings.  Next time, please ;)

> Signed-off-by: David Howells <[EMAIL PROTECTED]>
> ---
> 
>  kernel/time/ntp.c |   12 +++-

Thomas, do you consider ntp to fall under git-hrt?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Andrew Morton
On Thu, 21 Feb 2008 16:50:35 + David Howells [EMAIL PROTECTED] wrote:

 From: David Howells [EMAIL PROTECTED]
 
 The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make 
 it
 instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

On certain architectures.  It would have bene nice to mention what those
architectures are, and to quote the warnings.  Next time, please ;)

 Signed-off-by: David Howells [EMAIL PROTECTED]
 ---
 
  kernel/time/ntp.c |   12 +++-

Thomas, do you consider ntp to fall under git-hrt?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Thomas Gleixner
On Sat, 23 Feb 2008, Andrew Morton wrote:

 On Thu, 21 Feb 2008 16:50:35 + David Howells [EMAIL PROTECTED] wrote:
 
  From: David Howells [EMAIL PROTECTED]
  
  The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  
  Make it
  instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.
 
 On certain architectures.  It would have bene nice to mention what those
 architectures are, and to quote the warnings.  Next time, please ;)
 
  Signed-off-by: David Howells [EMAIL PROTECTED]
  ---
  
   kernel/time/ntp.c |   12 +++-
 
 Thomas, do you consider ntp to fall under git-hrt?

I'll pick it up.

Thanks,

tglx

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Andrew Morton
On Sat, 23 Feb 2008 22:01:55 +0100 (CET) Thomas Gleixner [EMAIL PROTECTED] 
wrote:

 On Sat, 23 Feb 2008, Andrew Morton wrote:
 
  On Thu, 21 Feb 2008 16:50:35 + David Howells [EMAIL PROTECTED] wrote:
  
   From: David Howells [EMAIL PROTECTED]
   
   The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  
   Make it
   instead hand 64-bit unsigned values.  This gets rid of a couple of 
   warnings.
  
  On certain architectures.  It would have bene nice to mention what those
  architectures are, and to quote the warnings.  Next time, please ;)
  
   Signed-off-by: David Howells [EMAIL PROTECTED]
   ---
   
kernel/time/ntp.c |   12 +++-
  
  Thomas, do you consider ntp to fall under git-hrt?
 
 I'll pick it up.
 


OK.  And this is still
git+ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt.git#mm,
yes?

Can we please define the scope of that tree?

Please review

fix-shadowed-variables-in-kernel-posix-cpu-timersc.patch
timers-simplify-lockdep-stuff.patch
hrtimers-simplify-lockdep-stuff.patch
kill-double_spin_lock.patch
ntp-make-the-kernel-ntp-code-hand-64-bit-unsigned-values-to-do_div.patch

from http://userweb.kernel.org/~akpm/mmotm/broken-out/.  I think they're
all probably git-hrt material.

Can we get that tree into linux-next too please?
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-23 Thread Thomas Gleixner
On Sat, 23 Feb 2008, Andrew Morton wrote:
   Thomas, do you consider ntp to fall under git-hrt?
  
  I'll pick it up.
  
 OK.  And this is still
 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/tglx/linux-2.6-hrt.git#mm,
 yes?

Yes
 
 Can we please define the scope of that tree?

Primary scope is hrtimer, posixtimer, clockevents  Co.

In the last month I fed a lot of timekeeping/ntp stuff via -hrt as
well. If there is no objection, I'm happy to provide the sink for
those.

 Please review
 
 fix-shadowed-variables-in-kernel-posix-cpu-timersc.patch
 timers-simplify-lockdep-stuff.patch
 hrtimers-simplify-lockdep-stuff.patch
 kill-double_spin_lock.patch
 ntp-make-the-kernel-ntp-code-hand-64-bit-unsigned-values-to-do_div.patch
 
 from http://userweb.kernel.org/~akpm/mmotm/broken-out/.  I think they're
 all probably git-hrt material.

Will do tomorrow, when I'm more awake.

 Can we get that tree into linux-next too please?

Will contact Stephen.

Thanks,

tglx

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #2]

2008-02-21 Thread David Howells
David Howells <[EMAIL PROTECTED]> wrote:

> Subject: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to
>   do_div() [try #2]

Ignore try #2.  I forgot to commit the changes before mailing.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #2]

2008-02-21 Thread David Howells
From: David Howells <[EMAIL PROTECTED]>

The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make it
instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

Signed-off-by: David Howells <[EMAIL PROTECTED]>
---

 kernel/time/ntp.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index c88b591..3bead00 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -342,13 +342,15 @@ int do_adjtimex(struct timex *txc)
freq_adj = shift_right(freq_adj, time_constant * 2 +
   (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > 
MAXSEC)) {
+   u64 utemp64;
temp64 = time_offset << (SHIFT_NSEC - SHIFT_FLL);
if (time_offset < 0) {
-   temp64 = -temp64;
-   do_div(temp64, mtemp);
+   utemp64 = -temp64;
+   do_div(utemp64, mtemp);
freq_adj -= temp64;
} else {
-   do_div(temp64, mtemp);
+   utemp64 = temp64;
+   do_div(utemp64, mtemp);
freq_adj += temp64;
}
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-21 Thread David Howells
From: David Howells <[EMAIL PROTECTED]>

The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make it
instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

Signed-off-by: David Howells <[EMAIL PROTECTED]>
---

 kernel/time/ntp.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)


diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index c88b591..d4bca92 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -342,14 +342,16 @@ int do_adjtimex(struct timex *txc)
freq_adj = shift_right(freq_adj, time_constant * 2 +
   (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > 
MAXSEC)) {
+   u64 utemp64;
temp64 = time_offset << (SHIFT_NSEC - SHIFT_FLL);
if (time_offset < 0) {
-   temp64 = -temp64;
-   do_div(temp64, mtemp);
-   freq_adj -= temp64;
+   utemp64 = -temp64;
+   do_div(utemp64, mtemp);
+   freq_adj -= utemp64;
} else {
-   do_div(temp64, mtemp);
-   freq_adj += temp64;
+   utemp64 = temp64;
+   do_div(utemp64, mtemp);
+   freq_adj += utemp64;
}
}
freq_adj += time_freq;

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-21 Thread David Howells
Andreas Schwab <[EMAIL PROTECTED]> wrote:

> do_div previously modified temp64 by side effect, now it no longer does
> that.

Good point.

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-21 Thread Andreas Schwab
David Howells <[EMAIL PROTECTED]> writes:

>   if (time_offset < 0) {
> - temp64 = -temp64;
> - do_div(temp64, mtemp);
> + utemp64 = -temp64;
> + do_div(utemp64, mtemp);
>   freq_adj -= temp64;

do_div previously modified temp64 by side effect, now it no longer does
that.

>   } else {
> - do_div(temp64, mtemp);
> + utemp64 = temp64;
> + do_div(utemp64, mtemp);
>   freq_adj += temp64;

Same.

Andreas.

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-21 Thread David Howells
From: David Howells <[EMAIL PROTECTED]>

The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make it
instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

Signed-off-by: David Howells <[EMAIL PROTECTED]>
---

 kernel/time/ntp.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index c88b591..3bead00 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -342,13 +342,15 @@ int do_adjtimex(struct timex *txc)
freq_adj = shift_right(freq_adj, time_constant * 2 +
   (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
if (mtemp >= MINSEC && (time_status & STA_FLL || mtemp > 
MAXSEC)) {
+   u64 utemp64;
temp64 = time_offset << (SHIFT_NSEC - SHIFT_FLL);
if (time_offset < 0) {
-   temp64 = -temp64;
-   do_div(temp64, mtemp);
+   utemp64 = -temp64;
+   do_div(utemp64, mtemp);
freq_adj -= temp64;
} else {
-   do_div(temp64, mtemp);
+   utemp64 = temp64;
+   do_div(utemp64, mtemp);
freq_adj += temp64;
}
}

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-21 Thread David Howells
From: David Howells [EMAIL PROTECTED]

The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make it
instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

Signed-off-by: David Howells [EMAIL PROTECTED]
---

 kernel/time/ntp.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index c88b591..3bead00 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -342,13 +342,15 @@ int do_adjtimex(struct timex *txc)
freq_adj = shift_right(freq_adj, time_constant * 2 +
   (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
if (mtemp = MINSEC  (time_status  STA_FLL || mtemp  
MAXSEC)) {
+   u64 utemp64;
temp64 = time_offset  (SHIFT_NSEC - SHIFT_FLL);
if (time_offset  0) {
-   temp64 = -temp64;
-   do_div(temp64, mtemp);
+   utemp64 = -temp64;
+   do_div(utemp64, mtemp);
freq_adj -= temp64;
} else {
-   do_div(temp64, mtemp);
+   utemp64 = temp64;
+   do_div(utemp64, mtemp);
freq_adj += temp64;
}
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #2]

2008-02-21 Thread David Howells
From: David Howells [EMAIL PROTECTED]

The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make it
instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

Signed-off-by: David Howells [EMAIL PROTECTED]
---

 kernel/time/ntp.c |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)


diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index c88b591..3bead00 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -342,13 +342,15 @@ int do_adjtimex(struct timex *txc)
freq_adj = shift_right(freq_adj, time_constant * 2 +
   (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
if (mtemp = MINSEC  (time_status  STA_FLL || mtemp  
MAXSEC)) {
+   u64 utemp64;
temp64 = time_offset  (SHIFT_NSEC - SHIFT_FLL);
if (time_offset  0) {
-   temp64 = -temp64;
-   do_div(temp64, mtemp);
+   utemp64 = -temp64;
+   do_div(utemp64, mtemp);
freq_adj -= temp64;
} else {
-   do_div(temp64, mtemp);
+   utemp64 = temp64;
+   do_div(utemp64, mtemp);
freq_adj += temp64;
}
}

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #3]

2008-02-21 Thread David Howells
From: David Howells [EMAIL PROTECTED]

The kernel NTP code shouldn't hand 64-bit *signed* values to do_div().  Make it
instead hand 64-bit unsigned values.  This gets rid of a couple of warnings.

Signed-off-by: David Howells [EMAIL PROTECTED]
---

 kernel/time/ntp.c |   12 +++-
 1 files changed, 7 insertions(+), 5 deletions(-)


diff --git a/kernel/time/ntp.c b/kernel/time/ntp.c
index c88b591..d4bca92 100644
--- a/kernel/time/ntp.c
+++ b/kernel/time/ntp.c
@@ -342,14 +342,16 @@ int do_adjtimex(struct timex *txc)
freq_adj = shift_right(freq_adj, time_constant * 2 +
   (SHIFT_PLL + 2) * 2 - SHIFT_NSEC);
if (mtemp = MINSEC  (time_status  STA_FLL || mtemp  
MAXSEC)) {
+   u64 utemp64;
temp64 = time_offset  (SHIFT_NSEC - SHIFT_FLL);
if (time_offset  0) {
-   temp64 = -temp64;
-   do_div(temp64, mtemp);
-   freq_adj -= temp64;
+   utemp64 = -temp64;
+   do_div(utemp64, mtemp);
+   freq_adj -= utemp64;
} else {
-   do_div(temp64, mtemp);
-   freq_adj += temp64;
+   utemp64 = temp64;
+   do_div(utemp64, mtemp);
+   freq_adj += utemp64;
}
}
freq_adj += time_freq;

--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div() [try #2]

2008-02-21 Thread David Howells
David Howells [EMAIL PROTECTED] wrote:

 Subject: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to
   do_div() [try #2]

Ignore try #2.  I forgot to commit the changes before mailing.

David
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-21 Thread David Howells
Andreas Schwab [EMAIL PROTECTED] wrote:

 do_div previously modified temp64 by side effect, now it no longer does
 that.

Good point.

David
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH] Make the kernel NTP code hand 64-bit *unsigned* values to do_div()

2008-02-21 Thread Andreas Schwab
David Howells [EMAIL PROTECTED] writes:

   if (time_offset  0) {
 - temp64 = -temp64;
 - do_div(temp64, mtemp);
 + utemp64 = -temp64;
 + do_div(utemp64, mtemp);
   freq_adj -= temp64;

do_div previously modified temp64 by side effect, now it no longer does
that.

   } else {
 - do_div(temp64, mtemp);
 + utemp64 = temp64;
 + do_div(utemp64, mtemp);
   freq_adj += temp64;

Same.

Andreas.

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/