22 Aug, 2009

2 commits

  • After talking with some application writers who want very fast, but not
    fine-grained timestamps, I decided to try to implement new clock_ids
    to clock_gettime(): CLOCK_REALTIME_COARSE and CLOCK_MONOTONIC_COARSE
    which returns the time at the last tick. This is very fast as we don't
    have to access any hardware (which can be very painful if you're using
    something like the acpi_pm clocksource), and we can even use the vdso
    clock_gettime() method to avoid the syscall. The only trade off is you
    only get low-res tick grained time resolution.

    This isn't a new idea, I know Ingo has a patch in the -rt tree that made
    the vsyscall gettimeofday() return coarse grained time when the
    vsyscall64 sysctrl was set to 2. However this affects all applications
    on a system.

    With this method, applications can choose the proper speed/granularity
    trade-off for themselves.

    Signed-off-by: John Stultz
    Cc: Andi Kleen
    Cc: nikolag@ca.ibm.com
    Cc: Darren Hart
    Cc: arjan@infradead.org
    Cc: jonathan@jonmasters.org
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    john stultz
     
  • This basically reverts commit 1a0c009ac (x86: unregister PIT
    clocksource when PIT is disabled) because the problem which was tried
    to address with that patch has been solved by commit 3f68535ada
    (clocksource: sanity check sysfs clocksource changes).

    The problem addressed by the original patch is that PIT could be
    selected as clocksource after the system switched the PIT off or set
    the PIT into one shot mode which would result in complete timekeeping
    wreckage.

    Now with the sysfs sanity check in place PIT cannot be selected again
    when the system is in oneshot mode. The system will not switch to one
    shot mode as long as PIT is installed because PIT is not suitable for
    one shot.

    The shutdown case which happens when the lapic timer is installed is
    covered by the fact that init_pit_clocksource() is called after the
    lapic timer take over and then does not install the PIT clocksource
    at all.

    We should have done the sanity checks back then, but ...

    This also solves the locking problem which was reported vs. the
    clocksource rework.

    LKML-Reference:
    Cc: Martin Schwidefsky
    Cc: john stultz
    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     

19 Aug, 2009

2 commits

  • stop_machine from a multithreaded workqueue is not allowed because
    of a circular locking dependency between cpu_down and the workqueue
    execution. Use a kernel thread to do the clocksource downgrade.

    Signed-off-by: Martin Schwidefsky
    Cc: Peter Zijlstra
    Cc: john stultz
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Martin pointed out that commit 6ea41d2529 (clocksource: Call
    clocksource_change_rating() outside of watchdog_lock) has a
    theoretical reference count problem. The calls to
    clocksource_change_rating() are now done outside of the clocksource
    mutex and outside of the watchdog lock. A concurrent
    clocksource_unregister() could remove the clock.

    Split out the code which changes the rating from
    clocksource_change_rating() into __clocksource_change_rating().

    Protect the clocksource_watchdog_work() code sequence with the
    clocksource_mutex() and call __clocksource_change_rating().

    LKML-Reference:
    Signed-off-by: Thomas Gleixner
    Cc: Martin Schwidefsky

    Thomas Gleixner
     

15 Aug, 2009

