03 May, 2008

1 commit

  • Force constants in kernel/timeconst.h (except shift counts) to be 64 bits,
    using U64_C() constructor macros, and eliminate constants that cannot
    be represented at all in 64 bits. This avoids warnings with some gcc
    versions.

    Drop generating 64-bit constants, since we have no real hope of
    getting a full set (operation on 64-bit values requires a 128-bit
    intermediate result, which gcc only supports on 64-bit platforms, and
    only with libgcc support on some.) Note that the use of these
    constants does not depend on if we are on a 32- or 64-bit architecture.

    This resolves Bugzilla 10153.

    Signed-off-by: H. Peter Anvin

    H. Peter Anvin
     

01 May, 2008

2 commits

  • x86 is the only arch right now, which provides an optimized for
    div_long_long_rem and it has the downside that one has to be very careful that
    the divide doesn't overflow.

    The API is a little akward, as the arguments for the unsigned divide are
    signed. The signed version also doesn't handle a negative divisor and
    produces worse code on 64bit archs.

    There is little incentive to keep this API alive, so this converts the few
    users to the new API.

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

    Roman Zippel
     
  • This converts a few users of do_div to div_[su]64 and this demonstrates nicely
    how it can reduce some expressions to one-liners.

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

    Roman Zippel
     

29 Apr, 2008

1 commit


22 Apr, 2008

1 commit


09 Feb, 2008

2 commits

  • When the conversion factor between jiffies and milli- or microseconds is
    not a single multiply or divide, as for the case of HZ == 300, we currently
    do a multiply followed by a divide. The intervening result, however, is
    subject to overflows, especially since the fraction is not simplified (for
    HZ == 300, we multiply by 300 and divide by 1000).

    This is exposed to the user when passing a large timeout to poll(), for
    example.

    This patch replaces the multiply-divide with a reciprocal multiplication on
    32-bit platforms. When the input is an unsigned long, there is no portable
    way to do this on 64-bit platforms there is no portable way to do this
    since it requires a 128-bit intermediate result (which gcc does support on
    64-bit platforms but may generate libgcc calls, e.g. on 64-bit s390), but
    since the output is a 32-bit integer in the cases affected, just simplify
    the multiply-divide (*3/10 instead of *300/1000).

    The reciprocal multiply used can have off-by-one errors in the upper half
    of the valid output range. This could be avoided at the expense of having
    to deal with a potential 65-bit intermediate result. Since the intent is
    to avoid overflow problems and most of the other time conversions are only
    semiexact, the off-by-one errors were considered an acceptable tradeoff.

    At Ralf Baechle's suggestion, this version uses a Perl script to compute
    the necessary constants. We already have dependencies on Perl for kernel
    compiles. This does, however, require the Perl module Math::BigInt, which
    is included in the standard Perl distribution starting with version 5.8.0.
    In order to support older versions of Perl, include a table of canned
    constants in the script itself, and structure the script so that
    Math::BigInt isn't required if pulling values from said table.

    Running the script requires that the HZ value is available from the
    Makefile. Thus, this patch also adds the Kconfig variable CONFIG_HZ to the
    architectures which didn't already have it (alpha, cris, frv, h8300, m32r,
    m68k, m68knommu, sparc, v850, and xtensa.) It does *not* touch the sh or
    sh64 architectures, since Paul Mundt has dealt with those separately in the
    sh tree.

    Signed-off-by: H. Peter Anvin
    Cc: Ralf Baechle ,
    Cc: Sam Ravnborg ,
    Cc: Paul Mundt ,
    Cc: Richard Henderson ,
    Cc: Michael Starvik ,
    Cc: David Howells ,
    Cc: Yoshinori Sato ,
    Cc: Hirokazu Takata ,
    Cc: Geert Uytterhoeven ,
    Cc: Roman Zippel ,
    Cc: William L. Irwin ,
    Cc: Chris Zankel ,
    Cc: H. Peter Anvin ,
    Cc: Jan Engelhardt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    H. Peter Anvin
     
  • Fix typo in comments.

    BTW: I have to fix coding style in arch/ia64/kernel/time.c also, otherwise
    checkpatch.pl will be complaining.

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

    Li Zefan
     

