15 Aug, 2009

1 commit


27 Feb, 2009

1 commit


26 Feb, 2009

14 commits

  • Impact: cleanup, no functionality changed

    The 'time_adj' local variable is named in a very confusing
    way because it almost shadows the 'time_adjust' global
    variable - which is used in this same function.

    Rename it to 'delta' - to make them stand apart more clearly.

    kernel/time/ntp.o:

    text data bss dec hex filename
    2545 114 144 2803 af3 ntp.o.before
    2545 114 144 2803 af3 ntp.o.after

    md5:
    1bf0b3be564512279ba7cee299d1d2be ntp.o.before.asm
    1bf0b3be564512279ba7cee299d1d2be ntp.o.after.asm

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: micro-optimization

    Convert the (internal) ntp_tick_adj value we store from unscaled
    units to scaled units. This is a constant that we never modify,
    so scaling it up once during bootup is enough - we dont have to
    do it for every adjustment step.

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    - make PPM_SCALE an explicit s64 constant, to
    remove (s64) casts from usage sites.

    kernel/time/ntp.o:

    text data bss dec hex filename
    2536 114 136 2786 ae2 ntp.o.before
    2536 114 136 2786 ae2 ntp.o.after

    md5:
    40a7728d1188aa18e83e21a81fa7b150 ntp.o.before.asm
    40a7728d1188aa18e83e21a81fa7b150 ntp.o.after.asm

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    Further simplify do_adjtimex():

    - introduce the ntp_start_leap_timer() helper function
    - eliminate the goto adj_done complication

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    do_adjtimex() is currently a monster function with a maze of
    branches. Refactor the txc->modes setting aspects of it into
    two new helper functions:

    process_adj_status()
    process_adjtimex_modes()

    kernel/time/ntp.o:

    text data bss dec hex filename
    2512 114 136 2762 aca ntp.o.before
    2512 114 136 2762 aca ntp.o.after

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: change (fix) the way the NTP PLL seconds offset is initialized/tracked

    Fix a bug and do a micro-optimization:

    When PLL is enabled we do not reset time_reftime. If the PLL
    was off for a long time (for example after bootup), this is
    arguably the wrong thing to do.

    We already had a hack for the common boot-time case in
    ntp_update_offset(), in form of:

    if (unlikely(time_status & STA_FREQHOLD || time_reftime == 0))
    secs = 0;

    But the update delta should be reset later on too - not just when
    the PLL is enabled for the first time after bootup.

    So do it on !STA_PLL -> STA_PLL transitions.

    This changes behavior, as previously if ntpd was disabled for
    a long time and we restarted it, we'd run from that last update,
    with a very large delta.

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    The time_reftime update in ntp_update_offset() to xtime.tv_sec
    is a convoluted way of saying that we want to freeze the frequency
    and want the 'secs' delta to be 0. Also make this branch unlikely.

    This shaves off 8 bytes from the code size:

    text data bss dec hex filename
    2504 114 136 2754 ac2 ntp.o.before
    2496 114 136 2746 aba ntp.o.after

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    Change ntp_update_offset_fll() to delta logic instead of
    absolute value logic. This eliminates 'freq_adj' from the
    function.

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    - introduce the ntp_update_offset_fll() helper
    - clean up the flow and variable naming

    kernel/time/ntp.o:

    text data bss dec hex filename
    2504 114 136 2754 ac2 ntp.o.before
    2504 114 136 2754 ac2 ntp.o.after

    md5:
    01f7b8e1a5472a3056f9e4ae84d46315 ntp.o.before.asm
    01f7b8e1a5472a3056f9e4ae84d46315 ntp.o.after.asm

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    Change ntp_update_frequency() from a hard to follow code
    flow that uses global variables as temporaries, to a clean
    input+output flow.

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    Prepare a refactoring of ntp_update_frequency().

    kernel/time/ntp.o:

    text data bss dec hex filename
    2504 114 136 2754 ac2 ntp.o.before
    2504 114 136 2754 ac2 ntp.o.after

    md5:
    41f3009debc9b397d7394dd77d912f0a ntp.o.before.asm
    41f3009debc9b397d7394dd77d912f0a ntp.o.after.asm

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    There's an ugly u64 typecase in the MAX_TICKADJ_SCALED definition,
    this can be eliminated by making the MAX_TICKADJ constant's type
    64-bit (signed).

    kernel/time/ntp.o:

    text data bss dec hex filename
    2504 114 136 2754 ac2 ntp.o.before
    2504 114 136 2754 ac2 ntp.o.after

    md5:
    41f3009debc9b397d7394dd77d912f0a ntp.o.before.asm
    41f3009debc9b397d7394dd77d912f0a ntp.o.after.asm

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    Instead of a hierarchy of conditions, transform them to clean
    gradual conditions and return's.

    This makes the flow easier to read and makes the purpose of
    the function easier to understand.

    kernel/time/ntp.o:

    text data bss dec hex filename
    2552 170 168 2890 b4a ntp.o.before
    2552 170 168 2890 b4a ntp.o.after

    md5:
    eae1275df0b7d6290c13f6f6f8f05c8c ntp.o.before.asm
    eae1275df0b7d6290c13f6f6f8f05c8c ntp.o.after.asm

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Impact: cleanup, no functionality changed

    Make this file a bit more readable by applying a consistent coding style.

    No code changed:

    kernel/time/ntp.o:

    text data bss dec hex filename
    2552 170 168 2890 b4a ntp.o.before
    2552 170 168 2890 b4a ntp.o.after

    md5:
    eae1275df0b7d6290c13f6f6f8f05c8c ntp.o.before.asm
    eae1275df0b7d6290c13f6f6f8f05c8c ntp.o.after.asm

    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

