02 May, 2009

1 commit

  • tick_handle_periodic() can lock up hard when a one shot clock event
    device is used in combination with jiffies clocksource.

    Avoid an endless loop issue by requiring that a highres valid
    clocksource be installed before we call tick_periodic() in a loop when
    using ONESHOT mode. The result is we will only increment jiffies once
    per interrupt until a continuous hardware clocksource is available.

    Without this, we can run into a endless loop, where each cycle through
    the loop, jiffies is updated which increments time by tick_period or
    more (due to clock steering), which can cause the event programming to
    think the next event was before the newly incremented time and fail
    causing tick_periodic() to be called again and the whole process loops
    forever.

    [ Impact: prevent hard lock up ]

    Signed-off-by: John Stultz
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner
    Cc: stable@kernel.org

    john stultz
     

22 Apr, 2009

2 commits

  • Add enable() and disable() callbacks for clocksources.

    This allows us to put unused clocksources in power save mode. The
    functions clocksource_enable() and clocksource_disable() wrap the
    callbacks and are inserted in the timekeeping code to enable before use
    and disable after switching to a new clocksource.

    Signed-off-by: Magnus Damm
    Acked-by: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Magnus Damm
     
  • Pass clocksource pointer to the read() callback for clocksources. This
    allows us to share the callback between multiple instances.

    [hugh@veritas.com: fix powerpc build of clocksource pass clocksource mods]
    [akpm@linux-foundation.org: cleanup]
    Signed-off-by: Magnus Damm
    Acked-by: John Stultz
    Cc: Thomas Gleixner
    Signed-off-by: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Magnus Damm
     

27 Mar, 2009

1 commit

  • * 'timers-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (26 commits)
    posix timers: fix RLIMIT_CPU && fork()
    time: ntp: fix bug in ntp_update_offset() & do_adjtimex(), fix
    time: ntp: clean up second_overflow()
    time: ntp: simplify ntp_tick_adj calculations
    time: ntp: make 64-bit constants more robust
    time: ntp: refactor do_adjtimex() some more
    time: ntp: refactor do_adjtimex()
    time: ntp: fix bug in ntp_update_offset() & do_adjtimex()
    time: ntp: micro-optimize ntp_update_offset()
    time: ntp: simplify ntp_update_offset_fll()
    time: ntp: refactor and clean up ntp_update_offset()
    time: ntp: refactor up ntp_update_frequency()
    time: ntp: clean up ntp_update_frequency()
    time: ntp: simplify the MAX_TICKADJ_SCALED definition
    time: ntp: simplify the second_overflow() code flow
    time: ntp: clean up kernel/time/ntp.c
    x86: hpet: stop HPET_COUNTER when programming periodic mode
    x86: hpet: provide separate functions to stop and start the counter
    x86: hpet: print HPET registers during setup (if hpet=verbose is used)
    time: apply NTP frequency/tick changes immediately
    ...

    Linus Torvalds
     

26 Mar, 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
     

16 Feb, 2009

2 commits

  • Mapping from a struct timecounter to a time returned by functions like
    ktime_get_real() is implemented. This is sufficient to use this code
    in a network device driver which wants to support hardware time
    stamping and transformation of hardware time stamps to system time.

    The interface could have been made more versatile by not depending on
    a time counter, but this wasn't done to avoid writing glue code
    elsewhere.

    The method implemented here is the one used and analyzed under the name
    "assisted PTP" in the LCI PTP paper:
    http://www.linuxclustersinstitute.org/conferences/archive/2008/PDF/Ohly_92221.pdf

    Acked-by: John Stultz
    Signed-off-by: Patrick Ohly
    Signed-off-by: David S. Miller

    Patrick Ohly
     
  • So far struct clocksource acted as the interface between time/timekeeping.c
    and hardware. This patch generalizes the concept so that a similar
    interface can also be used in other contexts. For that it introduces
    new structures and related functions *without* touching the existing
    struct clocksource.

    The reasons for adding these new structures to clocksource.[ch] are
    * the APIs are clearly related
    * struct clocksource could be cleaned up to use the new structs
    * avoids proliferation of files with similar names (timesource.h?
    timecounter.h?)

    As outlined in the discussion with John Stultz, this patch adds
    * struct cyclecounter: stateless API to hardware which counts clock cycles
    * struct timecounter: stateful utility code built on a cyclecounter which
    provides a nanosecond counter
    * only the function to read the nanosecond counter; deltas are used internally
    and not exposed to users of timecounter

    The code does no locking of the shared state. It must be called at least
    as often as the cycle counter wraps around to detect these wrap arounds.
    Both is the responsibility of the timecounter user.

    Acked-by: John Stultz
    Signed-off-by: Patrick Ohly
    Signed-off-by: David S. Miller

    Patrick Ohly
     

