[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20071222185822.80bd4540.akpm@linux-foundation.org>
Date: Sat, 22 Dec 2007 18:58:22 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: "H. Peter Anvin" <hpa@...or.com>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linux Arch Mailing List <linux-arch@...r.kernel.org>,
Ralf Baechle <ralf@...ux-mips.org>,
Sam Ravnborg <sam@...nborg.org>,
Paul Mundt <lethal@...ux-sh.org>,
Richard Henderson <rth@...ddle.net>,
Michael Starvik <starvik@...s.com>,
David Howells <dhowells@...hat.com>,
Yoshinori Sato <ysato@...rs.sourceforge.jp>,
Hirokazu Takata <takata@...ux-m32r.org>,
Geert Uytterhoeven <geert@...ux-m68k.org>,
Roman Zippel <zippel@...ux-m68k.org>,
"William L. Irwin" <sparclinux@...r.kernel.org>,
Chris Zankel <chris@...kel.net>,
Jan Engelhardt <jengelh@...putergmbh.de>
Subject: Re: [PATCH] Avoid overflows in kernel/time.c (version 5)
On Mon, 17 Dec 2007 13:53:23 -0800 "H. Peter Anvin" <hpa@...or.com> wrote:
> When the conversion factor between jiffies and milli- or microseconds
> is not a single multiply or divide, as for the case of HZ == 300, we
> currently do a multiply followed by a divide. The intervening
> result, however, is subject to overflows, especially since the
> fraction is not simplified (for HZ == 300, we multiply by 300 and
> divide by 1000).
>
> This is exposed to the user when passing a large timeout to poll(),
> for example.
>
> This patch replaces the multiply-divide with a reciprocal
> multiplication on 32-bit platforms. When the input is an unsigned
> long, there is no portable way to do this on 64-bit platforms there is
> no portable way to do this since it requires a 128-bit intermediate
> result (which gcc does support on 64-bit platforms but may generate
> libgcc calls, e.g. on 64-bit s390), but since the output is a 32-bit
> integer in the cases affected, just simplify the multiply-divide
> (*3/10 instead of *300/1000).
alpha allmodconfig:
kernel/time.c: In function 'jiffies_to_msecs':
kernel/time.c:248: error: 'HZ_TO_MSEC_NUM' undeclared (first use in this function)
kernel/time.c:248: error: (Each undeclared identifier is reported only once
kernel/time.c:248: error: for each function it appears in.)
kernel/time.c:248: error: 'HZ_TO_MSEC_DEN' undeclared (first use in this function)
kernel/time.c: In function 'jiffies_to_usecs':
kernel/time.c:264: error: 'HZ_TO_USEC_NUM' undeclared (first use in this function)
kernel/time.c:264: error: 'HZ_TO_USEC_DEN' undeclared (first use in this function)
kernel/time.c: In function 'usecs_to_jiffies':
kernel/time.c:486: error: 'm' undeclared (first use in this function)
kernel/time.c:489: warning: control reaches end of non-void function
kernel/time.c: In function 'jiffies_to_usecs':
kernel/time.c:267: warning: control reaches end of non-void function
kernel/time.c: In function 'jiffies_to_msecs':
kernel/time.c:251: warning: control reaches end of non-void function
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists