lkml.org 
[lkml]   [2009]   [Apr]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC][PATCH] Dynamic Tick: Allow 32-bit machines to sleep for more than 2.15 seconds

* Jon Hunter <jon-hunter@ti.com> wrote:

> Hello,
>
> From reviewing the dynamic tick code, I noticed that the
> "max_delta_ns" member of the "clock_event_device" structure,
> represents the upper limit between timer events in nanoseconds.
> The variable, "max_delta_ns", is defined as an unsigned long. An
> unsigned long is a 32-bit integer for 32-bit machines and is a
> 64-bit integer for 64-bit machines (if -m64 option is used for
> gcc). Also see [1].
>
> The variable, "max_delta_ns", is configured by calling function
> "clockevent_delta2ns()". The maximum value that "max_delta_ns" can
> be set to by calling clockevent_delta2ns(), is LONG_MAX. For a
> 32-bit machine LONG_MAX is equal to 0x7fffffff and in nanoseconds
> this equates to ~2.15 seconds. Hence, the maximum sleep time for a
> 32-bit machine is ~2.15 seconds, where as for a 64-bit machine it
> will be many years.
>
> Therefore, I wanted to propose changing the type of max_delta_ns
> to be "unsigned long long" instead of "unsigned long". My
> understanding is that a variable of type "unsigned long long" is
> 64-bits for both 32-bit and 64-bit machines and hence this would
> allow a 32-bit machine to sleep for longer than ~2.15 seconds.
> Please note that I also ended up making "min_delta_ns" of type
> "unsigned long long" too and although this is probably very
> unnecessary, it made the patch simpler. See below.
>
> Anyway, making this change has allowed my 32-bit machine to sleep
> for longer than ~2.15 seconds and thought this could be of
> interest to others. Your comments/feedback would be appreciated.
>
> [1] http://en.wikipedia.org/wiki/64-bit#64-bit_data_models
>
> Cheers
> Jon
>
>
> Signed-off-by: Jon Hunter <jon-hunter@ti.com>
> ---
> include/linux/clockchips.h | 6 +++---
> kernel/hrtimer.c | 2 +-
> kernel/time/clockevents.c | 10 +++++-----
> kernel/time/tick-oneshot.c | 2 +-
> kernel/time/timer_list.c | 4 ++--
> 5 files changed, 12 insertions(+), 12 deletions(-)

Looks like a good thing at first sight. Thomas, John, what do you
think?

Ingo


\
 
 \ /
  Last update: 2009-04-21 08:39    [W:0.079 / U:0.728 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site