Skip to content
Snippets Groups Projects
  1. Aug 12, 2020
  2. Aug 09, 2020
    • Masahiro Yamada's avatar
      kbuild: trace functions in subdirectories of lib/ · b16838c6
      Masahiro Yamada authored
      
      ccflags-remove-$(CONFIG_FUNCTION_TRACER) += $(CC_FLAGS_FTRACE)
      
      exists here in sub-directories of lib/ to keep the behavior of
      commit 2464a609 ("ftrace: do not trace library functions").
      
      Since that commit, not only the objects in lib/ but also the ones in
      the sub-directories are excluded from ftrace (although the commit
      description did not explicitly mention this).
      
      However, most of library functions in sub-directories are not so hot.
      Re-add them to ftrace.
      
      Going forward, only the objects right under lib/ will be excluded.
      
      Cc: Ingo Molnar <mingo@kernel.org>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      b16838c6
    • Masahiro Yamada's avatar
      kbuild: introduce ccflags-remove-y and asflags-remove-y · 15d5761a
      Masahiro Yamada authored
      
      CFLAGS_REMOVE_<file>.o filters out flags when compiling a particular
      object, but there is no convenient way to do that for every object in
      a directory.
      
      Add ccflags-remove-y and asflags-remove-y to make it easily.
      
      Use ccflags-remove-y to clean up some Makefiles.
      
      The add/remove order works as follows:
      
       [1] KBUILD_CFLAGS specifies compiler flags used globally
      
       [2] ccflags-y adds compiler flags for all objects in the
           current Makefile
      
       [3] ccflags-remove-y removes compiler flags for all objects in the
           current Makefile (New feature)
      
       [4] CFLAGS_<file> adds compiler flags per file.
      
       [5] CFLAGS_REMOVE_<file> removes compiler flags per file.
      
      Having [3] before [4] allows us to remove flags from most (but not all)
      objects in the current Makefile.
      
      For example, kernel/trace/Makefile removes $(CC_FLAGS_FTRACE)
      from all objects in the directory, then adds it back to
      trace_selftest_dynamic.o and CFLAGS_trace_kprobe_selftest.o
      
      The same applies to lib/livepatch/Makefile.
      
      Please note ccflags-remove-y has no effect to the sub-directories.
      In contrast, the previous notation got rid of compiler flags also from
      all the sub-directories.
      
      The following are not affected because they have no sub-directories:
      
        arch/arm/boot/compressed/
        arch/powerpc/xmon/
        arch/sh/
        kernel/trace/
      
      However, lib/ has several sub-directories.
      
      To keep the behavior, I added ccflags-remove-y to all Makefiles
      in subdirectories of lib/, except the following:
      
        lib/vdso/Makefile        - Kbuild does not descend into this Makefile
        lib/raid/test/Makefile   - This is not used for the kernel build
      
      I think commit 2464a609 ("ftrace: do not trace library functions")
      excluded too much. In the next commit, I will remove ccflags-remove-y
      from the sub-directories of lib/.
      
      Suggested-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      Acked-by: default avatarSteven Rostedt (VMware) <rostedt@goodmis.org>
      Acked-by: Michael Ellerman <mpe@ellerman.id.au> (powerpc)
      Acked-by: Brendan Higgins <brendanhiggins@google.com> (KUnit)
      Tested-by: default avatarAnders Roxell <anders.roxell@linaro.org>
      15d5761a
  3. Jun 15, 2020
    • Oleg Nesterov's avatar
      sched/cputime: Improve cputime_adjust() · 3dc167ba
      Oleg Nesterov authored
      
      People report that utime and stime from /proc/<pid>/stat become very
      wrong when the numbers are big enough, especially if you watch these
      counters incrementally.
      
      Specifically, the current implementation of: stime*rtime/total,
      results in a saw-tooth function on top of the desired line, where the
      teeth grow in size the larger the values become. IOW, it has a
      relative error.
      
      The result is that, when watching incrementally as time progresses
      (for large values), we'll see periods of pure stime or utime increase,
      irrespective of the actual ratio we're striving for.
      
      Replace scale_stime() with a math64.h helper: mul_u64_u64_div_u64()
      that is far more accurate. This also allows architectures to override
      the implementation -- for instance they can opt for the old algorithm
      if this new one turns out to be too expensive for them.
      
      Signed-off-by: default avatarOleg Nesterov <oleg@redhat.com>
      Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
      Link: https://lkml.kernel.org/r/20200519172506.GA317395@hirez.programming.kicks-ass.net
      3dc167ba
  4. Jun 05, 2020
  5. Jun 02, 2020
  6. Dec 05, 2019
    • Trent Piepho's avatar
      lib/math/rational.c: fix possible incorrect result from rational fractions helper · 323dd2c3
      Trent Piepho authored
      In some cases the previous algorithm would not return the closest
      approximation.  This would happen when a semi-convergent was the
      closest, as the previous algorithm would only consider convergents.
      
      As an example, consider an initial value of 5/4, and trying to find the
      closest approximation with a maximum of 4 for numerator and denominator.
      The previous algorithm would return 1/1 as the closest approximation,
      while this version will return the correct answer of 4/3.
      
      To do this, the main loop performs effectively the same operations as it
      did before.  It must now keep track of the last three approximations,
      n2/d2 ..  n0/d0, while before it only needed the last two.
      
      If an exact answer is not found, the algorithm will now calculate the
      best semi-convergent term, t, which is a single expression with two
      divisions:
      
          min((max_numerator - n0) / n1, (max_denominator - d0) / d1)
      
      This will be used if it is better than previous convergent.  The test
      for this is generally a simple comparison, 2*t > a.  But in an edge
      case, where the convergent's final term is even and the best allowable
      semi-convergent has a final term of exactly half the convergent's final
      term, the more complex comparison (d0*dp > d1*d) is used.
      
      I also wrote some comments explaining the code.  While one still needs
      to look up the math elsewhere, they should help a lot to follow how the
      code relates to that math.
      
      This routine is used in two places in the video4linux code, but in those
      cases it is only used to reduce a fraction to lowest terms, which the
      existing code will do correctly.  This could be done more efficiently
      with a different library routine but it would still be the Euclidean
      alogrithm at its heart.  So no change.
      
      The remain users are places where a fractional PLL divider is
      programmed.  What would happen is something asked for a clock of X MHz
      but instead gets Y MHz, where Y is close to X but not exactly due to the
      hardware limitations.  After this change they might, in some cases, get
      Y' MHz, where Y' is a little closer to X then Y was.
      
      Users like this are: Three UARTs, in 8250_mid, 8250_lpss, and imx.  One
      GPU in vp4_hdmi.  And three clock drivers, clk-cdce706, clk-si5351, and
      clk-fractional-divider.  The last is a generic clock driver and so would
      have more users referenced via device tree entries.
      
      I think there's a bug in that one, it's limiting an N bit field that is
      offset-by-1 to the range 0 ..  (1<<N)-2, when it should be (1<<N)-1 as
      the upper limit.
      
      I have an IMX system, one of the UARTs using this, so I can provide a
      real example.  If I request a custom baud rate of 1499978, the driver
      will program the PLL to produce a baud rate of 1500000.  After this
      change, the fractional divider in the UART is programmed to a ratio of
      65535/65536, which produces a baud rate of 1499977.0625.  Closer to the
      requested value.
      
      Link: http://lkml.kernel.org/r/20190330205855.19396-1-tpiepho@gmail.com
      
      
      Signed-off-by: default avatarTrent Piepho <tpiepho@gmail.com>
      Cc: Oskar Schirmer <oskar@scara.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      323dd2c3
  7. May 21, 2019
  8. May 15, 2019
Loading