Skip to contentSkip to conversation

msecs_to_jiffies() still returns values greater then MAX_JIFFY_OFFSET

DISCUSSION Andreas Herz 1 participant 1 message Apr 20, 2012

lore
Share & tools
lore
#0 lore raw

Hi,

i'm new to the LKML and so i couldn't reply to the old mail from Mar 2011.

On 29 Mar 2011 there was already a disucssion about this issue:

http://lkml.org/lkml/2011/3/29/262

The problem still exists, as /kernel/time.c wasn't patched. I stumbled upon this "bug" when i modified the ipset sourcecode that uses msecs_to_jiffies() for timeout calculations.

When i call msecs_to_jiffies(2147483000) the return value is 2147483000 on my x86 32-Bit System with 1000Hz. When i call the function with msecs_to_jiffies(2147484000) the return value is MAX_JIFFY_OFFSET what's 1073741822 on my system. That isn't the behaviour i expect from this comment in time.c:

* - 'too large' values [that would result in larger than
* MAX_JIFFY_OFFSET values] mean 'infinite timeout' too.

So you can pass values greater then MAX_JIFFY_OFFSET up to INT_MAX in this example although the limit should be at INT_MAX/2 for MAX_JIFFY_OFFSET.

I'm not sure if the solution is to increase MAX_JIFFY_OFFSET or to catch values between this gap. I also don't understand why the function returns a unsigned long but is limited to integer. It could be nice to increase the values that can be handled with this function.

Greetings

Signature · 1 line
Andreas Herz