29 Jul, 2020

1 commit

  • This patch moves ATOMIC_INIT from asm/atomic.h into linux/types.h.
    This allows users of atomic_t to use ATOMIC_INIT without having to
    include atomic.h as that way may lead to header loops.

    Signed-off-by: Herbert Xu
    Signed-off-by: Peter Zijlstra (Intel)
    Acked-by: Waiman Long
    Link: https://lkml.kernel.org/r/20200729123105.GB7047@gondor.apana.org.au

    Herbert Xu
     

24 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public licence as published by
    the free software foundation either version 2 of the licence or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 114 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190520170857.552531963@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 Jun, 2018

4 commits

  • Many of the inc/dec ops are mandatory, but for most architectures inc/dec are
    simply trivial wrappers around their corresponding add/sub ops.

    Let's make all the inc/dec ops optional, so that we can get rid of these
    boilerplate wrappers.

    The instrumented atomics are updated accordingly.

    There should be no functional change as a result of this patch.

    Signed-off-by: Mark Rutland
    Reviewed-by: Will Deacon
    Acked-by: Peter Zijlstra (Intel)
    Acked-by: Palmer Dabbelt
    Cc: Boqun Feng
    Cc: Linus Torvalds
    Cc: Thomas Gleixner
    Link: https://lore.kernel.org/lkml/20180621121321.4761-17-mark.rutland@arm.com
    Signed-off-by: Ingo Molnar

    Mark Rutland
     
  • Some of the atomics return the result of a test applied after the atomic
    operation, and almost all architectures implement these as trivial
    wrappers around the underlying atomic. Specifically:

    * _inc_and_test(v) is (_inc_return(v) == 0)
    * _dec_and_test(v) is (_dec_return(v) == 0)
    * _sub_and_test(i, v) is (_sub_return(i, v) == 0)
    * _add_negative(i, v) is (_add_return(i, v) < 0)

    Rather than have these definitions duplicated in all architectures, with
    minor inconsistencies in formatting and documentation, let's make these
    operations optional, with default fallbacks as above. Implementations
    must now provide a preprocessor symbol.

    The instrumented atomics are updated accordingly.

    Both x86 and m68k have custom implementations, which are left as-is,
    given preprocessor symbols to avoid being overridden.

    There should be no functional change as a result of this patch.

    Signed-off-by: Mark Rutland
    Reviewed-by: Will Deacon
    Acked-by: Geert Uytterhoeven
    Acked-by: Peter Zijlstra (Intel)
    Acked-by: Palmer Dabbelt
    Cc: Boqun Feng
    Cc: Linus Torvalds
    Cc: Thomas Gleixner
    Link: https://lore.kernel.org/lkml/20180621121321.4761-16-mark.rutland@arm.com
    Signed-off-by: Ingo Molnar

    Mark Rutland
     
  • Several architectures these have a near-identical implementation based
    on atomic_read() and atomic_cmpxchg() which we can instead define in
    , so let's do so, using something close to the existing
    x86 implementation with try_cmpxchg().

    Where an architecture provides its own atomic_fetch_add_unless(), it
    must define a preprocessor symbol for it. The instrumented atomics are
    updated accordingly.

    Note that arch/arc's existing atomic_fetch_add_unless() had redundant
    barriers, as these are already present in its atomic_cmpxchg()
    implementation.

    There should be no functional change as a result of this patch.

    Signed-off-by: Mark Rutland
    Reviewed-by: Geert Uytterhoeven
    Reviewed-by: Will Deacon
    Acked-by: Geert Uytterhoeven
    Acked-by: Peter Zijlstra (Intel)
    Acked-by: Palmer Dabbelt
    Cc: Boqun Feng
    Cc: Linus Torvalds
    Cc: Thomas Gleixner
    Cc: Vineet Gupta
    Link: https://lore.kernel.org/lkml/20180621121321.4761-7-mark.rutland@arm.com
    Signed-off-by: Ingo Molnar

    Mark Rutland
     
  • While __atomic_add_unless() was originally intended as a building-block
    for atomic_add_unless(), it's now used in a number of places around the
    kernel. It's the only common atomic operation named __atomic*(), rather
    than atomic_*(), and for consistency it would be better named
    atomic_fetch_add_unless().

    This lack of consistency is slightly confusing, and gets in the way of
    scripting atomics. Given that, let's clean things up and promote it to
    an official part of the atomics API, in the form of
    atomic_fetch_add_unless().

    This patch converts definitions and invocations over to the new name,
    including the instrumented version, using the following script:

    ----
    git grep -w __atomic_add_unless | while read line; do
    sed -i '{s/\/atomic_fetch_add_unless/}' "${line%%:*}";
    done
    git grep -w __arch_atomic_add_unless | while read line; do
    sed -i '{s/\/arch_atomic_fetch_add_unless/}' "${line%%:*}";
    done
    ----

    Note that we do not have atomic{64,_long}_fetch_add_unless(), which will
    be introduced by later patches.

    There should be no functional change as a result of this patch.

    Signed-off-by: Mark Rutland
    Reviewed-by: Will Deacon
    Acked-by: Geert Uytterhoeven
    Acked-by: Peter Zijlstra (Intel)
    Acked-by: Palmer Dabbelt
    Cc: Boqun Feng
    Cc: Linus Torvalds
    Cc: Thomas Gleixner
    Link: https://lore.kernel.org/lkml/20180621121321.4761-2-mark.rutland@arm.com
    Signed-off-by: Ingo Molnar

    Mark Rutland
     

