20 Jan, 2017

1 commit

  • commit b6416e61012429e0277bd15a229222fd17afc1c1 upstream.

    Modules that use static_key_deferred need a way to synchronize with
    any delayed work that is still pending when the module is unloaded.
    Introduce static_key_deferred_flush() which flushes any pending
    jump label updates.

    Signed-off-by: David Matlack
    Acked-by: Peter Zijlstra (Intel)
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Greg Kroah-Hartman

    David Matlack
     

05 Aug, 2016

1 commit

  • Pull more powerpc updates from Michael Ellerman:
    "These were delayed for various reasons, so I let them sit in next a
    bit longer, rather than including them in my first pull request.

    Fixes:
    - Fix early access to cpu_spec relocation from Benjamin Herrenschmidt
    - Fix incorrect event codes in power9-event-list from Madhavan Srinivasan
    - Move register_process_table() out of ppc_md from Michael Ellerman

    Use jump_label use for [cpu|mmu]_has_feature():
    - Add mmu_early_init_devtree() from Michael Ellerman
    - Move disable_radix handling into mmu_early_init_devtree() from Michael Ellerman
    - Do hash device tree scanning earlier from Michael Ellerman
    - Do radix device tree scanning earlier from Michael Ellerman
    - Do feature patching before MMU init from Michael Ellerman
    - Check features don't change after patching from Michael Ellerman
    - Make MMU_FTR_RADIX a MMU family feature from Aneesh Kumar K.V
    - Convert mmu_has_feature() to returning bool from Michael Ellerman
    - Convert cpu_has_feature() to returning bool from Michael Ellerman
    - Define radix_enabled() in one place & use static inline from Michael Ellerman
    - Add early_[cpu|mmu]_has_feature() from Michael Ellerman
    - Convert early cpu/mmu feature check to use the new helpers from Aneesh Kumar K.V
    - jump_label: Make it possible for arches to invoke jump_label_init() earlier from Kevin Hao
    - Call jump_label_init() in apply_feature_fixups() from Aneesh Kumar K.V
    - Remove mfvtb() from Kevin Hao
    - Move cpu_has_feature() to a separate file from Kevin Hao
    - Add kconfig option to use jump labels for cpu/mmu_has_feature() from Michael Ellerman
    - Add option to use jump label for cpu_has_feature() from Kevin Hao
    - Add option to use jump label for mmu_has_feature() from Kevin Hao
    - Catch usage of cpu/mmu_has_feature() before jump label init from Aneesh Kumar K.V
    - Annotate jump label assembly from Michael Ellerman

    TLB flush enhancements from Aneesh Kumar K.V:
    - radix: Implement tlb mmu gather flush efficiently
    - Add helper for finding SLBE LLP encoding
    - Use hugetlb flush functions
    - Drop multiple definition of mm_is_core_local
    - radix: Add tlb flush of THP ptes
    - radix: Rename function and drop unused arg
    - radix/hugetlb: Add helper for finding page size
    - hugetlb: Add flush_hugetlb_tlb_range
    - remove flush_tlb_page_nohash

    Add new ptrace regsets from Anshuman Khandual and Simon Guo:
    - elf: Add powerpc specific core note sections
    - Add the function flush_tmregs_to_thread
    - Enable in transaction NT_PRFPREG ptrace requests
    - Enable in transaction NT_PPC_VMX ptrace requests
    - Enable in transaction NT_PPC_VSX ptrace requests
    - Adapt gpr32_get, gpr32_set functions for transaction
    - Enable support for NT_PPC_CGPR
    - Enable support for NT_PPC_CFPR
    - Enable support for NT_PPC_CVMX
    - Enable support for NT_PPC_CVSX
    - Enable support for TM SPR state
    - Enable NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR
    - Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR
    - Enable support for EBB registers
    - Enable support for Performance Monitor registers"

    * tag 'powerpc-4.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (48 commits)
    powerpc/mm: Move register_process_table() out of ppc_md
    powerpc/perf: Fix incorrect event codes in power9-event-list
    powerpc/32: Fix early access to cpu_spec relocation
    powerpc/ptrace: Enable support for Performance Monitor registers
    powerpc/ptrace: Enable support for EBB registers
    powerpc/ptrace: Enable support for NT_PPPC_TAR, NT_PPC_PPR, NT_PPC_DSCR
    powerpc/ptrace: Enable NT_PPC_TM_CTAR, NT_PPC_TM_CPPR, NT_PPC_TM_CDSCR
    powerpc/ptrace: Enable support for TM SPR state
    powerpc/ptrace: Enable support for NT_PPC_CVSX
    powerpc/ptrace: Enable support for NT_PPC_CVMX
    powerpc/ptrace: Enable support for NT_PPC_CFPR
    powerpc/ptrace: Enable support for NT_PPC_CGPR
    powerpc/ptrace: Adapt gpr32_get, gpr32_set functions for transaction
    powerpc/ptrace: Enable in transaction NT_PPC_VSX ptrace requests
    powerpc/ptrace: Enable in transaction NT_PPC_VMX ptrace requests
    powerpc/ptrace: Enable in transaction NT_PRFPREG ptrace requests
    powerpc/process: Add the function flush_tmregs_to_thread
    elf: Add powerpc specific core note sections
    powerpc/mm: remove flush_tlb_page_nohash
    powerpc/mm/hugetlb: Add flush_hugetlb_tlb_range
    ...

    Linus Torvalds
     

04 Aug, 2016

3 commits

  • Pull module updates from Rusty Russell:
    "The only interesting thing here is Jessica's patch to add
    ro_after_init support to modules. The rest are all trivia"

    * tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
    extable.h: add stddef.h so "NULL" definition is not implicit
    modules: add ro_after_init support
    jump_label: disable preemption around __module_text_address().
    exceptions: fork exception table content from module.h into extable.h
    modules: Add kernel parameter to blacklist modules
    module: Do a WARN_ON_ONCE() for assert module mutex not held
    Documentation/module-signing.txt: Note need for version info if reusing a key
    module: Invalidate signatures on force-loaded modules
    module: Issue warnings when tainting kernel
    module: fix redundant test.
    module: fix noreturn attribute for __module_put_and_exit()

    Linus Torvalds
     
  • The current jump_label.h includes bug.h for things such as WARN_ON().
    This makes the header problematic for inclusion by kernel.h or any
    headers that kernel.h includes, since bug.h includes kernel.h (circular
    dependency). The inclusion of atomic.h is similarly problematic. Thus,
    this should make jump_label.h 'includable' from most places.

    Link: http://lkml.kernel.org/r/7060ce35ddd0d20b33bf170685e6b0fab816bdf2.1467837322.git.jbaron@akamai.com
    Signed-off-by: Jason Baron
    Cc: "David S. Miller"
    Cc: Arnd Bergmann
    Cc: Benjamin Herrenschmidt
    Cc: Chris Metcalf
    Cc: Heiko Carstens
    Cc: Joe Perches
    Cc: Martin Schwidefsky
    Cc: Michael Ellerman
    Cc: Paul Mackerras
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jason Baron
     
  • Steven reported a warning caused by not holding module_mutex or
    rcu_read_lock_sched: his backtrace was corrupted but a quick audit
    found this possible cause. It's wrong anyway...

    Reported-by: Steven Rostedt
    Signed-off-by: Rusty Russell

    Rusty Russell
     

01 Aug, 2016

1 commit


26 Jul, 2016

