16 Nov, 2015

1 commit

  • ….kernel.org/pub/scm/linux/kernel/git/tip/tip

    Pull irq and timer fixes from Thomas Gleixner:

    - An irq regression fix to restore the wakeup behaviour of chained
    interrupts.

    - A timer fix for a long standing race versus timers scheduled on a
    target cpu which got exposed by recent changes in the workqueue
    implementation.

    * 'irq-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    genirq/PM: Restore system wake up from chained interrupts

    * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    timers: Use proper base migration in add_timer_on()

    Linus Torvalds
     

10 Nov, 2015

1 commit

  • Switch everything to the new and more capable implementation of abs().
    Mainly to give the new abs() a bit of a workout.

    Cc: Michal Nazarewicz
    Cc: John Stultz
    Cc: Ingo Molnar
    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Masami Hiramatsu
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

05 Nov, 2015

1 commit

  • Regardless of the previous CPU a timer was on, add_timer_on()
    currently simply sets timer->flags to the new CPU. As the caller must
    be seeing the timer as idle, this is locally fine, but the timer
    leaving the old base while unlocked can lead to race conditions as
    follows.

    Let's say timer was on cpu 0.

    cpu 0 cpu 1
    -----------------------------------------------------------------------------
    del_timer(timer) succeeds
    del_timer(timer)
    lock_timer_base(timer) locks cpu_0_base
    add_timer_on(timer, 1)
    spin_lock(&cpu_1_base->lock)
    timer->flags set to cpu_1_base
    operates on @timer operates on @timer

    This triggered with mod_delayed_work_on() which contains
    "if (del_timer()) add_timer_on()" sequence eventually leading to the
    following oops.

    BUG: unable to handle kernel NULL pointer dereference at (null)
    IP: [] detach_if_pending+0x69/0x1a0
    ...
    Workqueue: wqthrash wqthrash_workfunc [wqthrash]
    task: ffff8800172ca680 ti: ffff8800172d0000 task.ti: ffff8800172d0000
    RIP: 0010:[] [] detach_if_pending+0x69/0x1a0
    ...
    Call Trace:
    [] del_timer+0x44/0x60
    [] try_to_grab_pending+0xb6/0x160
    [] mod_delayed_work_on+0x33/0x80
    [] wqthrash_workfunc+0x61/0x90 [wqthrash]
    [] process_one_work+0x1e8/0x650
    [] worker_thread+0x4e/0x450
    [] kthread+0xef/0x110
    [] ret_from_fork+0x3f/0x70

    Fix it by updating add_timer_on() to perform proper migration as
    __mod_timer() does.

    Reported-and-tested-by: Jeff Layton
    Signed-off-by: Tejun Heo
    Cc: Chris Worley
    Cc: bfields@fieldses.org
    Cc: Michael Skralivetsky
    Cc: Trond Myklebust
    Cc: Shaohua Li
    Cc: Jeff Layton
    Cc: kernel-team@fb.com
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/20151029103113.2f893924@tlielax.poochiereds.net
    Link: http://lkml.kernel.org/r/20151104171533.GI5749@mtj.duckdns.org
    Signed-off-by: Thomas Gleixner

    Tejun Heo
     

04 Nov, 2015

1 commit

  • Pull timer updates from Thomas Gleixner:
    "The timer departement provides:

    - More y2038 work in the area of ntp and pps.

    - Optimization of posix cpu timers

    - New time related selftests

    - Some new clocksource drivers

    - The usual pile of fixes, cleanups and improvements"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (25 commits)
    timeconst: Update path in comment
    timers/x86/hpet: Type adjustments
    clocksource/drivers/armada-370-xp: Implement ARM delay timer
    clocksource/drivers/tango_xtal: Add new timer for Tango SoCs
    clocksource/drivers/imx: Allow timer irq affinity change
    clocksource/drivers/exynos_mct: Use container_of() instead of this_cpu_ptr()
    clocksource/drivers/h8300_*: Remove unneeded memset()s
    clocksource/drivers/sh_cmt: Remove unneeded memset() in sh_cmt_setup()
    clocksource/drivers/em_sti: Remove unneeded memset()s
    clocksource/drivers/mediatek: Use GPT as sched clock source
    clockevents/drivers/mtk: Fix spurious interrupt leading to crash
    posix_cpu_timer: Reduce unnecessary sighand lock contention
    posix_cpu_timer: Convert cputimer->running to bool
    posix_cpu_timer: Check thread timers only when there are active thread timers
    posix_cpu_timer: Optimize fastpath_timer_check()
    timers, kselftest: Add 'adjtick' test to validate adjtimex() tick adjustments
    timers: Use __fls in apply_slack()
    clocksource: Remove return statement from void functions
    net: sfc: avoid using timespec
    ntp/pps: use y2038 safe types in pps_event_time
    ...

    Linus Torvalds
     