09 Feb, 2009

1 commit


31 Jan, 2009

1 commit

  • Impact: fix CPU hotplug hang on Power6 testbox

    On architectures that support offlining all cpus (at least powerpc/pseries),
    hot-unpluging the tick_do_timer_cpu can result in a system hang.

    This comes from the fact that if the cpu going down happens to be the
    cpu doing the tick, then as the tick_do_timer_cpu handover happens after the
    cpu is dead (via the CPU_DEAD notification), we're left without ticks,
    jiffies are frozen and any task relying on timers (msleep, ...) is stuck.
    That's particularly the case for the cpu looping in __cpu_die() waiting
    for the dying cpu to be dead.

    This patch addresses this by having the tick_do_timer_cpu handover happen
    earlier during the CPU_DYING notification. For this, a new clockevent
    notification type is introduced (CLOCK_EVT_NOTIFY_CPU_DYING) which is triggered
    in hrtimer_cpu_notify().

    Signed-off-by: Sebastien Dugue
    Cc:
    Signed-off-by: Ingo Molnar

    Sebastien Dugue
     

16 Jan, 2009

1 commit

  • Allow the set_mode() clockevent callback to decide and fill in delta
    details such as shift, mult, max_delta_ns and min_delta_ns.

    With this change the clockevent can be registered without delta details
    which allows us to keep the parent clock disabled until the clockevent
    gets setup using set_mode().

    Letting set_mode() fill in or update delta details allows us to save
    power by disabling the parent clock while the clockevent is unused.
    This may however make the parent clock rate change, so next time the
    clockevent gets enabled we need let set_mode() to update the detla
    details accordingly. Doing it at registration time is not enough.

    Furthermore, the delta details seem unused in the case of periodic-only
    clockevent drivers, so this change also allows registration of such
    drivers without the delta details filled in.

    Signed-off-by: Magnus Damm
    Signed-off-by: Thomas Gleixner

    Magnus Damm
     

15 Jan, 2009

1 commit


12 Jan, 2009

1 commit


08 Jan, 2009

1 commit

  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial: (24 commits)
    trivial: chack -> check typo fix in main Makefile
    trivial: Add a space (and a comma) to a printk in 8250 driver
    trivial: Fix misspelling of "firmware" in docs for ncr53c8xx/sym53c8xx
    trivial: Fix misspelling of "firmware" in powerpc Makefile
    trivial: Fix misspelling of "firmware" in usb.c
    trivial: Fix misspelling of "firmware" in qla1280.c
    trivial: Fix misspelling of "firmware" in a100u2w.c
    trivial: Fix misspelling of "firmware" in megaraid.c
    trivial: Fix misspelling of "firmware" in ql4_mbx.c
    trivial: Fix misspelling of "firmware" in acpi_memhotplug.c
    trivial: Fix misspelling of "firmware" in ipw2100.c
    trivial: Fix misspelling of "firmware" in atmel.c
    trivial: Fix misspelled firmware in Kconfig
    trivial: fix an -> a typos in documentation and comments
    trivial: fix then -> than typos in comments and documentation
    trivial: update Jesper Juhl CREDITS entry with new email
    trivial: fix singal -> signal typo
    trivial: Fix incorrect use of "loose" in event.c
    trivial: printk: fix indentation of new_text_line declaration
    trivial: rtc-stk17ta8: fix sparse warning
    ...

    Linus Torvalds
     

06 Jan, 2009

2 commits


04 Jan, 2009

3 commits

  • …/git/tip/linux-2.6-tip

    * 'cpus4096-for-linus-3' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (77 commits)
    x86: setup_per_cpu_areas() cleanup
    cpumask: fix compile error when CONFIG_NR_CPUS is not defined
    cpumask: use alloc_cpumask_var_node where appropriate
    cpumask: convert shared_cpu_map in acpi_processor* structs to cpumask_var_t
    x86: use cpumask_var_t in acpi/boot.c
    x86: cleanup some remaining usages of NR_CPUS where s/b nr_cpu_ids
    sched: put back some stack hog changes that were undone in kernel/sched.c
    x86: enable cpus display of kernel_max and offlined cpus
    ia64: cpumask fix for is_affinity_mask_valid()
    cpumask: convert RCU implementations, fix
    xtensa: define __fls
    mn10300: define __fls
    m32r: define __fls
    h8300: define __fls
    frv: define __fls
    cris: define __fls
    cpumask: CONFIG_DISABLE_OBSOLETE_CPUMASK_FUNCTIONS
    cpumask: zero extra bits in alloc_cpumask_var_node
    cpumask: replace for_each_cpu_mask_nr with for_each_cpu in kernel/time/
    cpumask: convert mm/
    ...

    Linus Torvalds
     
  • * 'cputime' of git://git390.osdl.marist.edu/pub/scm/linux-2.6:
    [PATCH] fast vdso implementation for CLOCK_THREAD_CPUTIME_ID
    [PATCH] improve idle cputime accounting
    [PATCH] improve precision of idle time detection.
    [PATCH] improve precision of process accounting.
    [PATCH] idle cputime accounting
    [PATCH] fix scaled & unscaled cputime accounting

    Linus Torvalds
     
  • …ux-2.6-cpumask into merge-rr-cpumask

    Conflicts:
    arch/x86/kernel/io_apic.c
    kernel/rcuclassic.c
    kernel/sched.c
    kernel/time/tick-sched.c

    Signed-off-by: Mike Travis <travis@sgi.com>
    [ mingo@elte.hu: backmerged typo fix for io_apic.c ]
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

    Mike Travis
     