1 commit

  • Pull locking updates from Ingo Molnar:
    "The locking tree was busier in this cycle than the usual pattern - a
    couple of major projects happened to coincide.

    The main changes are:

    - implement the atomic_fetch_{add,sub,and,or,xor}() API natively
    across all SMP architectures (Peter Zijlstra)

    - add atomic_fetch_{inc/dec}() as well, using the generic primitives
    (Davidlohr Bueso)

    - optimize various aspects of rwsems (Jason Low, Davidlohr Bueso,
    Waiman Long)

    - optimize smp_cond_load_acquire() on arm64 and implement LSE based
    atomic{,64}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}()
    on arm64 (Will Deacon)

    - introduce smp_acquire__after_ctrl_dep() and fix various barrier
    mis-uses and bugs (Peter Zijlstra)

    - after discovering ancient spin_unlock_wait() barrier bugs in its
    implementation and usage, strengthen its semantics and update/fix
    usage sites (Peter Zijlstra)

    - optimize mutex_trylock() fastpath (Peter Zijlstra)

    - ... misc fixes and cleanups"

    * 'locking-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (67 commits)
    locking/atomic: Introduce inc/dec variants for the atomic_fetch_$op() API
    locking/barriers, arch/arm64: Implement LDXR+WFE based smp_cond_load_acquire()
    locking/static_keys: Fix non static symbol Sparse warning
    locking/qspinlock: Use __this_cpu_dec() instead of full-blown this_cpu_dec()
    locking/atomic, arch/tile: Fix tilepro build
    locking/atomic, arch/m68k: Remove comment
    locking/atomic, arch/arc: Fix build
    locking/Documentation: Clarify limited control-dependency scope
    locking/atomic, arch/rwsem: Employ atomic_long_fetch_add()
    locking/atomic, arch/qrwlock: Employ atomic_fetch_add_acquire()
    locking/atomic, arch/mips: Convert to _relaxed atomics
    locking/atomic, arch/alpha: Convert to _relaxed atomics
    locking/atomic: Remove the deprecated atomic_{set,clear}_mask() functions
    locking/atomic: Remove linux/atomic.h:atomic_fetch_or()
    locking/atomic: Implement atomic{,64,_long}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}()
    locking/atomic: Fix atomic64_relaxed() bits
    locking/atomic, arch/xtensa: Implement atomic_fetch_{add,sub,and,or,xor}()
    locking/atomic, arch/x86: Implement atomic{,64}_fetch_{add,sub,and,or,xor}()
    locking/atomic, arch/tile: Implement atomic{,64}_fetch_{add,sub,and,or,xor}()
    locking/atomic, arch/sparc: Implement atomic{,64}_fetch_{add,sub,and,or,xor}()
    ...

    Linus Torvalds
     

07 Jul, 2016

1 commit

  • Fix the following sparse warnings:

    kernel/jump_label.c:473:23: warning:
    symbol 'jump_label_module_nb' was not declared. Should it be static?

    Signed-off-by: Wei Yongjun
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: http://lkml.kernel.org/r/1466183980-8903-1-git-send-email-weiyj_lk@163.com
    Signed-off-by: Ingo Molnar

    Wei Yongjun
     

24 Jun, 2016

1 commit

  • The following scenario is possible:

    CPU 1 CPU 2
    static_key_slow_inc()
    atomic_inc_not_zero()
    -> key.enabled == 0, no increment
    jump_label_lock()
    atomic_inc_return()
    -> key.enabled == 1 now
    static_key_slow_inc()
    atomic_inc_not_zero()
    -> key.enabled == 1, inc to 2
    return
    ** static key is wrong!
    jump_label_update()
    jump_label_unlock()

    Testing the static key at the point marked by (**) will follow the
    wrong path for jumps that have not been patched yet. This can
    actually happen when creating many KVM virtual machines with userspace
    LAPIC emulation; just run several copies of the following program:

    #include
    #include
    #include
    #include

    int main(void)
    {
    for (;;) {
    int kvmfd = open("/dev/kvm", O_RDONLY);
    int vmfd = ioctl(kvmfd, KVM_CREATE_VM, 0);
    close(ioctl(vmfd, KVM_CREATE_VCPU, 1));
    close(vmfd);
    close(kvmfd);
    }
    return 0;
    }

    Every KVM_CREATE_VCPU ioctl will attempt a static_key_slow_inc() call.
    The static key's purpose is to skip NULL pointer checks and indeed one
    of the processes eventually dereferences NULL.

    As explained in the commit that introduced the bug:

    706249c222f6 ("locking/static_keys: Rework update logic")

    jump_label_update() needs key.enabled to be true. The solution adopted
    here is to temporarily make key.enabled == -1, and use go down the
    slow path when key.enabled
    Signed-off-by: Paolo Bonzini
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: # v4.3+
    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Fixes: 706249c222f6 ("locking/static_keys: Rework update logic")
    Link: http://lkml.kernel.org/r/1466527937-69798-1-git-send-email-pbonzini@redhat.com
    [ Small stylistic edits to the changelog and the code. ]
    Signed-off-by: Ingo Molnar

    Paolo Bonzini
     

