1. 12 Jul, 2018 1 commit
  2. 30 Oct, 2017 1 commit
    • Arnd Bergmann's avatar
      time: Move old timekeeping interfaces to timekeeping32.h · 6546911e
      Arnd Bergmann authored
      The interfaces based on 'struct timespec' and 'unsigned long' seconds
      are no longer recommended for new code, and we are trying to migrate to
      ktime_t based interfaces and other y2038-safe variants.
      This moves all the legacy interfaces from linux/timekeeping.h into a
      new timekeeping32.h to better document this.
      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 <stephen.boyd@linaro.org>
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
  3. 26 Jun, 2017 1 commit
  4. 20 Jun, 2017 1 commit
  5. 25 Dec, 2016 2 commits
    • Thomas Gleixner's avatar
      ktime: Get rid of ktime_equal() · 1f3a8e49
      Thomas Gleixner authored
      No point in going through loops and hoops instead of just comparing the
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
    • Thomas Gleixner's avatar
      ktime: Get rid of the union · 2456e855
      Thomas Gleixner authored
      ktime is a union because the initial implementation stored the time in
      scalar nanoseconds on 64 bit machine and in a endianess optimized timespec
      variant for 32bit machines. The Y2038 cleanup removed the timespec variant
      and switched everything to scalar nanoseconds. The union remained, but
      become completely pointless.
      Get rid of the union and just keep ktime_t as simple typedef of type s64.
      The conversion was done with coccinelle and some manual mopping up.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Peter Zijlstra <peterz@infradead.org>
  6. 22 Sep, 2016 1 commit
  7. 31 Aug, 2016 1 commit
    • Vegard Nossum's avatar
      time: Avoid undefined behaviour in ktime_add_safe() · 979515c5
      Vegard Nossum authored
      I ran into this:
          UBSAN: Undefined behaviour in kernel/time/hrtimer.c:310:16
          signed integer overflow:
          9223372036854775807 + 50000 cannot be represented in type 'long long int'
          CPU: 2 PID: 4798 Comm: trinity-c2 Not tainted 4.8.0-rc1+ #91
          Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.9.3-0-ge2fc41e-prebuilt.qemu-project.org 04/01/2014
           0000000000000000 ffff88010ce6fb88 ffffffff82344740 0000000041b58ab3
           ffffffff84f97a20 ffffffff82344694 ffff88010ce6fbb0 ffff88010ce6fb60
           000000000000c350 ffff88010ce6f968 dffffc0000000000 ffffffff857bc320
          Call Trace:
           [<ffffffff82344740>] dump_stack+0xac/0xfc
           [<ffffffff82344694>] ? _atomic_dec_and_lock+0xc4/0xc4
           [<ffffffff8242df78>] ubsan_epilogue+0xd/0x8a
           [<ffffffff8242e6b4>] handle_overflow+0x202/0x23d
           [<ffffffff8242e4b2>] ? val_to_string.constprop.6+0x11e/0x11e
           [<ffffffff8236df71>] ? timerqueue_add+0x151/0x410
           [<ffffffff81485c48>] ? hrtimer_start_range_ns+0x3b8/0x1380
           [<ffffffff81795631>] ? memset+0x31/0x40
           [<ffffffff8242e6fd>] __ubsan_handle_add_overflow+0xe/0x10
           [<ffffffff81488ac9>] hrtimer_nanosleep+0x5d9/0x790
           [<ffffffff814884f0>] ? hrtimer_init_sleeper+0x80/0x80
           [<ffffffff813a9ffb>] ? __might_sleep+0x5b/0x260
           [<ffffffff8148be10>] common_nsleep+0x20/0x30
           [<ffffffff814906c7>] SyS_clock_nanosleep+0x197/0x210
           [<ffffffff81490530>] ? SyS_clock_getres+0x150/0x150
           [<ffffffff823c7113>] ? __this_cpu_preempt_check+0x13/0x20
           [<ffffffff8162ef60>] ? __context_tracking_exit.part.3+0x30/0x1b0
           [<ffffffff81490530>] ? SyS_clock_getres+0x150/0x150
           [<ffffffff81007bd3>] do_syscall_64+0x1b3/0x4b0
           [<ffffffff845f85aa>] entry_SYSCALL64_slow_path+0x25/0x25
      Add a new ktime_add_unsafe() helper which doesn't check for overflow, but
      doesn't throw a UBSAN warning when it does overflow either.
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Signed-off-by: default avatarVegard Nossum <vegard.nossum@oracle.com>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
  8. 13 May, 2015 1 commit
  9. 24 Jan, 2015 1 commit
    • Nicolas Pitre's avatar
      ktime: Optimize ktime_divns for constant divisors · 8b618628
      Nicolas Pitre authored
      At least on ARM, do_div() is optimized to turn constant divisors into
      an inline multiplication by the reciprocal value at compile time.
      However this optimization is missed entirely whenever ktime_divns() is
      used and the slow out-of-line division code is used all the time.
      Let ktime_divns() use do_div() inline whenever the divisor is constant
      and small enough.  This will make things like ktime_to_us() and
      ktime_to_ms() much faster.
      Cc: Arnd Bergmann <arnd.bergmann@linaro.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Nicolas Pitre <nico@linaro.org>
      Acked-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarNicolas Pitre <nico@linaro.org>
      Signed-off-by: default avatarJohn Stultz <john.stultz@linaro.org>
  10. 23 Jan, 2015 1 commit
  11. 23 Jul, 2014 5 commits
  12. 11 Jun, 2014 1 commit
  13. 25 Jul, 2013 1 commit
  14. 25 Jun, 2013 1 commit
  15. 28 May, 2013 2 commits
  16. 19 Apr, 2013 1 commit
    • Daniel Borkmann's avatar
      net: socket: move ktime2ts to ktime header api · 6e94d1ef
      Daniel Borkmann authored
      Currently, ktime2ts is a small helper function that is only used in
      net/socket.c. Move this helper into the ktime API as a small inline
      function, so that i) it's maintained together with ktime routines,
      and ii) also other files can make use of it. The function is named
      ktime_to_timespec_cond() and placed into the generic part of ktime,
      since we internally make use of ktime_to_timespec(). ktime_to_timespec()
      itself does not check the ktime variable for zero, hence, we name
      this function ktime_to_timespec_cond() for only a conditional
      conversion, and adapt its users to it.
      Signed-off-by: default avatarDaniel Borkmann <dborkman@redhat.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  17. 03 Nov, 2012 1 commit
  18. 15 Aug, 2012 1 commit
  19. 31 Mar, 2011 1 commit
  20. 14 May, 2010 1 commit
  21. 19 Apr, 2008 1 commit
  22. 14 Feb, 2008 1 commit
  23. 07 Feb, 2008 1 commit
  24. 10 Oct, 2007 1 commit
  25. 11 Jul, 2007 2 commits
  26. 15 Jun, 2007 1 commit
  27. 09 May, 2007 1 commit
  28. 26 Apr, 2007 1 commit
  29. 17 Mar, 2007 1 commit
  30. 16 Feb, 2007 1 commit
  31. 11 Feb, 2007 1 commit
  32. 07 Dec, 2006 1 commit
  33. 06 Sep, 2006 1 commit
    • Thomas Gleixner's avatar
      [PATCH] prevent timespec/timeval to ktime_t overflow · 96dd7421
      Thomas Gleixner authored
      Frank v.  Waveren pointed out that on 64bit machines the timespec to
      ktime_t conversion might overflow.  This is also true for timeval to
      ktime_t conversions.  This breaks a "sleep inf" on 64bit machines.
      While a timespec/timeval with tx.sec = MAX_LONG is valid by specification
      the internal representation of ktime_t is based on nanoseconds.  The
      conversion of seconds to nanoseconds overflows for seconds values >=
      Check the seconds argument to the conversion and limit it to the maximum
      time which can be represented by ktime_t.
      Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Frank v Waveren <fvw@var.cx>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>