13 Jun, 2014

1 commit

  • Pull more perf updates from Ingo Molnar:
    "A second round of perf updates:

    - wide reaching kprobes sanitization and robustization, with the hope
    of fixing all 'probe this function crashes the kernel' bugs, by
    Masami Hiramatsu.

    - uprobes updates from Oleg Nesterov: tmpfs support, corner case
    fixes and robustization work.

    - perf tooling updates and fixes from Jiri Olsa, Namhyung Ki, Arnaldo
    et al:
    * Add support to accumulate hist periods (Namhyung Kim)
    * various fixes, refactorings and enhancements"

    * 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (101 commits)
    perf: Differentiate exec() and non-exec() comm events
    perf: Fix perf_event_comm() vs. exec() assumption
    uprobes/x86: Rename arch_uprobe->def to ->defparam, minor comment updates
    perf/documentation: Add description for conditional branch filter
    perf/x86: Add conditional branch filtering support
    perf/tool: Add conditional branch filter 'cond' to perf record
    perf: Add new conditional branch filter 'PERF_SAMPLE_BRANCH_COND'
    uprobes: Teach copy_insn() to support tmpfs
    uprobes: Shift ->readpage check from __copy_insn() to uprobe_register()
    perf/x86: Use common PMU interrupt disabled code
    perf/ARM: Use common PMU interrupt disabled code
    perf: Disable sampled events if no PMU interrupt
    perf: Fix use after free in perf_remove_from_context()
    perf tools: Fix 'make help' message error
    perf record: Fix poll return value propagation
    perf tools: Move elide bool into perf_hpp_fmt struct
    perf tools: Remove elide setup for SORT_MODE__MEMORY mode
    perf tools: Fix "==" into "=" in ui_browser__warning assignment
    perf tools: Allow overriding sysfs and proc finding with env var
    perf tools: Consider header files outside perf directory in tags target
    ...

    Linus Torvalds
     

05 Jun, 2014

1 commit

  • 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: James Hogan
    Cc: Johannes Berg
    Cc: Daniel Santos
    Cc: Luciano Coelho
    Cc: Peter Zijlstra
    Cc: Paul E. McKenney
    Acked-by: Johannes Berg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    James Hogan
     

24 Apr, 2014

1 commit

  • 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: Masami Hiramatsu
    Link: http://lkml.kernel.org/r/20140417081705.26341.96719.stgit@ltc230.yrl.intra.hitachi.co.jp
    Cc: Alok Kataria
    Cc: Ananth N Mavinakayanahalli
    Cc: Andrew Morton
    Cc: Anil S Keshavamurthy
    Cc: Arnd Bergmann
    Cc: Christopher Li
    Cc: Chris Wright
    Cc: David S. Miller
    Cc: Jan-Simon Möller
    Cc: Jeremy Fitzhardinge
    Cc: Linus Torvalds
    Cc: Randy Dunlap
    Cc: Rusty Russell
    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: Ingo Molnar

    Masami Hiramatsu
     

10 Apr, 2014

1 commit


24 Jan, 2014

1 commit

  • Pull crypto update from Herbert Xu:
    "Here is the crypto update for 3.14:

    - Improved crypto_memneq helper
    - Use cyprto_memneq in arch-specific crypto code
    - Replaced orphaned DCP driver with Freescale MXS DCP driver
    - Added AVX/AVX2 version of AESNI-GCM encode and decode
    - Added AMD Cryptographic Coprocessor (CCP) driver
    - Misc fixes"

    * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (41 commits)
    crypto: aesni - fix build on x86 (32bit)
    crypto: mxs - Fix sparse non static symbol warning
    crypto: ccp - CCP device enabled/disabled changes
    crypto: ccp - Cleanup hash invocation calls
    crypto: ccp - Change data length declarations to u64
    crypto: ccp - Check for caller result area before using it
    crypto: ccp - Cleanup scatterlist usage
    crypto: ccp - Apply appropriate gfp_t type to memory allocations
    crypto: drivers - Sort drivers/crypto/Makefile
    ARM: mxs: dts: Enable DCP for MXS
    crypto: mxs - Add Freescale MXS DCP driver
    crypto: mxs - Remove the old DCP driver
    crypto: ahash - Fully restore ahash request before completing
    crypto: aesni - fix build on x86 (32bit)
    crypto: talitos - Remove redundant dev_set_drvdata
    crypto: ccp - Remove redundant dev_set_drvdata
    crypto: crypto4xx - Remove redundant dev_set_drvdata
    crypto: caam - simplify and harden key parsing
    crypto: omap-sham - Fix Polling mode for larger blocks
    crypto: tcrypt - Added speed tests for AEAD crypto alogrithms in tcrypt test suite
    ...

    Linus Torvalds
     