26 Oct, 2015

1 commit


20 Oct, 2015

1 commit


16 Oct, 2015

1 commit

  • timekeeping_init() can set the wall time offset, so we need to
    increment the clock_was_set_seq counter. That way hrtimers will pick
    up the early offset immediately. Otherwise on a machine which does not
    set wall time later in the boot process the hrtimer offset is stale at
    0 and wall time timers are going to expire with a delay of 45 years.

    Fixes: 868a3e915f7f "hrtimer: Make offset update smarter"
    Reported-and-tested-by: Heiko Carstens
    Signed-off-by: Thomas Gleixner
    Cc: Stefan Liebler
    Cc: Peter Zijlstra
    Cc: John Stultz

    Thomas Gleixner
     

15 Oct, 2015

4 commits

  • It was found while running a database workload on large systems that
    significant time was spent trying to acquire the sighand lock.

    The issue was that whenever an itimer expired, many threads ended up
    simultaneously trying to send the signal. Most of the time, nothing
    happened after acquiring the sighand lock because another thread
    had just already sent the signal and updated the "next expire" time.
    The fastpath_timer_check() didn't help much since the "next expire"
    time was updated after the threads exit fastpath_timer_check().

    This patch addresses this by having the thread_group_cputimer structure
    maintain a boolean to signify when a thread in the group is already
    checking for process wide timers, and adds extra logic in the fastpath
    to check the boolean.

    Signed-off-by: Jason Low
    Reviewed-by: Oleg Nesterov
    Reviewed-by: George Spelvin
    Cc: Paul E. McKenney
    Cc: Frederic Weisbecker
    Cc: Davidlohr Bueso
    Cc: Steven Rostedt
    Cc: hideaki.kimura@hpe.com
    Cc: terry.rudd@hpe.com
    Cc: scott.norton@hpe.com
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1444849677-29330-5-git-send-email-jason.low2@hp.com
    Signed-off-by: Thomas Gleixner

    Jason Low
     
  • In the next patch in this series, a new field 'checking_timer' will
    be added to 'struct thread_group_cputimer'. Both this and the
    existing 'running' integer field are just used as boolean values. To
    save space in the structure, we can make both of these fields booleans.

    This is a preparatory patch to convert the existing running integer
    field to a boolean.

    Suggested-by: George Spelvin
    Signed-off-by: Jason Low
    Reviewed: George Spelvin
    Cc: Oleg Nesterov
    Cc: Paul E. McKenney
    Cc: Frederic Weisbecker
    Cc: Davidlohr Bueso
    Cc: Steven Rostedt
    Cc: hideaki.kimura@hpe.com
    Cc: terry.rudd@hpe.com
    Cc: scott.norton@hpe.com
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1444849677-29330-4-git-send-email-jason.low2@hp.com
    Signed-off-by: Thomas Gleixner

    Jason Low
     
  • The fastpath_timer_check() contains logic to check for if any timers
    are set by checking if !task_cputime_zero(). Similarly, we can do this
    before calling check_thread_timers(). In the case where there
    are only process-wide timers, this will skip all of the computations for
    per-thread timers when there are no per-thread timers.

    As suggested by George, we can put the task_cputime_zero() check in
    check_thread_timers(), since that is more of an optization to the
    function. Similarly, we move the existing check of cputimer->running
    to check_process_timers().

    Signed-off-by: Jason Low
    Reviewed-by: Oleg Nesterov
    Reviewed-by: George Spelvin
    Cc: Paul E. McKenney
    Cc: Frederic Weisbecker
    Cc: Davidlohr Bueso
    Cc: Steven Rostedt
    Cc: hideaki.kimura@hpe.com
    Cc: terry.rudd@hpe.com
    Cc: scott.norton@hpe.com
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1444849677-29330-3-git-send-email-jason.low2@hp.com
    Signed-off-by: Thomas Gleixner

    Jason Low
     
  • In fastpath_timer_check(), the task_cputime() function is always
    called to compute the utime and stime values. However, this is not
    necessary if there are no per-thread timers to check for. This patch
    modifies the code such that we compute the task_cputime values only
    when there are per-thread timers set.

    Signed-off-by: Jason Low
    Reviewed-by: Oleg Nesterov
    Reviewed-by: Frederic Weisbecker
    Reviewed-by: Davidlohr Bueso
    Reviewed-by: George Spelvin
    Cc: Paul E. McKenney
    Cc: Steven Rostedt
    Cc: hideaki.kimura@hpe.com
    Cc: terry.rudd@hpe.com
    Cc: scott.norton@hpe.com
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/1444849677-29330-2-git-send-email-jason.low2@hp.com
    Signed-off-by: Thomas Gleixner

    Jason Low
     

