Bug 586800 - [RHEL4] select()'s maximum timeout interval is not compliant with LSB
[RHEL4] select()'s maximum timeout interval is not compliant with LSB
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: kernel (Show other bugs)
4.8
All Linux
medium Severity medium
: rc
: ---
Assigned To: Oleg Nesterov
Red Hat Kernel QE team
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-04-28 07:56 EDT by Martin Osvald
Modified: 2010-10-27 07:10 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-08-11 04:07:14 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
reproducer (845 bytes, text/x-csrc)
2010-04-28 07:56 EDT, Martin Osvald
no flags Details
[patch] (UNTESTED) teach sys_select() to play well with huge timeouts (3.46 KB, patch)
2010-06-01 12:25 EDT, Oleg Nesterov
no flags Details | Diff
[PATCH] fix the compilation on 32bit machines (494 bytes, patch)
2010-06-10 12:01 EDT, Oleg Nesterov
no flags Details | Diff

  None (edit)
Description Martin Osvald 2010-04-28 07:56:35 EDT
Created attachment 409790 [details]
reproducer

Description of problem:

According to the Single UNIX Specification, select() shall support a maximum timeout interval of at least 31 days. However, select() supports only for 24 days in RHEL4(x86).


Version-Release number of selected component (if applicable):

RHEL4 x86


How reproducible:

always


Steps to Reproduce:

1. Compile and run the attached program:

 $ gcc -o select_test select.c
 $ ./select_test 3000000

  
Actual results:

It will time out in 2147482 seconds/~24 days.


Expected results:

select() should support over 31 days for timeout value.


Additional info:

[linux-2.6/include/linux/sched.h]
182 #define MAX_SCHEDULE_TIMEOUT    LONG_MAX

[linux-2.6/fs/select.c]
290 #define MAX_SELECT_SECONDS \
291         ((unsigned long) (MAX_SCHEDULE_TIMEOUT / HZ)-1)
292
293 asmlinkage long
294 sys_select(int n, fd_set __user *inp, fd_set __user *outp, fd_set __user *exp, struct timeval __user *tvp)
295 {
(snip)
298         long timeout;
(snip)
314                 if ((unsigned long) sec < MAX_SELECT_SECONDS) {
315                         timeout = ROUND_UP(usec, 1000000/HZ);
316                         timeout += sec * (unsigned long) HZ;
317                 }
318         }

The variable "timeout" is long. HZ is 1000, and LONG_MAX is 2147483647. Therefore, the maximum value of timeout is 2147482. 2147482 seconds is about 24 days. So, this is not compliant with LSB(Single UNIX Specification).

Related Documentation/Related Bugzilla #
   - LSB v3.0
   - Single UNIX Specification:
     http://www.opengroup.org/onlinepubs/009695399/functions/pselect.html
     > All implementations shall support a maximum timeout interval of at least 31 days.
Comment 2 Oleg Nesterov 2010-06-01 12:25:00 EDT
Created attachment 418723 [details]
[patch] (UNTESTED) teach sys_select() to play well with huge timeouts

At first glance it is not hard to fix the problem.

But to me, the real problem is that it is not clear if
we should fix this problem in rhel4.

The patch was not tested AT ALL. I am showing it just to
explain how I think we can do this. If anybody has a better
idea (including "NACK! the problem don't worth a trouble")
I'd like to know ;)
Comment 4 Oleg Nesterov 2010-06-05 12:41:29 EDT
(In reply to comment #2)

> But to me, the real problem is that it is not clear if
> we should fix this problem in rhel4.

Nobody replied to this, and nobody volunteered to test the patch ;)

I tried to test it today using some artificial test-case, seems
to work.

[RHEL4 PATCH] bz#586800: teach sys_select() to handle the huge timeouts
http://post-office.corp.redhat.com/archives/rhkernel-list/2010-June/msg00284.html

compared to https://bugzilla.redhat.com/attachment.cgi?id=418723,
the only difference is that the new one uses u64 instead of
"unsigned long long".
Comment 6 Oleg Nesterov 2010-06-10 12:01:36 EDT
Created attachment 422960 [details]
[PATCH] fix the compilation on 32bit machines

(In reply to comment #5)
> What I see is neither unsigned long long nor u64 patch compiles on i686
> since it's blocking the use of __udivdi3 and __umoddi3.

Argh. I swear, I was going to check it compiles on 32bit, but forgot ;)

> Which should be fine with x86_64. Missing anything? 

No, you are right, thanks a lot!

I think the attached (uncompiled/untested) patch should fix the problem.
I'll reserve the 32bit machine, re-test this all, and then send the updated
patch.

Thanks!
Comment 7 Oleg Nesterov 2010-06-11 12:22:32 EDT
Updated patch:

[RHEL4 PATCH v2 1/1] bz#586800: teach sys_select() to handle the huge timeouts
http://post-office.corp.redhat.com/archives/rhkernel-list/2010-June/msg00582.html

Thanks Takuma.

It is still not clear if we really need the fix, the problem is
minor.

Note You need to log in before you can comment on or make changes to this bug.