27 Jul, 2011

1 commit

  • This allows us to move duplicated code in
    (atomic_inc_not_zero() for now) to

    Signed-off-by: Arun Sharma
    Reviewed-by: Eric Dumazet
    Cc: Ingo Molnar
    Cc: David Miller
    Cc: Eric Dumazet
    Acked-by: Mike Frysinger
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arun Sharma
     

31 Mar, 2011

1 commit


07 Oct, 2010

1 commit

  • Fix the IRQ flag handling naming. In linux/irqflags.h under one configuration,
    it maps:

    local_irq_enable() -> raw_local_irq_enable()
    local_irq_disable() -> raw_local_irq_disable()
    local_irq_save() -> raw_local_irq_save()
    ...

    and under the other configuration, it maps:

    raw_local_irq_enable() -> local_irq_enable()
    raw_local_irq_disable() -> local_irq_disable()
    raw_local_irq_save() -> local_irq_save()
    ...

    This is quite confusing. There should be one set of names expected of the
    arch, and this should be wrapped to give another set of names that are expected
    by users of this facility.

    Change this to have the arch provide:

    flags = arch_local_save_flags()
    flags = arch_local_irq_save()
    arch_local_irq_restore(flags)
    arch_local_irq_disable()
    arch_local_irq_enable()
    arch_irqs_disabled_flags(flags)
    arch_irqs_disabled()
    arch_safe_halt()

    Then linux/irqflags.h wraps these to provide:

    raw_local_save_flags(flags)
    raw_local_irq_save(flags)
    raw_local_irq_restore(flags)
    raw_local_irq_disable()
    raw_local_irq_enable()
    raw_irqs_disabled_flags(flags)
    raw_irqs_disabled()
    raw_safe_halt()

    with type checking on the flags 'arguments', and then wraps those to provide:

    local_save_flags(flags)
    local_irq_save(flags)
    local_irq_restore(flags)
    local_irq_disable()
    local_irq_enable()
    irqs_disabled_flags(flags)
    irqs_disabled()
    safe_halt()

    with tracing included if enabled.

    The arch functions can now all be inline functions rather than some of them
    having to be macros.

    Signed-off-by: David Howells [X86, FRV, MN10300]
    Signed-off-by: Chris Metcalf [Tile]
    Signed-off-by: Michal Simek [Microblaze]
    Tested-by: Catalin Marinas [ARM]
    Acked-by: Thomas Gleixner
    Acked-by: Haavard Skinnemoen [AVR]
    Acked-by: Tony Luck [IA-64]
    Acked-by: Hirokazu Takata [M32R]
    Acked-by: Greg Ungerer [M68K/M68KNOMMU]
    Acked-by: Ralf Baechle [MIPS]
    Acked-by: Kyle McMartin [PA-RISC]
    Acked-by: Paul Mackerras [PowerPC]
    Acked-by: Martin Schwidefsky [S390]
    Acked-by: Chen Liqin [Score]
    Acked-by: Matt Fleming [SH]
    Acked-by: David S. Miller [Sparc]
    Acked-by: Chris Zankel [Xtensa]
    Reviewed-by: Richard Henderson [Alpha]
    Reviewed-by: Yoshinori Sato [H8300]
    Cc: starvik@axis.com [CRIS]
    Cc: jesper.nilsson@axis.com [CRIS]
    Cc: linux-cris-kernel@axis.com

    David Howells
     

01 Jun, 2010

1 commit

  • * 'for-35' of git://repo.or.cz/linux-kbuild: (81 commits)
    kbuild: Revert part of e8d400a to resolve a conflict
    kbuild: Fix checking of scm-identifier variable
    gconfig: add support to show hidden options that have prompts
    menuconfig: add support to show hidden options which have prompts
    gconfig: remove show_debug option
    gconfig: remove dbg_print_ptype() and dbg_print_stype()
    kconfig: fix zconfdump()
    kconfig: some small fixes
    add random binaries to .gitignore
    kbuild: Include gen_initramfs_list.sh and the file list in the .d file
    kconfig: recalc symbol value before showing search results
    .gitignore: ignore *.lzo files
    headerdep: perlcritic warning
    scripts/Makefile.lib: Align the output of LZO
    kbuild: Generate modules.builtin in make modules_install
    Revert "kbuild: specify absolute paths for cscope"
    kbuild: Do not unnecessarily regenerate modules.builtin
    headers_install: use local file handles
    headers_check: fix perl warnings
    export_report: fix perl warnings
    ...

    Linus Torvalds
     