19 Feb, 2009

1 commit

  • Since the GENERIC_TIME changes landed, the adjtimex behavior changed
    for struct timex.tick and .freq changed. When the tick or freq value
    is set, we adjust the tick_length_base in ntp_update_frequency().
    However, this new value doesn't get applied to tick_length until the
    next second (via second_overflow).

    This means some applications that do quick time tweaking do not see the
    requested change made as quickly as expected.

    I've run a few tests with this change, and ntpd still functions fine.

    Signed-off-by: John Stultz
    Signed-off-by: Ingo Molnar

    john stultz
     

25 Nov, 2008

1 commit

  • Impact: cleanup, move all hrtimer processing into hardirq context

    This is an attempt at removing some of the hrtimer complexity by
    reducing the number of callback modes to 1.

    This means that all hrtimer callback functions will be ran from HARD-irq
    context.

    I went through all the 30 odd hrtimer callback functions in the kernel
    and saw only one that I'm not quite sure of, which is the one in
    net/can/bcm.c - hence I'm CC-ing the folks responsible for that code.

    Furthermore, the hrtimer core now calls callbacks directly with IRQs
    disabled in case you try to enqueue an expired timer. If this timer is a
    periodic timer (which should use hrtimer_forward() to advance its time)
    then it might be possible to end up in an inf. recursive loop due to the
    fact that hrtimer_forward() doesn't round up to the next timer
    granularity, and therefore keeps on calling the callback - obviously
    this needs a fix.

    Aside from that, this seems to compile and actually boot on my dual core
    test box - although I'm sure there are some bugs in, me not hitting any
    makes me certain :-)

    Signed-off-by: Peter Zijlstra
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

22 Oct, 2008

1 commit


20 Oct, 2008

1 commit


18 Oct, 2008

1 commit


24 Sep, 2008

2 commits

  • Change PPM_SCALE_INV_SHIFT so that it doesn't throw away any input bits
    (19 is the amount of the factor 2 in PPM_SCALE), the output frequency
    can then be calculated back to its input value, as the inverse divide
    produce a slightly larger value, which is then correctly rounded by the
    final shift.

    Reported-by: Martin Ziegler
    Signed-off-by: Roman Zippel
    Cc: John Stultz
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Roman Zippel
     
  • This is a change that makes the 11-minute RTC update be run in the process
    context. This is so that update_persistent_clock() can sleep, which may
    be required for certain types of RTC hardware -- most notably I2C devices.

    Signed-off-by: Maciej W. Rozycki
    Cc: Roman Zippel
    Cc: Rik van Riel
    Cc: David Brownell
    Acked-by: Alessandro Zummo
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Maciej W. Rozycki
     

06 Sep, 2008