12 Oct, 2015

3 commits


03 Oct, 2015

2 commits

  • Pull timer fixes from Ingo Molnar:
    "An abs64() fix in the watchdog driver, and two clocksource driver
    NO_IRQ assumption fixes"

    * 'timers-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    clocksource: Fix abs() usage w/ 64bit values
    clocksource/drivers/keystone: Fix bad NO_IRQ usage
    clocksource/drivers/rockchip: Fix bad NO_IRQ usage

    Linus Torvalds
     
  • This patch fixes one cases where abs() was being used with 64-bit
    nanosecond values, where the result may be capped at 32-bits.

    This potentially could cause watchdog false negatives on 32-bit
    systems, so this patch addresses the issue by using abs64().

    Signed-off-by: John Stultz
    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Ingo Molnar
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/1442279124-7309-2-git-send-email-john.stultz@linaro.org
    Signed-off-by: Thomas Gleixner

    John Stultz
     

02 Oct, 2015

3 commits

  • The sync_cmos_clock has one use of struct timespec, which we want to
    eventually replace with timespec64 or similar in the kernel. There
    is no way this one can overflow, but the conversion to timespec64
    is trivial and has no other dependencies.

    Acked-by: Richard Cochran
    Acked-by: David S. Miller
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Arnd Bergmann
    Signed-off-by: John Stultz

    Arnd Bergmann
     
  • There is exactly one caller of getnstime_raw_and_real in the kernel,
    which is the pps_get_ts function. This changes the caller and
    the implementation to work on timespec64 types rather than timespec,
    to avoid the time_t overflow on 32-bit architectures.

    For consistency with the other new functions (ktime_get_seconds,
    ktime_get_real_*, ...), I'm renaming the function to
    ktime_get_raw_and_real_ts64.

    We still need to convert from the internal 64-bit type to 32 bit
    types in the caller, but this conversion is now pushed out from
    getnstime_raw_and_real to pps_get_ts. A follow-up patch changes
    the remaining pps code to completely avoid the conversion.

    Acked-by: Richard Cochran
    Acked-by: David S. Miller
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Arnd Bergmann
    Signed-off-by: John Stultz

    Arnd Bergmann
     
  • There is only one user of the hardpps function in the kernel, so
    it makes sense to atomically change it over to using 64-bit
    timestamps for y2038 safety. In the hardpps implementation,
    we also need to change the pps_normtime structure, which is
    similar to struct timespec and also requires a 64-bit
    seconds portion.

    This introduces two temporary variables in pps_kc_event() to
    do the conversion, they will be removed again in the next step,
    which seemed preferable to having a larger patch changing it
    all at the same time.

    Acked-by: Richard Cochran
    Acked-by: David S. Miller
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Arnd Bergmann
    Signed-off-by: John Stultz

    Arnd Bergmann
     