13 Mar, 2010

1 commit

  • Currently sparse does not work with inline spinlock and rwlock functions.
    The problem is that they do not use the __acquires/__releases out-of-line
    functions, but use inline functions with no sparse annotations.

    This patch adds the appropriate annotations to make it work properly.

    Signed-off-by: Luca Barbieri
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Luca Barbieri
     

03 Mar, 2010

1 commit


15 Dec, 2009

7 commits

  • Make the name space hierarchy of locking functions consistent:
    raw_spin* -> _raw_spin* -> __raw_spin*

    No functional change.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Acked-by: Ingo Molnar

    Thomas Gleixner
     
  • The name space hierarchy for the internal lock functions is now a bit
    backwards. raw_spin* functions map to _spin* which use __spin*, while
    we would like to have _raw_spin* and __raw_spin*.

    _raw_spin* is already used by lock debugging, so rename those funtions
    to do_raw_spin* to free up the _raw_spin* name space.

    No functional change.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Acked-by: Ingo Molnar

    Thomas Gleixner
     
  • Now that the raw_spin name space is freed up, we can implement
    raw_spinlock and the related functions which are used to annotate the
    locks which are not converted to sleeping spinlocks in preempt-rt.

    A side effect is that only such locks can be used with the low level
    lock fsunctions which circumvent lockdep.

    For !rt spin_* functions are mapped to the raw_spin* implementations.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Acked-by: Ingo Molnar

    Thomas Gleixner
     
  • Not strictly necessary for -rt as -rt does not have non sleeping
    rwlocks, but it's odd to not have a consistent naming convention.

    No functional change.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Acked-by: David S. Miller
    Acked-by: Ingo Molnar
    Cc: linux-arch@vger.kernel.org

    Thomas Gleixner
     
  • Name space cleanup. No functional change.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Acked-by: David S. Miller
    Acked-by: Ingo Molnar
    Cc: linux-arch@vger.kernel.org

    Thomas Gleixner
     
  • The raw_spin* namespace was taken by lockdep for the architecture
    specific implementations. raw_spin_* would be the ideal name space for
    the spinlocks which are not converted to sleeping locks in preempt-rt.

    Linus suggested to convert the raw_ to arch_ locks and cleanup the
    name space instead of using an artifical name like core_spin,
    atomic_spin or whatever

    No functional change.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Acked-by: David S. Miller
    Acked-by: Ingo Molnar
    Cc: linux-arch@vger.kernel.org

    Thomas Gleixner
     
  • Move the rwlock defines and inlines into separate header files. This
    makes the selection for -rt easier.

    No functional change.

    Signed-off-by: Thomas Gleixner
    Acked-by: Peter Zijlstra
    Acked-by: Ingo Molnar

    Thomas Gleixner
     

24 Nov, 2009

2 commits


01 Sep, 2009

2 commits

  • For !DEBUG_SPINLOCK && !PREEMPT && SMP the spin_unlock()
    functions were always inlined by using special defines which
    would call the __raw* functions.

    The out-of-line variants for these functions would be generated
    anyway.

    Use the new per unlock/locking variant mechanism to force
    inlining of the unlock functions like before. This is not a
    functional change, we just get rid of one additional way to
    force inlining.

    Signed-off-by: Heiko Carstens
    Acked-by: Peter Zijlstra
    Cc: Arnd Bergmann
    Cc: Nick Piggin
    Cc: Martin Schwidefsky
    Cc: Horst Hartmann
    Cc: Christian Ehrhardt
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: David Miller
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Geert Uytterhoeven
    Cc: Roman Zippel
    Cc:
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Heiko Carstens
     
  • Move spinlock function bodies to header file by creating a
    static inline version of each variant. Use the inline version
    on the out-of-line code.

    This shouldn't make any difference besides that the spinlock
    code can now be used to generate inlined spinlock code.

    Signed-off-by: Heiko Carstens
    Acked-by: Arnd Bergmann
    Acked-by: Peter Zijlstra
    Cc: Nick Piggin
    Cc: Martin Schwidefsky
    Cc: Horst Hartmann
    Cc: Christian Ehrhardt
    Cc: Andrew Morton
    Cc: Linus Torvalds
    Cc: David Miller
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Geert Uytterhoeven
    Cc: Roman Zippel
    Cc:
    LKML-Reference:
    Signed-off-by: Ingo Molnar

    Heiko Carstens
     

10 Jul, 2009

