Hi,
The current include/asm-m32r/div64.h of 2.6.12-rc5 looks buggy.
Here is a patch for updating it to use asm-generic/div64.h for m32r
like other architectures.
Please apply.
Symptoms: for example
- idle time information of /proc/uptime is incorrect.
- "top" command sometimes reports incorrect cpu states like this:
> top - 14:05:01 up 5 min, 2 users, load average: 0.15, 0.14, 0.07
> Tasks: 28 total, 3 running, 25 sleeping, 0 stopped, 0 zombie
> Cpu(s): 2500.0% us, 12800.0% sy, 0.0% ni, 2200.0% id, -28100.0% wa, 0.0% hi,
> Mem: 26748k total, 22484k used, 4264k free, 0k buffers
> Swap: 0k total, 0k used, 0k free, 14656k cached
Thanks,
From: Bernardo Innocenti ([email protected])
Subject: [PATCH] Kill div64.h dupes, parenthesize do_div() macro params
Date: Tue Jul 01 2003 - 19:32:20 EST
> - move the 64/32bit do_div() macro to a new asm-generic/div64.h
> header;
>
> - kill multiple copies of the generic version in architecture
> specific subdirs. Most copies were either buggy or subtly
> different from each other;
>
> - ensure all surviving instances of do_div() have their parameters
> correctly parenthesized to avoid funny results;
>
> Note that the arm26, cris, m68knommu, sh, sparc and v850 architectures
> are silently clipping 64bit dividend to 32bit! This patch doesn't try
> to fix this because I can't test on all architectures.
>
> Patch submitted by Bernardo Innocenti <[email protected]>
>
> Applies to 2.5.73. Backporting to 2.4.21 is trivial.
>
> FOOT NOTE: what's the point with do_div()? Isn't gcc's long long
> arithmetic support good enough on all platforms? If not, why
> doesn't that get fixed in libgcc instead of polluting the kernel
> with silly (and sometimes bogus) implementations?
>
> asm-alpha/div64.h | 15 +--------------
> asm-arm26/div64.h | 15 +--------------
> asm-cris/div64.h | 17 +----------------
> asm-generic/div64.h | 13 +++++++++++++
> asm-h8300/div64.h | 14 +-------------
> asm-ia64/div64.h | 21 +--------------------
> asm-m68k/div64.h | 9 ---------
> asm-m68knommu/div64.h | 14 +-------------
> asm-mips64/div64.h | 20 +-------------------
> asm-parisc/div64.h | 36 ++++++++++--------------------------
> asm-ppc64/div64.h | 19 +------------------
> asm-s390/div64.h | 8 +-------
> asm-sh/div64.h | 11 +----------
> asm-sparc/div64.h | 12 +-----------
> asm-sparc64/div64.h | 15 +--------------
> asm-v850/div64.h | 12 +-----------
> asm-x86_64/div64.h | 15 +--------------
> 17 files changed, 37 insertions(+), 229 deletions(-)
Signed-off-by: Hitoshi Yamamoto <[email protected]>
Signed-off-by: Hirokazu Takata <[email protected]>
---
diff -ruNp a/include/asm-m32r/div64.h b/include/asm-m32r/div64.h
--- a/include/asm-m32r/div64.h 2004-12-25 06:33:49.000000000 +0900
+++ b/include/asm-m32r/div64.h 2005-05-31 19:49:38.000000000 +0900
@@ -1,38 +1 @@
-#ifndef _ASM_M32R_DIV64
-#define _ASM_M32R_DIV64
-
-/* $Id$ */
-
-/* unsigned long long division.
- * Input:
- * unsigned long long n
- * unsigned long base
- * Output:
- * n = n / base;
- * return value = n % base;
- */
-#define do_div(n, base) \
-({ \
- unsigned long _res, _high, _mid, _low; \
- \
- _low = (n) & 0xffffffffUL; \
- _high = (n) >> 32; \
- if (_high) { \
- _mid = (_high % (unsigned long)(base)) << 16; \
- _high = _high / (unsigned long)(base); \
- _mid += _low >> 16; \
- _low &= 0x0000ffffUL; \
- _low += (_mid % (unsigned long)(base)) << 16; \
- _mid = _mid / (unsigned long)(base); \
- _res = _low % (unsigned long)(base); \
- _low = _low / (unsigned long)(base); \
- n = _low + ((long long)_mid << 16) + \
- ((long long)_high << 32); \
- } else { \
- _res = _low % (unsigned long)(base); \
- n = (_low / (unsigned long)(base)); \
- } \
- _res; \
-})
-
-#endif /* _ASM_M32R_DIV64 */
+#include <asm-generic/div64.h>
--
Hirokazu Takata <[email protected]>
Linux/M32R Project: http://www.linux-m32r.org/
-
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/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]