1. 19 1月, 2015 2 次提交
  2. 18 12月, 2014 1 次提交
  3. 05 6月, 2014 1 次提交
    • J
      compiler.h: avoid sparse errors in __compiletime_error_fallback() · 2c0d259e
      James Hogan 提交于
      Usually, BUG_ON and friends aren't even evaluated in sparse, but recently
      compiletime_assert_atomic_type() was added, and that now results in a
      sparse warning every time it is used.
      
      The reason turns out to be the temporary variable, after it sparse no
      longer considers the value to be a constant, and results in a warning and
      an error.  The error is the more annoying part of this as it suppresses
      any further warnings in the same file, hiding other problems.
      
      Unfortunately the condition cannot be simply expanded out to avoid the
      temporary variable since it breaks compiletime_assert on old versions of
      GCC such as GCC 4.2.4 which the latest metag compiler is based on.
      
      Therefore #ifndef __CHECKER__ out the __compiletime_error_fallback which
      uses the potentially negative size array to trigger a conditional compiler
      error, so that sparse doesn't see it.
      Signed-off-by: NJames Hogan <james.hogan@imgtec.com>
      Cc: Johannes Berg <johannes.berg@intel.com>
      Cc: Daniel Santos <daniel.santos@pobox.com>
      Cc: Luciano Coelho <luciano.coelho@intel.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
      Acked-by: NJohannes Berg <johannes@sipsolutions.net>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2c0d259e
  4. 24 4月, 2014 1 次提交
    • M
      kprobes: Introduce NOKPROBE_SYMBOL() macro to maintain kprobes blacklist · 376e2424
      Masami Hiramatsu 提交于
      Introduce NOKPROBE_SYMBOL() macro which builds a kprobes
      blacklist at kernel build time.
      
      The usage of this macro is similar to EXPORT_SYMBOL(),
      placed after the function definition:
      
        NOKPROBE_SYMBOL(function);
      
      Since this macro will inhibit inlining of static/inline
      functions, this patch also introduces a nokprobe_inline macro
      for static/inline functions. In this case, we must use
      NOKPROBE_SYMBOL() for the inline function caller.
      
      When CONFIG_KPROBES=y, the macro stores the given function
      address in the "_kprobe_blacklist" section.
      
      Since the data structures are not fully initialized by the
      macro (because there is no "size" information),  those
      are re-initialized at boot time by using kallsyms.
      Signed-off-by: NMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
      Link: http://lkml.kernel.org/r/20140417081705.26341.96719.stgit@ltc230.yrl.intra.hitachi.co.jp
      Cc: Alok Kataria <akataria@vmware.com>
      Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Christopher Li <sparse@chrisli.org>
      Cc: Chris Wright <chrisw@sous-sol.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Jan-Simon Möller <dl9pf@gmx.de>
      Cc: Jeremy Fitzhardinge <jeremy@goop.org>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Randy Dunlap <rdunlap@infradead.org>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: linux-arch@vger.kernel.org
      Cc: linux-doc@vger.kernel.org
      Cc: linux-sparse@vger.kernel.org
      Cc: virtualization@lists.linux-foundation.org
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      376e2424
  5. 10 4月, 2014 1 次提交
  6. 12 1月, 2014 1 次提交
    • P
      arch: Introduce smp_load_acquire(), smp_store_release() · 47933ad4
      Peter Zijlstra 提交于
      A number of situations currently require the heavyweight smp_mb(),
      even though there is no need to order prior stores against later
      loads.  Many architectures have much cheaper ways to handle these
      situations, but the Linux kernel currently has no portable way
      to make use of them.
      
      This commit therefore supplies smp_load_acquire() and
      smp_store_release() to remedy this situation.  The new
      smp_load_acquire() primitive orders the specified load against
      any subsequent reads or writes, while the new smp_store_release()
      primitive orders the specifed store against any prior reads or
      writes.  These primitives allow array-based circular FIFOs to be
      implemented without an smp_mb(), and also allow a theoretical
      hole in rcu_assign_pointer() to be closed at no additional
      expense on most architectures.
      
      In addition, the RCU experience transitioning from explicit
      smp_read_barrier_depends() and smp_wmb() to rcu_dereference()
      and rcu_assign_pointer(), respectively resulted in substantial
      improvements in readability.  It therefore seems likely that
      replacing other explicit barriers with smp_load_acquire() and
      smp_store_release() will provide similar benefits.  It appears
      that roughly half of the explicit barriers in core kernel code
      might be so replaced.
      
      [Changelog by PaulMck]
      Reviewed-by: N"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Signed-off-by: NPeter Zijlstra <peterz@infradead.org>
      Acked-by: NWill Deacon <will.deacon@arm.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
      Cc: Michael Ellerman <michael@ellerman.id.au>
      Cc: Michael Neuling <mikey@neuling.org>
      Cc: Russell King <linux@arm.linux.org.uk>
      Cc: Geert Uytterhoeven <geert@linux-m68k.org>
      Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
      Cc: Victor Kaplansky <VICTORK@il.ibm.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Link: http://lkml.kernel.org/r/20131213150640.908486364@infradead.orgSigned-off-by: NIngo Molnar <mingo@kernel.org>
      47933ad4
  7. 05 12月, 2013 1 次提交
    • C
      crypto: more robust crypto_memneq · fe8c8a12
      Cesar Eduardo Barros 提交于
      Disabling compiler optimizations can be fragile, since a new
      optimization could be added to -O0 or -Os that breaks the assumptions
      the code is making.
      
      Instead of disabling compiler optimizations, use a dummy inline assembly
      (based on RELOC_HIDE) to block the problematic kinds of optimization,
      while still allowing other optimizations to be applied to the code.
      
      The dummy inline assembly is added after every OR, and has the
      accumulator variable as its input and output. The compiler is forced to
      assume that the dummy inline assembly could both depend on the
      accumulator variable and change the accumulator variable, so it is
      forced to compute the value correctly before the inline assembly, and
      cannot assume anything about its value after the inline assembly.
      
      This change should be enough to make crypto_memneq work correctly (with
      data-independent timing) even if it is inlined at its call sites. That
      can be done later in a followup patch.
      
      Compile-tested on x86_64.
      Signed-off-by: NCesar Eduardo Barros <cesarb@cesarb.eti.br>
      Acked-by: NDaniel Borkmann <dborkman@redhat.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      fe8c8a12
  8. 08 4月, 2013 1 次提交
  9. 22 2月, 2013 3 次提交
    • D
      bug.h, compiler.h: introduce compiletime_assert & BUILD_BUG_ON_MSG · 9a8ab1c3
      Daniel Santos 提交于
      Introduce compiletime_assert to compiler.h, which moves the details of
      how to break a build and emit an error message for a specific compiler
      to the headers where these details should be.  Following in the
      tradition of the POSIX assert macro, compiletime_assert creates a
      build-time error when the supplied condition is *false*.
      
      Next, we add BUILD_BUG_ON_MSG to bug.h which simply wraps
      compiletime_assert, inverting the logic, so that it fails when the
      condition is *true*, consistent with the language "build bug on." This
      macro allows you to specify the error message you want emitted when the
      supplied condition is true.
      
      Finally, we remove all other code from bug.h that mucks with these
      details (BUILD_BUG & BUILD_BUG_ON), and have them all call
      BUILD_BUG_ON_MSG.  This not only reduces source code bloat, but also
      prevents the possibility of code being changed for one macro and not for
      the other (which was previously the case for BUILD_BUG and
      BUILD_BUG_ON).
      
      Since __compiletime_error_fallback is now only used in compiler.h, I'm
      considering it a private macro and removing the double negation that's
      now extraneous.
      
      [akpm@linux-foundation.org: checkpatch fixes]
      Signed-off-by: NDaniel Santos <daniel.santos@pobox.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9a8ab1c3
    • D
      compiler.h, bug.h: prevent double error messages with BUILD_BUG{,_ON} · c361d3e5
      Daniel Santos 提交于
      Prior to the introduction of __attribute__((error("msg"))) in gcc 4.3,
      creating compile-time errors required a little trickery.
      BUILD_BUG{,_ON} uses this attribute when available to generate
      compile-time errors, but also uses the negative-sized array trick for
      older compilers, resulting in two error messages in some cases.  The
      reason it's "some" cases is that as of gcc 4.4, the negative-sized array
      will not create an error in some situations, like inline functions.
      
      This patch replaces the negative-sized array code with the new
      __compiletime_error_fallback() macro which expands to the same thing
      unless the the error attribute is available, in which case it expands to
      do{}while(0), resulting in exactly one compile-time error on all
      versions of gcc.
      
      Note that we are not changing the negative-sized array code for the
      unoptimized version of BUILD_BUG_ON, since it has the potential to catch
      problems that would be disabled in later versions of gcc were
      __compiletime_error_fallback used.  The reason is that that an
      unoptimized build can't always remove calls to an error-attributed
      function call (like we are using) that should effectively become dead
      code if it were optimized.  However, using a negative-sized array with a
      similar value will not result in an false-positive (error).  The only
      caveat being that it will also fail to catch valid conditions, which we
      should be expecting in an unoptimized build anyway.
      Signed-off-by: NDaniel Santos <daniel.santos@pobox.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: David Rientjes <rientjes@google.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      c361d3e5
    • D
      compiler{,-gcc4}.h, bug.h: Remove duplicate macros · 6ae8d048
      Daniel Santos 提交于
      __linktime_error() does the same thing as __compiletime_error() and is
      only used in bug.h.  Since the macro defines a function attribute that
      will cause a failure at compile-time (not link-time), it makes more sense
      to keep __compiletime_error(), which is also neatly mated with
      __compiletime_warning().
      Signed-off-by: NDaniel Santos <daniel.santos@pobox.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Acked-by: NBorislav Petkov <bp@alien8.de>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Joe Perches <joe@perches.com>
      Cc: Josh Triplett <josh@joshtriplett.org>
      Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      6ae8d048
  10. 18 12月, 2012 1 次提交
  11. 14 12月, 2012 1 次提交
    • R
      __UNIQUE_ID() · 6f33d587
      Rusty Russell 提交于
      Jan Beulich points out __COUNTER__ (gcc 4.3 and above), so let's use
      that to create unique ids.  This is better than __LINE__ which we use
      today, so provide a wrapper.
      
      Stanislaw Gruszka <sgruszka@redhat.com> reported that some module parameters
      start with a digit, so we need to prepend when we for the unique id.
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      Acked-by: NJan Beulich <jbeulich@suse.com>
      6f33d587
  12. 18 9月, 2012 1 次提交
  13. 28 2月, 2012 1 次提交
  14. 11 1月, 2012 1 次提交
    • D
      kernel.h: add BUILD_BUG() macro · 1399ff86
      David Daney 提交于
      We can place this in definitions that we expect the compiler to remove by
      dead code elimination.  If this assertion fails, we get a nice error
      message at build time.
      
      The GCC function attribute error("message") was added in version 4.3, so
      we define a new macro __linktime_error(message) to expand to this for
      GCC-4.3 and later.  This will give us an error diagnostic from the
      compiler on the line that fails.  For other compilers
      __linktime_error(message) expands to nothing, and we have to be content
      with a link time error, but at least we will still get a build error.
      
      BUILD_BUG() expands to the undefined function __build_bug_failed() and
      will fail at link time if the compiler ever emits code for it.  On GCC-4.3
      and later, attribute((error())) is used so that the failure will be noted
      at compile time instead.
      Signed-off-by: NDavid Daney <david.daney@cavium.com>
      Acked-by: NDavid Rientjes <rientjes@google.com>
      Cc: DM <dm.n9107@gmail.com>
      Cc: Ralf Baechle <ralf@linux-mips.org>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      1399ff86
  15. 20 8月, 2010 1 次提交
    • P
      rcu: define __rcu address space modifier for sparse · ca5ecddf
      Paul E. McKenney 提交于
      This commit provides definitions for the __rcu annotation defined earlier.
      This annotation permits sparse to check for correct use of RCU-protected
      pointers.  If a pointer that is annotated with __rcu is accessed
      directly (as opposed to via rcu_dereference(), rcu_assign_pointer(),
      or one of their variants), sparse can be made to complain.  To enable
      such complaints, use the new default-disabled CONFIG_SPARSE_RCU_POINTER
      kernel configuration option.  Please note that these sparse complaints are
      intended to be a debugging aid, -not- a code-style-enforcement mechanism.
      
      There are special rcu_dereference_protected() and rcu_access_pointer()
      accessors for use when RCU read-side protection is not required, for
      example, when no other CPU has access to the data structure in question
      or while the current CPU hold the update-side lock.
      
      This patch also updates a number of docbook comments that were showing
      their age.
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NPaul E. McKenney <paulmck@linux.vnet.ibm.com>
      Cc: Christopher Li <sparse@chrisli.org>
      Reviewed-by: NJosh Triplett <josh@joshtriplett.org>
      ca5ecddf
  16. 15 6月, 2010 1 次提交
  17. 05 2月, 2010 1 次提交
  18. 06 12月, 2009 1 次提交
  19. 02 11月, 2009 1 次提交
    • L
      compiler: Introduce __always_unused · 7b2a3513
      Li Zefan 提交于
      I wrote some code which is used as compile-time checker, and the
      code should be elided after compile.
      
      So I need to annotate the code as "always unused", compared to
      "maybe unused".
      Signed-off-by: NLi Zefan <lizf@cn.fujitsu.com>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      LKML-Reference: <4AEE2CEC.8040206@cn.fujitsu.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      7b2a3513
  20. 29 10月, 2009 1 次提交
  21. 03 10月, 2009 1 次提交
    • A
      x86: Add a Kconfig option to turn the copy_from_user warnings into errors · 63312b6a
      Arjan van de Ven 提交于
      For automated testing it is useful to have the option to turn
      the warnings on copy_from_user() etc checks into errors:
      
       In function ‘copy_from_user’,
           inlined from ‘fd_copyin’ at drivers/block/floppy.c:3080,
           inlined from ‘fd_ioctl’ at drivers/block/floppy.c:3503:
         linux/arch/x86/include/asm/uaccess_32.h:213:
        error: call to ‘copy_from_user_overflow’ declared with attribute error:
        copy_from_user buffer size is not provably correct
      Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      LKML-Reference: <20091002075050.4e9f7641@infradead.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      63312b6a
  22. 01 10月, 2009 1 次提交
    • A
      x86: Turn the copy_from_user check into an (optional) compile time warning · 4a312769
      Arjan van de Ven 提交于
      A previous patch added the buffer size check to copy_from_user().
      
      One of the things learned from analyzing the result of the previous
      patch is that in general, gcc is really good at proving that the
      code contains sufficient security checks to not need to do a
      runtime check. But that for those cases where gcc could not prove
      this, there was a relatively high percentage of real security
      issues.
      
      This patch turns the case of "gcc cannot prove" into a compile time
      warning, as long as a sufficiently new gcc is in use that supports
      this. The objective is that these warnings will trigger developers
      checking new cases out before a security hole enters a linux kernel
      release.
      Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: James Morris <jmorris@namei.org>
      Cc: Jan Beulich <jbeulich@novell.com>
      LKML-Reference: <20090930130523.348ae6c4@infradead.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      4a312769
  23. 26 9月, 2009 1 次提交
    • A
      x86: Use __builtin_object_size() to validate the buffer size for copy_from_user() · 9f0cf4ad
      Arjan van de Ven 提交于
      gcc (4.x) supports the __builtin_object_size() builtin, which
      reports the size of an object that a pointer point to, when known
      at compile time. If the buffer size is not known at compile time, a
      constant -1 is returned.
      
      This patch uses this feature to add a sanity check to
      copy_from_user(); if the target buffer is known to be smaller than
      the copy size, the copy is aborted and a WARNing is emitted in
      memory debug mode.
      
      These extra checks compile away when the object size is not known,
      or if both the buffer size and the copy length are constants.
      Signed-off-by: NArjan van de Ven <arjan@linux.intel.com>
      LKML-Reference: <20090926143301.2c396b94@infradead.org>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      9f0cf4ad
  24. 12 6月, 2009 1 次提交
  25. 08 4月, 2009 1 次提交
    • L
      Fix build errors due to CONFIG_BRANCH_TRACER=y · aeeae868
      Linus Torvalds 提交于
      The code that enables branch tracing for all (non-constant) branches
      plays games with the preprocessor and #define's the C 'if ()' construct
      to do tracing.
      
      That's all fine, but it fails for some unusual but valid C code that is
      sometimes used in macros, notably by the intel-iommu code:
      
      	if (i=drhd->iommu, drhd->ignored) ..
      
      because now the preprocessor complains about multiple arguments to the
      'if' macro.
      
      So make the macro expansion of this particularly horrid trick use
      varargs, and handle the case of comma-expressions in if-statements.  Use
      another macro to do it cleanly in just one place.
      
      This replaces a patch by David (and acked by Steven) that did this all
      inside that one already-too-horrid macro.
      Tested-by: NIngo Molnar <mingo@elte.hu>
      Cc: David Woodhouse <dwmw2@infradead.org>
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      aeeae868
  26. 07 4月, 2009 2 次提交
  27. 18 3月, 2009 1 次提交
  28. 03 1月, 2009 1 次提交
    • L
      Sanitize gcc version header includes · f153b821
      Linus Torvalds 提交于
       - include the gcc version-dependent header files from the generic gcc
         header file, rather than the other way around (iow: don't make the
         non-gcc header file have to know about gcc versions)
      
       - don't include compiler-gcc4.h for gcc 5 (for whenever it gets
         released).  That's just confusing and made us do odd things in the
         gcc4 header file (testing that we really had version 4!)
      
       - generate the name from the __GNUC__ version directly, rather than
         having a mess of #if conditionals.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      f153b821
  29. 23 11月, 2008 3 次提交
    • S
      trace: profile all if conditionals · 2bcd521a
      Steven Rostedt 提交于
      Impact: feature to profile if statements
      
      This patch adds a branch profiler for all if () statements.
      The results will be found in:
      
        /debugfs/tracing/profile_branch
      
      For example:
      
         miss      hit    %        Function                  File              Line
       ------- ---------  -        --------                  ----              ----
             0        1 100 x86_64_start_reservations      head64.c             127
             0        1 100 copy_bootdata                  head64.c             69
             1        0   0 x86_64_start_kernel            head64.c             111
            32        0   0 set_intr_gate                  desc.h               319
             1        0   0 reserve_ebda_region            head.c               51
             1        0   0 reserve_ebda_region            head.c               47
             0        1 100 reserve_ebda_region            head.c               42
             0        0   X maxcpus                        main.c               165
      
      Miss means the branch was not taken. Hit means the branch was taken.
      The percent is the percentage the branch was taken.
      
      This adds a significant amount of overhead and should only be used
      by those analyzing their system.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      2bcd521a
    • S
      trace: consolidate unlikely and likely profiler · 45b79749
      Steven Rostedt 提交于
      Impact: clean up to make one profiler of like and unlikely tracer
      
      The likely and unlikely profiler prints out the file and line numbers
      of the annotated branches that it is profiling. It shows the number
      of times it was correct or incorrect in its guess. Having two
      different files or sections for that matter to tell us if it was a
      likely or unlikely is pretty pointless. We really only care if
      it was correct or not.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      45b79749
    • S
      trace: remove extra assign in branch check · 42f565e1
      Steven Rostedt 提交于
      Impact: clean up of branch check
      
      The unlikely/likely profiler does an extra assign of the f.line.
      This is not needed since it is already calculated at compile time.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      42f565e1
  30. 13 11月, 2008 1 次提交
  31. 12 11月, 2008 2 次提交
    • I
      tracing: branch tracer, fix vdso crash · 2b7d0390
      Ingo Molnar 提交于
      Impact: fix bootup crash
      
      the branch tracer missed arch/x86/vdso/vclock_gettime.c from
      disabling tracing, which caused such bootup crashes:
      
        [  201.840097] init[1]: segfault at 7fffed3fe7c0 ip 00007fffed3fea2e sp 000077
      
      also clean up the ugly ifdefs in arch/x86/kernel/vsyscall_64.c by
      creating DISABLE_UNLIKELY_PROFILE facility for code to turn off
      instrumentation on a per file basis.
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      2b7d0390
    • S
      tracing: profile likely and unlikely annotations · 1f0d69a9
      Steven Rostedt 提交于
      Impact: new unlikely/likely profiler
      
      Andrew Morton recently suggested having an in-kernel way to profile
      likely and unlikely macros. This patch achieves that goal.
      
      When configured, every(*) likely and unlikely macro gets a counter attached
      to it. When the condition is hit, the hit and misses of that condition
      are recorded. These numbers can later be retrieved by:
      
        /debugfs/tracing/profile_likely    - All likely markers
        /debugfs/tracing/profile_unlikely  - All unlikely markers.
      
      # cat /debug/tracing/profile_unlikely | head
       correct incorrect  %        Function                  File              Line
       ------- ---------  -        --------                  ----              ----
          2167        0   0 do_arch_prctl                  process_64.c         832
             0        0   0 do_arch_prctl                  process_64.c         804
          2670        0   0 IS_ERR                         err.h                34
         71230     5693   7 __switch_to                    process_64.c         673
         76919        0   0 __switch_to                    process_64.c         639
         43184    33743  43 __switch_to                    process_64.c         624
         12740    64181  83 __switch_to                    process_64.c         594
         12740    64174  83 __switch_to                    process_64.c         590
      
      # cat /debug/tracing/profile_unlikely | \
        awk '{ if ($3 > 25) print $0; }' |head -20
         44963    35259  43 __switch_to                    process_64.c         624
         12762    67454  84 __switch_to                    process_64.c         594
         12762    67447  84 __switch_to                    process_64.c         590
          1478      595  28 syscall_get_error              syscall.h            51
             0     2821 100 syscall_trace_leave            ptrace.c             1567
             0        1 100 native_smp_prepare_cpus        smpboot.c            1237
         86338   265881  75 calc_delta_fair                sched_fair.c         408
        210410   108540  34 calc_delta_mine                sched.c              1267
             0    54550 100 sched_info_queued              sched_stats.h        222
         51899    66435  56 pick_next_task_fair            sched_fair.c         1422
             6       10  62 yield_task_fair                sched_fair.c         982
          7325     2692  26 rt_policy                      sched.c              144
             0     1270 100 pre_schedule_rt                sched_rt.c           1261
          1268    48073  97 pick_next_task_rt              sched_rt.c           884
             0    45181 100 sched_info_dequeued            sched_stats.h        177
             0       15 100 sched_move_task                sched.c              8700
             0       15 100 sched_move_task                sched.c              8690
         53167    33217  38 schedule                       sched.c              4457
             0    80208 100 sched_info_switch              sched_stats.h        270
         30585    49631  61 context_switch                 sched.c              2619
      
      # cat /debug/tracing/profile_likely | awk '{ if ($3 > 25) print $0; }'
         39900    36577  47 pick_next_task                 sched.c              4397
         20824    15233  42 switch_mm                      mmu_context_64.h     18
             0        7 100 __cancel_work_timer            workqueue.c          560
           617    66484  99 clocksource_adjust             timekeeping.c        456
             0   346340 100 audit_syscall_exit             auditsc.c            1570
            38   347350  99 audit_get_context              auditsc.c            732
             0   345244 100 audit_syscall_entry            auditsc.c            1541
            38     1017  96 audit_free                     auditsc.c            1446
             0     1090 100 audit_alloc                    auditsc.c            862
          2618     1090  29 audit_alloc                    auditsc.c            858
             0        6 100 move_masked_irq                migration.c          9
             1      198  99 probe_sched_wakeup             trace_sched_switch.c 58
             2        2  50 probe_wakeup                   trace_sched_wakeup.c 227
             0        2 100 probe_wakeup_sched_switch      trace_sched_wakeup.c 144
          4514     2090  31 __grab_cache_page              filemap.c            2149
         12882   228786  94 mapping_unevictable            pagemap.h            50
             4       11  73 __flush_cpu_slab               slub.c               1466
        627757   330451  34 slab_free                      slub.c               1731
          2959    61245  95 dentry_lru_del_init            dcache.c             153
           946     1217  56 load_elf_binary                binfmt_elf.c         904
           102       82  44 disk_put_part                  genhd.h              206
             1        1  50 dst_gc_task                    dst.c                82
             0       19 100 tcp_mss_split_point            tcp_output.c         1126
      
      As you can see by the above, there's a bit of work to do in rethinking
      the use of some unlikelys and likelys. Note: the unlikely case had 71 hits
      that were more than 25%.
      
      Note:  After submitting my first version of this patch, Andrew Morton
        showed me a version written by Daniel Walker, where I picked up
        the following ideas from:
      
        1)  Using __builtin_constant_p to avoid profiling fixed values.
        2)  Using __FILE__ instead of instruction pointers.
        3)  Using the preprocessor to stop all profiling of likely
             annotations from vsyscall_64.c.
      
      Thanks to Andrew Morton, Arjan van de Ven, Theodore Tso and Ingo Molnar
      for their feed back on this patch.
      
      (*) Not ever unlikely is recorded, those that are used by vsyscalls
       (a few of them) had to have profiling disabled.
      Signed-off-by: NSteven Rostedt <srostedt@redhat.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Theodore Tso <tytso@mit.edu>
      Cc: Arjan van de Ven <arjan@infradead.org>
      Cc: Steven Rostedt <srostedt@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@elte.hu>
      1f0d69a9
  32. 14 10月, 2008 1 次提交
  33. 18 8月, 2008 1 次提交