22 Sep, 2015

2 commits

  • timer_stats_account_timer() reads timer->start_site, then checks it
    for NULL and then re-reads it again, while
    timer_stats_timer_clear_start_info() can concurrently reset
    timer->start_site to NULL. This should not lead to crashes, but can
    double number of entries in timer stats as start_site is used during
    comparison, the doubled entries will have unuseful NULL start_site.

    Read timer->start_site only once in timer_stats_account_timer().

    The data race was found with KernelThreadSanitizer (KTSAN).

    Signed-off-by: Dmitry Vyukov
    Cc: andreyknvl@google.com
    Cc: glider@google.com
    Cc: kcc@google.com
    Cc: ktsan@googlegroups.com
    Cc: john.stultz@linaro.org
    Link: http://lkml.kernel.org/r/1442584463-69553-1-git-send-email-dvyukov@google.com
    Signed-off-by: Thomas Gleixner

    Dmitry Vyukov
     
  • Signed-off-by: Zhen Lei
    Cc: Hanjun Guo
    Cc: John Stultz
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Rafael J. Wysocki
    Cc: Thomas Gleixner
    Cc: Tianhong Ding
    Cc: Viresh Kumar
    Cc: Xinwei Hu
    Cc: Xunlei Pang
    Cc: Zefan Li
    Link: http://lkml.kernel.org/r/1440484973-13892-1-git-send-email-thunder.leizhen@huawei.com
    [ Fixed yet another typo in one of the sentences fixed. ]
    Signed-off-by: Ingo Molnar

    Zhen Lei
     

18 Sep, 2015

1 commit


14 Sep, 2015

1 commit

  • All users are migrated to the per-state callbacks, get rid of the
    unused interface and the core support code.

    Signed-off-by: Viresh Kumar
    Signed-off-by: Thomas Gleixner
    Cc: linaro-kernel@lists.linaro.org
    Cc: John Stultz
    Cc: Peter Zijlstra
    Link: http://lkml.kernel.org/r/fd60de14cf6d125489c031207567bb255ad946f6.1441943991.git.viresh.kumar@linaro.org
    Signed-off-by: Ingo Molnar

    Viresh Kumar
     

13 Sep, 2015

1 commit

  • The internal clocksteering done for fine-grained error
    correction uses a logarithmic approximation, so any time
    adjtimex() adjusts the clock steering, timekeeping_freqadjust()
    quickly approximates the correct clock frequency over a series
    of ticks.

    Unfortunately, the logic in timekeeping_freqadjust(), introduced
    in commit:

    dc491596f639 ("timekeeping: Rework frequency adjustments to work better w/ nohz")

    used the abs() function with a s64 error value to calculate the
    size of the approximated adjustment to be made.

    Per include/linux/kernel.h:

    "abs() should not be used for 64-bit types (s64, u64, long long) - use abs64()".

    Thus on 32-bit platforms, this resulted in the clocksteering to
    take a quite dampended random walk trying to converge on the
    proper frequency, which caused the adjustments to be made much
    slower then intended (most easily observed when large
    adjustments are made).

    This patch fixes the issue by using abs64() instead.

    Reported-by: Nuno Gonçalves
    Tested-by: Nuno Goncalves
    Signed-off-by: John Stultz
    Cc: # v3.17+
    Cc: Linus Torvalds
    Cc: Miroslav Lichvar
    Cc: Peter Zijlstra
    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1441840051-20244-1-git-send-email-john.stultz@linaro.org
    Signed-off-by: Ingo Molnar

    John Stultz
     

02 Sep, 2015