12 Jan, 2014

1 commit

  • 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: "Paul E. McKenney"
    Signed-off-by: Peter Zijlstra
    Acked-by: Will Deacon
    Cc: Benjamin Herrenschmidt
    Cc: Frederic Weisbecker
    Cc: Mathieu Desnoyers
    Cc: Michael Ellerman
    Cc: Michael Neuling
    Cc: Russell King
    Cc: Geert Uytterhoeven
    Cc: Heiko Carstens
    Cc: Linus Torvalds
    Cc: Martin Schwidefsky
    Cc: Victor Kaplansky
    Cc: Tony Luck
    Cc: Oleg Nesterov
    Link: http://lkml.kernel.org/r/20131213150640.908486364@infradead.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

05 Dec, 2013

1 commit

  • 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: Cesar Eduardo Barros
    Acked-by: Daniel Borkmann
    Signed-off-by: Herbert Xu

    Cesar Eduardo Barros
     

08 Apr, 2013

1 commit

  • Currently, __kprobes is defined in linux/kprobes.h which
    is too big to be included in small or basic headers
    that want to make use of this simple attribute.

    So move __kprobes definition into linux/compiler.h
    in which other compiler attributes are defined.

    Signed-off-by: Masami Hiramatsu
    Cc: Timo Juhani Lindfors
    Cc: Ananth N Mavinakayanahalli
    Cc: Pavel Emelyanov
    Cc: Jiri Kosina
    Cc: Nadia Yvette Chambers
    Cc: yrl.pp-manager.tt@hitachi.com
    Cc: David S. Miller
    Cc: Linus Torvalds
    Link: http://lkml.kernel.org/r/20130404104049.21071.20908.stgit@mhiramat-M0-7522
    [ Improved the attribute explanation a bit. ]
    Signed-off-by: Ingo Molnar

    Masami Hiramatsu
     

22 Feb, 2013

3 commits

  • 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: Daniel Santos
    Cc: Andi Kleen
    Cc: Borislav Petkov
    Cc: David Rientjes
    Cc: Joe Perches
    Cc: Josh Triplett
    Cc: Paul Gortmaker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    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: Daniel Santos
    Cc: Andi Kleen
    Cc: Borislav Petkov
    Cc: David Rientjes
    Cc: Joe Perches
    Cc: Josh Triplett
    Cc: Paul Gortmaker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    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: Daniel Santos
    Acked-by: David Rientjes
    Acked-by: Borislav Petkov
    Cc: Andi Kleen
    Cc: Joe Perches
    Cc: Josh Triplett
    Cc: Paul Gortmaker
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Daniel Santos
     

19 Dec, 2012

1 commit

  • Pull module update from Rusty Russell:
    "Nothing all that exciting; a new module-from-fd syscall for those who
    want to verify the source of the module (ChromeOS) and/or use standard
    IMA on it or other security hooks."

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    MODSIGN: Fix kbuild output when using default extra_certificates
    MODSIGN: Avoid using .incbin in C source
    modules: don't hand 0 to vmalloc.
    module: Remove a extra null character at the top of module->strtab.
    ASN.1: Use the ASN1_LONG_TAG and ASN1_INDEFINITE_LENGTH constants
    ASN.1: Define indefinite length marker constant
    moduleparam: use __UNIQUE_ID()
    __UNIQUE_ID()
    MODSIGN: Add modules_sign make target
    powerpc: add finit_module syscall.
    ima: support new kernel module syscall
    add finit_module syscall to asm-generic
    ARM: add finit_module syscall to ARM
    security: introduce kernel_module_from_file hook
    module: add flags arg to sys_finit_module()
    module: add syscall to load module from fd

    Linus Torvalds
     