16 commits

  • The changes to the watchdog logic introduced a lock inversion between
    watchdog_lock and clocksource_mutex. Change the rating outside of
    watchdog_lock to avoid it.

    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • Add the new function read_boot_clock to get the exact time the system
    has been started. For architectures without support for exact boot
    time a new weak function is added that returns 0. Use the exact boot
    time to initialize wall_to_monotonic, or xtime if the read_boot_clock
    returned 0.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • The persistent clock of some architectures (e.g. s390) have a
    better granularity than seconds. To reduce the delta between the
    host clock and the guest clock in a virtualized system change the
    read_persistent_clock function to return a struct timespec.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • update_wall_time calls change_clocksource HZ times per second to check
    if a new clock source is available. In close to 100% of all calls
    there is no new clock. Replace the tick based check by an update done
    with stop_machine.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Add timekeeper_read_clock_ntp and timekeeper_read_clock_raw and use
    them for getnstimeofday, ktime_get, ktime_get_ts and getrawmonotonic.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • The clocksource structure has two multipliers, the unmodified multiplier
    clock->mult_orig and the NTP corrected multiplier clock->mult. The NTP
    multiplier is misplaced in the struct clocksource, this is private
    information of the timekeeping code. Add the mult field to the struct
    timekeeper to contain the NTP corrected value, keep the unmodifed
    multiplier in clock->mult and remove clock->mult_orig.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • The xtime_nsec value in the timekeeper structure is shifted by a few
    bits to improve precision. This happens to be the same value as the
    clock->shift. To improve readability add xtime_shift to the timekeeper
    and use it instead of the clock->shift. Likewise add ntp_error_shift
    and replace all (NTP_SCALE_SHIFT - clock->shift) expressions.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Add struct timekeeper to keep the internal values timekeeping.c needs
    in regard to the currently selected clock source. This moves the
    timekeeping intervals, xtime_nsec and the ntp error value from struct
    clocksource to struct timekeeper. The raw_time is removed from the
    clocksource as well. It gets treated like xtime as a global variable.
    Eventually xtime raw_time should be moved to struct timekeeper.

    [ tglx: minor cleanup ]

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Move the downgrade of an unstable clocksource from the timer interrupt
    context into the process context of a work queue thread. This is
    needed to be able to do the clocksource switch with stop_machine.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Refactor clocksource watchdog code to make it more readable. Add
    clocksource_dequeue_watchdog to remove a clocksource from the watchdog
    list when it is unregistered.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • To resume the clocksource watchdog just remove the CLOCK_SOURCE_WATCHDOG
    bit from the watched clocksource.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • The clocksource watchdog marks a clock as highres capable before it
    checked the deviation from the watchdog clocksource even for a single
    time. Make sure that the deviation is at least checked once before
    doing the switch to highres mode.

    Signed-off-by: Martin Schwidefsky
    Cc: Ingo Molnar
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • If a non high-resolution clocksource is first set as override clock
    and then registered it becomes active even if the system is in one-shot
    mode. Move the override check from sysfs_override_clocksource to the
    clocksource selection. That fixes the bug and simplifies the code. The
    check in clocksource_register for double registration of the same
    clocksource is removed without replacement.

    To find the initial clocksource a new weak function in jiffies.c is
    defined that returns the jiffies clocksource. The architecture code
    can then override the weak function with a more suitable clocksource,
    e.g. the TOD clock on s390.

    [ tglx: Folded in a fix from John Stultz ]

    Signed-off-by: Martin Schwidefsky
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • change_clocksource resets the cycle_last value to zero then sets it to
    a value read from the clocksource. The reset to zero is required only
    for the TSC clocksource to make the read_tsc function work after a
    resume. The reason is that the TSC read function uses cycle_last to
    detect backwards going TSCs. In the resume case cycle_last contains
    the TSC value from the last update before the suspend. On resume the
    TSC starts counting from 0 again and would trip over the cycle_last
    comparison.

    This is subtle and surprising. Move the reset to a resume function in
    the tsc code.

    Signed-off-by: Martin Schwidefsky
    Acked-by: Thomas Gleixner
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • The three inline functions clocksource_read, clocksource_enable and
    clocksource_disable are simple wrappers of an indirect call plus the
    copy from and to the mult_orig value. The functions are exclusively
    used by the timekeeping code which has intimate knowledge of the
    clocksource anyway. Therefore remove the inline functions. No
    functional change.

    Signed-off-by: Martin Schwidefsky
    Acked-by: John Stultz
    Cc: Daniel Walker
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    Martin Schwidefsky
     
  • Move the adjustment of xtime, wall_to_monotonic and the update of the
    vsyscall variables to the timekeeping code.

    Signed-off-by: John Stultz
    Signed-off-by: Martin Schwidefsky
    LKML-Reference:
    Signed-off-by: Thomas Gleixner

    John Stultz
     

14 Aug, 2009

