1. 18 6月, 2015 1 次提交
  2. 12 6月, 2015 5 次提交
    • J
      selftests: timers: Add leap-second timer edge testing to leap-a-day.c · 0c4a5fc9
      John Stultz 提交于
      Prarit reported an issue w/ timers around the leapsecond, where a
      timer set for Midnight UTC (00:00:00) might fire a second early right
      before the leapsecond (23:59:60 - though it appears as a repeated
      23:59:59) is applied.
      
      So I've updated the leap-a-day.c test to integrate a similar test,
      where we set a timer and check if it triggers at the right time, and
      if the ntp state transition is managed properly.
      Reported-by: NDaniel Bristot de Oliveira <bristot@redhat.com>
      Reported-by: NPrarit Bhargava <prarit@redhat.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jiri Bohac <jbohac@suse.cz>
      Cc: Shuah Khan <shuahkh@osg.samsung.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1434063297-28657-6-git-send-email-john.stultz@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      0c4a5fc9
    • J
      ntp: Do leapsecond adjustment in adjtimex read path · 96efdcf2
      John Stultz 提交于
      Since the leapsecond is applied at tick-time, this means there is a
      small window of time at the start of a leap-second where we cross into
      the next second before applying the leap.
      
      This patch modified adjtimex so that the leap-second is applied on the
      second edge. Providing more correct leapsecond behavior.
      
      This does make it so that adjtimex()'s returned time values can be
      inconsistent with time values read from gettimeofday() or
      clock_gettime(CLOCK_REALTIME,...)  for a brief period of one tick at
      the leapsecond.  However, those other interfaces do not provide the
      TIME_OOP time_state return that adjtimex() provides, which allows the
      leapsecond to be properly represented. They instead only see a time
      discontinuity, and cannot tell the first 23:59:59 from the repeated
      23:59:59 leap second.
      
      This seems like a reasonable tradeoff given clock_gettime() /
      gettimeofday() cannot properly represent a leapsecond, and users
      likely care more about performance, while folks who are using
      adjtimex() more likely care about leap-second correctness.
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jiri Bohac <jbohac@suse.cz>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1434063297-28657-5-git-send-email-john.stultz@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      96efdcf2
    • J
      time: Prevent early expiry of hrtimers[CLOCK_REALTIME] at the leap second edge · 833f32d7
      John Stultz 提交于
      Currently, leapsecond adjustments are done at tick time. As a result,
      the leapsecond was applied at the first timer tick *after* the
      leapsecond (~1-10ms late depending on HZ), rather then exactly on the
      second edge.
      
      This was in part historical from back when we were always tick based,
      but correcting this since has been avoided since it adds extra
      conditional checks in the gettime fastpath, which has performance
      overhead.
      
      However, it was recently pointed out that ABS_TIME CLOCK_REALTIME
      timers set for right after the leapsecond could fire a second early,
      since some timers may be expired before we trigger the timekeeping
      timer, which then applies the leapsecond.
      
      This isn't quite as bad as it sounds, since behaviorally it is similar
      to what is possible w/ ntpd made leapsecond adjustments done w/o using
      the kernel discipline. Where due to latencies, timers may fire just
      prior to the settimeofday call. (Also, one should note that all
      applications using CLOCK_REALTIME timers should always be careful,
      since they are prone to quirks from settimeofday() disturbances.)
      
      However, the purpose of having the kernel do the leap adjustment is to
      avoid such latencies, so I think this is worth fixing.
      
      So in order to properly keep those timers from firing a second early,
      this patch modifies the ntp and timekeeping logic so that we keep
      enough state so that the update_base_offsets_now accessor, which
      provides the hrtimer core the current time, can check and apply the
      leapsecond adjustment on the second edge. This prevents the hrtimer
      core from expiring timers too early.
      
      This patch does not modify any other time read path, so no additional
      overhead is incurred. However, this also means that the leap-second
      continues to be applied at tick time for all other read-paths.
      
      Apologies to Richard Cochran, who pushed for similar changes years
      ago, which I resisted due to the concerns about the performance
      overhead.
      
      While I suspect this isn't extremely critical, folks who care about
      strict leap-second correctness will likely want to watch
      this. Potentially a -stable candidate eventually.
      Originally-suggested-by: NRichard Cochran <richardcochran@gmail.com>
      Reported-by: NDaniel Bristot de Oliveira <bristot@redhat.com>
      Reported-by: NPrarit Bhargava <prarit@redhat.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jiri Bohac <jbohac@suse.cz>
      Cc: Shuah Khan <shuahkh@osg.samsung.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1434063297-28657-4-git-send-email-john.stultz@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      833f32d7
    • J
      ntp: Introduce and use SECS_PER_DAY macro instead of 86400 · 90bf361c
      John Stultz 提交于
      Currently the leapsecond logic uses what looks like magic values.
      
      Improve this by defining SECS_PER_DAY and using that macro
      to make the logic more clear.
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Daniel Bristot de Oliveira <bristot@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Jiri Bohac <jbohac@suse.cz>
      Cc: Ingo Molnar <mingo@kernel.org>
      Link: http://lkml.kernel.org/r/1434063297-28657-3-git-send-email-john.stultz@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      90bf361c
    • J
      time: Move clock_was_set_seq update before updating shadow-timekeeper · d1518326
      John Stultz 提交于
      It was reported that 868a3e91 (hrtimer: Make offset
      update smarter) was causing timer problems after suspend/resume.
      
      The problem with that change is the modification to
      clock_was_set_seq in timekeeping_update is done prior to
      mirroring the time state to the shadow-timekeeper. Thus the
      next time we do update_wall_time() the updated sequence is
      overwritten by whats in the shadow copy.
      
      This patch moves the shadow-timekeeper mirroring to the end
      of the function, after all updates have been made, so all data
      is kept in sync.
      
      (This patch also affects the update_fast_timekeeper calls which
      were also problematically done prior to the mirroring).
      Reported-and-tested-by: NJeremiah Mahler <jmmahler@gmail.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Cc: Marcelo Tosatti <mtosatti@redhat.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Link: http://lkml.kernel.org/r/1434063297-28657-2-git-send-email-john.stultz@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      d1518326
  3. 10 6月, 2015 3 次提交
  4. 08 6月, 2015 1 次提交
  5. 02 6月, 2015 17 次提交
  6. 27 5月, 2015 1 次提交
  7. 23 5月, 2015 7 次提交
  8. 19 5月, 2015 5 次提交
    • T
      jiffies: Remove the extra indentation level · 4e3d9cb0
      Thomas Gleixner 提交于
      Somehow I missed to clean that up when applying the patches. Fix it up
      now.
      Reported-by: NJoe Perches <joe@perches.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Nicholas Mc Guire <der.herr@hofr.at>
      4e3d9cb0
    • V
      clockevents: Stop unused clockevent devices · d2540875
      Viresh Kumar 提交于
      To avoid getting spurious interrupts on a tickless CPU, clockevent
      device can now be stopped by switching to ONESHOT_STOPPED state.
      
      The natural place for handling this transition is tick_program_event().
      
      On 'expires == KTIME_MAX', we skip programming the event and so we need
      to fix such call sites as well, to always call tick_program_event()
      irrespective of the expires value.
      
      Once the clockevent device is required again, check if it was earlier
      put into ONESHOT_STOPPED state. If yes, switch its state to ONESHOT
      before programming its event.
      
      To make sure we haven't missed any corner case, add a WARN() for the
      case where we try to reprogram clockevent device while we aren't
      configured in ONESHOT_STOPPED state.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Cc: linaro-kernel@lists.linaro.org
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kevin Hilman <khilman@linaro.org>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/5146b07be7f0bc497e0ebae036590ec2fa73e540.1428031396.git.viresh.kumar@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      d2540875
    • V
      clockevents: Introduce CLOCK_EVT_STATE_ONESHOT_STOPPED state · 8fff52fd
      Viresh Kumar 提交于
      When no timers/hrtimers are pending, the expiry time is set to a
      special value: 'KTIME_MAX'. This normally happens with
      NO_HZ_{IDLE|FULL} in both LOWRES/HIGHRES modes.
      
      When 'expiry == KTIME_MAX', we either cancel the 'tick-sched' hrtimer
      (NOHZ_MODE_HIGHRES) or skip reprogramming clockevent device
      (NOHZ_MODE_LOWRES).  But, the clockevent device is already
      reprogrammed from the tick-handler for next tick.
      
      As the clock event device is programmed in ONESHOT mode it will at
      least fire one more time (unnecessarily). Timers on few
      implementations (like arm_arch_timer, etc.) only support PERIODIC mode
      and their drivers emulate ONESHOT over that. Which means that on these
      platforms we will get spurious interrupts periodically (at last
      programmed interval rate, normally tick rate).
      
      In order to avoid spurious interrupts, the clockevent device should be
      stopped or its interrupts should be masked.
      
      A simple (yet hacky) solution to get this fixed could be: update
      hrtimer_force_reprogram() to always reprogram clockevent device and
      update clockevent drivers to STOP generating events (or delay it to
      max time) when 'expires' is set to KTIME_MAX. But the drawback here is
      that every clockevent driver has to be hacked for this particular case
      and its very easy for new ones to miss this.
      
      However, Thomas suggested to add an optional state ONESHOT_STOPPED to
      solve this problem: lkml.org/lkml/2014/5/9/508.
      
      This patch adds support for ONESHOT_STOPPED state in clockevents
      core. It will only be available to drivers that implement the
      state-specific callbacks instead of the legacy ->set_mode() callback.
      Signed-off-by: NViresh Kumar <viresh.kumar@linaro.org>
      Reviewed-by: NPreeti U. Murthy <preeti@linux.vnet.ibm.com>
      Cc: linaro-kernel@lists.linaro.org
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Kevin Hilman <khilman@linaro.org>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lkml.kernel.org/r/b8b383a03ac07b13312c16850b5106b82e4245b5.1428031396.git.viresh.kumar@linaro.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      8fff52fd
    • T
      Merge branch 'linus' into timers/core · c3b5d3ce
      Thomas Gleixner 提交于
      Make sure the upstream fixes are applied before adding further
      modifications.
      c3b5d3ce
    • N
      time: Allow gcc to fold constants when possible · daa67b4b
      Nicholas Mc Guire 提交于
      To allow constant folding in msecs_to_jiffies() conditionally calls
      the HZ dependent _msecs_to_jiffies() helpers or, when gcc can not
      figure out constant folding, __msecs_to_jiffies which is the renamed
      original msecs_to_jiffies() function.
      Signed-off-by: NNicholas Mc Guire <hofrat@osadl.org>
      Cc: Masahiro Yamada <yamada.m@jp.panasonic.com>
      Cc: Sam Ravnborg <sam@ravnborg.org>
      Cc: Joe Perches <joe@perches.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Andrew Hunter <ahh@google.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Michal Marek <mmarek@suse.cz>
      Link: http://lkml.kernel.org/r/1431951554-5563-3-git-send-email-hofrat@osadl.orgSigned-off-by: NThomas Gleixner <tglx@linutronix.de>
      daa67b4b