public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <willy@w.ods.org>
To: Nishanth Aravamudan <nacc@us.ibm.com>
Cc: Davide Libenzi <davidel@xmailserver.org>,
	Andrew Morton <akpm@osdl.org>,
	Nish Aravamudan <nish.aravamudan@gmail.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 0/3] fixes for overflow in poll(), epoll(), and msec_to_jiffies()
Date: Mon, 26 Sep 2005 00:06:28 +0200	[thread overview]
Message-ID: <20050925220628.GA998@alpha.home.local> (raw)
In-Reply-To: <20050925205518.GB5079@us.ibm.com>

On Sun, Sep 25, 2005 at 01:55:18PM -0700, Nishanth Aravamudan wrote:
> On 24.09.2005 [21:38:39 +0200], Willy Tarreau wrote:
> > Hello,
> > 
> > After the discussion around epoll() timeout, I noticed that the functions used
> > to detect the timeout could themselves overflow for some values of HZ.
> > 
> > So I decided to fix them by defining a macro which represents the maximal
> > acceptable argument which is guaranteed not to overflow. As an added bonus,
> > those functions can now be used in poll() and ep_poll() and remove the divide
> > if HZ == 1000, or replace it with a shift if (1000 % HZ) or (HZ % 1000) is a
> > power of two.
> > 
> > Patches against 2.6.14-rc2-mm1 sent as replies to this mail.
> 
> These look really good, Willy. Thanks for the fixes!

Thanks.
I noticed that there still existed a high risk of overflow with HZ values
for which (HZ % 1000) != 0 && (1000 % HZ) != 0, because we hit the only
situation where we start with a multiply by HZ, which is even worse as HZ
grows. The only cases I've found are :

  - alpha : 1024 or 1200
  - ia64  : 1024

Fortunately, they're both 64 bits, and since the result is an unsigned long,
the multiply returns 64 bits result so it won't overflow in a while. However,
we should avoid those combinations on 32-bits archs, because the limit is
then rather low. For example, using HZ=1200 on an x86 will set MAX_MSEC_OFFSET
to 3579138 ms, which is just below one hour. For reference, with HZ=1000,
MAX_MSEC_OFFSET would be 2^32-1 ms, or 49.7 days, which makes quite a
difference.

It is possible that some self-made setups hit the overflow before the patch.
For this reason, I wonder how we could discourage people from using such
bastard HZ values on 32 bits platforms :-/

Regards,
Willy


  reply	other threads:[~2005-09-25 22:10 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-23 18:13 [patch] sys_epoll_wait() timeout saga Davide Libenzi
2005-09-23 18:24 ` Nish Aravamudan
2005-09-24  4:05 ` Willy Tarreau
2005-09-24  4:44   ` Nish Aravamudan
2005-09-24  6:15     ` Willy Tarreau
2005-09-24  7:33       ` Vadim Lobanov
2005-09-24  7:51         ` Willy Tarreau
2005-09-24 15:10       ` Davide Libenzi
2005-09-24 17:20         ` Willy Tarreau
2005-09-24 18:19           ` Davide Libenzi
2005-09-25  6:05             ` Andrew Morton
2005-09-25  6:20               ` Willy Tarreau
2005-09-25  6:32                 ` Andrew Morton
2005-09-25  7:08               ` Vadim Lobanov
2005-09-25  8:03                 ` Willy Tarreau
2005-09-24 17:19       ` Nishanth Aravamudan
2005-09-24 18:25         ` Davide Libenzi
2005-09-24 19:38           ` [PATCH 0/3] fixes for overflow in poll(), epoll(), and msec_to_jiffies() Willy Tarreau
2005-09-24 19:44             ` [PATCH 1/3] 2.6.14-rc2-mm1: fixes for overflow msec_to_jiffies() Willy Tarreau
2005-09-29  9:43               ` Andrew Morton
2005-09-29 19:41                 ` Willy Tarreau
2005-09-29 19:52                   ` Andrew Morton
2005-09-29 20:55                     ` Willy Tarreau
2005-10-01 17:39                     ` Willy Tarreau
2005-09-24 19:47             ` [PATCH 2/3] 2.6.14-rc2-mm1: fixes for overflow in epoll() Willy Tarreau
2005-09-24 19:52             ` [PATCH 3/3] 2.6.14-rc2-mm1 : fixes for overflow in sys_poll() Willy Tarreau
2005-10-01 20:39               ` Willy Tarreau
2005-09-24 20:08             ` [PATCH 0/3] fixes for overflow in poll(), epoll(), and msec_to_jiffies() Davide Libenzi
2005-09-24 20:21               ` Willy TARREAU
2005-09-25 20:55             ` Nishanth Aravamudan
2005-09-25 22:06               ` Willy Tarreau [this message]
2005-09-24 21:25           ` [patch] sys_epoll_wait() timeout saga Vadim Lobanov
2005-09-24 18:30         ` Willy Tarreau

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=20050925220628.GA998@alpha.home.local \
    --to=willy@w.ods.org \
    --cc=akpm@osdl.org \
    --cc=davidel@xmailserver.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nacc@us.ibm.com \
    --cc=nish.aravamudan@gmail.com \
    /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