10 commits

  • Reason: Martin's timekeeping cleanup series depends on both
    timers/core and mainline changes.

    Signed-off-by: Thomas Gleixner

    Thomas Gleixner
     
  • Linus Torvalds
     
  • free_irq() can remove an irqaction while the corresponding interrupt
    is in progress, but free_irq() sets action->thread to NULL
    unconditionally, which might lead to a NULL pointer dereference in
    handle_IRQ_event() when the hard interrupt context tries to wake up
    the handler thread.

    Prevent this by moving the thread stop after synchronize_irq(). No
    need to set action->thread to NULL either as action is going to be
    freed anyway.

    This fixes a boot crash reported against preempt-rt which uses the
    mainline irq threads code to implement full irq threading.

    [ tglx: removed local irqthread variable ]

    Signed-off-by: Linus Torvalds
    Signed-off-by: Thomas Gleixner

    Linus Torvalds
     
  • …x/kernel/git/tip/linux-2.6-tip

    * 'perfcounters-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    perf_counter: Report the cloning task as parent on perf_counter_fork()
    perf_counter: Fix an ipi-deadlock
    perf: Rework/fix the whole read vs group stuff
    perf_counter: Fix swcounter context invariance
    perf report: Don't show unresolved DSOs and symbols when -S/-d is used
    perf tools: Add a general option to enable raw sample records
    perf tools: Add a per tracepoint counter attribute to get raw sample
    perf_counter: Provide hw_perf_counter_setup_online() APIs
    perf list: Fix large list output by using the pager
    perf_counter, x86: Fix/improve apic fallback
    perf record: Add missing -C option support for specifying profile cpu
    perf tools: Fix dso__new handle() to handle deleted DSOs
    perf tools: Fix fallback to cplus_demangle() when bfd_demangle() is not available
    perf report: Show the tid too in -D
    perf record: Fix .tid and .pid fill-in when synthesizing events
    perf_counter, x86: Fix generic cache events on P6-mobile CPUs
    perf_counter, x86: Fix lapic printk message

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

    * 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    futex: Fix handling of bad requeue syscall pairing
    futex: Fix compat_futex to be same as futex for REQUEUE_PI
    locking, sched: Give waitqueue spinlocks their own lockdep classes
    futex: Update futex_q lock_ptr on requeue proxy lock

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

    * 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    x86: Fix oops in identify_cpu() on CPUs without CPUID
    x86: Clear incorrectly forced X86_FEATURE_LAHF_LM flag
    x86, mce: therm_throt - change when we print messages
    x86: Add reboot quirk for every 5 series MacBook/Pro

    Linus Torvalds
     
  • * 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2: (22 commits)
    ocfs2: Fix possible deadlock when extending quota file
    ocfs2: keep index within status_map[]
    ocfs2: Initialize the cluster we're writing to in a non-sparse extend
    ocfs2: Remove redundant BUG_ON in __dlm_queue_ast()
    ocfs2/quota: Release lock for error in ocfs2_quota_write.
    ocfs2: Define credit counts for quota operations
    ocfs2: Remove syncjiff field from quota info
    ocfs2: Fix initialization of blockcheck stats
    ocfs2: Zero out padding of on disk dquot structure
    ocfs2: Initialize blocks allocated to local quota file
    ocfs2: Mark buffer uptodate before calling ocfs2_journal_access_dq()
    ocfs2: Make global quota files blocksize aligned
    ocfs2: Use ocfs2_rec_clusters in ocfs2_adjust_adjacent_records.
    ocfs2: Fix deadlock on umount
    ocfs2: Add extra credits and access the modified bh in update_edge_lengths.
    ocfs2: Fail ocfs2_get_block() immediately when a block needs allocation
    ocfs2: Fix error return in ocfs2_write_cluster()
    ocfs2: Fix compilation warning for fs/ocfs2/xattr.c
    ocfs2: Initialize count in aio_write before generic_write_checks
    ocfs2: log the actual return value of ocfs2_file_aio_write()
    ...

    Linus Torvalds
     
  • * 'for-linus' of git://neil.brown.name/md:
    md: allow upper limit for resync/reshape to be set when array is read-only
    md/raid5: Properly remove excess drives after shrinking a raid5/6
    md/raid5: make sure a reshape restarts at the correct address.
    md/raid5: allow new reshape modes to be restarted in the middle.
    md: never advance 'events' counter by more than 1.
    Remove deadlock potential in md_open

    Linus Torvalds
     
  • * 'sh/for-2.6.31' of git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6:
    sh: fix i2c init order on ap325rxa V2
    sh: fix i2c init order on Migo-R V2
    sh: convert processor device setup functions to arch_initcall()

    Linus Torvalds
     
  • kernel_sendpage() does the proper default case handling for when the
    socket doesn't have a native sendpage implementation.

    Now, arguably this might be something that we could instead solve by
    just specifying that all protocols should do it themselves at the
    protocol level, but we really only care about the common protocols.
    Does anybody really care about sendpage on something like Appletalk? Not
    likely.

    Acked-by: David S. Miller
    Acked-by: Julien TINNES
    Acked-by: Tavis Ormandy
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

13 Aug, 2009