23 Nov, 2015

1 commit

  • There were still a number of references to my old Red Hat email
    address in the kernel source. Remove these while keeping the
    Red Hat copyright notices intact.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Arnaldo Carvalho de Melo
    Cc: Jiri Olsa
    Cc: Linus Torvalds
    Cc: Mike Galbraith
    Cc: Peter Zijlstra
    Cc: Stephane Eranian
    Cc: Thomas Gleixner
    Cc: Vince Weaver
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

03 Aug, 2015

6 commits

  • Add a little selftest that validates all combinations.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • There are various problems and short-comings with the current
    static_key interface:

    - static_key_{true,false}() read like a branch depending on the key
    value, instead of the actual likely/unlikely branch depending on
    init value.

    - static_key_{true,false}() are, as stated above, tied to the
    static_key init values STATIC_KEY_INIT_{TRUE,FALSE}.

    - we're limited to the 2 (out of 4) possible options that compile to
    a default NOP because that's what our arch_static_branch() assembly
    emits.

    So provide a new static_key interface:

    DEFINE_STATIC_KEY_TRUE(name);
    DEFINE_STATIC_KEY_FALSE(name);

    Which define a key of different types with an initial true/false
    value.

    Then allow:

    static_branch_likely()
    static_branch_unlikely()

    to take a key of either type and emit the right instruction for the
    case.

    This means adding a second arch_static_branch_jump() assembly helper
    which emits a JMP per default.

    In order to determine the right instruction for the right state,
    encode the branch type in the LSB of jump_entry::key.

    This is the final step in removing the naming confusion that has led to
    a stream of avoidable bugs such as:

    a833581e372a ("x86, perf: Fix static_key bug in load_mm_cr4()")

    ... but it also allows new static key combinations that will give us
    performance enhancements in the subsequent patches.

    Tested-by: Rabin Vincent # arm
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Michael Ellerman # ppc
    Acked-by: Heiko Carstens # s390
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Instead of spreading the branch_default logic all over the place,
    concentrate it into the one jump_label_type() function.

    This does mean we need to actually increment/decrement the enabled
    count _before_ calling the update path, otherwise jump_label_type()
    will not see the right state.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • Avoid some casting with a helper, also prepares the way for
    overloading the LSB of jump_entry::key.

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • … the static_key* pattern

    Rename the JUMP_LABEL_TYPE_* macros to be JUMP_TYPE_* and move the
    inline helpers into kernel/jump_label.c, since that's the only place
    they're ever used.

    Also rename the helpers where it's all about static keys.

    This is the second step in removing the naming confusion that has led to
    a stream of avoidable bugs such as:

    a833581e372a ("x86, perf: Fix static_key bug in load_mm_cr4()")

    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Peter Zijlstra
     
  • Since we've already stepped away from ENABLE is a JMP and DISABLE is a
    NOP with the branch_default bits, and are going to make it even worse,
    rename it to make it all clearer.

    This way we don't mix multiple levels of logic attributes, but have a
    plain 'physical' name for what the current instruction patching status
    of a jump label is.

    This is a first step in removing the naming confusion that has led to
    a stream of avoidable bugs such as:

    a833581e372a ("x86, perf: Fix static_key bug in load_mm_cr4()")

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    [ Beefed up the changelog. ]
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

27 May, 2015