1 commit

  • Adding smp_mb__after_lock define to be used as a smp_mb call after
    a lock.

    Making it nop for x86, since {read|write|spin}_lock() on x86 are
    full memory barriers.

    Signed-off-by: Jiri Olsa
    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Jiri Olsa
     

03 Apr, 2009

1 commit

  • Pass the original flags to rwlock arch-code, so that it can re-enable
    interrupts if implemented for that architecture.

    Initially, make __raw_read_lock_flags and __raw_write_lock_flags stubs
    which just do the same thing as non-flags variants.

    Signed-off-by: Petr Tesarik
    Signed-off-by: Robin Holt
    Acked-by: Peter Zijlstra
    Cc:
    Acked-by: Ingo Molnar
    Cc: "Luck, Tony"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Robin Holt
     

10 Feb, 2009

1 commit

  • Architectures other than mips and x86 are not using ticket spinlocks.
    Therefore, the contention on the lock is meaningless, since there is
    nobody known to be waiting on it (arguably /fairly/ unfair locks).

    Dummy it out to return 0 on other architectures.

    Signed-off-by: Kyle McMartin
    Acked-by: Ralf Baechle
    Acked-by: Ingo Molnar
    Signed-off-by: Linus Torvalds

    Kyle McMartin
     

11 Aug, 2008

1 commit

  • Expose the new lock protection lock.

    This can be used to annotate places where we take multiple locks of the
    same class and avoid deadlocks by always taking another (top-level) lock
    first.

    NOTE: we're still bound to the MAX_LOCK_DEPTH (48) limit.

    Signed-off-by: Peter Zijlstra
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

26 Jul, 2008

1 commit

  • There haave been several areas in the kernel where an int has been used for
    flags in local_irq_save() and friends instead of a long. This can cause some
    hard to debug problems on some architectures.

    This patch adds a typecheck inside the irqsave and restore functions to flag
    these cases.

    [akpm@linux-foundation.org: coding-style fixes]
    [akpm@linux-foundation.org: build fix]
    Signed-off-by: Steven Rostedt
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Steven Rostedt
     

17 Apr, 2008

1 commit

  • double_spin_lock() has no callers, and it can't be used without additional
    lockdep annotations, remove it.

    Signed-off-by: Oleg Nesterov
    Cc: Arjan van de Ven
    Cc: Heiko Carstens
    Cc: Ingo Molnar
    Cc: Peter Zijlstra
    Signed-off-by: Andrew Morton
    Signed-off-by: Thomas Gleixner

    Oleg Nesterov
     

12 Apr, 2008

1 commit


09 Feb, 2008

1 commit


30 Jan, 2008

1 commit

  • The break_lock data structure and code for spinlocks is quite nasty.
    Not only does it double the size of a spinlock but it changes locking to
    a potentially less optimal trylock.

    Put all of that under CONFIG_GENERIC_LOCKBREAK, and introduce a
    __raw_spin_is_contended that uses the lock data itself to determine whether
    there are waiters on the lock, to be used if CONFIG_GENERIC_LOCKBREAK is
    not set.

    Rename need_lockbreak to spin_needbreak, make it use spin_is_contended to
    decouple it from the spinlock implementation, and make it typesafe (rwlocks
    do not have any need_lockbreak sites -- why do they even get bloated up
    with that break_lock then?).

    Signed-off-by: Nick Piggin
    Signed-off-by: Ingo Molnar
    Signed-off-by: Thomas Gleixner

    Nick Piggin
     

17 Jul, 2007

1 commit

  • Introduce a write_trylock_irqsave() implementation. Similar in style to
    the implementation of spin_trylock_irqsave() in mainline.

    Signed-off-by: Satyam Sharma
    Cc: Sripathi Kodi
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Satyam Sharma
     

05 Mar, 2007