2 commits

  • The code ensures that when nohz full is running, at least the
    boot CPU serves as a housekeeper and it can't be later offlined.

    Let's assert this assumption to make sure that we have CPUs to
    handle unbound jobs like workqueues and timers while nohz full
    CPUs run undisturbed.

    Also improve the comments on housekeeper offlining prevention.

    Signed-off-by: Frederic Weisbecker
    Acked-by: Thomas Gleixner
    Cc: Chris Metcalf
    Cc: Christoph Lameter
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Preeti U Murthy
    Cc: Vatika Harlalka
    Link: http://lkml.kernel.org/r/1441119060-2230-3-git-send-email-fweisbec@gmail.com
    Signed-off-by: Ingo Molnar

    Frederic Weisbecker
     
  • Pull timer updates from Thomas Gleixner:
    "Rather large, but nothing exiting:

    - new range check for settimeofday() to prevent that boot time
    becomes negative.
    - fix for file time rounding
    - a few simplifications of the hrtimer code
    - fix for the proc/timerlist code so the output of clock realtime
    timers is accurate
    - more y2038 work
    - tree wide conversion of clockevent drivers to the new callbacks"

    * 'timers-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (88 commits)
    hrtimer: Handle failure of tick_init_highres() gracefully
    hrtimer: Unconfuse switch_hrtimer_base() a bit
    hrtimer: Simplify get_target_base() by returning current base
    hrtimer: Drop return code of hrtimer_switch_to_hres()
    time: Introduce timespec64_to_jiffies()/jiffies_to_timespec64()
    time: Introduce current_kernel_time64()
    time: Introduce struct itimerspec64
    time: Add the common weak version of update_persistent_clock()
    time: Always make sure wall_to_monotonic isn't positive
    time: Fix nanosecond file time rounding in timespec_trunc()
    timer_list: Add the base offset so remaining nsecs are accurate for non monotonic timers
    cris/time: Migrate to new 'set-state' interface
    kernel: broadcast-hrtimer: Migrate to new 'set-state' interface
    xtensa/time: Migrate to new 'set-state' interface
    unicore/time: Migrate to new 'set-state' interface
    um/time: Migrate to new 'set-state' interface
    sparc/time: Migrate to new 'set-state' interface
    sh/localtimer: Migrate to new 'set-state' interface
    score/time: Migrate to new 'set-state' interface
    s390/time: Migrate to new 'set-state' interface
    ...

    Linus Torvalds
     

01 Sep, 2015