18 Dec, 2012

1 commit


14 Dec, 2012

1 commit

  • 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 reported that some module parameters
    start with a digit, so we need to prepend when we for the unique id.

    Signed-off-by: Rusty Russell
    Acked-by: Jan Beulich

    Rusty Russell
     

18 Sep, 2012

1 commit

  • gcc 4.6+ has support for a externally_visible attribute that prevents the
    optimizer from optimizing unused symbols away. Add a __visible macro to
    use it with that compiler version or later.

    This is used (at least) by the "Link Time Optimization" patchset.

    Signed-off-by: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     

28 Feb, 2012

1 commit


11 Jan, 2012

1 commit

  • 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: David Daney
    Acked-by: David Rientjes
    Cc: DM
    Cc: Ralf Baechle
    Acked-by: David Howells
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Daney
     

20 Aug, 2010

1 commit

  • 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: Arnd Bergmann
    Signed-off-by: Paul E. McKenney
    Cc: Christopher Li
    Reviewed-by: Josh Triplett

    Paul E. McKenney
     

15 Jun, 2010

1 commit

  • This commit defines an __rcu API, but provides only vacuous definitions
    for it. This breaks dependencies among most of the subsequent patches,
    allowing them to reach mainline asynchronously via whatever trees are
    appropriate.

    Signed-off-by: Arnd Bergmann
    Signed-off-by: Paul E. McKenney
    Cc: Christopher Li
    Cc: Josh Triplett

    Paul E. McKenney
     

05 Jan, 2010

1 commit


06 Dec, 2009

3 commits

  • * 'x86-asm-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    include/linux/compiler-gcc4.h: Fix build bug - gcc-4.0.2 doesn't understand __builtin_object_size
    x86/alternatives: No need for alternatives-asm.h to re-invent stuff already in asm.h
    x86/alternatives: Check replacementlen t use the strict copy checks when branch profiling is in use
    x86, 64-bit: Move K8 B step iret fixup to fault entry asm
    x86: Generate cmpxchg build failures
    x86: Add a Kconfig option to turn the copy_from_user warnings into errors
    x86: Turn the copy_from_user check into an (optional) compile time warning
    x86: Use __builtin_memset and __builtin_memcpy for memset/memcpy
    x86: Use __builtin_object_size() to validate the buffer size for copy_from_user()

    Linus Torvalds
     
  • …el/git/tip/linux-2.6-tip

    * 'tracing-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (40 commits)
    tracing: Separate raw syscall from syscall tracer
    ring-buffer-benchmark: Add parameters to set produce/consumer priorities
    tracing, function tracer: Clean up strstrip() usage
    ring-buffer benchmark: Run producer/consumer threads at nice +19
    tracing: Remove the stale include/trace/power.h
    tracing: Only print objcopy version warning once from recordmcount
    tracing: Prevent build warning: 'ftrace_graph_buf' defined but not used
    ring-buffer: Move access to commit_page up into function used
    tracing: do not disable interrupts for trace_clock_local
    ring-buffer: Add multiple iterations between benchmark timestamps
    kprobes: Sanitize struct kretprobe_instance allocations
    tracing: Fix to use __always_unused attribute
    compiler: Introduce __always_unused
    tracing: Exit with error if a weak function is used in recordmcount.pl
    tracing: Move conditional into update_funcs() in recordmcount.pl
    tracing: Add regex for weak functions in recordmcount.pl
    tracing: Move mcount section search to front of loop in recordmcount.pl
    tracing: Fix objcopy revision check in recordmcount.pl
    tracing: Check absolute path of input file in recordmcount.pl
    tracing: Correct the check for number of arguments in recordmcount.pl
    ...

    Linus Torvalds
     
  • Starting with version 4.5, GCC has a new built-in function
    __builtin_unreachable() that can be used in places like the kernel's
    BUG() where inline assembly is used to transfer control flow. This
    eliminated the need for an endless loop in these places.

    The patch adds a new macro 'unreachable()' that will expand to either
    __builtin_unreachable() or an endless loop depending on the compiler
    version.

    Change from v1: Simplify unreachable() for non-GCC 4.5 case.

    Signed-off-by: David Daney
    Acked-by: Ralf Baechle
    Signed-off-by: Linus Torvalds

    David Daney
     