07 Feb, 2008

2 commits


02 Feb, 2008

1 commit

  • xtime_cache needs to be updated whenever xtime and or wall_to_monotic
    are changed. Otherwise users of xtime_cache might see a stale (and in
    the case of timezone changes utterly wrong) value until the next
    update happens.

    Fixup the obvious places, which miss this update.

    Signed-off-by: Thomas Gleixner
    Acked-by: John Stultz
    Tested-by: Dhaval Giani
    Signed-off-by: Ingo Molnar

    Thomas Gleixner
     

19 Oct, 2007

2 commits

  • Signed-off-by: Daniel Walker
    Cc: Thomas Gleixner
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Daniel Walker
     
  • On platforms that copy sys_tz into the vdso (currently only x86_64, soon to
    include powerpc), it is possible for the vdso to get out of sync if a user
    calls (admittedly unusual) settimeofday(NULL, ptr).

    This patch adds a hook for architectures that set
    CONFIG_GENERIC_TIME_VSYSCALL to ensure when sys_tz is updated they can also
    updatee their copy in the vdso.

    Signed-off-by: Tony Breeds
    Cc: Andi Kleen
    Cc: Tony Luck
    Acked-by: John Stultz
    Cc: Paul Mackerras
    Cc: Benjamin Herrenschmidt
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Tony Breeds
     

17 Oct, 2007

2 commits

  • This patch cleans up duplicate includes in
    kernel/

    Signed-off-by: Jesper Juhl
    Acked-by: Paul E. McKenney
    Reviewed-by: Satyam Sharma
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jesper Juhl
     
  • improve performance of sys_time(). sys_time() returns time in seconds,
    but it does so by calling do_gettimeofday() and then returning the
    tv_sec portion of the GTOD time. But the data structure "xtime", which
    is updated by every timer/scheduler tick, already offers HZ granularity
    time.

    the patch improves the sysbench oltp macrobenchmark by 4-5% on an AMD
    dual-core system:

    v2.6.23:

    #threads

    1: transactions: 4073 (407.23 per sec.)
    2: transactions: 8530 (852.81 per sec.)
    3: transactions: 8321 (831.88 per sec.)
    4: transactions: 8407 (840.58 per sec.)
    5: transactions: 8070 (806.74 per sec.)

    v2.6.23 + sys_time-speedup.patch:

    1: transactions: 4281 (428.09 per sec.)
    2: transactions: 8910 (890.85 per sec.)
    3: transactions: 8659 (865.79 per sec.)
    4: transactions: 8676 (867.34 per sec.)
    5: transactions: 8532 (852.91 per sec.)

    and by 4-5% on an Intel dual-core system too:

    2.6.23:

    1: transactions: 4560 (455.94 per sec.)
    2: transactions: 10094 (1009.30 per sec.)
    3: transactions: 9755 (975.36 per sec.)
    4: transactions: 9859 (985.78 per sec.)
    5: transactions: 9701 (969.72 per sec.)

    2.6.23 + sys_time-speedup.patch:

    1: transactions: 4779 (477.84 per sec.)
    2: transactions: 10103 (1010.14 per sec.)
    3: transactions: 10141 (1013.93 per sec.)
    4: transactions: 10371 (1036.89 per sec.)
    5: transactions: 10178 (1017.50 per sec.)

    (the more CPUs the system has, the more speedup this patch gives for
    this particular workload.)

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

    Ingo Molnar
     

26 Jul, 2007

1 commit

  • This avoids use of the kernel-internal "xtime" variable directly outside
    of the actual time-related functions. Instead, use the helper functions
    that we already have available to us.

    This doesn't actually change any behaviour, but this will allow us to
    fix the fact that "xtime" isn't updated very often with CONFIG_NO_HZ
    (because much of the realtime information is maintained as separate
    offsets to 'xtime'), which has caused interfaces that use xtime directly
    to get a time that is out of sync with the real-time clock by up to a
    third of a second or so.

    Signed-off-by: John Stultz
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Linus Torvalds

    john stultz
     

21 Jul, 2007