2 commits

  • Pull NOHZ updates from Ingo Molnar:
    "The main changes, mostly written by Frederic Weisbecker, include:

    - Fix some jiffies based cputime assumptions. (No real harm because
    the concerned code isn't used by full dynticks.)

    - Simplify jiffies usecs conversions. Remove dead code.

    - Remove early hacks on nohz full code that avoided messing up idle
    nohz internals. Now nohz integrates well full and idle and such
    hack have become needless.

    - Restart nohz full tick from irq exit. (A simplification and a
    preparation for future optimization on scheduler kick to nohz
    full)

    - Code cleanups.

    - Tile driver isolation enhancement on top of nohz. (Chris Metcalf)"

    * 'timers-nohz-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
    nohz: Remove useless argument on tick_nohz_task_switch()
    nohz: Move tick_nohz_restart_sched_tick() above its users
    nohz: Restart nohz full tick from irq exit
    nohz: Remove idle task special case
    nohz: Prevent tilegx network driver interrupts
    alpha: Fix jiffies based cputime assumption
    apm32: Fix cputime == jiffies assumption
    jiffies: Remove HZ > USEC_PER_SEC special case

    Linus Torvalds
     
  • Pull RCU updates from Ingo Molnar:
    "The main RCU changes in this cycle are:

    - the combination of tree geometry-initialization simplifications and
    OS-jitter-reduction changes to expedited grace periods. These two
    are stacked due to the large number of conflicts that would
    otherwise result.

    - privatize smp_mb__after_unlock_lock().

    This commit moves the definition of smp_mb__after_unlock_lock() to
    kernel/rcu/tree.h, in recognition of the fact that RCU is the only
    thing using this, that nothing else is likely to use it, and that
    it is likely to go away completely.

    - documentation updates.

    - torture-test updates.

    - misc fixes"

    * 'core-rcu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (60 commits)
    rcu,locking: Privatize smp_mb__after_unlock_lock()
    rcu: Silence lockdep false positive for expedited grace periods
    rcu: Don't disable CPU hotplug during OOM notifiers
    scripts: Make checkpatch.pl warn on expedited RCU grace periods
    rcu: Update MAINTAINERS entry
    rcu: Clarify CONFIG_RCU_EQS_DEBUG help text
    rcu: Fix backwards RCU_LOCKDEP_WARN() in synchronize_rcu_tasks()
    rcu: Rename rcu_lockdep_assert() to RCU_LOCKDEP_WARN()
    rcu: Make rcu_is_watching() really notrace
    cpu: Wait for RCU grace periods concurrently
    rcu: Create a synchronize_rcu_mult()
    rcu: Fix obsolete priority-boosting comment
    rcu: Use WRITE_ONCE in RCU_INIT_POINTER
    rcu: Hide RCU_NOCB_CPU behind RCU_EXPERT
    rcu: Add RCU-sched flavors of get-state and cond-sync
    rcu: Add fastpath bypassing funnel locking
    rcu: Rename RCU_GP_DONE_FQS to RCU_GP_DOING_FQS
    rcu: Pull out wait_event*() condition into helper function
    documentation: Describe new expedited stall warnings
    rcu: Add stall warnings to synchronize_sched_expedited()
    ...

    Linus Torvalds
     

22 Aug, 2015

1 commit

  • Commit 75e3b37d0598 ("hrtimer: Drop return code of hrtimer_switch_to_hres()")
    drops the return code of hrtimer_switch_to_hres(). While doing so, it also
    drops the return statement itself on failure. This may cause a system hang.
    Seen when running arm:multi_v7_defconfig in qemu with devicetree file
    vexpress-v2p-ca9.

    Fixes: 75e3b37d0598 ("hrtimer: Drop return code of hrtimer_switch_to_hres()")
    Cc: Luiz Capitulino
    Signed-off-by: Guenter Roeck
    Link: http://lkml.kernel.org/r/1440231047-16256-1-git-send-email-linux@roeck-us.net
    Signed-off-by: Thomas Gleixner

    Guenter Roeck
     

21 Aug, 2015

1 commit


19 Aug, 2015

2 commits

  • The variable called "this_base" is confusing because its name suggests
    it's of "struct hrtimer_clock_base" type, along with "base" and "new_base"
    which doesn't help understanding this complicated function.

    Make its name clearer and fix the misleading comment while at it.

    [ tglx: Fixed the comment for real ]

    Signed-off-by: Frederic Weisbecker
    Link: http://lkml.kernel.org/r/1439907509-9553-3-git-send-email-fweisbec@gmail.com
    Signed-off-by: Thomas Gleixner

    Frederic Weisbecker
     
  • Instead of fetching again the current cpu base, just take it from the
    parameter.

    Signed-off-by: Frederic Weisbecker
    Link: http://lkml.kernel.org/r/1439907509-9553-2-git-send-email-fweisbec@gmail.com
    Signed-off-by: Thomas Gleixner

    Frederic Weisbecker
     

18 Aug, 2015

8 commits

  • lock_timer_base() cannot prevent the following :

    CPU1 ( in __mod_timer()
    timer->flags |= TIMER_MIGRATING;
    spin_unlock(&base->lock);
    base = new_base;
    spin_lock(&base->lock);
    // The next line clears TIMER_MIGRATING
    timer->flags &= ~TIMER_BASEMASK;
    CPU2 (in lock_timer_base())
    see timer base is cpu0 base
    spin_lock_irqsave(&base->lock, *flags);
    if (timer->flags == tf)
    return base; // oops, wrong base
    timer->flags |= base->cpu // too late

    We must write timer->flags in one go, otherwise we can fool other cpus.

    Fixes: bc7a34b8b9eb ("timer: Reduce timer migration overhead if disabled")
    Signed-off-by: Eric Dumazet
    Cc: Jon Christopherson
    Cc: David Miller
    Cc: xen-devel@lists.xen.org
    Cc: david.vrabel@citrix.com
    Cc: Sander Eikelenboom
    Link: http://lkml.kernel.org/r/1439831928.32680.11.camel@edumazet-glaptop2.roam.corp.google.com
    Signed-off-by: Thomas Gleixner
    Cc: Thomas Gleixner

    Eric Dumazet
     
  • It's not checked by the caller.

    Signed-off-by: Luiz Capitulino
    Link: http://lkml.kernel.org/r/20150811164043.538241ef@redhat.com
    Signed-off-by: Thomas Gleixner

    Luiz Capitulino
     
  • The conversion between struct timespec and jiffies is not year 2038
    safe on 32bit systems. Introduce timespec64_to_jiffies() and
    jiffies_to_timespec64() functions which use struct timespec64 to
    make it ready for 2038 issue.

    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Baolin Wang
    Signed-off-by: John Stultz

    Baolin Wang
     
  • The current_kernel_time() is not year 2038 safe on 32bit systems
    since it returns a timespec value. Introduce current_kernel_time64()
    which returns a timespec64 value.

    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Baolin Wang
    Signed-off-by: John Stultz

    Baolin Wang
     
  • The weak update_persistent_clock64() calls update_persistent_clock(),
    if the architecture defines an update_persistent_clock64() to replace
    and remove its update_persistent_clock() version, when building the
    kernel the linker will throw an undefined symbol error, that is, any
    arch that switches to update_persistent_clock64() will have this issue.

    To solve the issue, we add the common weak update_persistent_clock().

    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Arnd Bergmann
    Signed-off-by: Xunlei Pang
    Signed-off-by: John Stultz

    Xunlei Pang
     
  • Two issues were found on an IMX6 development board without an
    enabled RTC device(resulting in the boot time and monotonic
    time being initialized to 0).

    Issue 1:exportfs -a generate:
    "exportfs: /opt/nfs/arm does not support NFS export"
    Issue 2:cat /proc/stat:
    "btime 4294967236"

    The same issues can be reproduced on x86 after running the
    following code:
    int main(void)
    {
    struct timeval val;
    int ret;

    val.tv_sec = 0;
    val.tv_usec = 0;
    ret = settimeofday(&val, NULL);
    return 0;
    }

    Two issues are different symptoms of same problem:
    The reason is a positive wall_to_monotonic pushes boot time back
    to the time before Epoch, and getboottime will return negative
    value.

    In symptom 1:
    negative boot time cause get_expiry() to overflow time_t
    when input expire time is 2147483647, then cache_flush()
    always clears entries just added in ip_map_parse.
    In symptom 2:
    show_stat() uses "unsigned long" to print negative btime
    value returned by getboottime.

    This patch fix the problem by prohibiting time from being set to a value which
    would cause a negative boot time. As a result one can't set the CLOCK_REALTIME
    time prior to (1970 + system uptime).

    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Wang YanQing
    [jstultz: reworded commit message]
    Signed-off-by: John Stultz

    Wang YanQing
     
  • timespec_trunc() avoids rounding if granularity 1 second.

    Cc: Prarit Bhargava
    Cc: Richard Cochran
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Karsten Blees
    Signed-off-by: John Stultz

    Karsten Blees
     
  • I noticed for non-monotonic timers in timer_list, some of the
    output looked a little confusing.

    For example:
    #1: , posix_timer_fn, S:01, hrtimer_start_range_ns, leap-a-day/2360
    # expires at 1434412800000000000-1434412800000000000 nsecs [in 1434410725062375469 to 1434410725062375469 nsecs]

    You'll note the relative time till the expiration "[in xxx to
    yyy nsecs]" is incorrect. This is because its printing the delta
    between CLOCK_MONOTONIC time to the CLOCK_REALTIME expiration.

    This patch fixes this issue by adding the clock offset to the
    "now" time which we use to calculate the delta.

    Cc: Prarit Bhargava
    Cc: Daniel Bristot de Oliveira
    Cc: Richard Cochran
    Cc: Jan Kara
    Cc: Jiri Bohac
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: Shuah Khan
    Signed-off-by: John Stultz

    John Stultz