1. 27 4月, 2019 1 次提交
    • C
      timers/sched_clock: Prevent generic sched_clock wrap caused by tick_freeze() · cd37fd46
      Chang-An Chen 提交于
      commit 3f2552f7e9c5abef2775c53f7af66532f8bf65bc upstream.
      
      tick_freeze() introduced by suspend-to-idle in commit 124cf911 ("PM /
      sleep: Make it possible to quiesce timers during suspend-to-idle") uses
      timekeeping_suspend() instead of syscore_suspend() during
      suspend-to-idle. As a consequence generic sched_clock will keep going
      because sched_clock_suspend() and sched_clock_resume() are not invoked
      during suspend-to-idle which can result in a generic sched_clock wrap.
      
      On a ARM system with suspend-to-idle enabled, sched_clock is registered
      as "56 bits at 13MHz, resolution 76ns, wraps every 4398046511101ns", which
      means the real wrapping duration is 8796093022202ns.
      
      [  134.551779] suspend-to-idle suspend (timekeeping_suspend())
      [ 1204.912239] suspend-to-idle resume (timekeeping_resume())
      ......
      [ 1206.912239] suspend-to-idle suspend (timekeeping_suspend())
      [ 5880.502807] suspend-to-idle resume (timekeeping_resume())
      ......
      [ 6000.403724] suspend-to-idle suspend (timekeeping_suspend())
      [ 8035.753167] suspend-to-idle resume  (timekeeping_resume())
      ......
      [ 8795.786684] (2)[321:charger_thread]......
      [ 8795.788387] (2)[321:charger_thread]......
      [    0.057226] (0)[0:swapper/0]......
      [    0.061447] (2)[0:swapper/2]......
      
      sched_clock was not stopped during suspend-to-idle, and sched_clock_poll
      hrtimer was not expired because timekeeping_suspend() was invoked during
      suspend-to-idle. It makes sched_clock wrap at kernel time 8796s.
      
      To prevent this, invoke sched_clock_suspend() and sched_clock_resume() in
      tick_freeze() together with timekeeping_suspend() and timekeeping_resume().
      
      Fixes: 124cf911 (PM / sleep: Make it possible to quiesce timers during suspend-to-idle)
      Signed-off-by: NChang-An Chen <chang-an.chen@mediatek.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Matthias Brugger <matthias.bgg@gmail.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Corey Minyard <cminyard@mvista.com>
      Cc: <linux-mediatek@lists.infradead.org>
      Cc: <linux-arm-kernel@lists.infradead.org>
      Cc: Stanley Chu <stanley.chu@mediatek.com>
      Cc: <kuohong.wang@mediatek.com>
      Cc: <freddy.hsin@mediatek.com>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/1553828349-8914-1-git-send-email-chang-an.chen@mediatek.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      cd37fd46
  2. 17 4月, 2019 1 次提交
  3. 13 2月, 2019 1 次提交
  4. 31 1月, 2019 1 次提交
    • T
      posix-cpu-timers: Unbreak timer rearming · 21c0d162
      Thomas Gleixner 提交于
      commit 93ad0fc088c5b4631f796c995bdd27a082ef33a6 upstream.
      
      The recent commit which prevented a division by 0 issue in the alarm timer
      code broke posix CPU timers as an unwanted side effect.
      
      The reason is that the common rearm code checks for timer->it_interval
      being 0 now. What went unnoticed is that the posix cpu timer setup does not
      initialize timer->it_interval as it stores the interval in CPU timer
      specific storage. The reason for the separate storage is historical as the
      posix CPU timers always had a 64bit nanoseconds representation internally
      while timer->it_interval is type ktime_t which used to be a modified
      timespec representation on 32bit machines.
      
      Instead of reverting the offending commit and fixing the alarmtimer issue
      in the alarmtimer code, store the interval in timer->it_interval at CPU
      timer setup time so the common code check works. This also repairs the
      existing inconistency of the posix CPU timer code which kept a single shot
      timer armed despite of the interval being 0.
      
      The separate storage can be removed in mainline, but that needs to be a
      separate commit as the current one has to be backported to stable kernels.
      
      Fixes: 0e334db6bb4b ("posix-timers: Fix division by zero bug")
      Reported-by: NH.J. Lu <hjl.tools@gmail.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: stable@vger.kernel.org
      Link: https://lkml.kernel.org/r/20190111133500.840117406@linutronix.deSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      21c0d162
  5. 29 12月, 2018 1 次提交
  6. 07 9月, 2018 1 次提交
  7. 13 8月, 2018 1 次提交
    • H
      parisc: Drop architecture-specific ENOTSUP define · 93cb8e20
      Helge Deller 提交于
      parisc is the only Linux architecture which has defined a value for ENOTSUP.
      All other architectures #define ENOTSUP as EOPNOTSUPP in their libc headers.
      
      Having an own value for ENOTSUP which is different than EOPNOTSUPP often gives
      problems with userspace programs which expect both to be the same.  One such
      example is a build error in the libuv package, as can be seen in
      https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=900237.
      
      Since we dropped HP-UX support, there is no real benefit in keeping an own
      value for ENOTSUP. This patch drops the parisc value for ENOTSUP from the
      kernel sources. glibc needs no patch, it reuses the exported headers.
      Signed-off-by: NHelge Deller <deller@gmx.de>
      93cb8e20
  8. 02 8月, 2018 3 次提交
  9. 01 8月, 2018 1 次提交
  10. 31 7月, 2018 1 次提交
  11. 21 7月, 2018 3 次提交
    • E
      signal: Pass pid and pid type into send_sigqueue · 24122c7f
      Eric W. Biederman 提交于
      Make the code more maintainable by performing more of the signal
      related work in send_sigqueue.
      
      A quick inspection of do_timer_create will show that this code path
      does not lookup a thread group by a thread's pid.  Making it safe
      to find the task pointed to by it_pid with "pid_task(it_pid, type)";
      
      This supports the changes needed in fork to tell if a signal was sent
      to a single process or a group of processes.
      
      Having the pid to task transition in signal.c will also make it easier
      to sort out races with de_thread and and the thread group leader
      exiting when it comes time to address that.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      24122c7f
    • E
      posix-timers: Noralize good_sigevent · 2118e1f5
      Eric W. Biederman 提交于
      In good_sigevent directly compute the default return value as
      "task_tgid(current)".  This is exactly the same as
      "task_pid(current->group_leader)" but written more clearly.
      
      In the thread case first compute the thread's pid.  Then veify that
      attached to that pid is a thread of the current thread group.
      
      This has the net effect of making the code a little clearer, and
      making it obvious that posix timers never look up a process by a the
      pid of a thread.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      2118e1f5
    • E
      pid: Implement PIDTYPE_TGID · 6883f81a
      Eric W. Biederman 提交于
      Everywhere except in the pid array we distinguish between a tasks pid and
      a tasks tgid (thread group id).  Even in the enumeration we want that
      distinction sometimes so we have added __PIDTYPE_TGID.  With leader_pid
      we almost have an implementation of PIDTYPE_TGID in struct signal_struct.
      
      Add PIDTYPE_TGID as a first class member of the pid_type enumeration and
      into the pids array.  Then remove the __PIDTYPE_TGID special case and the
      leader_pid in signal_struct.
      
      The net size increase is just an extra pointer added to struct pid and
      an extra pair of pointers of an hlist_node added to task_struct.
      
      The effect on code maintenance is the removal of a number of special
      cases today and the potential to remove many more special cases as
      PIDTYPE_TGID gets used to it's fullest.  The long term potential
      is allowing zombie thread group leaders to exit, which will remove
      a lot more special cases in the code.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      6883f81a
  12. 20 7月, 2018 8 次提交
    • B
      time: Introduce one suspend clocksource to compensate the suspend time · 39232ed5
      Baolin Wang 提交于
      On some hardware with multiple clocksources, we have coarse grained
      clocksources that support the CLOCK_SOURCE_SUSPEND_NONSTOP flag, but
      which are less than ideal for timekeeping whereas other clocksources
      can be better candidates but halt on suspend.
      
      Currently, the timekeeping core only supports timing suspend using
      CLOCK_SOURCE_SUSPEND_NONSTOP clocksources if that clocksource is the
      current clocksource for timekeeping.
      
      As a result, some architectures try to implement read_persistent_clock64()
      using those non-stop clocksources, but isn't really ideal, which will
      introduce more duplicate code. To fix this, provide logic to allow a
      registered SUSPEND_NONSTOP clocksource, which isn't the current
      clocksource, to be used to calculate the suspend time.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Miroslav Lichvar <mlichvar@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Cc: Daniel Lezcano <daniel.lezcano@linaro.org>
      Reviewed-by: NThomas Gleixner <tglx@linutronix.de>
      Reviewed-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
      Suggested-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NBaolin Wang <baolin.wang@linaro.org>
      [jstultz: minor tweaks to merge with previous resume changes]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      39232ed5
    • M
      time: Fix extra sleeptime injection when suspend fails · f473e5f4
      Mukesh Ojha 提交于
      Currently, there exists a corner case assuming when there is
      only one clocksource e.g RTC, and system failed to go to
      suspend mode. While resume rtc_resume() injects the sleeptime
      as timekeeping_rtc_skipresume() returned 'false' (default value
      of sleeptime_injected) due to which we can see mismatch in
      timestamps.
      
      This issue can also come in a system where more than one
      clocksource are present and very first suspend fails.
      
      Success case:
      ------------
                                              {sleeptime_injected=false}
      rtc_suspend() => timekeeping_suspend() => timekeeping_resume() =>
      
      (sleeptime injected)
       rtc_resume()
      
      Failure case:
      ------------
               {failure in sleep path} {sleeptime_injected=false}
      rtc_suspend()     =>          rtc_resume()
      
      {sleeptime injected again which was not required as the suspend failed}
      
      Fix this by handling the boolean logic properly.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Miroslav Lichvar <mlichvar@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Originally-by: NThomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NMukesh Ojha <mojha@codeaurora.org>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      f473e5f4
    • O
      timekeeping/ntp: Constify some function arguments · 985e6950
      Ondrej Mosnacek 提交于
      Add 'const' to some function arguments and variables to make it easier
      to read the code.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Miroslav Lichvar <mlichvar@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      [jstultz: Also fixup pre-existing checkpatch warnings for
       prototype arguments with no variable name]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      985e6950
    • P
      sched/clock: Move sched clock initialization and merge with generic clock · 5d2a4e91
      Pavel Tatashin 提交于
      sched_clock_postinit() initializes a generic clock on systems where no
      other clock is provided. This function may be called only after
      timekeeping_init().
      
      Rename sched_clock_postinit to generic_clock_inti() and call it from
      sched_clock_init(). Move the call for sched_clock_init() until after
      time_init().
      Suggested-by: NPeter Zijlstra <peterz@infradead.org>
      Signed-off-by: NPavel Tatashin <pasha.tatashin@oracle.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: steven.sistare@oracle.com
      Cc: daniel.m.jordan@oracle.com
      Cc: linux@armlinux.org.uk
      Cc: schwidefsky@de.ibm.com
      Cc: heiko.carstens@de.ibm.com
      Cc: john.stultz@linaro.org
      Cc: sboyd@codeaurora.org
      Cc: hpa@zytor.com
      Cc: douly.fnst@cn.fujitsu.com
      Cc: prarit@redhat.com
      Cc: feng.tang@intel.com
      Cc: pmladek@suse.com
      Cc: gnomes@lxorguk.ukuu.org.uk
      Cc: linux-s390@vger.kernel.org
      Cc: boris.ostrovsky@oracle.com
      Cc: jgross@suse.com
      Cc: pbonzini@redhat.com
      Link: https://lkml.kernel.org/r/20180719205545.16512-23-pasha.tatashin@oracle.com
      5d2a4e91
    • P
      timekeeping: Default boot time offset to local_clock() · 4b1b7f80
      Pavel Tatashin 提交于
      read_persistent_wall_and_boot_offset() is called during boot to read
      both the persistent clock and also return the offset between the boot time
      and the value of persistent clock.
      
      Change the default boot_offset from zero to local_clock() so architectures,
      that do not have a dedicated boot_clock but have early sched_clock(), such
      as SPARCv9, x86, and possibly more will benefit from this change by getting
      a better and more consistent estimate of the boot time without need for an
      arch specific implementation.
      Signed-off-by: NPavel Tatashin <pasha.tatashin@oracle.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: steven.sistare@oracle.com
      Cc: daniel.m.jordan@oracle.com
      Cc: linux@armlinux.org.uk
      Cc: schwidefsky@de.ibm.com
      Cc: heiko.carstens@de.ibm.com
      Cc: john.stultz@linaro.org
      Cc: sboyd@codeaurora.org
      Cc: hpa@zytor.com
      Cc: douly.fnst@cn.fujitsu.com
      Cc: peterz@infradead.org
      Cc: prarit@redhat.com
      Cc: feng.tang@intel.com
      Cc: pmladek@suse.com
      Cc: gnomes@lxorguk.ukuu.org.uk
      Cc: linux-s390@vger.kernel.org
      Cc: boris.ostrovsky@oracle.com
      Cc: jgross@suse.com
      Cc: pbonzini@redhat.com
      Link: https://lkml.kernel.org/r/20180719205545.16512-17-pasha.tatashin@oracle.com
      4b1b7f80
    • P
      timekeeping: Replace read_boot_clock64() with read_persistent_wall_and_boot_offset() · 3eca9937
      Pavel Tatashin 提交于
      If architecture does not support exact boot time, it is challenging to
      estimate boot time without having a reference to the current persistent
      clock value. Yet, it cannot read the persistent clock time again, because
      this may lead to math discrepancies with the caller of read_boot_clock64()
      who have read the persistent clock at a different time.
      
      This is why it is better to provide two values simultaneously: the
      persistent clock value, and the boot time.
      
      Replace read_boot_clock64() with:
      read_persistent_wall_and_boot_offset(wall_time, boot_offset)
      
      Where wall_time is returned by read_persistent_clock() And boot_offset is
      wall_time - boot time, which defaults to 0.
      Signed-off-by: NPavel Tatashin <pasha.tatashin@oracle.com>
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      Cc: steven.sistare@oracle.com
      Cc: daniel.m.jordan@oracle.com
      Cc: linux@armlinux.org.uk
      Cc: schwidefsky@de.ibm.com
      Cc: heiko.carstens@de.ibm.com
      Cc: john.stultz@linaro.org
      Cc: sboyd@codeaurora.org
      Cc: hpa@zytor.com
      Cc: douly.fnst@cn.fujitsu.com
      Cc: peterz@infradead.org
      Cc: prarit@redhat.com
      Cc: feng.tang@intel.com
      Cc: pmladek@suse.com
      Cc: gnomes@lxorguk.ukuu.org.uk
      Cc: linux-s390@vger.kernel.org
      Cc: boris.ostrovsky@oracle.com
      Cc: jgross@suse.com
      Cc: pbonzini@redhat.com
      Link: https://lkml.kernel.org/r/20180719205545.16512-16-pasha.tatashin@oracle.com
      3eca9937
    • O
      ntp: Use kstrtos64 for s64 variable · 86b2dcd4
      Ondrej Mosnacek 提交于
      ...instead of kstrtol with a dirty cast.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Miroslav Lichvar <mlichvar@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      86b2dcd4
    • O
      ntp: Remove redundant arguments · 0f9987b6
      Ondrej Mosnacek 提交于
      The 'ts' argument of process_adj_status() and process_adjtimex_modes()
      is unused and can be safely removed.
      
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Miroslav Lichvar <mlichvar@redhat.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Stephen Boyd <sboyd@kernel.org>
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      0f9987b6
  13. 19 7月, 2018 1 次提交
  14. 13 7月, 2018 1 次提交
  15. 11 7月, 2018 2 次提交
  16. 02 7月, 2018 3 次提交
  17. 24 6月, 2018 3 次提交
  18. 22 6月, 2018 1 次提交
  19. 19 6月, 2018 4 次提交
  20. 12 6月, 2018 1 次提交
  21. 27 5月, 2018 1 次提交
    • T
      PM / suspend: Prevent might sleep splats · c1a957d1
      Thomas Gleixner 提交于
      timekeeping suspend/resume calls read_persistent_clock() which takes
      rtc_lock. That results in might sleep warnings because at that point
      we run with interrupts disabled.
      
      We cannot convert rtc_lock to a raw spinlock as that would trigger
      other might sleep warnings.
      
      As a workaround we disable the might sleep warnings by setting
      system_state to SYSTEM_SUSPEND before calling sysdev_suspend() and
      restoring it to SYSTEM_RUNNING afer sysdev_resume(). There is no lock
      contention because hibernate / suspend to RAM is single-CPU at this
      point.
      
      In s2idle's case the system_state is set to SYSTEM_SUSPEND before
      timekeeping_suspend() which is invoked by the last CPU. In the resume
      case it set back to SYSTEM_RUNNING after timekeeping_resume() which is
      invoked by the first CPU in the resume case. The other CPUs will block
      on tick_freeze_lock.
      Signed-off-by: NThomas Gleixner <tglx@linutronix.de>
      [bigeasy: cover s2idle in tick_freeze() / tick_unfreeze()]
      Signed-off-by: NSebastian Andrzej Siewior <bigeasy@linutronix.de>
      Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
      c1a957d1