2 commits

  • This basically reverts commit 4e44f3497d41db4c3b9051c61410dee8ae4fb49c,
    while waiting for it to be re-done more completely. There are cases of
    people mixing "time()" with higher-resolution time sources, and we need
    to take the nanosecond offsets into account.

    Ingo has a patch that does that, but it's still under some discussion.
    In the meantime, just revert back to the old simple situation of just
    doing the whole exact timesource calculations.

    But rather than using do_gettimeofday(), use the internal nanosecond
    resolution getnstimeofday(), which at least avoids one unnecessary
    conversion (since we really don't care about whether the fractional
    seconds are nanoseconds or microseconds - we'll just throw them away).

    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Remove time_interpolator code (This is generic code, but
    only user was ia64. It has been superseded by the
    CONFIG_GENERIC_TIME code).

    Signed-off-by: Bob Picco
    Signed-off-by: John Stultz
    Signed-off-by: Peter Keilty
    Signed-off-by: Tony Luck

    Bob Picco
     

17 Jul, 2007

1 commit

  • Improve performance of sys_time(). sys_time() returns time in seconds, but
    it does so by calling do_gettimeofday() and then returning the tv_sec
    portion of the GTOD time. But the data structure "xtime", which is updated
    by every timer/scheduler tick, already offers HZ granularity time.

    The patch improves the sysbench OLTP macrobenchmark significantly:

    2.6.22-rc6:

    #threads
    1: transactions: 3733 (373.21 per sec.)
    2: transactions: 6676 (667.46 per sec.)
    3: transactions: 6957 (695.50 per sec.)
    4: transactions: 7055 (705.48 per sec.)
    5: transactions: 6596 (659.33 per sec.)

    2.6.22-rc6 + sys_time.patch:

    1: transactions: 4005 (400.47 per sec.)
    2: transactions: 7379 (737.77 per sec.)
    3: transactions: 7347 (734.49 per sec.)
    4: transactions: 7468 (746.65 per sec.)
    5: transactions: 7428 (742.47 per sec.)

    Mixed API uses of gettimeofday() and time() are guaranteed to be coherent
    via the use of a at-most-once-per-second slowpath that updates xtime.

    [akpm@linux-foundation.org: build fixes]
    Signed-off-by: Ingo Molnar
    Cc: John Stultz
    Cc: Thomas Gleixner
    Cc: Roman Zippel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ingo Molnar
     

09 May, 2007

2 commits

  • Remove includes of where it is not used/needed.
    Suggested by Al Viro.

    Builds cleanly on x86_64, i386, alpha, ia64, powerpc, sparc,
    sparc64, and arm (all 59 defconfigs).

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • The first thing done by timespec_trunc() is :

    if (gran
    imul $0x3e8,%eax,%eax
    cmp %ebx,%eax

    This patch reorders kernel/time.c a bit so that jiffies_to_usecs() is defined
    before timespec_trunc() so that compiler now generates :

    cmp $0x3d0900,%edx (HZ=250 on my machine)

    This gives a better code (timespec_trunc() becoming a leaf function), and
    shorter kernel size as well.

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

    Eric Dumazet
     

26 Apr, 2007

2 commits

  • Change tcp_probe to use ktime (needed to add one export).
    Add option to only get events when cwnd changes - from Doug Leith

    Signed-off-by: Stephen Hemminger
    Signed-off-by: David S. Miller

    Stephen Hemminger
     
  • We currently use a special structure (struct skb_timeval) and plain
    'struct timeval' to store packet timestamps in sk_buffs and struct
    sock.

    This has some drawbacks :
    - Fixed resolution of micro second.
    - Waste of space on 64bit platforms where sizeof(struct timeval)=16

    I suggest using ktime_t that is a nice abstraction of high resolution
    time services, currently capable of nanosecond resolution.

    As sizeof(ktime_t) is 8 bytes, using ktime_t in 'struct sock' permits
    a 8 byte shrink of this structure on 64bit architectures. Some other
    structures also benefit from this size reduction (struct ipq in
    ipv4/ip_fragment.c, struct frag_queue in ipv6/reassembly.c, ...)

    Once this ktime infrastructure adopted, we can more easily provide
    nanosecond resolution on top of it. (ioctl SIOCGSTAMPNS and/or
    SO_TIMESTAMPNS/SCM_TIMESTAMPNS)

    Note : this patch includes a bug correction in
    compat_sock_get_timestamp() where a "err = 0;" was missing (so this
    syscall returned -ENOENT instead of 0)

    Signed-off-by: Eric Dumazet
    CC: Stephen Hemminger
    CC: John find
    Signed-off-by: David S. Miller

    Eric Dumazet
     

05 Apr, 2007

1 commit

  • This patch adds 2 missing symbol exports: jiffies_to_timeval() and
    timeval_to_jiffies(). The (not yet merged) dm-raid4-5 module will need
    them, and they used to be indirectly exported by virtue of being inline
    functions.

    Commit 8b9365d753d9870bb6451504c13570b81923228f ("[PATCH] Uninline
    jiffies.h functions") uninlined them, and thus modules now need them
    explicitly exported to use them.

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

    Thomas Bittermann
     

17 Feb, 2007

2 commits

  • Fix multiple conversion bugs in msecs_to_jiffies().

    The main problem is that this condition:

    if (m > jiffies_to_msecs(MAX_JIFFY_OFFSET))

    overflows if HZ is smaller than 1000!

    This change is user-visible: for HZ=250 SUS-compliant poll()-timeout
    value of -20 is mistakenly converted to 'immediate timeout'.

    (The new dyntick code also triggered this, that's how we noticed.)

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

    Ingo Molnar
     
  • There are loads of fat functions hidden in jiffies.h. Uninline them. No code
    changes.

    [jeremy@goop.org: export fix]
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner
    Cc: john stultz
    Cc: Roman Zippel
    Cc: Jeremy Fitzhardinge
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ingo Molnar
     

01 Oct, 2006

1 commit


27 Jun, 2006

1 commit


01 Apr, 2006

1 commit

  • I was grepping through the code and some `grep ganularity -R .` didn't
    catch what I thought. Then looking closer I saw the term "granuality"
    used in only four places (in comments) and granularity in many more
    places describing the same idea. Some other facts:

    dictionary.com does not know such a word
    define:granuality on google is not found (and pages for granuality are
    mostly related to patches to the kernel)
    it has not been discussed as a term on LKML, AFAICS (=Can Search)

    To be consistent, I think granularity should be used everywhere.

    Signed-off-by: Kalin KOZHUHAROV
    Signed-off-by: Adrian Bunk

    Kalin KOZHUHAROV
     

27 Mar, 2006

1 commit

  • nsec_t predates ktime_t and has mostly been superseded by it. In the few
    places that are left it's better to make it explicit that we're dealing with
    64 bit values here.

    Signed-off-by: Roman Zippel
    Acked-by: Thomas Gleixner
    Acked-by: John Stultz
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Roman Zippel
     

26 Mar, 2006

1 commit

  • This removes the support for pps. It's completely unused within the kernel
    and is basically in the way for further cleanups. It should be easier to
    readd proper support for it after the rest has been converted to NTP4
    (where the pps mechanisms are quite different from NTP3 anyway).

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

    Roman Zippel
     

04 Feb, 2006

1 commit


01 Feb, 2006

1 commit


12 Jan, 2006

1 commit

  • - Move capable() from sched.h to capability.h;

    - Use where capable() is used
    (in include/, block/, ipc/, kernel/, a few drivers/,
    mm/, security/, & sound/;
    many more drivers/ to go)

    Signed-off-by: Randy Dunlap
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy.Dunlap
     

11 Jan, 2006

6 commits


13 Dec, 2005

1 commit

  • There are several functions that might seem appropriate for a timestamp:

    get_cycles()
    current_kernel_time()
    do_gettimeofday()

    Each has problems with combinations of SMP-safety, low resolution, and
    monotonicity. This patch adds a new function that returns a monotonic SMP-safe
    timestamp with nanosecond resolution where available.

    Changes:
    Split timestamp into separate patch
    Moved to kernel/time.c
    Renamed to getnstimestamp
    Fixed unintended-pointer-arithmetic bug

    Signed-off-by: Matt Helsley
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Matt Helsley