2 commits

  • We have a bug in the calculation of the next jiffie to trigger the RTC
    synchronisation. The aim here is to run sync_cmos_clock() as close as
    possible to the middle of a second. Which means we want this function to
    be called less than or equal to half a jiffie away from when now.tv_nsec
    equals 5e8 (500000000).

    If this is not the case for a given call to the function, for this purpose
    instead of updating the RTC we calculate the offset in nanoseconds to the
    next point in time where now.tv_nsec will be equal 5e8. The calculated
    offset is then converted to jiffies as these are the unit used by the
    timer.

    Hovewer timespec_to_jiffies() used here uses a ceil()-type rounding mode,
    where the resulting value is rounded up. As a result the range of
    now.tv_nsec when the timer will trigger is from 5e8 to 5e8 + TICK_NSEC
    rather than the desired 5e8 - TICK_NSEC / 2 to 5e8 + TICK_NSEC / 2.

    As a result if for example sync_cmos_clock() happens to be called at the
    time when now.tv_nsec is between 5e8 + TICK_NSEC / 2 and 5e8 to 5e8 +
    TICK_NSEC, it will simply be rescheduled HZ jiffies later, falling in the
    same range of now.tv_nsec again. Similarly for cases offsetted by an
    integer multiple of TICK_NSEC.

    This change addresses the problem by subtracting TICK_NSEC / 2 from the
    nanosecond offset to the next point in time where now.tv_nsec will be
    equal 5e8, effectively shifting the following rounding in
    timespec_to_jiffies() so that it produces a rounded-to-nearest result.

    Signed-off-by: Maciej W. Rozycki
    Signed-off-by: Andrew Morton
    Signed-off-by: Ingo Molnar

    Maciej W. Rozycki
     
  • In order to be able to do range hrtimers we need to use accessor functions
    to the "expire" member of the hrtimer struct.
    This patch converts kernel/* to these accessors.

    Signed-off-by: Arjan van de Ven

    Arjan van de Ven
     

22 Aug, 2008

1 commit

  • Thanks to the review by Michael Kerrisk a bug in the recent
    ADJ_OFFSET_SS_READ option was discovered, where the ntp time_offset was
    inadvertently set by it. This fixes this by making the adjtime code
    more separate from the ntp_adjtime code (both of which really want to
    be separate syscalls).

    Signed-off-by: Roman Zippel
    Signed-off-by: Andrew Morton
    Acked-by: John Stultz
    Signed-off-by: Ingo Molnar

    Roman Zippel
     

01 May, 2008

10 commits

  • Remove the leap second handling from second_overflow(), which doesn't have to
    check for it every second anymore. With CONFIG_NO_HZ this also makes sure the
    leap second is handled close to the full second. Additionally this makes it
    possible to abort a leap second properly by resetting the STA_INS/STA_DEL
    status bits.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • current_tick_length used to do a little more, but now it just returns
    tick_length, which we can also access directly at the few places, where it's
    needed.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • As TICK_LENGTH_SHIFT is used for more than just the tick length, the name
    isn't quite approriate anymore, so this renames it to NTP_SCALE_SHIFT.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • This adds support for setting the TAI value (International Atomic Time). The
    value is reported back to userspace via timex (as we don't have a
    ntp_gettime() syscall).

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • time_offset is already a 64bit value but its resolution barely used, so this
    makes better use of it by replacing SHIFT_UPDATE with TICK_LENGTH_SHIFT.

    Side note: the SHIFT_HZ in SHIFT_UPDATE was incorrect for CONFIG_NO_HZ and the
    primary reason for changing time_offset to 64bit to avoid the overflow.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • This changes time_freq to a 64bit value and makes it static (the only outside
    user had no real need to modify it). Intermediate values were already 64bit,
    so the change isn't that big, but it saves a little in shifts by replacing
    SHIFT_NSEC with TICK_LENGTH_SHIFT. PPM_SCALE is then used to convert between
    user space and kernel space representation.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • This adds a few more things from the ntp nanokernel related to user space.
    It's now possible to select the resolution used of some values via STA_NANO
    and the kernel reports in which mode it works (pll/fll).

    If some values for adjtimex() are outside the acceptable range, they are now
    simply normalized instead of letting the syscall fail. I removed
    MOD_CLKA/MOD_CLKB as the mapping didn't really makes any sense, the kernel
    doesn't support setting the clock.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • This is mostly a style cleanup of ntp.c and extracts part of do_adjtimex as
    ntp_update_offset(). Otherwise the functionality is still the same as before.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • x86 is the only arch right now, which provides an optimized for
    div_long_long_rem and it has the downside that one has to be very careful that
    the divide doesn't overflow.

    The API is a little akward, as the arguments for the unsigned divide are
    signed. The signed version also doesn't handle a negative divisor and
    produces worse code on 64bit archs.

    There is little incentive to keep this API alive, so this converts the few
    users to the new API.

    Signed-off-by: Roman Zippel
    Cc: Ralf Baechle
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: john stultz
    Cc: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     
  • This converts a few users of do_div to div_[su]64 and this demonstrates nicely
    how it can reduce some expressions to one-liners.

    Signed-off-by: Roman Zippel
    Cc: john stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     

09 Mar, 2008

2 commits

  • The first version of the ntp_interval/tick_length inconsistent usage patch was
    recently merged as bbe4d18ac2e058c56adb0cd71f49d9ed3216a405

    http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=bbe4d18ac2e058c56adb0cd71f49d9ed3216a405

    While the fix did greatly improve the situation, it was correctly pointed out
    by Roman that it does have a small bug: If the users change clocksources after
    the system has been running and NTP has made corrections, the correctoins made
    against the old clocksource will be applied against the new clocksource,
    causing error.

    The second attempt, which corrects the issue in the NTP_INTERVAL_LENGTH
    definition has also made it up-stream as commit
    e13a2e61dd5152f5499d2003470acf9c838eab84

    http://git.kernel.org/gitweb.cgi?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=e13a2e61dd5152f5499d2003470acf9c838eab84

    Roman has correctly pointed out that CLOCK_TICK_ADJUST is calculated
    based on the PIT's frequency, and isn't really relevant to non-PIT
    driven clocksources (that is, clocksources other then jiffies and pit).

    This patch reverts both of those changes, and simply removes
    CLOCK_TICK_ADJUST.

    This does remove the granularity error correction for users of PIT and Jiffies
    clocksource users, but the granularity error but for the majority of users, it
    should be within the 500ppm range NTP can accommodate for.

    For systems that have granularity errors greater then 500ppm, the
    "ntp_tick_adj=" boot option can be used to compensate.

    [johnstul@us.ibm.com: provided changelog]
    [mattilinnanvuori@yahoo.com: maek ntp_tick_adj static]
    Signed-off-by: Roman Zippel
    Acked-by: john stultz
    Signed-off-by: Matti Linnanvuori
    Signed-off-by: Andrew Morton
    Cc: mingo@elte.hu
    Signed-off-by: Thomas Gleixner

    Roman Zippel
     
  • The kernel NTP code shouldn't hand 64-bit *signed* values to do_div(). Make it
    instead hand 64-bit unsigned values. This gets rid of a couple of warnings.

    Signed-off-by: David Howells
    Cc: Roman Zippel
    Cc: Ingo Molnar
    Cc: john stultz
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    David Howells
     

10 Feb, 2008

1 commit

  • clocksource initialization and error accumulation. This corrects a 280ppm
    drift seen on some systems using acpi_pm, and affects other clocksources as
    well (likely to a lesser degree).

    Signed-off-by: John Stultz
    Cc: Roman Zippel
    Cc: Steven Rostedt
    Signed-off-by: Andrew Morton
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner

    john stultz
     

27 Nov, 2007

1 commit

  • Michael Kerrisk reported that a long standing bug in the adjtimex()
    system call causes glibc's adjtime(3) function to deliver the wrong
    results if 'delta' is NULL.

    add the ADJ_OFFSET_SS_READ API detail, which will be used by glibc
    to fix this API compatibility bug.

    Also see: http://bugzilla.kernel.org/show_bug.cgi?id=6761

    [ mingo@elte.hu: added patch description and made it backwards compatible ]

    NOTE: the new flag is defined 0xa001 so that it returns -EINVAL on
    older kernels - this way glibc can use it safely. Suggested by Ulrich
    Drepper.

    Acked-by: Ulrich Drepper
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner

    John Stultz