03 Jan, 2009

1 commit

  • …/git/tip/linux-2.6-tip

    * 'cpus4096-for-linus-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (66 commits)
    x86: export vector_used_by_percpu_irq
    x86: use logical apicid in x2apic_cluster's x2apic_cpu_mask_to_apicid_and()
    sched: nominate preferred wakeup cpu, fix
    x86: fix lguest used_vectors breakage, -v2
    x86: fix warning in arch/x86/kernel/io_apic.c
    sched: fix warning in kernel/sched.c
    sched: move test_sd_parent() to an SMP section of sched.h
    sched: add SD_BALANCE_NEWIDLE at MC and CPU level for sched_mc>0
    sched: activate active load balancing in new idle cpus
    sched: bias task wakeups to preferred semi-idle packages
    sched: nominate preferred wakeup cpu
    sched: favour lower logical cpu number for sched_mc balance
    sched: framework for sched_mc/smt_power_savings=N
    sched: convert BALANCE_FOR_xx_POWER to inline functions
    x86: use possible_cpus=NUM to extend the possible cpus allowed
    x86: fix cpu_mask_to_apicid_and to include cpu_online_mask
    x86: update io_apic.c to the new cpumask code
    x86: Introduce topology_core_cpumask()/topology_thread_cpumask()
    x86: xen: use smp_call_function_many()
    x86: use work_on_cpu in x86/kernel/cpu/mcheck/mce_amd_64.c
    ...

    Fixed up trivial conflict in kernel/time/tick-sched.c manually

    Linus Torvalds
     

01 Jan, 2009

2 commits


31 Dec, 2008

3 commits

  • The cpu time spent by the idle process actually doing something is
    currently accounted as idle time. This is plain wrong, the architectures
    that support VIRT_CPU_ACCOUNTING=y can do better: distinguish between the
    time spent doing nothing and the time spent by idle doing work. The first
    is accounted with account_idle_time and the second with account_system_time.
    The architectures that use the account_xxx_time interface directly and not
    the account_xxx_ticks interface now need to do the check for the idle
    process in their arch code. In particular to improve the system vs true
    idle time accounting the arch code needs to measure the true idle time
    instead of just testing for the idle process.
    To improve the tick based accounting as well we would need an architecture
    primitive that can tell us if the pt_regs of the interrupted context
    points to the magic instruction that halts the cpu.

    In addition idle time is no more added to the stime of the idle process.
    This field now contains the system time of the idle process as it should
    be. On systems without VIRT_CPU_ACCOUNTING this will always be zero as
    every tick that occurs while idle is running will be accounted as idle
    time.

    This patch contains the necessary common code changes to be able to
    distinguish idle system time and true idle time. The architectures with
    support for VIRT_CPU_ACCOUNTING need some changes to exploit this.

    Signed-off-by: Martin Schwidefsky

    Martin Schwidefsky
     
  • The utimescaled / stimescaled fields in the task structure and the
    global cpustat should be set on all architectures. On s390 the calls
    to account_user_time_scaled and account_system_time_scaled never have
    been added. In addition system time that is accounted as guest time
    to the user time of a process is accounted to the scaled system time
    instead of the scaled user time.
    To fix the bugs and to prevent future forgetfulness this patch merges
    account_system_time_scaled into account_system_time and
    account_user_time_scaled into account_user_time.

    Cc: Benjamin Herrenschmidt
    Cc: Hidetoshi Seto
    Cc: Tony Luck
    Cc: Jeremy Fitzhardinge
    Cc: Chris Wright
    Cc: Michael Neuling
    Acked-by: Paul Mackerras
    Signed-off-by: Martin Schwidefsky

    Martin Schwidefsky
     
  • Conflicts:

    arch/x86/kernel/io_apic.c

    Rusty Russell