02 Nov, 2009

1 commit

  • 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: Li Zefan
    Cc: Steven Rostedt
    Cc: Frederic Weisbecker
    Cc: Linus Torvalds
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Li Zefan
     

29 Oct, 2009

1 commit

  • We have to make __kernel "__attribute__((address_space(0)))" so we can
    cast to it.

    tj: * put_cpu_var() update.

    * Annotations added to dynamic allocator interface.

    Signed-off-by: Rusty Russell
    Cc: Al Viro
    Signed-off-by: Tejun Heo

    Rusty Russell
     

03 Oct, 2009

1 commit

  • 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: Arjan van de Ven
    Cc: Linus Torvalds
    Cc: Andrew Morton
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arjan van de Ven
     

01 Oct, 2009

1 commit

  • 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: Arjan van de Ven
    Cc: Linus Torvalds
    Cc: "David S. Miller"
    Cc: James Morris
    Cc: Jan Beulich
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arjan van de Ven
     

26 Sep, 2009

1 commit

  • 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: Arjan van de Ven
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Arjan van de Ven
     

12 Jun, 2009

1 commit


07 Apr, 2009

2 commits

  • Fix the branch tracer barfing on comma statements within if ()
    statements.

    Signed-off-by: Ingo Molnar

    Linus Torvalds
     
  • One of the changes between kernels 2.6.28 and 2.6.29 is that a branch profiler
    has been added for if() statements. Unfortunately this patch makes the sparse
    output unusable with CONFIG_TRACE_BRANCH_PROFILING=y: when branch profiling is
    enabled, sparse prints so much false positives that the real issues are no
    longer visible. This behavior can be reproduced as follows:
    * enable CONFIG_TRACE_BRANCH_PROFILING, e.g. by running make allyesconfig or
    make allmodconfig.
    * run make C=2

    Result: a huge number of the following sparse warnings.
    ...
    include/linux/cpumask.h:547:2: warning: symbol '______r' shadows an earlier one
    include/linux/cpumask.h:547:2: originally declared here
    ...

    The patch below fixes this by disabling branch profiling while analyzing the
    kernel code with sparse.

    See also:
    * http://lkml.org/lkml/2008/11/21/18
    * http://bugzilla.kernel.org/show_bug.cgi?id=12925

    Signed-off-by: Bart Van Assche
    Cc: Andrew Morton
    Cc: Steven Rostedt
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Bart Van Assche
     

18 Mar, 2009

1 commit

  • Impact: better performance for if branch tracer

    Use an array to count the hit and misses of a conditional instead
    of using another conditional. This cuts down on saturation of branch
    predictions and increases performance of modern pipelined architectures.

    Signed-off-by: Witold Baryluk
    Signed-off-by: Steven Rostedt

    Witold Baryluk
     

03 Jan, 2009

1 commit

  • - 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: Linus Torvalds

    Linus Torvalds
     

23 Nov, 2008

3 commits

  • 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: Steven Rostedt
    Signed-off-by: Ingo Molnar

    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: Steven Rostedt
    Signed-off-by: Ingo Molnar

    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: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Steven Rostedt
     

13 Nov, 2008

1 commit

  • Impact: name change of unlikely tracer and profiler

    Ingo Molnar suggested changing the config from UNLIKELY_PROFILE
    to BRANCH_PROFILING. I never did like the "unlikely" name so I
    went one step farther, and renamed all the unlikely configurations
    to a "BRANCH" variant.

    Signed-off-by: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Steven Rostedt
     

12 Nov, 2008

2 commits

  • 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: Ingo Molnar

    Ingo Molnar
     
  • 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: Steven Rostedt
    Cc: Andrew Morton
    Cc: Frederic Weisbecker
    Cc: Theodore Tso
    Cc: Arjan van de Ven
    Cc: Steven Rostedt
    Signed-off-by: Ingo Molnar

    Steven Rostedt
     

14 Oct, 2008

1 commit