10 Mar, 2018

1 commit


25 Feb, 2017

1 commit

  • Using the l.lwa and l.swa atomic instruction pair.
    Most openrisc processor cores provide these instructions now. If the
    instructions are not available emulation is provided.

    Acked-by: Peter Zijlstra (Intel)
    Cc: Peter Zijlstra
    Signed-off-by: Stefan Kristiansson
    [shorne@gmail.com: remove OPENRISC_HAVE_INST_LWA_SWA config suggesed by
    Alan Cox https://lkml.org/lkml/2014/7/23/666]
    [shorne@gmail.com: expand to implement all ops suggested by Peter
    Zijlstra https://lkml.org/lkml/2017/2/20/317]
    Signed-off-by: Stafford Horne

    Stefan Kristiansson
     

16 Jun, 2016

2 commits

  • Since all architectures have this implemented now natively, remove this
    dead code.

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

    Peter Zijlstra
     
  • …relaxed,_acquire,_release}()

    Now that all the architectures have implemented support for these new
    atomic primitives add on the generic infrastructure to expose and use
    it.

    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Cc: Andrew Morton <akpm@linux-foundation.org>
    Cc: Arnd Bergmann <arnd@arndb.de>
    Cc: Boqun Feng <boqun.feng@gmail.com>
    Cc: Borislav Petkov <bp@suse.de>
    Cc: Davidlohr Bueso <dave@stgolabs.net>
    Cc: Frederic Weisbecker <fweisbec@gmail.com>
    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: Will Deacon <will.deacon@arm.com>
    Cc: linux-arch@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Peter Zijlstra
     

23 Sep, 2015

1 commit

  • This patch makes sure that atomic_{read,set}() are at least
    {READ,WRITE}_ONCE().

    We already had the 'requirement' that atomic_read() should use
    ACCESS_ONCE(), and most archs had this, but a few were lacking.
    All are now converted to use READ_ONCE().

    And, by a symmetry and general paranoia argument, upgrade atomic_set()
    to use WRITE_ONCE().

    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Andrew Morton
    Cc: Dmitry Vyukov
    Cc: Linus Torvalds
    Cc: Paul E. McKenney
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: james.hogan@imgtec.com
    Cc: linux-kernel@vger.kernel.org
    Cc: oleg@redhat.com
    Cc: will.deacon@arm.com
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

27 Jul, 2015

3 commits


03 Oct, 2014

1 commit

  • Use the much more reader friendly ACCESS_ONCE() instead of the cast to volatile.
    This is purely a stylistic change.

    Signed-off-by: Pranith Kumar
    Acked-by: Jesper Nilsson
    Acked-by: Hans-Christian Egtvedt
    Acked-by: Max Filippov
    Signed-off-by: Peter Zijlstra (Intel)
    Cc: Linus Torvalds
    Cc: linux-arch@vger.kernel.org
    Link: http://lkml.kernel.org/r/1411482607-20948-1-git-send-email-bobby.prani@gmail.com
    Signed-off-by: Ingo Molnar

    Pranith Kumar
     

14 Aug, 2014

1 commit

  • Rewrite generic atomic support to only require cmpxchg(), generate all
    other primitives from that.

    Furthermore reduce the endless repetition for all these primitives to
    a few CPP macros. This way we get more for less lines.

    Signed-off-by: Peter Zijlstra
    Link: http://lkml.kernel.org/r/20140508135852.940119622@infradead.org
    Cc: Arnd Bergmann
    Cc: David Howells
    Cc: Paul E. McKenney
    Cc: David S. Miller
    Cc: Linus Torvalds
    Cc: linux-arch@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

18 Apr, 2014

1 commit

  • Since the smp_mb__{before,after}*() ops are fundamentally dependent on
    how an arch can implement atomics it doesn't make sense to have 3
    variants of them. They must all be the same.

    Furthermore, the 3 variants suggest they're only valid for those 3
    atomic ops, while we have many more where they could be applied.

    So move away from
    smp_mb__{before,after}_{atomic,clear}_{dec,inc,bit}() and reduce the
    interface to just the two: smp_mb__{before,after}_atomic().

    This patch prepares the way by introducing default implementations in
    asm-generic/barrier.h that default to a full barrier and providing
    __deprecated inlines for the previous 6 barriers if they're not
    provided by the arch.

    This should allow for a mostly painless transition (lots of deprecated
    warns in the interim).

    Signed-off-by: Peter Zijlstra
    Acked-by: Paul E. McKenney
    Link: http://lkml.kernel.org/n/tip-wr59327qdyi9mbzn6x937s4e@git.kernel.org
    Cc: Arnd Bergmann
    Cc: "Chen, Gong"
    Cc: John Sullivan
    Cc: Linus Torvalds
    Cc: Mauro Carvalho Chehab
    Cc: Srinivas Pandruvada
    Cc: "Theodore Ts'o"
    Cc: linux-arch@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Peter Zijlstra
     

13 Mar, 2013

1 commit

  • asm/cmpxchg.h can be included on its own and needs to be self-consistent.
    The definitions for the cmpxchg*_local macros, as such, need to be part
    of this file.

    This fixes a build issue on OpenRISC since the system.h smashing patch
    96f951edb1f1bdbbc99b0cd458f9808bb83d58ae that introdued the direct inclusion
    asm/cmpxchg.h into linux/llist.h.

    CC: David Howells
    Signed-off-by: Jonas Bonn
    Acked-by: Arnd Bergmann

    Jonas Bonn
     

29 Mar, 2012

2 commits

  • Remove all #inclusions of asm/system.h preparatory to splitting and killing
    it. Performed with the following command:

    perl -p -i -e 's!^#\s*include\s*.*\n!!' `grep -Irl '^#\s*include\s*' *`

    Signed-off-by: David Howells

    David Howells
     
  • Make asm-generic/cmpxchg.h #include asm-generic/cmpxchg-local.h as all arch
    files that #include the former also #include the latter. See:

    grep -rl asm-generic/cmpxchg-local[.]h arch/ | sort > b
    grep -rl asm-generic/cmpxchg[.]h arch/ | sort > a
    comm a b

    This simplifies the disintegration of asm-generic/system.h for arches that
    don't have their own.

    Signed-off-by: David Howells
    Acked-by: Arnd Bergmann

    David Howells
     

27 Jul, 2011

8 commits

  • Only a few core funcs need to be implemented for SMP systems, so allow the
    arches to override them while getting the rest for free.

    At least, this is enough to allow the Blackfin SMP port to use things.

    Signed-off-by: Mike Frysinger
    Cc: Arun Sharma
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     
  • Since arches are expected to implement this guy, add a common version for
    people the same way as atomic_clear_mask is handled.

    Signed-off-by: Mike Frysinger
    Cc: Arun Sharma
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     
  • The atomic helpers are supposed to take an atomic_t pointer, not a random
    unsigned long pointer. So convert atomic_clear_mask over.

    While we're here, also add some nice documentation to the func.

    Signed-off-by: Mike Frysinger
    Cc: Arun Sharma
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     
  • We already declared inc/dec helpers, so we don't need to call the
    atomic_{add,sub}_return funcs directly.

    Signed-off-by: Mike Frysinger
    Cc: Arun Sharma
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     
  • This clarifies the differences between and

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

    Arun Sharma
     
  • After changing all consumers of atomics to include , we
    ran into some compile time errors due to this dependency chain:

    linux/atomic.h
    -> asm/atomic.h
    -> asm-generic/atomic-long.h

    where atomic-long.h could use funcs defined later in linux/atomic.h
    without a prototype. This patches moves the code that includes
    asm-generic/atomic*.h to linux/atomic.h.

    Archs that need need to select
    CONFIG_GENERIC_ATOMIC64 from now on (some of them used to include it
    unconditionally).

    Compile tested on i386 and x86_64 with allnoconfig.

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

    Arun Sharma
     
  • This is in preparation for more generic atomic primitives based on
    __atomic_add_unless.

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

    Arun Sharma
     
  • 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
     

23 Oct, 2010

1 commit

  • * git://git.kernel.org/pub/scm/linux/kernel/git/arnd/asm-generic:
    asm-generic/io.h: allow people to override individual funcs
    bitops: remove duplicated extern declarations
    bitops: make asm-generic/bitops/find.h more generic
    asm-generic: kdebug.h: Checkpatch cleanup
    asm-generic: fcntl: make exported headers use strict posix types
    asm-generic: cmpxchg does not handle non-long arguments
    asm-generic: make atomic_add_unless a function

    Linus Torvalds
     

10 Oct, 2010

1 commit

  • atomic_add_unless is a macro so, bad things happen if the caller defines
    a local variable named c, just like like the local variable c defined by
    the macro. Thus, convert atomic_add_unless to a function. (bug triggered
    by net/ipv4/netfilter/ipt_CLUSTERIP.c: clusterip_config_find_get calls
    atomic_inc_not_zero)

    Signed-off-by: Mathieu Lacage
    Signed-off-by: Arnd Bergmann

    Mathieu Lacage
     

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
     

10 Aug, 2010

1 commit

  • The start/stop_critical_timing functions for preemptirqsoff, preemptoff
    and irqsoff tracers contain atomic_inc() and atomic_dec() operations.

    Atomic operations use local_irq_save/restore macros to ensure atomic
    access but they are traced by the same function which is causing recursion
    problem.

    The reason is when these tracers are turn ON then the
    local_irq_save/restore macros are changed in include/linux/irqflags.h to
    call trace_hardirqs_on/off which call start/stop_critical_timing.

    Microblaze was affected because it uses generic atomic implementation.

    Signed-off-by: Michal Simek
    Acked-by: Steven Rostedt
    Cc: Ingo Molnar
    Cc: Thomas Gleixner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michal Simek
     

25 May, 2010

1 commit

  • 32-bit Sparc used to only allow usage of 24-bit of it's atomic_t type.
    This was corrected with linux 2.6.3 when Keith M Wesolowski changed the
    implementation to use the parisc approach of having an array of spinlocks
    to protect the atomic_t.

    These warnings were also removed from the sparc implementation when the
    new implementation was merged in BKrev:402e4949VThdc6D3iaosSFUgabMfvw, but
    the warning still remained in some other places without any 24-bit-only
    atomic_t implementation inside the kernel.

    We should remove these warnings to allow users to rely on the full 32-bit
    range of atomic_t.

    Signed-off-by: Peter Fritzsche
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Peter Fritzsche
     

17 May, 2010

1 commit


12 Jun, 2009

2 commits


03 May, 2009

1 commit

  • On a linux-next allyesconfig build:

    kernel/trace/ring_buffer.c:1726:
    warning: passing argument 1 of 'atomic_cmpxchg' from incompatible pointer type
    linux-next/arch/s390/include/asm/atomic.h:112:
    note: expected 'struct atomic_t *' but argument is of type 'struct atomic64_t *'

    atomic_long_cmpxchg and atomic_long_xchg are incorrectly defined for 64
    bit architectures. They should be mapped to the atomic64_* variants.

    Acked-by: Mathieu Desnoyers
    Signed-off-by: Heiko Carstens
    Acked-by: Ingo Molnar
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Heiko Carstens
     

11 Dec, 2008

1 commit


05 Jul, 2008

1 commit

  • Remove all clameter@sgi.com addresses from the kernel tree since they will
    become invalid on June 27th. Change my maintainer email address for the
    slab allocators to cl@linux-foundation.org (which will be the new email
    address for the future).

    Signed-off-by: Christoph Lameter
    Signed-off-by: Christoph Lameter
    Cc: Pekka Enberg
    Cc: Stephen Rothwell
    Cc: Matt Mackall
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Lameter
     

09 May, 2007

1 commit

  • atomic_add_unless as inline. Remove system.h atomic.h circular dependency.
    I agree (with Andi Kleen) this typeof is not needed and more error
    prone. All the original atomic.h code that uses cmpxchg (which includes
    the atomic_add_unless) uses defines instead of inline functions,
    probably to circumvent a circular dependency between system.h and
    atomic.h on powerpc (which my patch addresses). Therefore, it makes
    sense to use inline functions that will provide type checking.

    atomic_add_unless as inline. Remove system.h atomic.h circular dependency.
    Digging into the FRV architecture shows me that it is also affected by
    such a circular dependency. Here is the diff applying this against the
    rest of my atomic.h patches.

    It applies over the atomic.h standardization patches.

    Signed-off-by: Mathieu Desnoyers
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mathieu Desnoyers