linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Arch Mailing List <linux-arch@vger.kernel.org>,
	Ralf Baechle <ralf@linux-mips.org>,
	Sam Ravnborg <sam@ravnborg.org>, Paul Mundt <lethal@linux-sh.org>,
	Richard Henderson <rth@twiddle.net>,
	Michael Starvik <starvik@axis.com>,
	David Howells <dhowells@redhat.com>,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	Hirokazu Takata <takata@linux-m32r.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Roman Zippel <zippel@linux-m68k.org>,
	"William L. Irwin" <sparclinux@vger.kernel.org>,
	Chris Zankel <chris@zankel.net>,
	Jan Engelhardt <jengelh@computergmbh.de>
Subject: Re: [PATCH] Avoid overflows in kernel/time.c (version 5)
Date: Sat, 22 Dec 2007 18:58:22 -0800	[thread overview]
Message-ID: <20071222185822.80bd4540.akpm@linux-foundation.org> (raw)
In-Reply-To: <200712180541.lBI5fnqB028037@tazenda.hos.anvin.org>

On Mon, 17 Dec 2007 13:53:23 -0800 "H. Peter Anvin" <hpa@zytor.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


  reply	other threads:[~2007-12-23  3:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-17 23:45 [PATCH] Avoid overflows in kernel/time.c (version 4) H. Peter Anvin
2007-12-18  5:37 ` Sam Ravnborg
2007-12-17 21:53   ` [PATCH] Avoid overflows in kernel/time.c (version 5) H. Peter Anvin
2007-12-23  2:58     ` Andrew Morton [this message]
2007-12-23  5:52       ` [PATCH] Avoid overflows in kernel/time.c (version 6) H. Peter Anvin
2007-12-24  0:14     ` [PATCH] Avoid overflows in kernel/time.c (version 5) Roman Zippel

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=20071222185822.80bd4540.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=chris@zankel.net \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=hpa@zytor.com \
    --cc=jengelh@computergmbh.de \
    --cc=lethal@linux-sh.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ralf@linux-mips.org \
    --cc=rth@twiddle.net \
    --cc=sam@ravnborg.org \
    --cc=sparclinux@vger.kernel.org \
    --cc=starvik@axis.com \
    --cc=takata@linux-m32r.org \
    --cc=ysato@users.sourceforge.jp \
    --cc=zippel@linux-m68k.org \
    /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;
as well as URLs for NNTP newsgroup(s).