10 commits

  • A bug in (9f498cc: perf_counter: Full task tracing) makes
    profiling multi-threaded apps it go belly up.

    [ output as: (PID:TID):(PPID:PTID) ]

    # ./perf report -D | grep FORK
    0x4b0 [0x18]: PERF_EVENT_FORK: (3237:3237):(3236:3236)
    0xa10 [0x18]: PERF_EVENT_FORK: (3237:3238):(3236:3236)
    0xa70 [0x18]: PERF_EVENT_FORK: (3237:3239):(3236:3236)
    0xad0 [0x18]: PERF_EVENT_FORK: (3237:3240):(3236:3236)
    0xb18 [0x18]: PERF_EVENT_FORK: (3237:3241):(3236:3236)

    Shows us that the test (27d028d perf report: Update for the new
    FORK/EXIT events) in builtin-report.c:

    /*
    * A thread clone will have the same PID for both
    * parent and child.
    */
    if (thread == parent)
    return 0;

    Will clearly fail.

    The problem is that perf_counter_fork() reports the actual
    parent, instead of the cloning thread.

    Fixing that (with the below patch), yields:

    # ./perf report -D | grep FORK
    0x4c8 [0x18]: PERF_EVENT_FORK: (1590:1590):(1589:1589)
    0xbd8 [0x18]: PERF_EVENT_FORK: (1590:1591):(1590:1590)
    0xc80 [0x18]: PERF_EVENT_FORK: (1590:1592):(1590:1590)
    0x3338 [0x18]: PERF_EVENT_FORK: (1590:1593):(1590:1590)
    0x66b0 [0x18]: PERF_EVENT_FORK: (1590:1594):(1590:1590)

    Which both makes more sense and doesn't confuse perf report
    anymore.

    Reported-by: Pekka Enberg
    Signed-off-by: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: paulus@samba.org
    Cc: Anton Blanchard
    Cc: Arjan van de Ven
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • perf_pending_counter() is called from IRQ context and will call
    perf_counter_disable(), however perf_counter_disable() uses
    smp_call_function_single() which doesn't fancy being used with
    IRQs disabled due to IPI deadlocks.

    Fix this by making it use the local __perf_counter_disable()
    call and teaching the counter_sched_out() code about pending
    disables as well.

    This should cover the case where a counter migrates before the
    pending queue gets processed.

    Signed-off-by: Peter Zijlstra
    Cc: Corey J Ashford
    Cc: Paul Mackerras
    Cc: stephane eranian
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Replace PERF_SAMPLE_GROUP with PERF_SAMPLE_READ and introduce
    PERF_FORMAT_GROUP to deal with group reads in a more generic
    way.

    This allows you to get group reads out of read() as well.

    Signed-off-by: Peter Zijlstra
    Cc: Corey J Ashford
    Cc: Paul Mackerras
    Cc: stephane eranian
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • perf_swcounter_is_counting() uses a lock, which means we cannot
    use swcounters from NMI or when holding that particular lock,
    this is unintended.

    The below removes the lock, this opens up race window, but not
    worse than the swcounters already experience due to RCU
    traversal of the context in perf_swcounter_ctx_event().

    This also fixes the hard lockups while opening a lockdep
    tracepoint counter.

    Signed-off-by: Peter Zijlstra
    Acked-by: Frederic Weisbecker
    Cc: Paul Mackerras
    Cc: stephane eranian
    Cc: Corey J Ashford
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • We're interested in just those symbols/DSOs, so filter out the
    unresolved ones.

    Signed-off-by: Arnaldo Carvalho de Melo
    Cc: Peter Zijlstra
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • While we can enable the perf sample records per tracepoint
    counter, we may also want to enable this option for every
    tracepoint counters to open, so that we don't need to add a
    :record flag for all of them.

    Add the -R, --raw-samples options for this purpose.

    Signed-off-by: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     
  • Add a new flag field while opening a tracepoint perf counter:

    -e tracepoint_subsystem:tracepoint_name:flags

    This is intended to be generic although for now it only supports the
    r[e[c[o[r[d]]]]] flag:

    ./perf record -e workqueue:workqueue_insertion:record
    ./perf record -e workqueue:workqueue_insertion:r

    will have the same effect: enabling the raw samples record for
    the given tracepoint counter.

    In the future, we may want to support further flags, separated
    by commas.

    Signed-off-by: Frederic Weisbecker
    Cc: Peter Zijlstra
    Cc: Arnaldo Carvalho de Melo
    Cc: Mike Galbraith
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     
  • Provide weak aliases for hw_perf_counter_setup_online(). This is
    used by the BTS patches (for v2.6.32), but it interacts with
    fixes so propagate this upstream. (it has no effect as of yet)

    Also export perf_counter_output() to architecture code.

    Cc: Peter Zijlstra
    Cc: Paul Mackerras
    Cc: Frederic Weisbecker
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • When /sys/kernel/debug is mounted the list can be imense, so
    use the pager like the other tools.

    Signed-off-by: Arnaldo Carvalho de Melo
    Acked-by: Frederic Weisbecker
    Cc: Peter Zijlstra
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arnaldo Carvalho de Melo
     
  • Convert the AP325RXA board code to register devices at
    arch_initcall() time instead of device_initcall(). This
    fix unbreaks pcf8563 RTC driver support.

    Signed-off-by: Magnus Damm
    Signed-off-by: Paul Mundt

    Magnus Damm