1 commit

  • As per the module core lockdep annotations in the coming patch:

    [ 18.034047] ---[ end trace 9294429076a9c673 ]---
    [ 18.047760] Hardware name: Intel Corporation S2600GZ/S2600GZ, BIOS SE5C600.86B.02.02.0002.122320131210 12/23/2013
    [ 18.059228] ffffffff817d8676 ffff880036683c38 ffffffff8157e98b 0000000000000001
    [ 18.067541] 0000000000000000 ffff880036683c78 ffffffff8105fbc7 ffff880036683c68
    [ 18.075851] ffffffffa0046b08 0000000000000000 ffffffffa0046d00 ffffffffa0046cc8
    [ 18.084173] Call Trace:
    [ 18.086906] [] dump_stack+0x4f/0x7b
    [ 18.092649] [] warn_slowpath_common+0x97/0xe0
    [ 18.099361] [] warn_slowpath_null+0x1a/0x20
    [ 18.105880] [] __module_address+0x1d2/0x1e0
    [ 18.112400] [] jump_label_module_notify+0x143/0x1e0
    [ 18.119710] [] notifier_call_chain+0x4f/0x70
    [ 18.126326] [] __blocking_notifier_call_chain+0x5e/0x90
    [ 18.134009] [] blocking_notifier_call_chain+0x16/0x20
    [ 18.141490] [] load_module+0x1b50/0x2660
    [ 18.147720] [] SyS_init_module+0xce/0x100
    [ 18.154045] [] system_call_fastpath+0x12/0x17
    [ 18.160748] ---[ end trace 9294429076a9c674 ]---

    Jump labels is not doing it right; fix this.

    Cc: Rusty Russell
    Cc: Jason Baron
    Acked-by: Paul E. McKenney
    Signed-off-by: Peter Zijlstra (Intel)
    Signed-off-by: Rusty Russell

    Peter Zijlstra
     

20 Oct, 2013

1 commit

  • Usage of the static key primitives to toggle a branch must not be used
    before jump_label_init() is called from init/main.c. jump_label_init
    reorganizes and wires up the jump_entries so usage before that could
    have unforeseen consequences.

    Following primitives are now checked for correct use:
    * static_key_slow_inc
    * static_key_slow_dec
    * static_key_slow_dec_deferred
    * jump_label_rate_limit

    The x86 architecture already checks this by testing if the default_nop
    was already replaced with an optimal nop or with a branch instruction. It
    will panic then. Other architectures don't check for this.

    Because we need to relax this check for the x86 arch to allow code to
    transition from default_nop to the enabled state and other architectures
    did not check for this at all this patch introduces checking on the
    static_key primitives in a non-arch dependent manner.

    All checked functions are considered slow-path so the additional check
    does no harm to performance.

    The warnings are best observed with earlyprintk.

    Based on a patch from Andi Kleen.

    Cc: Steven Rostedt
    Cc: Peter Zijlstra
    Cc: Andi Kleen
    Signed-off-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Hannes Frederic Sowa
     

09 Aug, 2013

