Re: [PATCH 0/3] fixes for overflow in poll(), epoll(), and msec_to_jiffies()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, 24 Sep 2005, 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.

Why all that code, when you can have it with:

#define MAX_LONG_MSTIMEO (long) min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, LONG_MAX / HZ - 1000ULL)

that gcc-O2 collapses into a single constant?


- Davide


-
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]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux