13 May, 2015

1 commit

  • It was noted that the 32bit implementation of ktime_divns()
    was doing unsigned division and didn't properly handle
    negative values.

    And when a ktime helper was changed to utilize
    ktime_divns, it caused a regression on some IR blasters.
    See the following bugzilla for details:
    https://bugzilla.redhat.com/show_bug.cgi?id=1200353

    This patch fixes the problem in ktime_divns by checking
    and preserving the sign bit, and then reapplying it if
    appropriate after the division, it also changes the return
    type to a s64 to make it more obvious this is expected.

    Nicolas also pointed out that negative dividers would
    cause infinite loops on 32bit systems, negative dividers
    is unlikely for users of this function, but out of caution
    this patch adds checks for negative dividers for both
    32-bit (BUG_ON) and 64-bit(WARN_ON) versions to make sure
    no such use cases creep in.

    [ tglx: Hand an u64 to do_div() to avoid the compiler warning ]

    Fixes: 166afb64511e 'ktime: Sanitize ktime_to_us/ms conversion'
    Reported-and-tested-by: Trevor Cordes
    Signed-off-by: John Stultz
    Acked-by: Nicolas Pitre
    Cc: Ingo Molnar
    Cc: Josh Boyer
    Cc: One Thousand Gnomes
    Cc:
    Link: http://lkml.kernel.org/r/1431118043-23452-1-git-send-email-john.stultz@linaro.org
    Signed-off-by: Thomas Gleixner

    John Stultz
     

24 Jan, 2015

2 commits


23 Jan, 2015

1 commit

  • This patch adds a reusable time difference function which returns the
    difference in millisecond, as often used in some driver code, e.g.
    mtd/test, media/rc, etc.

    Signed-off-by: Chunyan Zhang
    Acked-by: Arnd Bergmann
    Cc: zhang.lyra@gmail.com
    Cc: davem@davemloft.net
    Cc: john.stultz@linaro.org
    Cc: dborkman@redhat.com
    Link: http://lkml.kernel.org/r/1418793095-18780-1-git-send-email-zhang.chunyan@linaro.org
    Signed-off-by: Thomas Gleixner

    Chunyan Zhang
     

24 Jul, 2014

5 commits

  • Right now we have time related prototypes in 3 different header
    files. Move it to a single timekeeping header file and move the core
    internal stuff into a core private header.

    Signed-off-by: Thomas Gleixner
    Signed-off-by: John Stultz

    Thomas Gleixner
     
  • Helper and conversion functions for timespec64.

    Signed-off-by: John Stultz
    Signed-off-by: Thomas Gleixner
    Signed-off-by: John Stultz

    John Stultz
     
  • In order to support dates past 2038 on 32bit systems, ktime_set()
    needs to handle 64bit second values.

    [ tglx: Removed the BITS_PER_LONG check ]

    Signed-off-by: John Stultz
    Signed-off-by: Thomas Gleixner
    Signed-off-by: John Stultz

    John Stultz
     
  • With the plain nanoseconds based ktime_t we can simply use
    ktime_divns() instead of going through loops and hoops of
    timespec/timeval conversion.

    Reported-by: John Stultz
    Signed-off-by: Thomas Gleixner
    Signed-off-by: John Stultz

    Thomas Gleixner
     
  • The non-scalar ktime_t implementation is basically a timespec
    which has to be changed to support dates past 2038 on 32bit
    systems.

    This patch removes the non-scalar ktime_t implementation, forcing
    the scalar s64 nanosecond version on all architectures.

    This may have additional performance overhead on some 32bit
    systems when converting between ktime_t and timespec structures,
    however the majority of 32bit systems (arm and i386) were already
    using scalar ktime_t, so no performance regressions will be seen
    on those platforms.

    On affected platforms, I'm open to finding optimizations, including
    avoiding converting to timespecs where possible.

    [ tglx: We can now cleanup the ktime_t.tv64 mess, but thats a
    different issue and we can throw a coccinelle script at it ]

    Signed-off-by: John Stultz
    Signed-off-by: Thomas Gleixner
    Signed-off-by: John Stultz

    John Stultz
     

12 Jun, 2014

1 commit


25 Jul, 2013

1 commit

  • When building the htmldocs (in verbose mode), scripts/kernel-doc reports the
    following type of warnings:
    Warning(include/linux/ktime.h:75): No description found for return value of
    'ktime_set'

    Fix them by using a "Return:" section to describe the return values.
    (Also apply some minor reformatting along the way.)

    Signed-off-by: Yacine Belkadi
    Acked-by: Rob Landley
    Signed-off-by: Jiri Kosina

    Yacine Belkadi
     

10 Jul, 2013

1 commit

  • Pull networking updates from David Miller:
    "This is a re-do of the net-next pull request for the current merge
    window. The only difference from the one I made the other day is that
    this has Eliezer's interface renames and the timeout handling changes
    made based upon your feedback, as well as a few bug fixes that have
    trickeled in.

    Highlights:

    1) Low latency device polling, eliminating the cost of interrupt
    handling and context switches. Allows direct polling of a network
    device from socket operations, such as recvmsg() and poll().

    Currently ixgbe, mlx4, and bnx2x support this feature.

    Full high level description, performance numbers, and design in
    commit 0a4db187a999 ("Merge branch 'll_poll'")

    From Eliezer Tamir.

    2) With the routing cache removed, ip_check_mc_rcu() gets exercised
    more than ever before in the case where we have lots of multicast
    addresses. Use a hash table instead of a simple linked list, from
    Eric Dumazet.

    3) Add driver for Atheros CQA98xx 802.11ac wireless devices, from
    Bartosz Markowski, Janusz Dziedzic, Kalle Valo, Marek Kwaczynski,
    Marek Puzyniak, Michal Kazior, and Sujith Manoharan.

    4) Support reporting the TUN device persist flag to userspace, from
    Pavel Emelyanov.

    5) Allow controlling network device VF link state using netlink, from
    Rony Efraim.

    6) Support GRE tunneling in openvswitch, from Pravin B Shelar.

    7) Adjust SOCK_MIN_RCVBUF and SOCK_MIN_SNDBUF for modern times, from
    Daniel Borkmann and Eric Dumazet.

    8) Allow controlling of TCP quickack behavior on a per-route basis,
    from Cong Wang.

    9) Several bug fixes and improvements to vxlan from Stephen
    Hemminger, Pravin B Shelar, and Mike Rapoport. In particular,
    support receiving on multiple UDP ports.

    10) Major cleanups, particular in the area of debugging and cookie
    lifetime handline, to the SCTP protocol code. From Daniel
    Borkmann.

    11) Allow packets to cross network namespaces when traversing tunnel
    devices. From Nicolas Dichtel.

    12) Allow monitoring netlink traffic via AF_PACKET sockets, in a
    manner akin to how we monitor real network traffic via ptype_all.
    From Daniel Borkmann.

    13) Several bug fixes and improvements for the new alx device driver,
    from Johannes Berg.

    14) Fix scalability issues in the netem packet scheduler's time queue,
    by using an rbtree. From Eric Dumazet.

    15) Several bug fixes in TCP loss recovery handling, from Yuchung
    Cheng.

    16) Add support for GSO segmentation of MPLS packets, from Simon
    Horman.

    17) Make network notifiers have a real data type for the opaque
    pointer that's passed into them. Use this to properly handle
    network device flag changes in arp_netdev_event(). From Jiri
    Pirko and Timo Teräs.

    18) Convert several drivers over to module_pci_driver(), from Peter
    Huewe.

    19) tcp_fixup_rcvbuf() can loop 500 times over loopback, just use a
    O(1) calculation instead. From Eric Dumazet.

    20) Support setting of explicit tunnel peer addresses in ipv6, just
    like ipv4. From Nicolas Dichtel.

    21) Protect x86 BPF JIT against spraying attacks, from Eric Dumazet.

    22) Prevent a single high rate flow from overruning an individual cpu
    during RX packet processing via selective flow shedding. From
    Willem de Bruijn.

    23) Don't use spinlocks in TCP md5 signing fast paths, from Eric
    Dumazet.

    24) Don't just drop GSO packets which are above the TBF scheduler's
    burst limit, chop them up so they are in-bounds instead. Also
    from Eric Dumazet.

    25) VLAN offloads are missed when configured on top of a bridge, fix
    from Vlad Yasevich.

    26) Support IPV6 in ping sockets. From Lorenzo Colitti.

    27) Receive flow steering targets should be updated at poll() time
    too, from David Majnemer.

    28) Fix several corner case regressions in PMTU/redirect handling due
    to the routing cache removal, from Timo Teräs.

    29) We have to be mindful of ipv4 mapped ipv6 sockets in
    upd_v6_push_pending_frames(). From Hannes Frederic Sowa.

    30) Fix L2TP sequence number handling bugs, from James Chapman."

    * git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next: (1214 commits)
    drivers/net: caif: fix wrong rtnl_is_locked() usage
    drivers/net: enic: release rtnl_lock on error-path
    vhost-net: fix use-after-free in vhost_net_flush
    net: mv643xx_eth: do not use port number as platform device id
    net: sctp: confirm route during forward progress
    virtio_net: fix race in RX VQ processing
    virtio: support unlocked queue poll
    net/cadence/macb: fix bug/typo in extracting gem_irq_read_clear bit
    Documentation: Fix references to defunct linux-net@vger.kernel.org
    net/fs: change busy poll time accounting
    net: rename low latency sockets functions to busy poll
    bridge: fix some kernel warning in multicast timer
    sfc: Fix memory leak when discarding scattered packets
    sit: fix tunnel update via netlink
    dt:net:stmmac: Add dt specific phy reset callback support.
    dt:net:stmmac: Add support to dwmac version 3.610 and 3.710
    dt:net:stmmac: Allocate platform data only if its NULL.
    net:stmmac: fix memleak in the open method
    ipv6: rt6_check_neigh should successfully verify neigh if no NUD information are available
    net: ipv6: fix wrong ping_v6_sendmsg return value
    ...

    Linus Torvalds
     

26 Jun, 2013

1 commit


29 May, 2013

2 commits

  • The function is currently mainly used in the networking code and
    if others start using it, they must check the result, otherwise
    it cannot be determined if the timespec conversion suceeded.
    Currently no user lacks this check, but make future users aware of
    a possible misusage.

    Signed-off-by: Daniel Borkmann
    Signed-off-by: John Stultz

    Daniel Borkmann
     
  • We've got the macro NSEC_PER_USEC defined in header file
    include/linux/time.h. To make the code decent, this patch
    replaces the immediate number 1000 to convert bewteen a
    time value in microseconds and one in nanoseconds with the
    macro NSEC_PER_USEC.

    Signed-off-by: Liu Ying
    Cc: David S. Miller
    Cc: Daniel Borkmann
    Cc: Thomas Gleixner
    Cc: John Stultz
    Signed-off-by: John Stultz

    Liu Ying
     

20 Apr, 2013

1 commit

  • 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: Daniel Borkmann
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

04 Nov, 2012

1 commit

  • Some years ago, the ktime_t helper functions ktime_now() and ktime_lt()
    have been introduced. Instead of defining them inside pktgen.c, they
    should either use ktime_t library functions or, if not available, they
    should be defined in ktime.h, so that also others can benefit from them.
    ktime_compare() is introduced with a similar notion as in timespec_compare().

    Signed-off-by: Daniel Borkmann
    Cc: Cong Wang
    Cc: Stephen Hemminger
    Cc: Thomas Gleixner
    Acked-by: Thomas Gleixner
    Signed-off-by: David S. Miller

    Daniel Borkmann
     

15 Aug, 2012

1 commit

  • Unexpected behavior could occur if the time is set to a value large
    enough to overflow a 64bit ktime_t (which is something larger then the
    year 2262).

    Also unexpected behavior could occur if large negative offsets are
    injected via adjtimex.

    So this patch improves the sanity check timekeeping inputs by
    improving the timespec_valid() check, and then makes better use of
    timespec_valid() to make sure we don't set the time to an invalid
    negative value or one that overflows ktime_t.

    Note: This does not protect from setting the time close to overflowing
    ktime_t and then letting natural accumulation cause the overflow.

    Reported-by: CAI Qian
    Reported-by: Sasha Levin
    Signed-off-by: John Stultz
    Cc: Peter Zijlstra
    Cc: Prarit Bhargava
    Cc: Zhouping Liu
    Cc: Ingo Molnar
    Cc: stable@vger.kernel.org
    Link: http://lkml.kernel.org/r/1344454580-17031-1-git-send-email-john.stultz@linaro.org
    Signed-off-by: Thomas Gleixner

    John Stultz
     

31 Mar, 2011

1 commit


15 May, 2010

1 commit

  • To report ktime statistics to user space in milliseconds, a new helper
    is required.

    When considering how to do this conversion, I didn't immediately see
    why the extra step of converting ktime to a timeval was needed. To
    make that more clear, introduce a couple of large comments.

    Signed-off-by: Chuck Lever
    Signed-off-by: Trond Myklebust

    Chuck Lever
     

20 Apr, 2008

1 commit


15 Feb, 2008

1 commit

  • Various user space callers ask for relative timeouts. While we fixed
    that overflow issue in hrtimer_start(), the sites which convert
    relative user space values to absolute timeouts themself were uncovered.

    Instead of putting overflow checks into each place add a function
    which does the sanity checking and convert all affected callers to use
    it.

    Thanks to Frans Pop, who reported the problem and tested the fixes.

    Signed-off-by: Thomas Gleixner
    Acked-by: Ingo Molnar
    Tested-by: Frans Pop

    Thomas Gleixner
     

08 Feb, 2008

1 commit

  • Commit ad7f71674ad7c3c4467e48f6ab9e85516dae2720 ("[POWERPC] Use a
    sensible default for clock_getres() in the VDSO") corrected the clock
    resolution reported by the VDSO clock_getres() but introduced another
    problem in that older versions of gcc (gcc-4.0 and earlier) fail to
    compile the new code in arch/powerpc/kernel/asm-offsets.c.

    This fixes it by introducing a new MONOTONIC_RES_NSEC define in the
    generic code which is equivalent to KTIME_MONOTONIC_RES but is just an
    integer constant, not a ktime union.

    Signed-off-by: Tony Breeds
    Signed-off-by: Paul Mackerras
    Signed-off-by: Linus Torvalds

    Tony Breeds
     

11 Oct, 2007

1 commit


11 Jul, 2007

2 commits


16 Jun, 2007

1 commit

  • Commit 164891aadf1721fca4dce473bb0e0998181537c6 broke RTT
    sampling of congestion control modules. Inaccurate timestamps
    could be fed to them without providing any way for them to
    identify such cases. Previously RTT sampler was called only if
    FLAG_RETRANS_DATA_ACKED was not set filtering inaccurate
    timestamps nicely. In addition, the new behavior could give an
    invalid timestamp (zero) to RTT sampler if only skbs with
    TCPCB_RETRANS were ACKed. This solves both problems.

    Signed-off-by: Ilpo Järvinen
    Signed-off-by: David S. Miller

    Ilpo Järvinen
     

10 May, 2007

1 commit

  • Some smarty went and inflicted ktime_t as a typedef upon us, so we cannot
    forward declare it.

    Create a new `union ktime', map ktime_t onto that. Now we need to kill off
    this ktime_t thing.

    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: john stultz
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

26 Apr, 2007

1 commit


17 Mar, 2007

1 commit


17 Feb, 2007

1 commit

  • Implement high resolution timers on top of the hrtimers infrastructure and the
    clockevents / tick-management framework. This provides accurate timers for
    all hrtimer subsystem users.

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Ingo Molnar
    Cc: john stultz
    Cc: Roman Zippel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Gleixner
     

12 Feb, 2007

1 commit

  • A variety of (mostly) innocuous fixes to the embedded kernel-doc content in
    source files, including:

    * make multi-line initial descriptions single line
    * denote some function names, constants and structs as such
    * change erroneous opening '/*' to '/**' in a few places
    * reword some text for clarity

    Signed-off-by: Robert P. J. Day
    Cc: "Randy.Dunlap"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robert P. J. Day
     

08 Dec, 2006

1 commit

  • The 32 bit implementation of ktime_to_ns returns unsigned value, while the
    64 bit version correctly returns an signed value. There is no current user
    affected by this, but it has to be fixed, as ktime values can be negative.

    Pointed-out-by: Helmut Duregger
    Signed-off-by: Thomas Gleixner
    Acked-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Gleixner
     

07 Sep, 2006

1 commit

  • 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 >=
    (MAX_LONG / NSEC_PER_SEC).

    Check the seconds argument to the conversion and limit it to the maximum
    time which can be represented by ktime_t.

    Signed-off-by: Thomas Gleixner
    Cc: Ingo Molnar
    Cc: Frank v Waveren
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Gleixner
     

26 Jun, 2006

1 commit


27 Mar, 2006

1 commit


16 Feb, 2006

1 commit


02 Feb, 2006

1 commit


12 Jan, 2006

1 commit


11 Jan, 2006

1 commit

  • hrtimer subsystem core. It is initialized at bootup and expired by the timer
    interrupt, but is otherwise not utilized by any other subsystem yet.

    Signed-off-by: Thomas Gleixner
    Signed-off-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Thomas Gleixner