1 commit

  • Commit b202952075f62603bea9bfb6ebc6b0420db11949 ("perf, core: Rate limit
    perf_sched_events jump_label patching") introduced rate limiting
    for jump label disabling. The changes were made in the jump label code
    in order to be more widely available and to keep things tidier. This is
    all fine, except now jump_label.h includes linux/workqueue.h, which
    makes it impossible to include jump_label.h from anything that
    workqueue.h needs. For example, it's now impossible to include
    jump_label.h from asm/spinlock.h, which is done in proposed
    pv-ticketlock patches. This patch splits out the rate limiting related
    changes from jump_label.h into a new file, jump_label_ratelimit.h, to
    resolve the issue.

    Signed-off-by: Andrew Jones
    Link: http://lkml.kernel.org/r/1376058122-8248-10-git-send-email-raghavendra.kt@linux.vnet.ibm.com
    Reviewed-by: Konrad Rzeszutek Wilk
    Signed-off-by: Raghavendra K T
    Acked-by: Ingo Molnar
    Signed-off-by: H. Peter Anvin

    Andrew Jones
     

07 Aug, 2012

1 commit


29 Feb, 2012

1 commit

  • In the jump label enabled case, calling static_key_enabled()
    results in a function call. The function returns the results of
    a compare, so it really doesn't need the overhead of a full
    function call. Let's make it 'static inline' for both the jump
    label enabled and disabled cases.

    Signed-off-by: Jason Baron
    Cc: a.p.zijlstra@chello.nl
    Cc: rostedt@goodmis.org
    Cc: mathieu.desnoyers@polymtl.ca
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Link: http://lkml.kernel.org/r/201202281849.q1SIn1p2023270@int-mx10.intmail.prod.int.phx2.redhat.com
    Signed-off-by: Ingo Molnar

    Jason Baron
     

24 Feb, 2012

1 commit

  • …_key_slow_[inc|dec]()

    So here's a boot tested patch on top of Jason's series that does
    all the cleanups I talked about and turns jump labels into a
    more intuitive to use facility. It should also address the
    various misconceptions and confusions that surround jump labels.

    Typical usage scenarios:

    #include <linux/static_key.h>

    struct static_key key = STATIC_KEY_INIT_TRUE;

    if (static_key_false(&key))
    do unlikely code
    else
    do likely code

    Or:

    if (static_key_true(&key))
    do likely code
    else
    do unlikely code

    The static key is modified via:

    static_key_slow_inc(&key);
    ...
    static_key_slow_dec(&key);

    The 'slow' prefix makes it abundantly clear that this is an
    expensive operation.

    I've updated all in-kernel code to use this everywhere. Note
    that I (intentionally) have not pushed through the rename
    blindly through to the lowest levels: the actual jump-label
    patching arch facility should be named like that, so we want to
    decouple jump labels from the static-key facility a bit.

    On non-jump-label enabled architectures static keys default to
    likely()/unlikely() branches.

    Signed-off-by: Ingo Molnar <mingo@elte.hu>
    Acked-by: Jason Baron <jbaron@redhat.com>
    Acked-by: Steven Rostedt <rostedt@goodmis.org>
    Cc: a.p.zijlstra@chello.nl
    Cc: mathieu.desnoyers@efficios.com
    Cc: davem@davemloft.net
    Cc: ddaney.cavm@gmail.com
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Link: http://lkml.kernel.org/r/20120222085809.GA26397@elte.hu
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

    Ingo Molnar
     

22 Feb, 2012

2 commits

  • While cross-compiling on sparc64, I found:

    kernel/jump_label.c: In function 'jump_label_update':
    kernel/jump_label.c:447:40: warning: cast from pointer to
    integer of different size [-Wpointer-to-int-cast]

    Fix by casting to 'unsigned long'.

    Signed-off-by: Jason Baron
    Cc: rostedt@goodmis.org
    Cc: mathieu.desnoyers@efficios.com
    Cc: davem@davemloft.net
    Cc: ddaney.cavm@gmail.com
    Cc: a.p.zijlstra@chello.nl
    Link: http://lkml.kernel.org/r/08026cbc6df80619cae833ef1ebbbc43efab69ab.1329851692.git.jbaron@redhat.com
    Signed-off-by: Ingo Molnar

    Jason Baron
     
  • The count on a jump label key should never go negative. Add a
    WARN() to check for this condition.

    Signed-off-by: Jason Baron
    Cc: Gleb Natapov
    Cc: rostedt@goodmis.org
    Cc: mathieu.desnoyers@efficios.com
    Cc: davem@davemloft.net
    Cc: ddaney.cavm@gmail.com
    Cc: a.p.zijlstra@chello.nl
    Link: http://lkml.kernel.org/r/3c68556121be4d1920417a3fe367da1ec38246b4.1329851692.git.jbaron@redhat.com
    Signed-off-by: Ingo Molnar

    Jason Baron
     

27 Dec, 2011

2 commits

  • * tip/perf/core: (66 commits)
    perf, x86: Expose perf capability to other modules
    perf, x86: Implement arch event mask as quirk
    x86, perf: Disable non available architectural events
    jump_label: Provide jump_label_key initializers
    jump_label, x86: Fix section mismatch
    perf, core: Rate limit perf_sched_events jump_label patching
    perf: Fix enable_on_exec for sibling events
    perf: Remove superfluous arguments
    perf, x86: Prefer fixed-purpose counters when scheduling
    perf, x86: Fix event scheduler for constraints with overlapping counters
    perf, x86: Implement event scheduler helper functions
    perf: Avoid a useless pmu_disable() in the perf-tick
    x86/tools: Add decoded instruction dump mode
    x86: Update instruction decoder to support new AVX formats
    x86/tools: Fix insn_sanity message outputs
    x86/tools: Fix instruction decoder message output
    x86: Fix instruction decoder to handle grouped AVX instructions
    x86/tools: Fix Makefile to build all test tools
    perf test: Soft errors shouldn't stop the "Validate PERF_RECORD_" test
    perf test: Validate PERF_RECORD_ events and perf_sample fields
    ...

    Signed-off-by: Avi Kivity

    * commit 'b3d9468a8bd218a695e3a0ff112cd4efd27b670a': (66 commits)
    perf, x86: Expose perf capability to other modules
    perf, x86: Implement arch event mask as quirk
    x86, perf: Disable non available architectural events
    jump_label: Provide jump_label_key initializers
    jump_label, x86: Fix section mismatch
    perf, core: Rate limit perf_sched_events jump_label patching
    perf: Fix enable_on_exec for sibling events
    perf: Remove superfluous arguments
    perf, x86: Prefer fixed-purpose counters when scheduling
    perf, x86: Fix event scheduler for constraints with overlapping counters
    perf, x86: Implement event scheduler helper functions
    perf: Avoid a useless pmu_disable() in the perf-tick
    x86/tools: Add decoded instruction dump mode
    x86: Update instruction decoder to support new AVX formats
    x86/tools: Fix insn_sanity message outputs
    x86/tools: Fix instruction decoder message output
    x86: Fix instruction decoder to handle grouped AVX instructions
    x86/tools: Fix Makefile to build all test tools
    perf test: Soft errors shouldn't stop the "Validate PERF_RECORD_" test
    perf test: Validate PERF_RECORD_ events and perf_sample fields
    ...

    Avi Kivity
     
  • Export these two symbols, they will be used by KVM mmu audit

    Signed-off-by: Xiao Guangrong
    Signed-off-by: Avi Kivity

    Xiao Guangrong
     

07 Dec, 2011

2 commits

  • Provide two initializers for jump_label_key that initialize it enabled
    or disabled. Also modify all jump_label code to allow for jump_labels to be
    initialized enabled.

    Signed-off-by: Peter Zijlstra
    Cc: Jason Baron
    Link: http://lkml.kernel.org/n/tip-p40e3yj21b68y03z1yv825e7@git.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     
  • WARNING: arch/x86/kernel/built-in.o(.text+0x4c71): Section mismatch in
    reference from the function arch_jump_label_transform_static() to the
    function .init.text:text_poke_early()
    The function arch_jump_label_transform_static() references
    the function __init text_poke_early().
    This is often because arch_jump_label_transform_static lacks a __init
    annotation or the annotation of text_poke_early is wrong.

    Signed-off-by: Peter Zijlstra
    Cc: Jason Baron
    Link: http://lkml.kernel.org/n/tip-9lefe89mrvurrwpqw5h8xm8z@git.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

06 Dec, 2011

2 commits

  • jump_lable patching is very expensive operation that involves pausing all
    cpus. The patching of perf_sched_events jump_label is easily controllable
    from userspace by unprivileged user.

    When te user runs a loop like this:

    "while true; do perf stat -e cycles true; done"

    ... the performance of my test application that just increments a counter
    for one second drops by 4%.

    This is on a 16 cpu box with my test application using only one of
    them. An impact on a real server doing real work will be worse.

    Performance of KVM PMU drops nearly 50% due to jump_lable for "perf
    record" since KVM PMU implementation creates and destroys perf event
    frequently.

    This patch introduces a way to rate limit jump_label patching and uses
    it to fix the above problem.

    I believe that as jump_label use will spread the problem will become more
    common and thus solving it in a generic code is appropriate. Also fixing
    it in the perf code would result in moving jump_label accounting logic to
    perf code with all the ifdefs in case of JUMP_LABEL=n kernel. With this
    patch all details are nicely hidden inside jump_label code.

    Signed-off-by: Gleb Natapov
    Acked-by: Jason Baron
    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20111127155909.GO2557@redhat.com
    Signed-off-by: Ingo Molnar

    Gleb Natapov
     
  • If cpu A calls jump_label_inc() just after atomic_add_return() is
    called by cpu B, atomic_inc_not_zero() will return value greater then
    zero and jump_label_inc() will return to a caller before jump_label_update()
    finishes its job on cpu B.

    Link: http://lkml.kernel.org/r/20111018175551.GH17571@redhat.com

    Cc: stable@vger.kernel.org
    Cc: Peter Zijlstra
    Acked-by: Jason Baron
    Signed-off-by: Gleb Natapov
    Signed-off-by: Steven Rostedt

    Gleb Natapov
     

11 Nov, 2011

1 commit


08 Nov, 2011

1 commit

  • If cpu A calls jump_label_inc() just after atomic_add_return() is
    called by cpu B, atomic_inc_not_zero() will return value greater then
    zero and jump_label_inc() will return to a caller before jump_label_update()
    finishes its job on cpu B.

    Link: http://lkml.kernel.org/r/20111018175551.GH17571@redhat.com

    Cc: stable@vger.kernel.org
    Cc: Peter Zijlstra
    Acked-by: Jason Baron
    Signed-off-by: Gleb Natapov
    Signed-off-by: Steven Rostedt

    Gleb Natapov
     

26 Oct, 2011

3 commits


29 Jun, 2011

1 commit

  • The jump labels entries for modules do not stop at __stop__jump_table,
    but after mod->jump_entries + mod_num_jump_entries.

    By checking the wrong end point, module trace events never get enabled.

    Cc: Ingo Molnar
    Acked-by: Jason Baron
    Tested-by: Avi Kivity
    Tested-by: Johannes Berg
    Signed-off-by: Xiao Guangrong
    Link: http://lkml.kernel.org/r/4E00038B.2060404@cn.fujitsu.com
    Signed-off-by: Steven Rostedt

    Xiao Guangrong
     

26 May, 2011

1 commit

  • When iterating the jump_label entries array (core or modules),
    the __jump_label_update function peeks over the last entry.

    The reason is that the end of the for loop depends on the key
    value of the processed entry. Thus when going through the
    last array entry, we will touch the memory behind the array
    limit.

    This bug probably will never be triggered, since most likely the
    memory behind the jump_label entries will be accesable and the
    entry->key will be different than the expected value.

    Signed-off-by: Jiri Olsa
    Acked-by: Jason Baron
    Link: http://lkml.kernel.org/r/20110510104346.GC1899@jolsa.brq.redhat.com
    Signed-off-by: Steven Rostedt

    Jiri Olsa
     

05 Apr, 2011

1 commit

  • Introduce:

    static __always_inline bool static_branch(struct jump_label_key *key);

    instead of the old JUMP_LABEL(key, label) macro.

    In this way, jump labels become really easy to use:

    Define:

    struct jump_label_key jump_key;

    Can be used as:

    if (static_branch(&jump_key))
    do unlikely code

    enable/disale via:

    jump_label_inc(&jump_key);
    jump_label_dec(&jump_key);

    that's it!

    For the jump labels disabled case, the static_branch() becomes an
    atomic_read(), and jump_label_inc()/dec() are simply atomic_inc(),
    atomic_dec() operations. We show testing results for this change below.

    Thanks to H. Peter Anvin for suggesting the 'static_branch()' construct.

    Since we now require a 'struct jump_label_key *key', we can store a pointer into
    the jump table addresses. In this way, we can enable/disable jump labels, in
    basically constant time. This change allows us to completely remove the previous
    hashtable scheme. Thanks to Peter Zijlstra for this re-write.

    Testing:

    I ran a series of 'tbench 20' runs 5 times (with reboots) for 3
    configurations, where tracepoints were disabled.

    jump label configured in
    avg: 815.6

    jump label *not* configured in (using atomic reads)
    avg: 800.1

    jump label *not* configured in (regular reads)
    avg: 803.4

    Signed-off-by: Peter Zijlstra
    LKML-Reference:
    Signed-off-by: Jason Baron
    Suggested-by: H. Peter Anvin
    Tested-by: David Daney
    Acked-by: Ralf Baechle
    Acked-by: David S. Miller
    Acked-by: Mathieu Desnoyers
    Signed-off-by: Steven Rostedt

    Jason Baron
     

30 Oct, 2010

1 commit


28 Oct, 2010

1 commit

  • register_kprobe() downs the 'text_mutex' and then calls
    jump_label_text_reserved(), which downs the 'jump_label_mutex'.
    However, the jump label code takes those mutexes in the reverse
    order.

    Fix by requiring the caller of jump_label_text_reserved() to do
    the jump label locking via the newly added: jump_label_lock(),
    jump_label_unlock(). Currently, kprobes is the only user
    of jump_label_text_reserved().

    Reported-by: Ingo Molnar
    Acked-by: Masami Hiramatsu
    Signed-off-by: Jason Baron
    LKML-Reference:
    Signed-off-by: Steven Rostedt

    Jason Baron