1 commit

  • Doing something like this on a two cpu system

    # echo 0 > /sys/devices/system/cpu/cpu0/online
    # echo 1 > /sys/devices/system/cpu/cpu0/online
    # echo 0 > /sys/devices/system/cpu/cpu1/online

    will give me this:

    =======================================================
    [ INFO: possible circular locking dependency detected ]
    2.6.21-rc2-g562aa1d4-dirty #7
    -------------------------------------------------------
    bash/1282 is trying to acquire lock:
    (&cpu_base->lock_key){.+..}, at: [] hrtimer_cpu_notify+0xc6/0x240

    but task is already holding lock:
    (&cpu_base->lock_key#2){.+..}, at: [] hrtimer_cpu_notify+0xbc/0x240

    which lock already depends on the new lock.

    This happens because we have the following code in kernel/hrtimer.c:

    migrate_hrtimers(int cpu)
    [...]
    old_base = &per_cpu(hrtimer_bases, cpu);
    new_base = &get_cpu_var(hrtimer_bases);
    [...]
    spin_lock(&new_base->lock);
    spin_lock(&old_base->lock);

    Which means the spinlocks are taken in an order which depends on which cpu
    gets shut down from which other cpu. Therefore lockdep complains that there
    might be an ABBA deadlock. Since migrate_hrtimers() gets only called on
    cpu hotplug it's safe to assume that it isn't executed concurrently on a

    The same problem exists in kernel/timer.c: migrate_timers().

    As pointed out by Christian Borntraeger one possible solution to avoid
    the locking order complaints would be to make sure that the locks are
    always taken in the same order. E.g. by taking the lock of the cpu with
    the lower number first.

    To achieve this we introduce two new spinlock functions double_spin_lock
    and double_spin_unlock which lock or unlock two locks in a given order.

    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Cc: Roman Zippel
    Cc: John Stultz
    Cc: Christian Borntraeger
    Cc: Martin Schwidefsky
    Signed-off-by: Heiko Carstens
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

12 Feb, 2007

1 commit


08 Dec, 2006

1 commit

  • With CONFIG_SMP=n:

    drivers/input/ff-memless.c:384: warning: implicit declaration of function 'local_bh_disable'
    drivers/input/ff-memless.c:393: warning: implicit declaration of function 'local_bh_enable'

    Really linux/spinlock.h should include linux/interrupt.h. But interrupt.h
    includes sched.h which will need spinlock.h.

    So the patch breaks the _bh declarations out into a separate header and
    includes it in both interrupt.h and spinlock.h.

    Cc: "Randy.Dunlap"
    Cc: Andi Kleen
    Cc:
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

27 Nov, 2006

1 commit

  • This reverts commit ee3ce191e8eaa4cc15c51a28b34143b36404c4f5, since it
    broke on at least ARM, MIPS and PA-RISC due to complicated header file
    dependencies.

    Conflicts in include/linux/spinlock.h (due to the "nested" variety
    fixes) fixed up by hand.

    Cc: Alexey Dobriyan
    Cc: Ralf Baechle
    Cc: Kyle McMartin
    Cc: Russell King
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     

26 Nov, 2006

2 commits

  • Introduce spin_lock_irqsave_nested(); implementation from:
    http://lkml.org/lkml/2006/6/1/122
    Patch from:
    http://lkml.org/lkml/2006/9/13/258

    [akpm@osdl.org: two compile fixes]
    Signed-off-by: Arjan van de Ven
    Signed-off-by: Jiri Kosina
    Signed-off-by: Peter Zijlstra
    Acked-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Arjan van de Ven
     
  • Make it break or warn if you pass to spin_lock_irqsave() and friends
    something different from "unsigned long flags;". Suprisingly large amount
    of these was caught by recent commit
    c53421b18f205c5f97c604ae55c6a921f034b0f6 and others.

    Idea is largely from FRV typechecking. Suggestions from Andrew Morton.
    All stupid typos in first version fixed.

    Passes allmodconfig on i386, x86_64, alpha, arm as well as my usual config.

    Note #1: checking with sparse is still needed, because a driver can save
    and pass around flags or something. So far patch is very intrusive.
    Note #2: techically, we should break only if
    sizeof(flags) < sizeof(unsigned long),
    however, the more pain for getting suspicious code into kernel,
    the better.

    Signed-off-by: Alexey Dobriyan
    Cc: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Dobriyan
     

30 Sep, 2006

2 commits


04 Jul, 2006

1 commit


26 Apr, 2006

1 commit


26 Dec, 2005

1 commit

  • This patch fixes a problem when we use well known kernel symbols as module
    names.

    For example, if module source name is current.c, idle_stack.c or etc.,
    we have a bad KBUILD_MODNAME value.
    For example, KBUILD_MODNAME will be "get_current()" instead of "current", or
    "(init_thread_union.stack)" instead of "idle_task".

    The trick is to define a stringify macro on the commandline - named
    KBUILD_STR for namespace reasons - and then to stringify the module
    name.

    There are a few uses of KBUILD_MODNAME throughout the tree but the usage
    is for debug and will not be harmed by this change so left untouched for now.

    While at it KBUILD_BASENAME was changed too. Any spinlock usage in the
    unix module would have created wrong section names without it.
    Usage in spinlock.h fixed so it no longer stringify KBUILD_BASENAME.

    Original patch from Ustyogov Roman - all bugs introduced by me.

    Signed-off-by: Sam Ravnborg

    Ustyugov Roman
     

31 Oct, 2005

1 commit


11 Sep, 2005

1 commit

  • This patch (written by me and also containing many suggestions of Arjan van
    de Ven) does a major cleanup of the spinlock code. It does the following
    things:

    - consolidates and enhances the spinlock/rwlock debugging code

    - simplifies the asm/spinlock.h files

    - encapsulates the raw spinlock type and moves generic spinlock
    features (such as ->break_lock) into the generic code.

    - cleans up the spinlock code hierarchy to get rid of the spaghetti.

    Most notably there's now only a single variant of the debugging code,
    located in lib/spinlock_debug.c. (previously we had one SMP debugging
    variant per architecture, plus a separate generic one for UP builds)

    Also, i've enhanced the rwlock debugging facility, it will now track
    write-owners. There is new spinlock-owner/CPU-tracking on SMP builds too.
    All locks have lockup detection now, which will work for both soft and hard
    spin/rwlock lockups.

    The arch-level include files now only contain the minimally necessary
    subset of the spinlock code - all the rest that can be generalized now
    lives in the generic headers:

    include/asm-i386/spinlock_types.h | 16
    include/asm-x86_64/spinlock_types.h | 16

    I have also split up the various spinlock variants into separate files,
    making it easier to see which does what. The new layout is:

    SMP | UP
    ----------------------------|-----------------------------------
    asm/spinlock_types_smp.h | linux/spinlock_types_up.h
    linux/spinlock_types.h | linux/spinlock_types.h
    asm/spinlock_smp.h | linux/spinlock_up.h
    linux/spinlock_api_smp.h | linux/spinlock_api_up.h
    linux/spinlock.h | linux/spinlock.h

    /*
    * here's the role of the various spinlock/rwlock related include files:
    *
    * on SMP builds:
    *
    * asm/spinlock_types.h: contains the raw_spinlock_t/raw_rwlock_t and the
    * initializers
    *
    * linux/spinlock_types.h:
    * defines the generic type and initializers
    *
    * asm/spinlock.h: contains the __raw_spin_*()/etc. lowlevel
    * implementations, mostly inline assembly code
    *
    * (also included on UP-debug builds:)
    *
    * linux/spinlock_api_smp.h:
    * contains the prototypes for the _spin_*() APIs.
    *
    * linux/spinlock.h: builds the final spin_*() APIs.
    *
    * on UP builds:
    *
    * linux/spinlock_type_up.h:
    * contains the generic, simplified UP spinlock type.
    * (which is an empty structure on non-debug builds)
    *
    * linux/spinlock_types.h:
    * defines the generic type and initializers
    *
    * linux/spinlock_up.h:
    * contains the __raw_spin_*()/etc. version of UP
    * builds. (which are NOPs on non-debug, non-preempt
    * builds)
    *
    * (included on UP-non-debug builds:)
    *
    * linux/spinlock_api_up.h:
    * builds the _spin_*() APIs.
    *
    * linux/spinlock.h: builds the final spin_*() APIs.
    */

    All SMP and UP architectures are converted by this patch.

    arm, i386, ia64, ppc, ppc64, s390/s390x, x64 was build-tested via
    crosscompilers. m32r, mips, sh, sparc, have not been tested yet, but should
    be mostly fine.

    From: Grant Grundler

    Booted and lightly tested on a500-44 (64-bit, SMP kernel, dual CPU).
    Builds 32-bit SMP kernel (not booted or tested). I did not try to build
    non-SMP kernels. That should be trivial to fix up later if necessary.

    I converted bit ops atomic_hash lock to raw_spinlock_t. Doing so avoids
    some ugly nesting of linux/*.h and asm/*.h files. Those particular locks
    are well tested and contained entirely inside arch specific code. I do NOT
    expect any new issues to arise with them.

    If someone does ever need to use debug/metrics with them, then they will
    need to unravel this hairball between spinlocks, atomic ops, and bit ops
    that exist only because parisc has exactly one atomic instruction: LDCW
    (load and clear word).

    From: "Luck, Tony"

    ia64 fix

    Signed-off-by: Ingo Molnar
    Signed-off-by: Arjan van de Ven
    Signed-off-by: Grant Grundler
    Cc: Matthew Wilcox
    Signed-off-by: Hirokazu Takata
    Signed-off-by: Mikael Pettersson
    Signed-off-by: Benoit Boissinot
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ingo Molnar