1. 03 6月, 2017 1 次提交
  2. 09 5月, 2017 1 次提交
  3. 01 2月, 2017 1 次提交
  4. 08 10月, 2016 1 次提交
  5. 18 8月, 2015 1 次提交
  6. 05 8月, 2015 1 次提交
  7. 29 7月, 2015 1 次提交
    • F
      jiffies: Remove HZ > USEC_PER_SEC special case · e0758676
      Frederic Weisbecker 提交于
      HZ never goes much further 1000 and a bit. And if we ever reach one tick
      per microsecond, we might be having a problem.
      
      Lets stop maintaining this special case, just leave a paranoid check.
      Reviewed-by: NRik van Riel <riel@redhat.com>
      Cc: Christoph Lameter <cl@linux.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc; John Stultz <john.stultz@linaro.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Preeti U Murthy <preeti@linux.vnet.ibm.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Viresh Kumar <viresh.kumar@linaro.org>
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      e0758676
  8. 10 6月, 2015 2 次提交
  9. 19 5月, 2015 3 次提交
  10. 13 9月, 2014 1 次提交
    • A
      jiffies: Fix timeval conversion to jiffies · d78c9300
      Andrew Hunter 提交于
      timeval_to_jiffies tried to round a timeval up to an integral number
      of jiffies, but the logic for doing so was incorrect: intervals
      corresponding to exactly N jiffies would become N+1. This manifested
      itself particularly repeatedly stopping/starting an itimer:
      
      setitimer(ITIMER_PROF, &val, NULL);
      setitimer(ITIMER_PROF, NULL, &val);
      
      would add a full tick to val, _even if it was exactly representable in
      terms of jiffies_ (say, the result of a previous rounding.)  Doing
      this repeatedly would cause unbounded growth in val.  So fix the math.
      
      Here's what was wrong with the conversion: we essentially computed
      (eliding seconds)
      
      jiffies = usec  * (NSEC_PER_USEC/TICK_NSEC)
      
      by using scaling arithmetic, which took the best approximation of
      NSEC_PER_USEC/TICK_NSEC with denominator of 2^USEC_JIFFIE_SC =
      x/(2^USEC_JIFFIE_SC), and computed:
      
      jiffies = (usec * x) >> USEC_JIFFIE_SC
      
      and rounded this calculation up in the intermediate form (since we
      can't necessarily exactly represent TICK_NSEC in usec.) But the
      scaling arithmetic is a (very slight) *over*approximation of the true
      value; that is, instead of dividing by (1 usec/ 1 jiffie), we
      effectively divided by (1 usec/1 jiffie)-epsilon (rounding
      down). This would normally be fine, but we want to round timeouts up,
      and we did so by adding 2^USEC_JIFFIE_SC - 1 before the shift; this
      would be fine if our division was exact, but dividing this by the
      slightly smaller factor was equivalent to adding just _over_ 1 to the
      final result (instead of just _under_ 1, as desired.)
      
      In particular, with HZ=1000, we consistently computed that 10000 usec
      was 11 jiffies; the same was true for any exact multiple of
      TICK_NSEC.
      
      We could possibly still round in the intermediate form, adding
      something less than 2^USEC_JIFFIE_SC - 1, but easier still is to
      convert usec->nsec, round in nanoseconds, and then convert using
      time*spec*_to_jiffies.  This adds one constant multiplication, and is
      not observably slower in microbenchmarks on recent x86 hardware.
      
      Tested: the following program:
      
      int main() {
        struct itimerval zero = {{0, 0}, {0, 0}};
        /* Initially set to 10 ms. */
        struct itimerval initial = zero;
        initial.it_interval.tv_usec = 10000;
        setitimer(ITIMER_PROF, &initial, NULL);
        /* Save and restore several times. */
        for (size_t i = 0; i < 10; ++i) {
          struct itimerval prev;
          setitimer(ITIMER_PROF, &zero, &prev);
          /* on old kernels, this goes up by TICK_USEC every iteration */
          printf("previous value: %ld %ld %ld %ld\n",
                 prev.it_interval.tv_sec, prev.it_interval.tv_usec,
                 prev.it_value.tv_sec, prev.it_value.tv_usec);
          setitimer(ITIMER_PROF, &prev, NULL);
        }
          return 0;
      }
      
      Cc: stable@vger.kernel.org
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Paul Turner <pjt@google.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Reviewed-by: NPaul Turner <pjt@google.com>
      Reported-by: NAaron Jacobs <jacobsa@google.com>
      Signed-off-by: NAndrew Hunter <ahh@google.com>
      [jstultz: Tweaked to apply to 3.17-rc]
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      d78c9300
  11. 16 1月, 2014 1 次提交
    • K
      sched/nohz: Fix overflow error in scheduler_tick_max_deferment() · 8fe8ff09
      Kevin Hilman 提交于
      While calculating the scheduler tick max deferment, the delta is
      converted from microseconds to nanoseconds through a multiplication
      against NSEC_PER_USEC.
      
      But this microseconds operand is an unsigned int, thus the result may
      likely overflow. The result is cast to u64 but only once the operation
      is completed, which is too late to avoid overflown result.
      
      This is currently not a problem because the scheduler tick max deferment
      is 1 second. But this may become an issue as we plan to make this
      value tunable.
      
      So lets fix this by casting the usecs value to u64 before multiplying by
      NSECS_PER_USEC.
      
      Also to prevent from this kind of mistake to happen again, move this
      ad-hoc jiffies -> nsecs conversion to a new helper.
      Signed-off-by: NKevin Hilman <khilman@linaro.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Alex Shi <alex.shi@linaro.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Kevin Hilman <khilman@linaro.org>
      Link: http://lkml.kernel.org/r/1387315388-31676-2-git-send-email-khilman@linaro.org
      [move ad-hoc conversion to jiffies_to_nsecs helper]
      Signed-off-by: NFrederic Weisbecker <fweisbec@gmail.com>
      8fe8ff09
  12. 21 8月, 2013 1 次提交
    • P
      jiffies: Avoid undefined behavior from signed overflow · 5a581b36
      Paul E. McKenney 提交于
      According to the C standard 3.4.3p3, overflow of a signed integer results
      in undefined behavior.  This commit therefore changes the definitions
      of time_after(), time_after_eq(), time_after64(), and time_after_eq64()
      to avoid this undefined behavior.  The trick is that the subtraction
      is done using unsigned arithmetic, which according to 6.2.5p9 cannot
      overflow because it is defined as modulo arithmetic.  This has the added
      (though admittedly quite small) benefit of shortening four lines of code
      by four characters each.
      
      Note that the C standard considers the cast from unsigned to
      signed to be implementation-defined, see 6.3.1.3p3.  However, on a
      two's-complement system, an implementation that defines anything other
      than a reinterpretation of the bits is free to come to me, and I will be
      happy to act as a witness for its being committed to an insane asylum.
      (Although I have nothing against saturating arithmetic or signals in some
      cases, these things really should not be the default when compiling an
      operating-system kernel.)
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: Kevin Easton <kevin@guarana.org>
      [ paulmck: Included time_after64() and time_after_eq64(), as suggested
        by Eric Dumazet, also fixed commit message.]
      Reviewed-by: NJosh Triplett <josh@joshtriplett.org>
      5a581b36
  13. 03 7月, 2013 1 次提交
  14. 23 3月, 2013 1 次提交
  15. 14 11月, 2012 1 次提交
  16. 29 9月, 2012 1 次提交
    • A
      time/jiffies: bring back unconditional LATCH definition · 015a830d
      Arnd Bergmann 提交于
      Patch a7ea3bbf "time/jiffies: Allow CLOCK_TICK_RATE to be undefined"
      breaks the compilation of targets that rely on the LATCH definition,
      because of recursive header file inclusion not defining CLOCK_TICK_RATE
      before it is checked here.
      
      This fixes the problem by moving LATCH back to where it was, but it
      seems that there are still cases where SHIFTED_HZ is defined incorrectly
      because of the same problem. Need to investigate further.
      
      Without this patch, building h7201_defconfig results in:
      
      arch/arm/mach-h720x/common.c: In function 'h720x_gettimeoffset':
      arch/arm/mach-h720x/common.c:50:73: error: 'LATCH' undeclared (first use in this function)
      arch/arm/mach-h720x/common.c:50:73: note: each undeclared identifier is reported only once for each function it appears in
      arch/arm/mach-h720x/common.c:51:1: warning: control reaches end of non-void function [-Wreturn-type]
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: John Stultz <john.stultz@linaro.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      015a830d
  17. 25 9月, 2012 2 次提交
    • J
      jiffies: Remove compile time assumptions about CLOCK_TICK_RATE · b3c869d3
      John Stultz 提交于
      CLOCK_TICK_RATE is used to accurately caclulate exactly how
      a tick will be at a given HZ.
      
      This is useful, because while we'd expect NSEC_PER_SEC/HZ,
      the underlying hardware will have some granularity limit,
      so we won't be able to have exactly HZ ticks per second.
      
      This slight error can cause timekeeping quality problems
      when using the jiffies or other jiffies driven clocksources.
      Thus we currently use compile time CLOCK_TICK_RATE value to
      generate SHIFTED_HZ and NSEC_PER_JIFFIES, which we then use
      to adjust the jiffies clocksource to correct this error.
      
      Unfortunately though, since CLOCK_TICK_RATE is a compile
      time value, and the jiffies clocksource is registered very
      early during boot, there are a number of cases where there
      are different possible hardware timers that have different
      tick rates. This causes problems in cases like ARM where
      there are numerous different types of hardware, each having
      their own compile-time CLOCK_TICK_RATE, making it hard to
      accurately support different hardware with a single kernel.
      
      For the most part, this doesn't matter all that much, as not
      too many systems actually utilize the jiffies or jiffies driven
      clocksource. Usually there are other highres clocksources
      who's granularity error is negligable.
      
      Even so, we have some complicated calcualtions that we do
      everywhere to handle these edge cases.
      
      This patch removes the compile time SHIFTED_HZ value, and
      introduces a register_refined_jiffies() function. This results
      in the default jiffies clock as being assumed a perfect HZ
      freq, and allows archtectures that care about jiffies accuracy
      to call register_refined_jiffies() with the tick rate, specified
      dynamically at boot.
      
      This allows us, where necessary, to not have a compile time
      CLOCK_TICK_RATE constant, simplifies the jiffies code, and
      still provides a way to have an accurate jiffies clock.
      
      NOTE: Since this patch does not add register_refinied_jiffies()
      calls for every arch, it may cause time quality regressions
      in some cases. Its likely these will not be noticable, but
      if they are an issue, adding the following to the end of
      setup_arch() should resolve the regression:
      	register_refinied_jiffies(CLOCK_TICK_RATE)
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      b3c869d3
    • J
      jiffies: Kill unused TICK_USEC_TO_NSEC · 7916a1f1
      John Stultz 提交于
      No one is using TICK_USEC_TO_NSEC, so kill it.
      
      Cc: Catalin Marinas <catalin.marinas@arm.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Richard Cochran <richardcochran@gmail.com>
      Cc: Prarit Bhargava <prarit@redhat.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NJohn Stultz <john.stultz@linaro.org>
      7916a1f1
  18. 10 8月, 2012 1 次提交
    • E
      time: jiffies_delta_to_clock_t() helper to the rescue · a399a805
      Eric Dumazet 提交于
      Various /proc/net files sometimes report crazy timer values, expressed
      in clock_t units.
      
      This happens when an expired timer delta (expires - jiffies) is passed
      to jiffies_to_clock_t().
      
      This function has an overflow in :
      
      return div_u64((u64)x * TICK_NSEC, NSEC_PER_SEC / USER_HZ);
      
      commit cbbc719f (time: Change jiffies_to_clock_t() argument type
      to unsigned long) only got around the problem.
      
      As we cant output negative values in /proc/net/tcp without breaking
      various tools, I suggest adding a jiffies_delta_to_clock_t() wrapper
      that caps the negative delta to a 0 value.
      Signed-off-by: NEric Dumazet <edumazet@google.com>
      Reported-by: NMaciej Żenczykowski <maze@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: hank <pyu@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      a399a805
  19. 31 7月, 2012 2 次提交
  20. 21 9月, 2011 1 次提交
  21. 31 3月, 2011 1 次提交
  22. 26 1月, 2011 1 次提交
  23. 26 11月, 2009 1 次提交
    • H
      sched, time: Define nsecs_to_jiffies() · b7b20df9
      Hidetoshi Seto 提交于
      Use of msecs_to_jiffies() for nsecs_to_cputime() have some
      problems:
      
       - The type of msecs_to_jiffies()'s argument is unsigned int, so
         it cannot convert msecs greater than UINT_MAX = about 49.7 days.
      
       - msecs_to_jiffies() returns MAX_JIFFY_OFFSET if MSB of argument
         is set, assuming that input was negative value.  So it cannot
         convert msecs greater than INT_MAX = about 24.8 days too.
      
      This patch defines a new function nsecs_to_jiffies() that can
      deal greater values, and that can deal all incoming values as
      unsigned.
      Signed-off-by: NHidetoshi Seto <seto.hidetoshi@jp.fujitsu.com>
      Acked-by: NPeter Zijlstra <peterz@infradead.org>
      Cc: Stanislaw Gruszka <sgruszka@redhat.com>
      Cc: Spencer Candland <spencer@bluehost.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Balbir Singh <balbir@in.ibm.com>
      Cc: Amrico Wang <xiyou.wangcong@gmail.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: John Stultz <johnstul@linux.vnet.ibm.com>
      LKML-Reference: <4B0E16E7.5070307@jp.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      b7b20df9
  24. 24 12月, 2008 1 次提交
    • P
      optimize attribute timeouts for "noac" and "actimeo=0" · 64672d55
      Peter Staubach 提交于
      Hi.
      
      I've been looking at a bugzilla which describes a problem where
      a customer was advised to use either the "noac" or "actimeo=0"
      mount options to solve a consistency problem that they were
      seeing in the file attributes.  It turned out that this solution
      did not work reliably for them because sometimes, the local
      attribute cache was believed to be valid and not timed out.
      (With an attribute cache timeout of 0, the cache should always
      appear to be timed out.)
      
      In looking at this situation, it appears to me that the problem
      is that the attribute cache timeout code has an off-by-one
      error in it.  It is assuming that the cache is valid in the
      region, [read_cache_jiffies, read_cache_jiffies + attrtimeo].  The
      cache should be considered valid only in the region,
      [read_cache_jiffies, read_cache_jiffies + attrtimeo).  With this
      change, the options, "noac" and "actimeo=0", work as originally
      expected.
      
      This problem was previously addressed by special casing the
      attrtimeo == 0 case.  However, since the problem is only an off-
      by-one error, the cleaner solution is address the off-by-one
      error and thus, not require the special case.
      
          Thanx...
      
              ps
      Signed-off-by: NPeter Staubach <staubach@redhat.com>
      Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      64672d55
  25. 01 5月, 2008 1 次提交
    • R
      remove div_long_long_rem · f8bd2258
      Roman Zippel 提交于
      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: NRoman Zippel <zippel@linux-m68k.org>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: john stultz <johnstul@us.ibm.com>
      Cc: Christoph Lameter <clameter@sgi.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f8bd2258
  26. 22 4月, 2008 1 次提交
  27. 21 4月, 2008 1 次提交
  28. 09 2月, 2008 1 次提交
  29. 26 1月, 2008 1 次提交
  30. 17 10月, 2007 1 次提交
  31. 13 10月, 2007 1 次提交
  32. 10 10月, 2007 1 次提交
    • F
      Re: [NFS] [PATCH] Attribute timeout handling and wrapping u32 jiffies · c7e15961
      Fabio Olive Leite 提交于
      I would like to discuss the idea that the current checks for attribute
      timeout using time_after are inadequate for 32bit architectures, since
      time_after works correctly only when the two timestamps being compared
      are within 2^31 jiffies of each other. The signed overflow caused by
      comparing values more than 2^31 jiffies apart will flip the result,
      causing incorrect assumptions of validity.
      
      2^31 jiffies is a fairly large period of time (~25 days) when compared
      to the lifetime of most kernel data structures, but for long lived NFS
      mounts that can sit idle for months (think that for some reason autofs
      cannot be used), it is easy to compare inode attribute timestamps with
      very disparate or even bogus values (as in when jiffies have wrapped
      many times, where the comparison doesn't even make sense).
      
      Currently the code tests for attribute timeout by simply adding the
      desired amount of jiffies to the stored timestamp and comparing that
      with the current timestamp of obtained attribute data with time_after.
      This is incorrect, as it returns true for the desired timeout period
      and another full 2^31 range of jiffies.
      
      In testing with artificial jumps (several small jumps, not one big
      crank) of the jiffies I was able to reproduce a problem found in a
      server with very long lived NFS mounts, where attributes would not be
      refreshed even after touching files and directories in the server:
      
      Initial uptime:
      03:42:01 up 6 min, 0 users, load average: 0.01, 0.12, 0.07
      
      NFS volume is mounted and time is advanced:
      03:38:09 up 25 days, 2 min, 0 users, load average: 1.22, 1.05, 1.08
      
      # ls -l /local/A/foo/bar /nfs/A/foo/bar
      -rw-r--r--  1 root root 0 Dec 17 03:38 /local/A/foo/bar
      -rw-r--r--  1 root root 0 Nov 22 00:36 /nfs/A/foo/bar
      
      # touch /local/A/foo/bar
      
      # ls -l /local/A/foo/bar /nfs/A/foo/bar
      -rw-r--r--  1 root root 0 Dec 17 03:47 /local/A/foo/bar
      -rw-r--r--  1 root root 0 Nov 22 00:36 /nfs/A/foo/bar
      
      We can see the local mtime is updated, but the NFS mount still shows
      the old value. The patch below makes it work:
      
      Initial setup...
      07:11:02 up 25 days, 1 min,  0 users,  load average: 0.15, 0.03, 0.04
      
      # ls -l /local/A/foo/bar /nfs/A/foo/bar
      -rw-r--r--  1 root root 0 Jan 11 07:11 /local/A/foo/bar
      -rw-r--r--  1 root root 0 Jan 11 07:11 /nfs/A/foo/bar
      
      # touch /local/A/foo/bar
      
      # ls -l /local/A/foo/bar /nfs/A/foo/bar
      -rw-r--r--  1 root root 0 Jan 11 07:14 /local/A/foo/bar
      -rw-r--r--  1 root root 0 Jan 11 07:14 /nfs/A/foo/bar
      Signed-off-by: NFabio Olive Leite <fleite@redhat.com>
      Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
      c7e15961
  33. 17 2月, 2007 2 次提交
  34. 30 11月, 2006 1 次提交