atomics: generate atomic headers / instrument arm64
Subsystems (3)
tip-bot for Mark Rutland
merge bot[tip:locking/core] locking/atomics: Switch to generated instrumentation
In reply to Mark Rutlandlocking/atomics: Switch to generated instrumentation
Commit-ID: aa525d063851a98e020b827fdd1d7776ae652301 Gitweb: https://git.kernel.org/tip/aa525d063851a98e020b827fdd1d7776ae652301 Author: Mark Rutland <[email protected]> AuthorDate: Tue, 4 Sep 2018 11:48:28 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 1 Nov 2018 11:01:03 +0100
locking/atomics: Switch to generated instrumentation
As a step towards ensuring the atomic* APIs are consistent, let's switch to wrappers generated by gen-atomic-instrumented.h, using the same table used to generate the fallbacks and atomic-long wrappers.
These are checked in rather than generated with Kbuild, since:
* This allows inspection of the atomics with git grep and ctags on a pristine tree, which Linus strongly prefers being able to do.
* The fallbacks are not affected by machine details or configuration options, so it is not necessary to regenerate them to take these into account.
* These are included by files required *very* early in the build process (e.g. for generating bounds.h), and we'd rather not complicate the top-level Kbuild file with dependencies.
Generating the atomic headers means that the instrumented wrappers will remain in sync with the rest of the atomic APIs, and we gain all the ordering variants of each atomic without having to manually expanded them all.
The KASAN checks are automatically generated based on the function parameters defined in atomics.tbl. Note that try_cmpxchg() now correctly treats 'old' as a parameter that may be written to, and not only read as the hand-written instrumentation assumed.
Other than the change to try_cmpxchg(), existing code should not be affected by this patch. The patch introduces instrumentation for all optional atomics (and ordering variants), along with the ifdeffery this requires, enabling other architectures to make use of the instrumented atomics.
--- include/asm-generic/atomic-instrumented.h | 1688 +++++++++++++++++++++++++---- 1 file changed, 1504 insertions(+), 184 deletions(-)
include/asm-generic/atomic-instrumented.h +1504 -184
@@ -1,3 +1,8 @@ +// SPDX-License-Identifier: GPL-2.0 + +// Generated by scripts/atomic/gen-atomic-instrumented.sh +// DO NOT MODIFY THIS FILE DIRECTLY +/* * This file provides wrappers with KASAN instrumentation for atomic operations. * To use this functionality an arch's atomic.h file needs to define all
@@ -9,459 +14,1774 @@* arch_ variants (i.e. arch_atomic_read()/arch_atomic_cmpxchg()) to avoid * double instrumentation. */ +#ifndef _ASM_GENERIC_ATOMIC_INSTRUMENTED_H +#define _ASM_GENERIC_ATOMIC_INSTRUMENTED_H + +#include <linux/build_bug.h> +#include <linux/kasan-checks.h> + +static inline int +atomic_read (const atomic_t *v) +{ +kasan_check_read (v,sizeof (*v)); +return arch_atomic_read (v); +} +#define atomic_read atomic_read + +#if defined(arch_atomic_read_acquire) +static inline int +atomic_read_acquire (const atomic_t *v) +{ +kasan_check_read (v,sizeof (*v)); +return arch_atomic_read_acquire (v); +} +#define atomic_read_acquire atomic_read_acquire +#endif + +static inline void +atomic_set (atomic_t *v,int i) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_set (v, i); +} +#define atomic_set atomic_set + +#if defined(arch_atomic_set_release) +static inline void +atomic_set_release (atomic_t *v,int i) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_set_release (v, i); +} +#define atomic_set_release atomic_set_release +#endif + +static inline void +atomic_add (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_add (i, v); +} +#define atomic_add atomic_add + +#if !defined(arch_atomic_add_return_relaxed) || defined(arch_atomic_add_return) +static inline int +atomic_add_return (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_add_return (i, v); +} +#define atomic_add_return atomic_add_return +#endif + +#if defined(arch_atomic_add_return_acquire) +static inline int +atomic_add_return_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_add_return_acquire (i, v); +} +#define atomic_add_return_acquire atomic_add_return_acquire +#endif + +#if defined(arch_atomic_add_return_release) +static inline int +atomic_add_return_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_add_return_release (i, v); +} +#define atomic_add_return_release atomic_add_return_release +#endif + +#if defined(arch_atomic_add_return_relaxed) +static inline int +atomic_add_return_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_add_return_relaxed (i, v); +} +#define atomic_add_return_relaxed atomic_add_return_relaxed +#endif + +#if !defined(arch_atomic_fetch_add_relaxed) || defined(arch_atomic_fetch_add) +static inline int +atomic_fetch_add (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_add (i, v); +} +#define atomic_fetch_add atomic_fetch_add +#endif + +#if defined(arch_atomic_fetch_add_acquire) +static inline int +atomic_fetch_add_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_add_acquire (i, v); +} +#define atomic_fetch_add_acquire atomic_fetch_add_acquire +#endif + +#if defined(arch_atomic_fetch_add_release) +static inline int +atomic_fetch_add_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_add_release (i, v); +} +#define atomic_fetch_add_release atomic_fetch_add_release +#endif + +#if defined(arch_atomic_fetch_add_relaxed) +static inline int +atomic_fetch_add_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_add_relaxed (i, v); +} +#define atomic_fetch_add_relaxed atomic_fetch_add_relaxed +#endif + +static inline void +atomic_sub (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_sub (i, v); +} +#define atomic_sub atomic_sub + +#if !defined(arch_atomic_sub_return_relaxed) || defined(arch_atomic_sub_return) +static inline int +atomic_sub_return (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_sub_return (i, v); +} +#define atomic_sub_return atomic_sub_return +#endif + +#if defined(arch_atomic_sub_return_acquire) +static inline int +atomic_sub_return_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_sub_return_acquire (i, v); +} +#define atomic_sub_return_acquire atomic_sub_return_acquire +#endif + +#if defined(arch_atomic_sub_return_release) +static inline int +atomic_sub_return_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_sub_return_release (i, v); +} +#define atomic_sub_return_release atomic_sub_return_release +#endif + +#if defined(arch_atomic_sub_return_relaxed) +static inline int +atomic_sub_return_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_sub_return_relaxed (i, v); +} +#define atomic_sub_return_relaxed atomic_sub_return_relaxed +#endif + +#if !defined(arch_atomic_fetch_sub_relaxed) || defined(arch_atomic_fetch_sub) +static inline int +atomic_fetch_sub (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_sub (i, v); +} +#define atomic_fetch_sub atomic_fetch_sub +#endif + +#if defined(arch_atomic_fetch_sub_acquire) +static inline int +atomic_fetch_sub_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_sub_acquire (i, v); +} +#define atomic_fetch_sub_acquire atomic_fetch_sub_acquire +#endif + +#if defined(arch_atomic_fetch_sub_release) +static inline int +atomic_fetch_sub_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_sub_release (i, v); +} +#define atomic_fetch_sub_release atomic_fetch_sub_release +#endif + +#if defined(arch_atomic_fetch_sub_relaxed) +static inline int +atomic_fetch_sub_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_sub_relaxed (i, v); +} +#define atomic_fetch_sub_relaxed atomic_fetch_sub_relaxed +#endif + +#if defined(arch_atomic_inc) +static inline void +atomic_inc (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_inc (v); +} +#define atomic_inc atomic_inc +#endif + +#if defined(arch_atomic_inc_return) +static inline int +atomic_inc_return (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_inc_return (v); +} +#define atomic_inc_return atomic_inc_return +#endif + +#if defined(arch_atomic_inc_return_acquire) +static inline int +atomic_inc_return_acquire (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_inc_return_acquire (v); +} +#define atomic_inc_return_acquire atomic_inc_return_acquire +#endif + +#if defined(arch_atomic_inc_return_release) +static inline int +atomic_inc_return_release (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_inc_return_release (v); +} +#define atomic_inc_return_release atomic_inc_return_release +#endif + +#if defined(arch_atomic_inc_return_relaxed) +static inline int +atomic_inc_return_relaxed (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_inc_return_relaxed (v); +} +#define atomic_inc_return_relaxed atomic_inc_return_relaxed +#endif + +#if defined(arch_atomic_fetch_inc) +static inline int +atomic_fetch_inc (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_inc (v); +} +#define atomic_fetch_inc atomic_fetch_inc +#endif + +#if defined(arch_atomic_fetch_inc_acquire) +static inline int +atomic_fetch_inc_acquire (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_inc_acquire (v); +} +#define atomic_fetch_inc_acquire atomic_fetch_inc_acquire +#endif + +#if defined(arch_atomic_fetch_inc_release) +static inline int +atomic_fetch_inc_release (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_inc_release (v); +} +#define atomic_fetch_inc_release atomic_fetch_inc_release +#endif + +#if defined(arch_atomic_fetch_inc_relaxed) +static inline int +atomic_fetch_inc_relaxed (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_inc_relaxed (v); +} +#define atomic_fetch_inc_relaxed atomic_fetch_inc_relaxed +#endif + +#if defined(arch_atomic_dec) +static inline void +atomic_dec (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_dec (v); +} +#define atomic_dec atomic_dec +#endif + +#if defined(arch_atomic_dec_return) +static inline int +atomic_dec_return (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_dec_return (v); +} +#define atomic_dec_return atomic_dec_return +#endif + +#if defined(arch_atomic_dec_return_acquire) +static inline int +atomic_dec_return_acquire (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_dec_return_acquire (v); +} +#define atomic_dec_return_acquire atomic_dec_return_acquire +#endif + +#if defined(arch_atomic_dec_return_release) +static inline int +atomic_dec_return_release (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_dec_return_release (v); +} +#define atomic_dec_return_release atomic_dec_return_release +#endif + +#if defined(arch_atomic_dec_return_relaxed) +static inline int +atomic_dec_return_relaxed (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_dec_return_relaxed (v); +} +#define atomic_dec_return_relaxed atomic_dec_return_relaxed +#endif + +#if defined(arch_atomic_fetch_dec) +static inline int +atomic_fetch_dec (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_dec (v); +} +#define atomic_fetch_dec atomic_fetch_dec +#endif + +#if defined(arch_atomic_fetch_dec_acquire) +static inline int +atomic_fetch_dec_acquire (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_dec_acquire (v); +} +#define atomic_fetch_dec_acquire atomic_fetch_dec_acquire +#endif + +#if defined(arch_atomic_fetch_dec_release) +static inline int +atomic_fetch_dec_release (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_dec_release (v); +} +#define atomic_fetch_dec_release atomic_fetch_dec_release +#endif + +#if defined(arch_atomic_fetch_dec_relaxed) +static inline int +atomic_fetch_dec_relaxed (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_dec_relaxed (v); +} +#define atomic_fetch_dec_relaxed atomic_fetch_dec_relaxed +#endif + +static inline void +atomic_and (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_and (i, v); +} +#define atomic_and atomic_and + +#if !defined(arch_atomic_fetch_and_relaxed) || defined(arch_atomic_fetch_and) +static inline int +atomic_fetch_and (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_and (i, v); +} +#define atomic_fetch_and atomic_fetch_and +#endif + +#if defined(arch_atomic_fetch_and_acquire) +static inline int +atomic_fetch_and_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_and_acquire (i, v); +} +#define atomic_fetch_and_acquire atomic_fetch_and_acquire +#endif + +#if defined(arch_atomic_fetch_and_release) +static inline int +atomic_fetch_and_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_and_release (i, v); +} +#define atomic_fetch_and_release atomic_fetch_and_release +#endif + +#if defined(arch_atomic_fetch_and_relaxed) +static inline int +atomic_fetch_and_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_and_relaxed (i, v); +} +#define atomic_fetch_and_relaxed atomic_fetch_and_relaxed +#endif + +#if defined(arch_atomic_andnot) +static inline void +atomic_andnot (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_andnot (i, v); +} +#define atomic_andnot atomic_andnot +#endif + +#if defined(arch_atomic_fetch_andnot) +static inline int +atomic_fetch_andnot (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_andnot (i, v); +} +#define atomic_fetch_andnot atomic_fetch_andnot +#endif + +#if defined(arch_atomic_fetch_andnot_acquire) +static inline int +atomic_fetch_andnot_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_andnot_acquire (i, v); +} +#define atomic_fetch_andnot_acquire atomic_fetch_andnot_acquire +#endif + +#if defined(arch_atomic_fetch_andnot_release) +static inline int +atomic_fetch_andnot_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_andnot_release (i, v); +} +#define atomic_fetch_andnot_release atomic_fetch_andnot_release +#endif + +#if defined(arch_atomic_fetch_andnot_relaxed) +static inline int +atomic_fetch_andnot_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_andnot_relaxed (i, v); +} +#define atomic_fetch_andnot_relaxed atomic_fetch_andnot_relaxed +#endif + +static inline void +atomic_or (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_or (i, v); +} +#define atomic_or atomic_or + +#if !defined(arch_atomic_fetch_or_relaxed) || defined(arch_atomic_fetch_or) +static inline int +atomic_fetch_or (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_or (i, v); +} +#define atomic_fetch_or atomic_fetch_or +#endif + +#if defined(arch_atomic_fetch_or_acquire) +static inline int +atomic_fetch_or_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_or_acquire (i, v); +} +#define atomic_fetch_or_acquire atomic_fetch_or_acquire +#endif + +#if defined(arch_atomic_fetch_or_release) +static inline int +atomic_fetch_or_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_or_release (i, v); +} +#define atomic_fetch_or_release atomic_fetch_or_release +#endif + +#if defined(arch_atomic_fetch_or_relaxed) +static inline int +atomic_fetch_or_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_or_relaxed (i, v); +} +#define atomic_fetch_or_relaxed atomic_fetch_or_relaxed +#endif + +static inline void +atomic_xor (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic_xor (i, v); +} +#define atomic_xor atomic_xor + +#if !defined(arch_atomic_fetch_xor_relaxed) || defined(arch_atomic_fetch_xor) +static inline int +atomic_fetch_xor (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_xor (i, v); +} +#define atomic_fetch_xor atomic_fetch_xor +#endif + +#if defined(arch_atomic_fetch_xor_acquire) +static inline int +atomic_fetch_xor_acquire (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_xor_acquire (i, v); +} +#define atomic_fetch_xor_acquire atomic_fetch_xor_acquire +#endif + +#if defined(arch_atomic_fetch_xor_release) +static inline int +atomic_fetch_xor_release (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_xor_release (i, v); +} +#define atomic_fetch_xor_release atomic_fetch_xor_release +#endif + +#if defined(arch_atomic_fetch_xor_relaxed) +static inline int +atomic_fetch_xor_relaxed (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_xor_relaxed (i, v); +} +#define atomic_fetch_xor_relaxed atomic_fetch_xor_relaxed +#endif + +#if !defined(arch_atomic_xchg_relaxed) || defined(arch_atomic_xchg) +static inline int +atomic_xchg (atomic_t *v,int i) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_xchg (v, i); +} +#define atomic_xchg atomic_xchg +#endif + +#if defined(arch_atomic_xchg_acquire) +static inline int +atomic_xchg_acquire (atomic_t *v,int i) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_xchg_acquire (v, i); +} +#define atomic_xchg_acquire atomic_xchg_acquire +#endif + +#if defined(arch_atomic_xchg_release) +static inline int +atomic_xchg_release (atomic_t *v,int i) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_xchg_release (v, i); +} +#define atomic_xchg_release atomic_xchg_release +#endif + +#if defined(arch_atomic_xchg_relaxed) +static inline int +atomic_xchg_relaxed (atomic_t *v,int i) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_xchg_relaxed (v, i); +} +#define atomic_xchg_relaxed atomic_xchg_relaxed +#endif + +#if !defined(arch_atomic_cmpxchg_relaxed) || defined(arch_atomic_cmpxchg) +static inline int +atomic_cmpxchg (atomic_t *v,int old,int new) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_cmpxchg (v, old, new); +} +#define atomic_cmpxchg atomic_cmpxchg +#endif + +#if defined(arch_atomic_cmpxchg_acquire) +static inline int +atomic_cmpxchg_acquire (atomic_t *v,int old,int new) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_cmpxchg_acquire (v, old, new); +} +#define atomic_cmpxchg_acquire atomic_cmpxchg_acquire +#endif + +#if defined(arch_atomic_cmpxchg_release) +static inline int +atomic_cmpxchg_release (atomic_t *v,int old,int new) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_cmpxchg_release (v, old, new); +} +#define atomic_cmpxchg_release atomic_cmpxchg_release +#endif + +#if defined(arch_atomic_cmpxchg_relaxed) +static inline int +atomic_cmpxchg_relaxed (atomic_t *v,int old,int new) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_cmpxchg_relaxed (v, old, new); +} +#define atomic_cmpxchg_relaxed atomic_cmpxchg_relaxed +#endif + +#if defined(arch_atomic_try_cmpxchg) +static inline bool +atomic_try_cmpxchg (atomic_t *v,int *old,int new) +{ +kasan_check_write (v,sizeof (*v)); +kasan_check_write (old,sizeof (*old)); +return arch_atomic_try_cmpxchg (v, old, new); +} +#define atomic_try_cmpxchg atomic_try_cmpxchg +#endif + +#if defined(arch_atomic_try_cmpxchg_acquire) +static inline bool +atomic_try_cmpxchg_acquire (atomic_t *v,int *old,int new) +{ +kasan_check_write (v,sizeof (*v)); +kasan_check_write (old,sizeof (*old)); +return arch_atomic_try_cmpxchg_acquire (v, old, new); +} +#define atomic_try_cmpxchg_acquire atomic_try_cmpxchg_acquire +#endif + +#if defined(arch_atomic_try_cmpxchg_release) +static inline bool +atomic_try_cmpxchg_release (atomic_t *v,int *old,int new) +{ +kasan_check_write (v,sizeof (*v)); +kasan_check_write (old,sizeof (*old)); +return arch_atomic_try_cmpxchg_release (v, old, new); +} +#define atomic_try_cmpxchg_release atomic_try_cmpxchg_release +#endif + +#if defined(arch_atomic_try_cmpxchg_relaxed) +static inline bool +atomic_try_cmpxchg_relaxed (atomic_t *v,int *old,int new) +{ +kasan_check_write (v,sizeof (*v)); +kasan_check_write (old,sizeof (*old)); +return arch_atomic_try_cmpxchg_relaxed (v, old, new); +} +#define atomic_try_cmpxchg_relaxed atomic_try_cmpxchg_relaxed +#endif + +#if defined(arch_atomic_sub_and_test) +static inline bool +atomic_sub_and_test (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_sub_and_test (i, v); +} +#define atomic_sub_and_test atomic_sub_and_test +#endif + +#if defined(arch_atomic_dec_and_test) +static inline bool +atomic_dec_and_test (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_dec_and_test (v); +} +#define atomic_dec_and_test atomic_dec_and_test +#endif + +#if defined(arch_atomic_inc_and_test) +static inline bool +atomic_inc_and_test (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_inc_and_test (v); +} +#define atomic_inc_and_test atomic_inc_and_test +#endif + +#if defined(arch_atomic_add_negative) +static inline bool +atomic_add_negative (int i,atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_add_negative (i, v); +} +#define atomic_add_negative atomic_add_negative +#endif + +#if defined(arch_atomic_fetch_add_unless) +static inline int +atomic_fetch_add_unless (atomic_t *v,int a,int u) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_fetch_add_unless (v, a, u); +} +#define atomic_fetch_add_unless atomic_fetch_add_unless +#endif + +#if defined(arch_atomic_add_unless) +static inline bool +atomic_add_unless (atomic_t *v,int a,int u) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_add_unless (v, a, u); +} +#define atomic_add_unless atomic_add_unless +#endif + +#if defined(arch_atomic_inc_not_zero) +static inline bool +atomic_inc_not_zero (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_inc_not_zero (v); +} +#define atomic_inc_not_zero atomic_inc_not_zero +#endif + +#if defined(arch_atomic_inc_unless_negative) +static inline bool +atomic_inc_unless_negative (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_inc_unless_negative (v); +} +#define atomic_inc_unless_negative atomic_inc_unless_negative +#endif + +#if defined(arch_atomic_dec_unless_positive) +static inline bool +atomic_dec_unless_positive (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_dec_unless_positive (v); +} +#define atomic_dec_unless_positive atomic_dec_unless_positive +#endif + +#if defined(arch_atomic_dec_if_positive) +static inline int +atomic_dec_if_positive (atomic_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic_dec_if_positive (v); +} +#define atomic_dec_if_positive atomic_dec_if_positive +#endif + +static inline s64 +atomic64_read (const atomic64_t *v) +{ +kasan_check_read (v,sizeof (*v)); +return arch_atomic64_read (v); +} +#define atomic64_read atomic64_read + +#if defined(arch_atomic64_read_acquire) +static inline s64 +atomic64_read_acquire (const atomic64_t *v) +{ +kasan_check_read (v,sizeof (*v)); +return arch_atomic64_read_acquire (v); +} +#define atomic64_read_acquire atomic64_read_acquire +#endif + +static inline void +atomic64_set (atomic64_t *v,s64 i) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic64_set (v, i); +} +#define atomic64_set atomic64_set + +#if defined(arch_atomic64_set_release) +static inline void +atomic64_set_release (atomic64_t *v,s64 i) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic64_set_release (v, i); +} +#define atomic64_set_release atomic64_set_release +#endif + +static inline void +atomic64_add (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic64_add (i, v); +} +#define atomic64_add atomic64_add + +#if !defined(arch_atomic64_add_return_relaxed) || defined(arch_atomic64_add_return) +static inline s64 +atomic64_add_return (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_add_return (i, v); +} +#define atomic64_add_return atomic64_add_return +#endif + +#if defined(arch_atomic64_add_return_acquire) +static inline s64 +atomic64_add_return_acquire (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_add_return_acquire (i, v); +} +#define atomic64_add_return_acquire atomic64_add_return_acquire +#endif + +#if defined(arch_atomic64_add_return_release) +static inline s64 +atomic64_add_return_release (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_add_return_release (i, v); +} +#define atomic64_add_return_release atomic64_add_return_release +#endif + +#if defined(arch_atomic64_add_return_relaxed) +static inline s64 +atomic64_add_return_relaxed (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_add_return_relaxed (i, v); +} +#define atomic64_add_return_relaxed atomic64_add_return_relaxed +#endif + +#if !defined(arch_atomic64_fetch_add_relaxed) || defined(arch_atomic64_fetch_add) +static inline s64 +atomic64_fetch_add (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_add (i, v); +} +#define atomic64_fetch_add atomic64_fetch_add +#endif + +#if defined(arch_atomic64_fetch_add_acquire) +static inline s64 +atomic64_fetch_add_acquire (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_add_acquire (i, v); +} +#define atomic64_fetch_add_acquire atomic64_fetch_add_acquire +#endif + +#if defined(arch_atomic64_fetch_add_release) +static inline s64 +atomic64_fetch_add_release (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_add_release (i, v); +} +#define atomic64_fetch_add_release atomic64_fetch_add_release +#endif + +#if defined(arch_atomic64_fetch_add_relaxed) +static inline s64 +atomic64_fetch_add_relaxed (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_add_relaxed (i, v); +} +#define atomic64_fetch_add_relaxed atomic64_fetch_add_relaxed +#endif + +static inline void +atomic64_sub (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +arch_atomic64_sub (i, v); +} +#define atomic64_sub atomic64_sub -#ifndef _LINUX_ATOMIC_INSTRUMENTED_H -#define _LINUX_ATOMIC_INSTRUMENTED_H +#if !defined(arch_atomic64_sub_return_relaxed) || defined(arch_atomic64_sub_return) +static inline s64 +atomic64_sub_return (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_sub_return (i, v); +} +#define atomic64_sub_return atomic64_sub_return +#endif -#include <linux/build_bug.h> -#include <linux/kasan-checks.h> +#if defined(arch_atomic64_sub_return_acquire) +static inline s64 +atomic64_sub_return_acquire (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_sub_return_acquire (i, v); +} +#define atomic64_sub_return_acquire atomic64_sub_return_acquire +#endif -static __always_inline int atomic_read(const atomic_t *v) +#if defined(arch_atomic64_sub_return_release) +static inline s64 +atomic64_sub_return_release (s64 i,atomic64_t *v) { -kasan_check_read (v,sizeof (*v)); -return arch_atomic_read (v); +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_sub_return_release (i, v); } +#define atomic64_sub_return_release atomic64_sub_return_release +#endif -static __always_inline s64 atomic64_read(const atomic64_t *v) +#if defined(arch_atomic64_sub_return_relaxed) +static inline s64 +atomic64_sub_return_relaxed (s64 i,atomic64_t *v) { -kasan_check_read (v,sizeof (*v)); -return arch_atomic64_read (v); +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_sub_return_relaxed (i, v); } +#define atomic64_sub_return_relaxed atomic64_sub_return_relaxed +#endif -static __always_inline void atomic_set(atomic_t *v, int i) +#if !defined(arch_atomic64_fetch_sub_relaxed) || defined(arch_atomic64_fetch_sub) +static inline s64 +atomic64_fetch_sub (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_set (v, i); +return arch_atomic64_fetch_sub (i, v); } +#define atomic64_fetch_sub atomic64_fetch_sub +#endif -static __always_inline void atomic64_set(atomic64_t *v, s64 i) +#if defined(arch_atomic64_fetch_sub_acquire) +static inline s64 +atomic64_fetch_sub_acquire (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic64_set (v, i); +return arch_atomic64_fetch_sub_acquire (i, v); } +#define atomic64_fetch_sub_acquire atomic64_fetch_sub_acquire +#endif -static __always_inline int atomic_xchg(atomic_t *v, int i) +#if defined(arch_atomic64_fetch_sub_release) +static inline s64 +atomic64_fetch_sub_release (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_xchg (v, i); +return arch_atomic64_fetch_sub_release (i, v); } +#define atomic64_fetch_sub_release atomic64_fetch_sub_release +#endif -static __always_inline s64 atomic64_xchg(atomic64_t *v, s64 i) +#if defined(arch_atomic64_fetch_sub_relaxed) +static inline s64 +atomic64_fetch_sub_relaxed (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_xchg (v, i); +return arch_atomic64_fetch_sub_relaxed (i, v); } +#define atomic64_fetch_sub_relaxed atomic64_fetch_sub_relaxed +#endif -static __always_inline int atomic_cmpxchg(atomic_t *v, int old, int new) +#if defined(arch_atomic64_inc) +static inline void +atomic64_inc (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_cmpxchg (v, old, new); +arch_atomic64_inc (v); } +#define atomic64_inc atomic64_inc +#endif -static __always_inline s64 atomic64_cmpxchg(atomic64_t *v, s64 old, s64 new) +#if defined(arch_atomic64_inc_return) +static inline s64 +atomic64_inc_return (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_cmpxchg (v, old, new); +return arch_atomic64_inc_return (v); } +#define atomic64_inc_return atomic64_inc_return +#endif -#ifdef arch_atomic_try_cmpxchg -#define atomic_try_cmpxchg atomic_try_cmpxchg -static __always_inline bool atomic_try_cmpxchg(atomic_t *v, int *old, int new) +#if defined(arch_atomic64_inc_return_acquire) +static inline s64 +atomic64_inc_return_acquire (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -kasan_check_read (old,sizeof (*old)); -return arch_atomic_try_cmpxchg (v, old, new); +return arch_atomic64_inc_return_acquire (v); } +#define atomic64_inc_return_acquire atomic64_inc_return_acquire#endif -#ifdef arch_atomic64_try_cmpxchg -#define atomic64_try_cmpxchg atomic64_try_cmpxchg -static __always_inline bool atomic64_try_cmpxchg(atomic64_t *v, s64 *old, s64 new) +#if defined(arch_atomic64_inc_return_release) +static inline s64 +atomic64_inc_return_release (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -kasan_check_read (old,sizeof (*old)); -return arch_atomic64_try_cmpxchg (v, old, new); +return arch_atomic64_inc_return_release (v); } +#define atomic64_inc_return_release atomic64_inc_return_release#endif -#ifdef arch_atomic_fetch_add_unless -#define atomic_fetch_add_unless atomic_fetch_add_unless -static __always_inline int atomic_fetch_add_unless(atomic_t *v, int a, int u) +#if defined(arch_atomic64_inc_return_relaxed) +static inline s64 +atomic64_inc_return_relaxed (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_fetch_add_unless (v, a, u); +return arch_atomic64_inc_return_relaxed (v); } +#define atomic64_inc_return_relaxed atomic64_inc_return_relaxed#endif -#ifdef arch_atomic64_fetch_add_unless -#define atomic64_fetch_add_unless atomic64_fetch_add_unless -static __always_inline s64 atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u) +#if defined(arch_atomic64_fetch_inc) +static inline s64 +atomic64_fetch_inc (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_fetch_add_unless (v, a, u); +return arch_atomic64_fetch_inc (v); } +#define atomic64_fetch_inc atomic64_fetch_inc#endif -#ifdef arch_atomic_inc -#define atomic_inc atomic_inc -static __always_inline void atomic_inc(atomic_t *v) +#if defined(arch_atomic64_fetch_inc_acquire) +static inline s64 +atomic64_fetch_inc_acquire (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_inc (v); +return arch_atomic64_fetch_inc_acquire (v); } +#define atomic64_fetch_inc_acquire atomic64_fetch_inc_acquire#endif -#ifdef arch_atomic64_inc -#define atomic64_inc atomic64_inc -static __always_inline void atomic64_inc(atomic64_t *v) +#if defined(arch_atomic64_fetch_inc_release) +static inline s64 +atomic64_fetch_inc_release (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic64_inc (v); +return arch_atomic64_fetch_inc_release (v); } +#define atomic64_fetch_inc_release atomic64_fetch_inc_release#endif -#ifdef arch_atomic_dec -#define atomic_dec atomic_dec -static __always_inline void atomic_dec(atomic_t *v) +#if defined(arch_atomic64_fetch_inc_relaxed) +static inline s64 +atomic64_fetch_inc_relaxed (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_dec (v); +return arch_atomic64_fetch_inc_relaxed (v); } +#define atomic64_fetch_inc_relaxed atomic64_fetch_inc_relaxed#endif -#ifdef atch_atomic64_dec -#define atomic64_dec -static __always_inline void atomic64_dec(atomic64_t *v) +#if defined(arch_atomic64_dec) +static inline void +atomic64_dec (atomic64_t *v) {kasan_check_write (v,sizeof (*v));arch_atomic64_dec (v); } +#define atomic64_dec atomic64_dec#endif -static __always_inline void atomic_add(int i, atomic_t *v) +#if defined(arch_atomic64_dec_return) +static inline s64 +atomic64_dec_return (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_add (i, v); +return arch_atomic64_dec_return (v); } +#define atomic64_dec_return atomic64_dec_return +#endif -static __always_inline void atomic64_add(s64 i, atomic64_t *v) +#if defined(arch_atomic64_dec_return_acquire) +static inline s64 +atomic64_dec_return_acquire (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic64_add (i, v); +return arch_atomic64_dec_return_acquire (v); } +#define atomic64_dec_return_acquire atomic64_dec_return_acquire +#endif -static __always_inline void atomic_sub(int i, atomic_t *v) +#if defined(arch_atomic64_dec_return_release) +static inline s64 +atomic64_dec_return_release (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_sub (i, v); +return arch_atomic64_dec_return_release (v); } +#define atomic64_dec_return_release atomic64_dec_return_release +#endif -static __always_inline void atomic64_sub(s64 i, atomic64_t *v) +#if defined(arch_atomic64_dec_return_relaxed) +static inline s64 +atomic64_dec_return_relaxed (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic64_sub (i, v); +return arch_atomic64_dec_return_relaxed (v); } +#define atomic64_dec_return_relaxed atomic64_dec_return_relaxed +#endif -static __always_inline void atomic_and(int i, atomic_t *v) +#if defined(arch_atomic64_fetch_dec) +static inline s64 +atomic64_fetch_dec (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_and (i, v); +return arch_atomic64_fetch_dec (v); +} +#define atomic64_fetch_dec atomic64_fetch_dec +#endif + +#if defined(arch_atomic64_fetch_dec_acquire) +static inline s64 +atomic64_fetch_dec_acquire (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_dec_acquire (v); +} +#define atomic64_fetch_dec_acquire atomic64_fetch_dec_acquire +#endif + +#if defined(arch_atomic64_fetch_dec_release) +static inline s64 +atomic64_fetch_dec_release (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_dec_release (v); } +#define atomic64_fetch_dec_release atomic64_fetch_dec_release +#endif + +#if defined(arch_atomic64_fetch_dec_relaxed) +static inline s64 +atomic64_fetch_dec_relaxed (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_dec_relaxed (v); +} +#define atomic64_fetch_dec_relaxed atomic64_fetch_dec_relaxed +#endif -static __always_inline void atomic64_and(s64 i, atomic64_t *v) +static inline void +atomic64_and (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v));arch_atomic64_and (i, v); } +#define atomic64_and atomic64_and -static __always_inline void atomic_or(int i, atomic_t *v) +#if !defined(arch_atomic64_fetch_and_relaxed) || defined(arch_atomic64_fetch_and) +static inline s64 +atomic64_fetch_and (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_or (i, v); +return arch_atomic64_fetch_and (i, v); } +#define atomic64_fetch_and atomic64_fetch_and +#endif -static __always_inline void atomic64_or(s64 i, atomic64_t *v) +#if defined(arch_atomic64_fetch_and_acquire) +static inline s64 +atomic64_fetch_and_acquire (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic64_or (i, v); +return arch_atomic64_fetch_and_acquire (i, v); } +#define atomic64_fetch_and_acquire atomic64_fetch_and_acquire +#endif -static __always_inline void atomic_xor(int i, atomic_t *v) +#if defined(arch_atomic64_fetch_and_release) +static inline s64 +atomic64_fetch_and_release (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic_xor (i, v); +return arch_atomic64_fetch_and_release (i, v); } +#define atomic64_fetch_and_release atomic64_fetch_and_release +#endif -static __always_inline void atomic64_xor(s64 i, atomic64_t *v) +#if defined(arch_atomic64_fetch_and_relaxed) +static inline s64 +atomic64_fetch_and_relaxed (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -arch_atomic64_xor (i, v); +return arch_atomic64_fetch_and_relaxed (i, v); } +#define atomic64_fetch_and_relaxed atomic64_fetch_and_relaxed +#endif -#ifdef arch_atomic_inc_return -#define atomic_inc_return atomic_inc_return -static __always_inline int atomic_inc_return(atomic_t *v) +#if defined(arch_atomic64_andnot) +static inline void +atomic64_andnot (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_inc_return (v); +arch_atomic64_andnot (i, v); } +#define atomic64_andnot atomic64_andnot#endif -#ifdef arch_atomic64_in_return -#define atomic64_inc_return atomic64_inc_return -static __always_inline s64 atomic64_inc_return(atomic64_t *v) +#if defined(arch_atomic64_fetch_andnot) +static inline s64 +atomic64_fetch_andnot (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_inc_return (v); +return arch_atomic64_fetch_andnot (i, v); } +#define atomic64_fetch_andnot atomic64_fetch_andnot#endif -#ifdef arch_atomic_dec_return -#define atomic_dec_return atomic_dec_return -static __always_inline int atomic_dec_return(atomic_t *v) +#if defined(arch_atomic64_fetch_andnot_acquire) +static inline s64 +atomic64_fetch_andnot_acquire (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_dec_return (v); +return arch_atomic64_fetch_andnot_acquire (i, v); } +#define atomic64_fetch_andnot_acquire atomic64_fetch_andnot_acquire#endif -#ifdef arch_atomic64_dec_return -#define atomic64_dec_return atomic64_dec_return -static __always_inline s64 atomic64_dec_return(atomic64_t *v) +#if defined(arch_atomic64_fetch_andnot_release) +static inline s64 +atomic64_fetch_andnot_release (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_dec_return (v); +return arch_atomic64_fetch_andnot_release (i, v); } +#define atomic64_fetch_andnot_release atomic64_fetch_andnot_release#endif -#ifdef arch_atomic64_inc_not_zero -#define atomic64_inc_not_zero atomic64_inc_not_zero -static __always_inline bool atomic64_inc_not_zero(atomic64_t *v) +#if defined(arch_atomic64_fetch_andnot_relaxed) +static inline s64 +atomic64_fetch_andnot_relaxed (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_inc_not_zero (v); +return arch_atomic64_fetch_andnot_relaxed (i, v); } +#define atomic64_fetch_andnot_relaxed atomic64_fetch_andnot_relaxed#endif -#ifdef arch_atomic64_dec_if_positive -#define atomic64_dec_if_positive atomic64_dec_if_positive -static __always_inline s64 atomic64_dec_if_positive(atomic64_t *v) +static inline void +atomic64_or (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_dec_if_positive (v); +arch_atomic64_or (i, v); +} +#define atomic64_or atomic64_or + +#if !defined(arch_atomic64_fetch_or_relaxed) || defined(arch_atomic64_fetch_or) +static inline s64 +atomic64_fetch_or (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_or (i, v); } +#define atomic64_fetch_or atomic64_fetch_or#endif -#ifdef arch_atomic_dec_and_test -#define atomic_dec_and_test atomic_dec_and_test -static __always_inline bool atomic_dec_and_test(atomic_t *v) +#if defined(arch_atomic64_fetch_or_acquire) +static inline s64 +atomic64_fetch_or_acquire (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_dec_and_test (v); +return arch_atomic64_fetch_or_acquire (i, v); } +#define atomic64_fetch_or_acquire atomic64_fetch_or_acquire#endif -#ifdef arch_atomic64_dec_and_test -#define atomic64_dec_and_test atomic64_dec_and_test -static __always_inline bool atomic64_dec_and_test(atomic64_t *v) +#if defined(arch_atomic64_fetch_or_release) +static inline s64 +atomic64_fetch_or_release (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_dec_and_test (v); +return arch_atomic64_fetch_or_release (i, v); } +#define atomic64_fetch_or_release atomic64_fetch_or_release#endif -#ifdef arch_atomic_inc_and_test -#define atomic_inc_and_test atomic_inc_and_test -static __always_inline bool atomic_inc_and_test(atomic_t *v) +#if defined(arch_atomic64_fetch_or_relaxed) +static inline s64 +atomic64_fetch_or_relaxed (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_inc_and_test (v); +return arch_atomic64_fetch_or_relaxed (i, v); } +#define atomic64_fetch_or_relaxed atomic64_fetch_or_relaxed#endif -#ifdef arch_atomic64_inc_and_test -#define atomic64_inc_and_test atomic64_inc_and_test -static __always_inline bool atomic64_inc_and_test(atomic64_t *v) +static inline void +atomic64_xor (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_inc_and_test (v); +arch_atomic64_xor (i, v); +} +#define atomic64_xor atomic64_xor + +#if !defined(arch_atomic64_fetch_xor_relaxed) || defined(arch_atomic64_fetch_xor) +static inline s64 +atomic64_fetch_xor (s64 i,atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_xor (i, v); } +#define atomic64_fetch_xor atomic64_fetch_xor#endif -static __always_inline int atomic_add_return(int i, atomic_t *v) +#if defined(arch_atomic64_fetch_xor_acquire) +static inline s64 +atomic64_fetch_xor_acquire (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_add_return (i, v); +return arch_atomic64_fetch_xor_acquire (i, v); } +#define atomic64_fetch_xor_acquire atomic64_fetch_xor_acquire +#endif -static __always_inline s64 atomic64_add_return(s64 i, atomic64_t *v) +#if defined(arch_atomic64_fetch_xor_release) +static inline s64 +atomic64_fetch_xor_release (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_add_return (i, v); +return arch_atomic64_fetch_xor_release (i, v); } +#define atomic64_fetch_xor_release atomic64_fetch_xor_release +#endif -static __always_inline int atomic_sub_return(int i, atomic_t *v) +#if defined(arch_atomic64_fetch_xor_relaxed) +static inline s64 +atomic64_fetch_xor_relaxed (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_sub_return (i, v); +return arch_atomic64_fetch_xor_relaxed (i, v); } +#define atomic64_fetch_xor_relaxed atomic64_fetch_xor_relaxed +#endif -static __always_inline s64 atomic64_sub_return(s64 i, atomic64_t *v) +#if !defined(arch_atomic64_xchg_relaxed) || defined(arch_atomic64_xchg) +static inline s64 +atomic64_xchg (atomic64_t *v,s64 i) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_sub_return (i, v); +return arch_atomic64_xchg (v, i); } +#define atomic64_xchg atomic64_xchg +#endif -static __always_inline int atomic_fetch_add(int i, atomic_t *v) +#if defined(arch_atomic64_xchg_acquire) +static inline s64 +atomic64_xchg_acquire (atomic64_t *v,s64 i) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_fetch_add (i, v); +return arch_atomic64_xchg_acquire (v, i); } +#define atomic64_xchg_acquire atomic64_xchg_acquire +#endif -static __always_inline s64 atomic64_fetch_add(s64 i, atomic64_t *v) +#if defined(arch_atomic64_xchg_release) +static inline s64 +atomic64_xchg_release (atomic64_t *v,s64 i) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_fetch_add (i, v); +return arch_atomic64_xchg_release (v, i); } +#define atomic64_xchg_release atomic64_xchg_release +#endif -static __always_inline int atomic_fetch_sub(int i, atomic_t *v) +#if defined(arch_atomic64_xchg_relaxed) +static inline s64 +atomic64_xchg_relaxed (atomic64_t *v,s64 i) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_fetch_sub (i, v); +return arch_atomic64_xchg_relaxed (v, i); } +#define atomic64_xchg_relaxed atomic64_xchg_relaxed +#endif -static __always_inline s64 atomic64_fetch_sub(s64 i, atomic64_t *v) +#if !defined(arch_atomic64_cmpxchg_relaxed) || defined(arch_atomic64_cmpxchg) +static inline s64 +atomic64_cmpxchg (atomic64_t *v,s64 old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_fetch_sub (i, v); +return arch_atomic64_cmpxchg (v, old, new); } +#define atomic64_cmpxchg atomic64_cmpxchg +#endif -static __always_inline int atomic_fetch_and(int i, atomic_t *v) +#if defined(arch_atomic64_cmpxchg_acquire) +static inline s64 +atomic64_cmpxchg_acquire (atomic64_t *v,s64 old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_fetch_and (i, v); +return arch_atomic64_cmpxchg_acquire (v, old, new); } +#define atomic64_cmpxchg_acquire atomic64_cmpxchg_acquire +#endif -static __always_inline s64 atomic64_fetch_and(s64 i, atomic64_t *v) +#if defined(arch_atomic64_cmpxchg_release) +static inline s64 +atomic64_cmpxchg_release (atomic64_t *v,s64 old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_fetch_and (i, v); +return arch_atomic64_cmpxchg_release (v, old, new); } +#define atomic64_cmpxchg_release atomic64_cmpxchg_release +#endif -static __always_inline int atomic_fetch_or(int i, atomic_t *v) +#if defined(arch_atomic64_cmpxchg_relaxed) +static inline s64 +atomic64_cmpxchg_relaxed (atomic64_t *v,s64 old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_fetch_or (i, v); +return arch_atomic64_cmpxchg_relaxed (v, old, new); } +#define atomic64_cmpxchg_relaxed atomic64_cmpxchg_relaxed +#endif -static __always_inline s64 atomic64_fetch_or(s64 i, atomic64_t *v) +#if defined(arch_atomic64_try_cmpxchg) +static inline bool +atomic64_try_cmpxchg (atomic64_t *v,s64 *old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_fetch_or (i, v); +kasan_check_write (old,sizeof (*old)); +return arch_atomic64_try_cmpxchg (v, old, new); } +#define atomic64_try_cmpxchg atomic64_try_cmpxchg +#endif -static __always_inline int atomic_fetch_xor(int i, atomic_t *v) +#if defined(arch_atomic64_try_cmpxchg_acquire) +static inline bool +atomic64_try_cmpxchg_acquire (atomic64_t *v,s64 *old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_fetch_xor (i, v); +kasan_check_write (old,sizeof (*old)); +return arch_atomic64_try_cmpxchg_acquire (v, old, new); } +#define atomic64_try_cmpxchg_acquire atomic64_try_cmpxchg_acquire +#endif -static __always_inline s64 atomic64_fetch_xor(s64 i, atomic64_t *v) +#if defined(arch_atomic64_try_cmpxchg_release) +static inline bool +atomic64_try_cmpxchg_release (atomic64_t *v,s64 *old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic64_fetch_xor (i, v); +kasan_check_write (old,sizeof (*old)); +return arch_atomic64_try_cmpxchg_release (v, old, new); } +#define atomic64_try_cmpxchg_release atomic64_try_cmpxchg_release +#endif -#ifdef arch_atomic_sub_and_test -#define atomic_sub_and_test atomic_sub_and_test -static __always_inline bool atomic_sub_and_test(int i, atomic_t *v) +#if defined(arch_atomic64_try_cmpxchg_relaxed) +static inline bool +atomic64_try_cmpxchg_relaxed (atomic64_t *v,s64 *old,s64 new) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_sub_and_test (i, v); +kasan_check_write (old,sizeof (*old)); +return arch_atomic64_try_cmpxchg_relaxed (v, old, new); } +#define atomic64_try_cmpxchg_relaxed atomic64_try_cmpxchg_relaxed#endif -#ifdef arch_atomic64_sub_and_test -#define atomic64_sub_and_test atomic64_sub_and_test -static __always_inline bool atomic64_sub_and_test(s64 i, atomic64_t *v) +#if defined(arch_atomic64_sub_and_test) +static inline bool +atomic64_sub_and_test (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v));return arch_atomic64_sub_and_test (i, v); } +#define atomic64_sub_and_test atomic64_sub_and_test#endif -#ifdef arch_atomic_add_negative -#define atomic_add_negative atomic_add_negative -static __always_inline bool atomic_add_negative(int i, atomic_t *v) +#if defined(arch_atomic64_dec_and_test) +static inline bool +atomic64_dec_and_test (atomic64_t *v) {kasan_check_write (v,sizeof (*v)); -return arch_atomic_add_negative (i, v); +return arch_atomic64_dec_and_test (v); } +#define atomic64_dec_and_test atomic64_dec_and_test#endif -#ifdef arch_atomic64_add_negative -#define atomic64_add_negative atomic64_add_negative -static __always_inline bool atomic64_add_negative(s64 i, atomic64_t *v) +#if defined(arch_atomic64_inc_and_test) +static inline bool +atomic64_inc_and_test (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_inc_and_test (v); +} +#define atomic64_inc_and_test atomic64_inc_and_test +#endif + +#if defined(arch_atomic64_add_negative) +static inline bool +atomic64_add_negative (s64 i,atomic64_t *v) {kasan_check_write (v,sizeof (*v));return arch_atomic64_add_negative (i, v); } +#define atomic64_add_negative atomic64_add_negative +#endif + +#if defined(arch_atomic64_fetch_add_unless) +static inline s64 +atomic64_fetch_add_unless (atomic64_t *v,s64 a,s64 u) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_fetch_add_unless (v, a, u); +} +#define atomic64_fetch_add_unless atomic64_fetch_add_unless +#endif + +#if defined(arch_atomic64_add_unless) +static inline bool +atomic64_add_unless (atomic64_t *v,s64 a,s64 u) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_add_unless (v, a, u); +} +#define atomic64_add_unless atomic64_add_unless +#endif + +#if defined(arch_atomic64_inc_not_zero) +static inline bool +atomic64_inc_not_zero (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_inc_not_zero (v); +} +#define atomic64_inc_not_zero atomic64_inc_not_zero +#endif + +#if defined(arch_atomic64_inc_unless_negative) +static inline bool +atomic64_inc_unless_negative (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_inc_unless_negative (v); +} +#define atomic64_inc_unless_negative atomic64_inc_unless_negative#endif -#define xchg (ptr, new) \ +#if defined(arch_atomic64_dec_unless_positive) +static inline bool +atomic64_dec_unless_positive (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_dec_unless_positive (v); +} +#define atomic64_dec_unless_positive atomic64_dec_unless_positive +#endif + +#if defined(arch_atomic64_dec_if_positive) +static inline s64 +atomic64_dec_if_positive (atomic64_t *v) +{ +kasan_check_write (v,sizeof (*v)); +return arch_atomic64_dec_if_positive (v); +} +#define atomic64_dec_if_positive atomic64_dec_if_positive +#endif + +#if !defined(arch_xchg_relaxed) || defined(arch_xchg) +#define xchg (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_xchg(__ai_ptr, __VA_ARGS__); \ +}) +#endif + +#if defined(arch_xchg_acquire) +#define xchg_acquire (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_xchg_acquire(__ai_ptr, __VA_ARGS__); \ +}) +#endif + +#if defined(arch_xchg_release) +#define xchg_release (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_xchg_release(__ai_ptr, __VA_ARGS__); \ +}) +#endif + +#if defined(arch_xchg_relaxed) +#define xchg_relaxed (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_xchg_relaxed(__ai_ptr, __VA_ARGS__); \ +}) +#endif + +#if !defined(arch_cmpxchg_relaxed) || defined(arch_cmpxchg) +#define cmpxchg (ptr, ...) \ ({ \ typeof(ptr) __ai_ptr = (ptr); \ - kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ - arch_xchg(__ai_ptr, (new)); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg(__ai_ptr, __VA_ARGS__); \ }) +#endif + +#if defined(arch_cmpxchg_acquire) +#define cmpxchg_acquire (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg_acquire(__ai_ptr, __VA_ARGS__); \ +}) +#endif + +#if defined(arch_cmpxchg_release) +#define cmpxchg_release (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg_release(__ai_ptr, __VA_ARGS__); \ +}) +#endif + +#if defined(arch_cmpxchg_relaxed) +#define cmpxchg_relaxed (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg_relaxed(__ai_ptr, __VA_ARGS__); \ +}) +#endif -#define cmpxchg (ptr, old, new) \ +#if !defined(arch_cmpxchg64_relaxed) || defined(arch_cmpxchg64) +#define cmpxchg64 (ptr, ...) \ ({ \ typeof(ptr) __ai_ptr = (ptr); \ - kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ - arch_cmpxchg(__ai_ptr, (old), (new)); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg64(__ai_ptr, __VA_ARGS__); \ }) +#endif + +#if defined(arch_cmpxchg64_acquire) +#define cmpxchg64_acquire (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg64_acquire(__ai_ptr, __VA_ARGS__); \ +}) +#endif + +#if defined(arch_cmpxchg64_release) +#define cmpxchg64_release (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg64_release(__ai_ptr, __VA_ARGS__); \ +}) +#endif -#define sync_cmpxchg (ptr, old, new) \ +#if defined(arch_cmpxchg64_relaxed) +#define cmpxchg64_relaxed (ptr, ...) \ ({ \ typeof(ptr) __ai_ptr = (ptr); \ - kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ - arch_sync_cmpxchg(__ai_ptr, (old), (new)); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg64_relaxed(__ai_ptr, __VA_ARGS__); \ }) +#endif -#define cmpxchg_local (ptr, old, new) \ +#define cmpxchg_local (ptr, ...) \ ({ \ typeof(ptr) __ai_ptr = (ptr); \ - kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ - arch_cmpxchg_local(__ai_ptr, (old), (new)); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg_local(__ai_ptr, __VA_ARGS__); \ }) -#define cmpxchg64 (ptr, old, new) \ +#define cmpxchg64_local (ptr, ...) \ ({ \ typeof(ptr) __ai_ptr = (ptr); \ - kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ - arch_cmpxchg64(__ai_ptr, (old), (new)); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_cmpxchg64_local(__ai_ptr, __VA_ARGS__); \ }) -#define cmpxchg64_local (ptr, old, new) \ +#define sync_cmpxchg (ptr, ...) \ ({ \ typeof(ptr) __ai_ptr = (ptr); \ - kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ - arch_cmpxchg64_local(__ai_ptr, (old), (new)); \ + kasan_check_write(__ai_ptr, sizeof(*__ai_ptr)); \ + arch_sync_cmpxchg(__ai_ptr, __VA_ARGS__); \ }) -#define cmpxchg_double (p1, p2, o1, o2, n1, n2) \ +#define cmpxchg_double (ptr, ...) \ ({ \ - typeof(p1) __ai_p1 = (p1); \ - kasan_check_write(__ai_p1, 2 * sizeof(*__ai_p1)); \ - arch_cmpxchg_double(__ai_p1, (p2), (o1), (o2), (n1), (n2)); \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, 2 * sizeof(*__ai_ptr)); \ + arch_cmpxchg_double(__ai_ptr, __VA_ARGS__); \ }) -#define cmpxchg_double_local (p1, p2, o1, o2, n1, n2) \ -({ \ - typeof(p1) __ai_p1 = (p1); \ - kasan_check_write(__ai_p1, 2 * sizeof(*__ai_p1)); \ - arch_cmpxchg_double_local(__ai_p1, (p2), (o1), (o2), (n1), (n2)); \ + +#define cmpxchg_double_local (ptr, ...) \ +({ \ + typeof(ptr) __ai_ptr = (ptr); \ + kasan_check_write(__ai_ptr, 2 * sizeof(*__ai_ptr)); \ + arch_cmpxchg_double_local(__ai_ptr, __VA_ARGS__); \ }) -#endif /* _LINUX_ATOMIC_INSTRUMENTED_H */ +#endif /* _ASM_GENERIC_ATOMIC_INSTRUMENTED_H */
Mark Rutland
reviewerPATCH v3 5/6 atomics: check generated headers are up-to-date
In reply to Mark RutlandNow that all the generated atomic headers are in place, it would be good to ensure that:
a) the headers are up-to-date when scripting changes.
b) developers don't directly modify the generated headers.
To ensure both of these properties, let's add a Kbuild step to check that the generated headers are up-to-date.
--- Kbuild | 18 ++++++++++++++++-- scripts/atomic/check-atomics.sh | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 scripts/atomic/check-atomics.sh
Kbuild +16 -2
@@ -6,7 +6,8 @@ # 2) Generate timeconst.h # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h) # 4) Check for missing system calls -# 5) Generate constants.py (may need bounds.h) +# 5) check atomics headers are up-to-date +# 6) Generate constants.py (may need bounds.h) ##### # 1) Generate bounds.h
@@ -72,7 +73,20 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE $(call cmd,syscalls) ##### -# 5) Generate constants for Python GDB integration +# 5) Check atomic headers are up-to-date +# + +always += old-atomics +targets += old-atomics + +quiet_cmd_atomics = CALL $< + cmd_atomics = $(CONFIG_SHELL) scripts/atomic/check-atomics.sh + +old-atomics: scripts/atomic/check-atomics.sh FORCE + $(call cmd,atomics) + +##### +# 6) Generate constants for Python GDB integration # extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
scripts/atomic/check-atomics.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Check if atomic headers are up-to-date + +ATOMICDIR=$(dirname $0) +ATOMICTBL=${ATOMICDIR}/atomics.tbl +LINUXDIR=${ATOMICDIR}/../.. + +cat <<EOF | +gen-atomic-instrumented.sh asm-generic/atomic-instrumented.h +gen-atomic-long.sh asm-generic/atomic-long.h +gen-atomic-fallback.sh linux/atomic-fallback.h +EOF +while read script header; do + if ! (${ATOMICDIR}/${script} ${ATOMICTBL} | diff - ${LINUXDIR}/include/${header} > /dev/null); then + printf "warning: include/${header} is out-of-date.\n" + fi +done
Signature · 1 line
2.11.0
tip-bot for Mark Rutland
merge bot[tip:locking/core] locking/atomics: Check generated headers are up-to-date
locking/atomics: Check generated headers are up-to-date
Commit-ID: 85f8507192fbfb4ad2ac01de879cb50045f4247f Gitweb: https://git.kernel.org/tip/85f8507192fbfb4ad2ac01de879cb50045f4247f Author: Mark Rutland <[email protected]> AuthorDate: Tue, 4 Sep 2018 11:48:29 +0100 Committer: Peter Zijlstra <[email protected]> CommitDate: Thu, 1 Nov 2018 10:48:19 +0100
locking/atomics: Check generated headers are up-to-date
Now that all the generated atomic headers are in place, it would be good to ensure that:
a) the headers are up-to-date when scripting changes.
b) developers don't directly modify the generated headers.
To ensure both of these properties, let's add a Kbuild step to check that the generated headers are up-to-date.
--- Kbuild | 18 ++++++++++++++++-- scripts/atomic/check-atomics.sh | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
Kbuild +16 -2
@@ -6,7 +6,8 @@ # 2) Generate timeconst.h # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h) # 4) Check for missing system calls -# 5) Generate constants.py (may need bounds.h) +# 5) check atomics headers are up-to-date +# 6) Generate constants.py (may need bounds.h) ##### # 1) Generate bounds.h
@@ -72,7 +73,20 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE $(call cmd,syscalls) ##### -# 5) Generate constants for Python GDB integration +# 5) Check atomic headers are up-to-date +# + +always += old-atomics +targets += old-atomics + +quiet_cmd_atomics = CALL $< + cmd_atomics = $(CONFIG_SHELL) scripts/atomic/check-atomics.sh + +old-atomics: scripts/atomic/check-atomics.sh FORCE + $(call cmd,atomics) + +##### +# 6) Generate constants for Python GDB integration # extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
scripts/atomic/check-atomics.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Check if atomic headers are up-to-date + +ATOMICDIR=$(dirname $0) +ATOMICTBL=${ATOMICDIR}/atomics.tbl +LINUXDIR=${ATOMICDIR}/../.. + +cat <<EOF | +gen-atomic-instrumented.sh asm-generic/atomic-instrumented.h +gen-atomic-long.sh asm-generic/atomic-long.h +gen-atomic-fallback.sh linux/atomic-fallback.h +EOF +while read script header; do + if ! (${ATOMICDIR}/${script} ${ATOMICTBL} | diff - ${LINUXDIR}/include/${header} > /dev/null); then + printf "warning: include/${header} is out-of-date.\n" + fi +done
tip-bot for Mark Rutland
merge bot[tip:locking/core] locking/atomics: Check generated headers are up-to-date
In reply to Mark Rutlandlocking/atomics: Check generated headers are up-to-date
Commit-ID: 8d32588077bdc390420cfa6946f407033a20d7a8 Gitweb: https://git.kernel.org/tip/8d32588077bdc390420cfa6946f407033a20d7a8 Author: Mark Rutland <[email protected]> AuthorDate: Tue, 4 Sep 2018 11:48:29 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 1 Nov 2018 11:01:10 +0100
locking/atomics: Check generated headers are up-to-date
Now that all the generated atomic headers are in place, it would be good to ensure that:
a) the headers are up-to-date when scripting changes.
b) developers don't directly modify the generated headers.
To ensure both of these properties, let's add a Kbuild step to check that the generated headers are up-to-date.
--- Kbuild | 18 ++++++++++++++++-- scripts/atomic/check-atomics.sh | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
Kbuild +16 -2
@@ -6,7 +6,8 @@ # 2) Generate timeconst.h # 3) Generate asm-offsets.h (may need bounds.h and timeconst.h) # 4) Check for missing system calls -# 5) Generate constants.py (may need bounds.h) +# 5) check atomics headers are up-to-date +# 6) Generate constants.py (may need bounds.h) ##### # 1) Generate bounds.h
@@ -72,7 +73,20 @@ missing-syscalls: scripts/checksyscalls.sh $(offsets-file) FORCE $(call cmd,syscalls) ##### -# 5) Generate constants for Python GDB integration +# 5) Check atomic headers are up-to-date +# + +always += old-atomics +targets += old-atomics + +quiet_cmd_atomics = CALL $< + cmd_atomics = $(CONFIG_SHELL) scripts/atomic/check-atomics.sh + +old-atomics: scripts/atomic/check-atomics.sh FORCE + $(call cmd,atomics) + +##### +# 6) Generate constants for Python GDB integration # extra-$(CONFIG_GDB_SCRIPTS) += build_constants_py
scripts/atomic/check-atomics.sh new file +19 -0
@@ -0,0 +1,19 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# +# Check if atomic headers are up-to-date + +ATOMICDIR=$(dirname $0) +ATOMICTBL=${ATOMICDIR}/atomics.tbl +LINUXDIR=${ATOMICDIR}/../.. + +cat <<EOF | +gen-atomic-instrumented.sh asm-generic/atomic-instrumented.h +gen-atomic-long.sh asm-generic/atomic-long.h +gen-atomic-fallback.sh linux/atomic-fallback.h +EOF +while read script header; do + if ! (${ATOMICDIR}/${script} ${ATOMICTBL} | diff - ${LINUXDIR}/include/${header} > /dev/null); then + printf "warning: include/${header} is out-of-date.\n" + fi +done
Re: [tip:locking/core] locking/atomics: Check generated headers are up-to-date
Quoted 32 lines · tip-bot for Mark Rutland
Commit-ID: 8d32588077bdc390420cfa6946f407033a20d7a8 Gitweb: https://git.kernel.org/tip/8d32588077bdc390420cfa6946f407033a20d7a8 Author: Mark Rutland <[email protected]> AuthorDate: Tue, 4 Sep 2018 11:48:29 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 1 Nov 2018 11:01:10 +0100locking/atomics: Check generated headers are up-to-date
Now that all the generated atomic headers are in place, it would be good to ensure that:
a) the headers are up-to-date when scripting changes.
b) developers don't directly modify the generated headers.
To ensure both of these properties, let's add a
Kbuildstep to check that the generated headers are up-to-date.Signed-off-by Mark Rutland <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Cc Will Deacon <[email protected]>Cc Boqun Feng <[email protected]>Signed-off-by Ingo Molnar <[email protected]>
Quoted 4 lines
--- Kbuild | 18 ++++++++++++++++-- scripts/atomic/check-atomics.sh | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
These scripts are *awfully* slow to be run at every kernel build - even a reasonably fast machine:
model name : Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz
... they are adding 3-4 seconds to the build time:
[Before]:
galatea:~/linux/linux> perf stat --null --repeat 3 make kernel/sched/core.o CALL scripts/checksyscalls.sh DESCEND objtool CALL scripts/checksyscalls.sh DESCEND objtool CALL scripts/checksyscalls.sh DESCEND objtool
Performance counter stats for 'make kernel/sched/core.o' (3 runs):
1.201874 +- 0.000371 seconds time elapsed ( +- 0.03% )
[After]:
galatea:~/linux/linux> perf stat --null --repeat 3 make kernel/sched/core.o
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
Performance counter stats for 'make kernel/sched/core.o' (3 runs):
4.5987 +- 0.0109 seconds time elapsed ( +- 0.24% )
Could we please get this fixed so that proper dependencies are checked and it's only regenerated when needed? This slowdown makes additive-build kernel development quite painful, as ~5 seconds is in the 'too long' category already, while 1.2 seconds is basically instantaneous.
I cannot even imagine the slowdown on a truly slow box where kernel development *has* to be additive.
Thanks,
Ingo
Mark Rutland
reviewerRe: [tip:locking/core] locking/atomics: Check generated headers are up-to-date
Hi Ingo,
Quoted 40 lines · Ingo Molnar
Quoted 32 lines · tip-bot for Mark Rutland
Commit-ID: 8d32588077bdc390420cfa6946f407033a20d7a8 Gitweb: https://git.kernel.org/tip/8d32588077bdc390420cfa6946f407033a20d7a8 Author: Mark Rutland <[email protected]> AuthorDate: Tue, 4 Sep 2018 11:48:29 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 1 Nov 2018 11:01:10 +0100locking/atomics: Check generated headers are up-to-date
Now that all the generated atomic headers are in place, it would be good to ensure that:
a) the headers are up-to-date when scripting changes.
b) developers don't directly modify the generated headers.
To ensure both of these properties, let's add a
Kbuildstep to check that the generated headers are up-to-date.Signed-off-by Mark Rutland <[email protected]>Signed-off-by Peter Zijlstra (Intel) <[email protected]>Cc Will Deacon <[email protected]>Cc Boqun Feng <[email protected]>Signed-off-by Ingo Molnar <[email protected]>Quoted 4 lines
--- Kbuild | 18 ++++++++++++++++-- scripts/atomic/check-atomics.sh | 19 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-)
Quoted 2 lines
These scripts are *awfully* slow to be run at every kernel build - even a reasonably fast machine:
Andrew also reported this, and I'm trying to figure out what to do.
I looked into optimizing the scripts, but that turned out to be a dead end. The majority of the cost is in the fork() etc for sub-shells, which the scripts make heavy use of to capture string return values. Trying to avoid sub-shells rendered the scripts unreadable.
Quoted 4 lines
Could we please get this fixed so that proper dependencies are checked and it's only regenerated when needed? This slowdown makes additive-build kernel development quite painful, as ~5 seconds is in the 'too long' category already, while 1.2 seconds is basically instantaneous.
Just to check, are we happy to eat the full cost for the first build of a pristine tree?
One reason we do the check rather than (re-)generating the headers is that Linus requested [1] the generated header be committed so that they show up in git grep, but it looks like he was happy to be flexible on that.
If we're happy to not commit in the generated headers, and if we're happy to pay the cost for a pristine tree, that's fairly straightforward to do. Otherwise, this has to be an optional check.
Thoughts?
Thanks,
Mark.
[1] https://lkml.kernel.org/r/CA+55aFxjU0op8QLLu0n-RjHBs7gQsLvD8jcyedgw6jeZFN7B+Q@mail.gmail.com
Re: [tip:locking/core] locking/atomics: Check generated headers are up-to-date
Quoted 7 lines · Mark Rutland
Quoted 4 lines
Could we please get this fixed so that proper dependencies are checked and it's only regenerated when needed? This slowdown makes additive-build kernel development quite painful, as ~5 seconds is in the 'too long' category already, while 1.2 seconds is basically instantaneous.
Just to check, are we happy to eat the full cost for the first build of a pristine tree?
No, not happy to add 3-4 seconds to a full build that usually takes less than 60 seconds. This stuff isn't parallelized nor particularly well optimized it appears.
This *must* get faster.
Quoted 4 lines
One reason we do the check rather than (re-)generating the headers is that Linus requested [1] the generated header be committed so that they show up in git grep, but it looks like he was happy to be flexible on that.
I think the generated headers should be part of the commit space, the grepping is important.
Quoted 3 lines
If we're happy to not commit in the generated headers, and if we're happy to pay the cost for a pristine tree, that's fairly straightforward to do. Otherwise, this has to be an optional check.
Or faster code, or a different concept!
Thanks,
Ingo
Mark Rutland
reviewerPATCH v3 6/6 arm64: use instrumented atomics
In reply to Mark RutlandNow that the generic atomic headers provide instrumented wrappers of all the atomics implemented by arm64, let's migrate arm64 over to these.
The additional instrumentation will help to find bugs (e.g. when fuzzing with Syzkaller).
Mostly this change involves adding an arch_ prefix to a number of function names and macro definitions. When LSE atomics are used, the out-of-line LL/SC atomics will be named __ll_sc_arch_atomic_${OP}.
Adding the arch_ prefix requires some whitespace fixups to keep things aligned. Some other unusual whitespace is fixed up at the same time (e.g. in the cmpxchg wrappers).
--- arch/arm64/include/asm/atomic.h | 237 +++++++++++++++++----------------- arch/arm64/include/asm/atomic_ll_sc.h | 28 ++-- arch/arm64/include/asm/atomic_lse.h | 38 +++--- arch/arm64/include/asm/cmpxchg.h | 60 ++++----- arch/arm64/include/asm/sync_bitops.h | 16 +-- 5 files changed, 193 insertions(+), 186 deletions(-)
arch/arm64/include/asm/atomic.h +122 -115
@@ -42,124 +42,131 @@#define ATOMIC_INIT (i) { (i) } -#define atomic_read (v) READ_ONCE((v)->counter) -#define atomic_set (v, i) WRITE_ONCE(((v)->counter), (i)) - -#define atomic_add_return_relaxed atomic_add_return_relaxed -#define atomic_add_return_acquire atomic_add_return_acquire -#define atomic_add_return_release atomic_add_return_release -#define atomic_add_return atomic_add_return - -#define atomic_sub_return_relaxed atomic_sub_return_relaxed -#define atomic_sub_return_acquire atomic_sub_return_acquire -#define atomic_sub_return_release atomic_sub_return_release -#define atomic_sub_return atomic_sub_return - -#define atomic_fetch_add_relaxed atomic_fetch_add_relaxed -#define atomic_fetch_add_acquire atomic_fetch_add_acquire -#define atomic_fetch_add_release atomic_fetch_add_release -#define atomic_fetch_add atomic_fetch_add - -#define atomic_fetch_sub_relaxed atomic_fetch_sub_relaxed -#define atomic_fetch_sub_acquire atomic_fetch_sub_acquire -#define atomic_fetch_sub_release atomic_fetch_sub_release -#define atomic_fetch_sub atomic_fetch_sub - -#define atomic_fetch_and_relaxed atomic_fetch_and_relaxed -#define atomic_fetch_and_acquire atomic_fetch_and_acquire -#define atomic_fetch_and_release atomic_fetch_and_release -#define atomic_fetch_and atomic_fetch_and - -#define atomic_fetch_andnot_relaxed atomic_fetch_andnot_relaxed -#define atomic_fetch_andnot_acquire atomic_fetch_andnot_acquire -#define atomic_fetch_andnot_release atomic_fetch_andnot_release -#define atomic_fetch_andnot atomic_fetch_andnot - -#define atomic_fetch_or_relaxed atomic_fetch_or_relaxed -#define atomic_fetch_or_acquire atomic_fetch_or_acquire -#define atomic_fetch_or_release atomic_fetch_or_release -#define atomic_fetch_or atomic_fetch_or - -#define atomic_fetch_xor_relaxed atomic_fetch_xor_relaxed -#define atomic_fetch_xor_acquire atomic_fetch_xor_acquire -#define atomic_fetch_xor_release atomic_fetch_xor_release -#define atomic_fetch_xor atomic_fetch_xor - -#define atomic_xchg_relaxed (v, new) xchg_relaxed(&((v)->counter), (new)) -#define atomic_xchg_acquire (v, new) xchg_acquire(&((v)->counter), (new)) -#define atomic_xchg_release (v, new) xchg_release(&((v)->counter), (new)) -#define atomic_xchg (v, new) xchg(&((v)->counter), (new)) - -#define atomic_cmpxchg_relaxed (v, old, new) \ - cmpxchg_relaxed(&((v)->counter), (old), (new)) -#define atomic_cmpxchg_acquire (v, old, new) \ - cmpxchg_acquire(&((v)->counter), (old), (new)) -#define atomic_cmpxchg_release (v, old, new) \ - cmpxchg_release(&((v)->counter), (old), (new)) -#define atomic_cmpxchg (v, old, new) cmpxchg(&((v)->counter), (old), (new)) - -#define atomic_andnot atomic_andnot +#define arch_atomic_read (v) READ_ONCE((v)->counter) +#define arch_atomic_set (v, i) WRITE_ONCE(((v)->counter), (i)) + +#define arch_atomic_add_return_relaxed arch_atomic_add_return_relaxed +#define arch_atomic_add_return_acquire arch_atomic_add_return_acquire +#define arch_atomic_add_return_release arch_atomic_add_return_release +#define arch_atomic_add_return arch_atomic_add_return + +#define arch_atomic_sub_return_relaxed arch_atomic_sub_return_relaxed +#define arch_atomic_sub_return_acquire arch_atomic_sub_return_acquire +#define arch_atomic_sub_return_release arch_atomic_sub_return_release +#define arch_atomic_sub_return arch_atomic_sub_return + +#define arch_atomic_fetch_add_relaxed arch_atomic_fetch_add_relaxed +#define arch_atomic_fetch_add_acquire arch_atomic_fetch_add_acquire +#define arch_atomic_fetch_add_release arch_atomic_fetch_add_release +#define arch_atomic_fetch_add arch_atomic_fetch_add + +#define arch_atomic_fetch_sub_relaxed arch_atomic_fetch_sub_relaxed +#define arch_atomic_fetch_sub_acquire arch_atomic_fetch_sub_acquire +#define arch_atomic_fetch_sub_release arch_atomic_fetch_sub_release +#define arch_atomic_fetch_sub arch_atomic_fetch_sub + +#define arch_atomic_fetch_and_relaxed arch_atomic_fetch_and_relaxed +#define arch_atomic_fetch_and_acquire arch_atomic_fetch_and_acquire +#define arch_atomic_fetch_and_release arch_atomic_fetch_and_release +#define arch_atomic_fetch_and arch_atomic_fetch_and + +#define arch_atomic_fetch_andnot_relaxed arch_atomic_fetch_andnot_relaxed +#define arch_atomic_fetch_andnot_acquire arch_atomic_fetch_andnot_acquire +#define arch_atomic_fetch_andnot_release arch_atomic_fetch_andnot_release +#define arch_atomic_fetch_andnot arch_atomic_fetch_andnot + +#define arch_atomic_fetch_or_relaxed arch_atomic_fetch_or_relaxed +#define arch_atomic_fetch_or_acquire arch_atomic_fetch_or_acquire +#define arch_atomic_fetch_or_release arch_atomic_fetch_or_release +#define arch_atomic_fetch_or arch_atomic_fetch_or + +#define arch_atomic_fetch_xor_relaxed arch_atomic_fetch_xor_relaxed +#define arch_atomic_fetch_xor_acquire arch_atomic_fetch_xor_acquire +#define arch_atomic_fetch_xor_release arch_atomic_fetch_xor_release +#define arch_atomic_fetch_xor arch_atomic_fetch_xor + +#define arch_atomic_xchg_relaxed (v, new) \ + arch_xchg_relaxed(&((v)->counter), (new)) +#define arch_atomic_xchg_acquire (v, new) \ + arch_xchg_acquire(&((v)->counter), (new)) +#define arch_atomic_xchg_release (v, new) \ + arch_xchg_release(&((v)->counter), (new)) +#define arch_atomic_xchg (v, new) \ + arch_xchg(&((v)->counter), (new)) + +#define arch_atomic_cmpxchg_relaxed (v, old, new) \ + arch_cmpxchg_relaxed(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg_acquire (v, old, new) \ + arch_cmpxchg_acquire(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg_release (v, old, new) \ + arch_cmpxchg_release(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg (v, old, new) \ + arch_cmpxchg(&((v)->counter), (old), (new)) + +#define arch_atomic_andnot arch_atomic_andnot/* -* 64-bit atomic operations. +* 64-bit arch_atomic operations. */ -#define ATOMIC64_INIT ATOMIC_INIT -#define atomic64_read atomic_read -#define atomic64_set atomic_set - -#define atomic64_add_return_relaxed atomic64_add_return_relaxed -#define atomic64_add_return_acquire atomic64_add_return_acquire -#define atomic64_add_return_release atomic64_add_return_release -#define atomic64_add_return atomic64_add_return - -#define atomic64_sub_return_relaxed atomic64_sub_return_relaxed -#define atomic64_sub_return_acquire atomic64_sub_return_acquire -#define atomic64_sub_return_release atomic64_sub_return_release -#define atomic64_sub_return atomic64_sub_return - -#define atomic64_fetch_add_relaxed atomic64_fetch_add_relaxed -#define atomic64_fetch_add_acquire atomic64_fetch_add_acquire -#define atomic64_fetch_add_release atomic64_fetch_add_release -#define atomic64_fetch_add atomic64_fetch_add - -#define atomic64_fetch_sub_relaxed atomic64_fetch_sub_relaxed -#define atomic64_fetch_sub_acquire atomic64_fetch_sub_acquire -#define atomic64_fetch_sub_release atomic64_fetch_sub_release -#define atomic64_fetch_sub atomic64_fetch_sub - -#define atomic64_fetch_and_relaxed atomic64_fetch_and_relaxed -#define atomic64_fetch_and_acquire atomic64_fetch_and_acquire -#define atomic64_fetch_and_release atomic64_fetch_and_release -#define atomic64_fetch_and atomic64_fetch_and - -#define atomic64_fetch_andnot_relaxed atomic64_fetch_andnot_relaxed -#define atomic64_fetch_andnot_acquire atomic64_fetch_andnot_acquire -#define atomic64_fetch_andnot_release atomic64_fetch_andnot_release -#define atomic64_fetch_andnot atomic64_fetch_andnot - -#define atomic64_fetch_or_relaxed atomic64_fetch_or_relaxed -#define atomic64_fetch_or_acquire atomic64_fetch_or_acquire -#define atomic64_fetch_or_release atomic64_fetch_or_release -#define atomic64_fetch_or atomic64_fetch_or - -#define atomic64_fetch_xor_relaxed atomic64_fetch_xor_relaxed -#define atomic64_fetch_xor_acquire atomic64_fetch_xor_acquire -#define atomic64_fetch_xor_release atomic64_fetch_xor_release -#define atomic64_fetch_xor atomic64_fetch_xor - -#define atomic64_xchg_relaxed atomic_xchg_relaxed -#define atomic64_xchg_acquire atomic_xchg_acquire -#define atomic64_xchg_release atomic_xchg_release -#define atomic64_xchg atomic_xchg - -#define atomic64_cmpxchg_relaxed atomic_cmpxchg_relaxed -#define atomic64_cmpxchg_acquire atomic_cmpxchg_acquire -#define atomic64_cmpxchg_release atomic_cmpxchg_release -#define atomic64_cmpxchg atomic_cmpxchg - -#define atomic64_andnot atomic64_andnot - -#define atomic64_dec_if_positive atomic64_dec_if_positive +#define ATOMIC64_INIT ATOMIC_INIT +#define arch_atomic64_read arch_atomic_read +#define arch_atomic64_set arch_atomic_set + +#define arch_atomic64_add_return_relaxed arch_atomic64_add_return_relaxed +#define arch_atomic64_add_return_acquire arch_atomic64_add_return_acquire +#define arch_atomic64_add_return_release arch_atomic64_add_return_release +#define arch_atomic64_add_return arch_atomic64_add_return + +#define arch_atomic64_sub_return_relaxed arch_atomic64_sub_return_relaxed +#define arch_atomic64_sub_return_acquire arch_atomic64_sub_return_acquire +#define arch_atomic64_sub_return_release arch_atomic64_sub_return_release +#define arch_atomic64_sub_return arch_atomic64_sub_return + +#define arch_atomic64_fetch_add_relaxed arch_atomic64_fetch_add_relaxed +#define arch_atomic64_fetch_add_acquire arch_atomic64_fetch_add_acquire +#define arch_atomic64_fetch_add_release arch_atomic64_fetch_add_release +#define arch_atomic64_fetch_add arch_atomic64_fetch_add + +#define arch_atomic64_fetch_sub_relaxed arch_atomic64_fetch_sub_relaxed +#define arch_atomic64_fetch_sub_acquire arch_atomic64_fetch_sub_acquire +#define arch_atomic64_fetch_sub_release arch_atomic64_fetch_sub_release +#define arch_atomic64_fetch_sub arch_atomic64_fetch_sub + +#define arch_atomic64_fetch_and_relaxed arch_atomic64_fetch_and_relaxed +#define arch_atomic64_fetch_and_acquire arch_atomic64_fetch_and_acquire +#define arch_atomic64_fetch_and_release arch_atomic64_fetch_and_release +#define arch_atomic64_fetch_and arch_atomic64_fetch_and + +#define arch_atomic64_fetch_andnot_relaxed arch_atomic64_fetch_andnot_relaxed +#define arch_atomic64_fetch_andnot_acquire arch_atomic64_fetch_andnot_acquire +#define arch_atomic64_fetch_andnot_release arch_atomic64_fetch_andnot_release +#define arch_atomic64_fetch_andnot arch_atomic64_fetch_andnot + +#define arch_atomic64_fetch_or_relaxed arch_atomic64_fetch_or_relaxed +#define arch_atomic64_fetch_or_acquire arch_atomic64_fetch_or_acquire +#define arch_atomic64_fetch_or_release arch_atomic64_fetch_or_release +#define arch_atomic64_fetch_or arch_atomic64_fetch_or + +#define arch_atomic64_fetch_xor_relaxed arch_atomic64_fetch_xor_relaxed +#define arch_atomic64_fetch_xor_acquire arch_atomic64_fetch_xor_acquire +#define arch_atomic64_fetch_xor_release arch_atomic64_fetch_xor_release +#define arch_atomic64_fetch_xor arch_atomic64_fetch_xor + +#define arch_atomic64_xchg_relaxed arch_atomic_xchg_relaxed +#define arch_atomic64_xchg_acquire arch_atomic_xchg_acquire +#define arch_atomic64_xchg_release arch_atomic_xchg_release +#define arch_atomic64_xchg arch_atomic_xchg + +#define arch_atomic64_cmpxchg_relaxed arch_atomic_cmpxchg_relaxed +#define arch_atomic64_cmpxchg_acquire arch_atomic_cmpxchg_acquire +#define arch_atomic64_cmpxchg_release arch_atomic_cmpxchg_release +#define arch_atomic64_cmpxchg arch_atomic_cmpxchg + +#define arch_atomic64_andnot arch_atomic64_andnot + +#define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive + +#include <asm-generic/atomic-instrumented.h> #endif #endif
arch/arm64/include/asm/atomic_ll_sc.h +14 -14
@@ -39,7 +39,7 @@#define ATOMIC_OP (op, asm_op) \ __LL_SC_INLINE void \ -__LL_SC_PREFIX(atomic_##op(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_##op(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int result; \
@@ -53,11 +53,11 @@ __LL_SC_PREFIX(atomic_##op(int i, atomic_t *v)) \ : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) \ : "Ir" (i)); \ } \ -__LL_SC_EXPORT(atomic_##op); +__LL_SC_EXPORT(arch_atomic_##op);#define ATOMIC_OP_RETURN (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE int \ -__LL_SC_PREFIX(atomic_##op##_return##name(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_##op##_return##name(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int result; \
@@ -75,11 +75,11 @@ __LL_SC_PREFIX(atomic_##op##_return##name(int i, atomic_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic_##op##_return##name); +__LL_SC_EXPORT(arch_atomic_##op##_return##name);#define ATOMIC_FETCH_OP (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE int \ -__LL_SC_PREFIX(atomic_fetch_##op##name(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_fetch_##op##name(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int val, result; \
@@ -97,7 +97,7 @@ __LL_SC_PREFIX(atomic_fetch_##op##name(int i, atomic_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic_fetch_##op##name); +__LL_SC_EXPORT(arch_atomic_fetch_##op##name);#define ATOMIC_OPS (...) \ ATOMIC_OP(__VA_ARGS__) \
@@ -133,7 +133,7 @@ ATOMIC_OPS(xor, eor)#define ATOMIC64_OP (op, asm_op) \ __LL_SC_INLINE void \ -__LL_SC_PREFIX(atomic64_##op(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_##op(long i, atomic64_t *v)) \ { \ long result; \ unsigned long tmp; \
@@ -147,11 +147,11 @@ __LL_SC_PREFIX(atomic64_##op(long i, atomic64_t *v)) \ : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) \ : "Ir" (i)); \ } \ -__LL_SC_EXPORT(atomic64_##op); +__LL_SC_EXPORT(arch_atomic64_##op);#define ATOMIC64_OP_RETURN (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE long \ -__LL_SC_PREFIX(atomic64_##op##_return##name(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_##op##_return##name(long i, atomic64_t *v))\ { \ long result; \ unsigned long tmp; \
@@ -169,11 +169,11 @@ __LL_SC_PREFIX(atomic64_##op##_return##name(long i, atomic64_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic64_##op##_return##name); +__LL_SC_EXPORT(arch_atomic64_##op##_return##name);#define ATOMIC64_FETCH_OP (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE long \ -__LL_SC_PREFIX(atomic64_fetch_##op##name(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_fetch_##op##name(long i, atomic64_t *v)) \ { \ long result, val; \ unsigned long tmp; \
@@ -191,7 +191,7 @@ __LL_SC_PREFIX(atomic64_fetch_##op##name(long i, atomic64_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic64_fetch_##op##name); +__LL_SC_EXPORT(arch_atomic64_fetch_##op##name);#define ATOMIC64_OPS (...) \ ATOMIC64_OP(__VA_ARGS__) \
@@ -226,7 +226,7 @@ ATOMIC64_OPS(xor, eor)#undef ATOMIC64_OP__LL_SC_INLINE long -__LL_SC_PREFIX (atomic64_dec_if_positive (atomic64_t *v)) +__LL_SC_PREFIX (arch_atomic64_dec_if_positive (atomic64_t *v)) {long result;unsigned long tmp;
@@ -246,7 +246,7 @@ __LL_SC_PREFIX(atomic64_dec_if_positive(atomic64_t *v))return result; } -__LL_SC_EXPORT (atomic64_dec_if_positive); +__LL_SC_EXPORT (arch_atomic64_dec_if_positive);#define __CMPXCHG_CASE (w, sz, name, mb, acq, rel, cl) \ __LL_SC_INLINE unsigned long \
arch/arm64/include/asm/atomic_lse.h +19 -19
@@ -25,9 +25,9 @@#error "please don't include this file directly"#endif -#define __LL_SC_ATOMIC (op) __LL_SC_CALL(atomic_##op) +#define __LL_SC_ATOMIC (op) __LL_SC_CALL(arch_atomic_##op)#define ATOMIC_OP (op, asm_op) \ -static inline void atomic_##op(int i, atomic_t *v) \ +static inline void arch_atomic_##op(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -47,7 +47,7 @@ ATOMIC_OP(add, stadd)#undef ATOMIC_OP #define ATOMIC_FETCH_OP(name, mb, op, asm_op, cl...) \ -static inline int atomic_fetch_##op##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_##op##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -79,7 +79,7 @@ ATOMIC_FETCH_OPS(add, ldadd)#undef ATOMIC_FETCH_OPS #define ATOMIC_OP_ADD_RETURN(name, mb, cl...) \ -static inline int atomic_add_return##name(int i, atomic_t *v) \ +static inline int arch_atomic_add_return##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -105,7 +105,7 @@ ATOMIC_OP_ADD_RETURN( , al, "memory")#undef ATOMIC_OP_ADD_RETURN -static inline void atomic_and (int i,atomic_t *v) +static inline void arch_atomic_and (int i,atomic_t *v) { register int w0 asm ("w0") = i; register atomic_t *x1 asm ("x1") = v;
@@ -123,7 +123,7 @@ static inline void atomic_and(int i, atomic_t *v) } #define ATOMIC_FETCH_OP_AND(name, mb, cl...) \ -static inline int atomic_fetch_and##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_and##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -149,7 +149,7 @@ ATOMIC_FETCH_OP_AND( , al, "memory")#undef ATOMIC_FETCH_OP_AND -static inline void atomic_sub (int i,atomic_t *v) +static inline void arch_atomic_sub (int i,atomic_t *v) { register int w0 asm ("w0") = i; register atomic_t *x1 asm ("x1") = v;
@@ -167,7 +167,7 @@ static inline void atomic_sub(int i, atomic_t *v) } #define ATOMIC_OP_SUB_RETURN(name, mb, cl...) \ -static inline int atomic_sub_return##name(int i, atomic_t *v) \ +static inline int arch_atomic_sub_return##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -195,7 +195,7 @@ ATOMIC_OP_SUB_RETURN( , al, "memory")#undef ATOMIC_OP_SUB_RETURN #define ATOMIC_FETCH_OP_SUB(name, mb, cl...) \ -static inline int atomic_fetch_sub##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_sub##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -222,9 +222,9 @@ ATOMIC_FETCH_OP_SUB( , al, "memory")#undef ATOMIC_FETCH_OP_SUB#undef __LL_SC_ATOMIC -#define __LL_SC_ATOMIC64 (op) __LL_SC_CALL(atomic64_##op) +#define __LL_SC_ATOMIC64 (op) __LL_SC_CALL(arch_atomic64_##op)#define ATOMIC64_OP (op, asm_op) \ -static inline void atomic64_##op(long i, atomic64_t *v) \ +static inline void arch_atomic64_##op(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -244,7 +244,7 @@ ATOMIC64_OP(add, stadd)#undef ATOMIC64_OP #define ATOMIC64_FETCH_OP(name, mb, op, asm_op, cl...) \ -static inline long atomic64_fetch_##op##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_##op##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -276,7 +276,7 @@ ATOMIC64_FETCH_OPS(add, ldadd)#undef ATOMIC64_FETCH_OPS #define ATOMIC64_OP_ADD_RETURN(name, mb, cl...) \ -static inline long atomic64_add_return##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_add_return##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -302,7 +302,7 @@ ATOMIC64_OP_ADD_RETURN( , al, "memory")#undef ATOMIC64_OP_ADD_RETURN -static inline void atomic64_and (long i,atomic64_t *v) +static inline void arch_atomic64_and (long i,atomic64_t *v) { register long x0 asm ("x0") = i; register atomic64_t *x1 asm ("x1") = v;
@@ -320,7 +320,7 @@ static inline void atomic64_and(long i, atomic64_t *v) } #define ATOMIC64_FETCH_OP_AND(name, mb, cl...) \ -static inline long atomic64_fetch_and##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_and##name(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -346,7 +346,7 @@ ATOMIC64_FETCH_OP_AND( , al, "memory")#undef ATOMIC64_FETCH_OP_AND -static inline void atomic64_sub (long i,atomic64_t *v) +static inline void arch_atomic64_sub (long i,atomic64_t *v) { register long x0 asm ("x0") = i; register atomic64_t *x1 asm ("x1") = v;
@@ -364,7 +364,7 @@ static inline void atomic64_sub(long i, atomic64_t *v) } #define ATOMIC64_OP_SUB_RETURN(name, mb, cl...) \ -static inline long atomic64_sub_return##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_sub_return##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -392,7 +392,7 @@ ATOMIC64_OP_SUB_RETURN( , al, "memory")#undef ATOMIC64_OP_SUB_RETURN #define ATOMIC64_FETCH_OP_SUB(name, mb, cl...) \ -static inline long atomic64_fetch_sub##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_sub##name(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -418,7 +418,7 @@ ATOMIC64_FETCH_OP_SUB( , al, "memory")#undef ATOMIC64_FETCH_OP_SUB -static inline long atomic64_dec_if_positive (atomic64_t *v) +static inline long arch_atomic64_dec_if_positive (atomic64_t *v) { register long x0 asm ("x0") = (long)v;
arch/arm64/include/asm/cmpxchg.h +30 -30
82 lines not on this page · raw message
arch/arm64/include/asm/sync_bitops.h +8 -8
@@ -15,13 +15,13 @@* ops which are SMP safe even on a UP kernel. */ -#define sync_set_bit (nr, p) set_bit(nr, p) -#define sync_clear_bit (nr, p) clear_bit(nr, p) -#define sync_change_bit (nr, p) change_bit(nr, p) -#define sync_test_and_set_bit (nr, p) test_and_set_bit(nr, p) -#define sync_test_and_clear_bit (nr, p) test_and_clear_bit(nr, p) -#define sync_test_and_change_bit (nr, p) test_and_change_bit(nr, p) -#define sync_test_bit (nr, addr) test_bit(nr, addr) -#define sync_cmpxchg cmpxchg +#define sync_set_bit (nr, p) set_bit(nr, p) +#define sync_clear_bit (nr, p) clear_bit(nr, p) +#define sync_change_bit (nr, p) change_bit(nr, p) +#define sync_test_and_set_bit (nr, p) test_and_set_bit(nr, p) +#define sync_test_and_clear_bit (nr, p) test_and_clear_bit(nr, p) +#define sync_test_and_change_bit (nr, p) test_and_change_bit(nr, p) +#define sync_test_bit (nr, addr) test_bit(nr, addr) +#define arch_sync_cmpxchg arch_cmpxchg#endif
Signature · 1 line
2.11.0
tip-bot for Mark Rutland
merge bot[tip:locking/core] arm64: Use instrumented atomics
arm64: Use instrumented atomics
Commit-ID: 30bc7baa9de81efc0584b9290ce8040a1130f156 Gitweb: https://git.kernel.org/tip/30bc7baa9de81efc0584b9290ce8040a1130f156 Author: Mark Rutland <[email protected]> AuthorDate: Tue, 4 Sep 2018 11:48:30 +0100 Committer: Peter Zijlstra <[email protected]> CommitDate: Thu, 1 Nov 2018 10:48:19 +0100
arm64: Use instrumented atomics
Now that the generic atomic headers provide instrumented wrappers of all the atomics implemented by arm64, let's migrate arm64 over to these.
The additional instrumentation will help to find bugs (e.g. when fuzzing with Syzkaller).
Mostly this change involves adding an arch_ prefix to a number of function names and macro definitions. When LSE atomics are used, the out-of-line LL/SC atomics will be named __ll_sc_arch_atomic_${OP}.
Adding the arch_ prefix requires some whitespace fixups to keep things aligned. Some other unusual whitespace is fixed up at the same time (e.g. in the cmpxchg wrappers).
--- arch/arm64/include/asm/atomic.h | 237 +++++++++++++++++----------------- arch/arm64/include/asm/atomic_ll_sc.h | 28 ++-- arch/arm64/include/asm/atomic_lse.h | 38 +++--- arch/arm64/include/asm/cmpxchg.h | 60 ++++----- arch/arm64/include/asm/sync_bitops.h | 16 +-- 5 files changed, 193 insertions(+), 186 deletions(-)
arch/arm64/include/asm/atomic.h +122 -115
@@ -42,124 +42,131 @@#define ATOMIC_INIT (i) { (i) } -#define atomic_read (v) READ_ONCE((v)->counter) -#define atomic_set (v, i) WRITE_ONCE(((v)->counter), (i)) - -#define atomic_add_return_relaxed atomic_add_return_relaxed -#define atomic_add_return_acquire atomic_add_return_acquire -#define atomic_add_return_release atomic_add_return_release -#define atomic_add_return atomic_add_return - -#define atomic_sub_return_relaxed atomic_sub_return_relaxed -#define atomic_sub_return_acquire atomic_sub_return_acquire -#define atomic_sub_return_release atomic_sub_return_release -#define atomic_sub_return atomic_sub_return - -#define atomic_fetch_add_relaxed atomic_fetch_add_relaxed -#define atomic_fetch_add_acquire atomic_fetch_add_acquire -#define atomic_fetch_add_release atomic_fetch_add_release -#define atomic_fetch_add atomic_fetch_add - -#define atomic_fetch_sub_relaxed atomic_fetch_sub_relaxed -#define atomic_fetch_sub_acquire atomic_fetch_sub_acquire -#define atomic_fetch_sub_release atomic_fetch_sub_release -#define atomic_fetch_sub atomic_fetch_sub - -#define atomic_fetch_and_relaxed atomic_fetch_and_relaxed -#define atomic_fetch_and_acquire atomic_fetch_and_acquire -#define atomic_fetch_and_release atomic_fetch_and_release -#define atomic_fetch_and atomic_fetch_and - -#define atomic_fetch_andnot_relaxed atomic_fetch_andnot_relaxed -#define atomic_fetch_andnot_acquire atomic_fetch_andnot_acquire -#define atomic_fetch_andnot_release atomic_fetch_andnot_release -#define atomic_fetch_andnot atomic_fetch_andnot - -#define atomic_fetch_or_relaxed atomic_fetch_or_relaxed -#define atomic_fetch_or_acquire atomic_fetch_or_acquire -#define atomic_fetch_or_release atomic_fetch_or_release -#define atomic_fetch_or atomic_fetch_or - -#define atomic_fetch_xor_relaxed atomic_fetch_xor_relaxed -#define atomic_fetch_xor_acquire atomic_fetch_xor_acquire -#define atomic_fetch_xor_release atomic_fetch_xor_release -#define atomic_fetch_xor atomic_fetch_xor - -#define atomic_xchg_relaxed (v, new) xchg_relaxed(&((v)->counter), (new)) -#define atomic_xchg_acquire (v, new) xchg_acquire(&((v)->counter), (new)) -#define atomic_xchg_release (v, new) xchg_release(&((v)->counter), (new)) -#define atomic_xchg (v, new) xchg(&((v)->counter), (new)) - -#define atomic_cmpxchg_relaxed (v, old, new) \ - cmpxchg_relaxed(&((v)->counter), (old), (new)) -#define atomic_cmpxchg_acquire (v, old, new) \ - cmpxchg_acquire(&((v)->counter), (old), (new)) -#define atomic_cmpxchg_release (v, old, new) \ - cmpxchg_release(&((v)->counter), (old), (new)) -#define atomic_cmpxchg (v, old, new) cmpxchg(&((v)->counter), (old), (new)) - -#define atomic_andnot atomic_andnot +#define arch_atomic_read (v) READ_ONCE((v)->counter) +#define arch_atomic_set (v, i) WRITE_ONCE(((v)->counter), (i)) + +#define arch_atomic_add_return_relaxed arch_atomic_add_return_relaxed +#define arch_atomic_add_return_acquire arch_atomic_add_return_acquire +#define arch_atomic_add_return_release arch_atomic_add_return_release +#define arch_atomic_add_return arch_atomic_add_return + +#define arch_atomic_sub_return_relaxed arch_atomic_sub_return_relaxed +#define arch_atomic_sub_return_acquire arch_atomic_sub_return_acquire +#define arch_atomic_sub_return_release arch_atomic_sub_return_release +#define arch_atomic_sub_return arch_atomic_sub_return + +#define arch_atomic_fetch_add_relaxed arch_atomic_fetch_add_relaxed +#define arch_atomic_fetch_add_acquire arch_atomic_fetch_add_acquire +#define arch_atomic_fetch_add_release arch_atomic_fetch_add_release +#define arch_atomic_fetch_add arch_atomic_fetch_add + +#define arch_atomic_fetch_sub_relaxed arch_atomic_fetch_sub_relaxed +#define arch_atomic_fetch_sub_acquire arch_atomic_fetch_sub_acquire +#define arch_atomic_fetch_sub_release arch_atomic_fetch_sub_release +#define arch_atomic_fetch_sub arch_atomic_fetch_sub + +#define arch_atomic_fetch_and_relaxed arch_atomic_fetch_and_relaxed +#define arch_atomic_fetch_and_acquire arch_atomic_fetch_and_acquire +#define arch_atomic_fetch_and_release arch_atomic_fetch_and_release +#define arch_atomic_fetch_and arch_atomic_fetch_and + +#define arch_atomic_fetch_andnot_relaxed arch_atomic_fetch_andnot_relaxed +#define arch_atomic_fetch_andnot_acquire arch_atomic_fetch_andnot_acquire +#define arch_atomic_fetch_andnot_release arch_atomic_fetch_andnot_release +#define arch_atomic_fetch_andnot arch_atomic_fetch_andnot + +#define arch_atomic_fetch_or_relaxed arch_atomic_fetch_or_relaxed +#define arch_atomic_fetch_or_acquire arch_atomic_fetch_or_acquire +#define arch_atomic_fetch_or_release arch_atomic_fetch_or_release +#define arch_atomic_fetch_or arch_atomic_fetch_or + +#define arch_atomic_fetch_xor_relaxed arch_atomic_fetch_xor_relaxed +#define arch_atomic_fetch_xor_acquire arch_atomic_fetch_xor_acquire +#define arch_atomic_fetch_xor_release arch_atomic_fetch_xor_release +#define arch_atomic_fetch_xor arch_atomic_fetch_xor + +#define arch_atomic_xchg_relaxed (v, new) \ + arch_xchg_relaxed(&((v)->counter), (new)) +#define arch_atomic_xchg_acquire (v, new) \ + arch_xchg_acquire(&((v)->counter), (new)) +#define arch_atomic_xchg_release (v, new) \ + arch_xchg_release(&((v)->counter), (new)) +#define arch_atomic_xchg (v, new) \ + arch_xchg(&((v)->counter), (new)) + +#define arch_atomic_cmpxchg_relaxed (v, old, new) \ + arch_cmpxchg_relaxed(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg_acquire (v, old, new) \ + arch_cmpxchg_acquire(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg_release (v, old, new) \ + arch_cmpxchg_release(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg (v, old, new) \ + arch_cmpxchg(&((v)->counter), (old), (new)) + +#define arch_atomic_andnot arch_atomic_andnot/* -* 64-bit atomic operations. +* 64-bit arch_atomic operations. */ -#define ATOMIC64_INIT ATOMIC_INIT -#define atomic64_read atomic_read -#define atomic64_set atomic_set - -#define atomic64_add_return_relaxed atomic64_add_return_relaxed -#define atomic64_add_return_acquire atomic64_add_return_acquire -#define atomic64_add_return_release atomic64_add_return_release -#define atomic64_add_return atomic64_add_return - -#define atomic64_sub_return_relaxed atomic64_sub_return_relaxed -#define atomic64_sub_return_acquire atomic64_sub_return_acquire -#define atomic64_sub_return_release atomic64_sub_return_release -#define atomic64_sub_return atomic64_sub_return - -#define atomic64_fetch_add_relaxed atomic64_fetch_add_relaxed -#define atomic64_fetch_add_acquire atomic64_fetch_add_acquire -#define atomic64_fetch_add_release atomic64_fetch_add_release -#define atomic64_fetch_add atomic64_fetch_add - -#define atomic64_fetch_sub_relaxed atomic64_fetch_sub_relaxed -#define atomic64_fetch_sub_acquire atomic64_fetch_sub_acquire -#define atomic64_fetch_sub_release atomic64_fetch_sub_release -#define atomic64_fetch_sub atomic64_fetch_sub - -#define atomic64_fetch_and_relaxed atomic64_fetch_and_relaxed -#define atomic64_fetch_and_acquire atomic64_fetch_and_acquire -#define atomic64_fetch_and_release atomic64_fetch_and_release -#define atomic64_fetch_and atomic64_fetch_and - -#define atomic64_fetch_andnot_relaxed atomic64_fetch_andnot_relaxed -#define atomic64_fetch_andnot_acquire atomic64_fetch_andnot_acquire -#define atomic64_fetch_andnot_release atomic64_fetch_andnot_release -#define atomic64_fetch_andnot atomic64_fetch_andnot - -#define atomic64_fetch_or_relaxed atomic64_fetch_or_relaxed -#define atomic64_fetch_or_acquire atomic64_fetch_or_acquire -#define atomic64_fetch_or_release atomic64_fetch_or_release -#define atomic64_fetch_or atomic64_fetch_or - -#define atomic64_fetch_xor_relaxed atomic64_fetch_xor_relaxed -#define atomic64_fetch_xor_acquire atomic64_fetch_xor_acquire -#define atomic64_fetch_xor_release atomic64_fetch_xor_release -#define atomic64_fetch_xor atomic64_fetch_xor - -#define atomic64_xchg_relaxed atomic_xchg_relaxed -#define atomic64_xchg_acquire atomic_xchg_acquire -#define atomic64_xchg_release atomic_xchg_release -#define atomic64_xchg atomic_xchg - -#define atomic64_cmpxchg_relaxed atomic_cmpxchg_relaxed -#define atomic64_cmpxchg_acquire atomic_cmpxchg_acquire -#define atomic64_cmpxchg_release atomic_cmpxchg_release -#define atomic64_cmpxchg atomic_cmpxchg - -#define atomic64_andnot atomic64_andnot - -#define atomic64_dec_if_positive atomic64_dec_if_positive +#define ATOMIC64_INIT ATOMIC_INIT +#define arch_atomic64_read arch_atomic_read +#define arch_atomic64_set arch_atomic_set + +#define arch_atomic64_add_return_relaxed arch_atomic64_add_return_relaxed +#define arch_atomic64_add_return_acquire arch_atomic64_add_return_acquire +#define arch_atomic64_add_return_release arch_atomic64_add_return_release +#define arch_atomic64_add_return arch_atomic64_add_return + +#define arch_atomic64_sub_return_relaxed arch_atomic64_sub_return_relaxed +#define arch_atomic64_sub_return_acquire arch_atomic64_sub_return_acquire +#define arch_atomic64_sub_return_release arch_atomic64_sub_return_release +#define arch_atomic64_sub_return arch_atomic64_sub_return + +#define arch_atomic64_fetch_add_relaxed arch_atomic64_fetch_add_relaxed +#define arch_atomic64_fetch_add_acquire arch_atomic64_fetch_add_acquire +#define arch_atomic64_fetch_add_release arch_atomic64_fetch_add_release +#define arch_atomic64_fetch_add arch_atomic64_fetch_add + +#define arch_atomic64_fetch_sub_relaxed arch_atomic64_fetch_sub_relaxed +#define arch_atomic64_fetch_sub_acquire arch_atomic64_fetch_sub_acquire +#define arch_atomic64_fetch_sub_release arch_atomic64_fetch_sub_release +#define arch_atomic64_fetch_sub arch_atomic64_fetch_sub + +#define arch_atomic64_fetch_and_relaxed arch_atomic64_fetch_and_relaxed +#define arch_atomic64_fetch_and_acquire arch_atomic64_fetch_and_acquire +#define arch_atomic64_fetch_and_release arch_atomic64_fetch_and_release +#define arch_atomic64_fetch_and arch_atomic64_fetch_and + +#define arch_atomic64_fetch_andnot_relaxed arch_atomic64_fetch_andnot_relaxed +#define arch_atomic64_fetch_andnot_acquire arch_atomic64_fetch_andnot_acquire +#define arch_atomic64_fetch_andnot_release arch_atomic64_fetch_andnot_release +#define arch_atomic64_fetch_andnot arch_atomic64_fetch_andnot + +#define arch_atomic64_fetch_or_relaxed arch_atomic64_fetch_or_relaxed +#define arch_atomic64_fetch_or_acquire arch_atomic64_fetch_or_acquire +#define arch_atomic64_fetch_or_release arch_atomic64_fetch_or_release +#define arch_atomic64_fetch_or arch_atomic64_fetch_or + +#define arch_atomic64_fetch_xor_relaxed arch_atomic64_fetch_xor_relaxed +#define arch_atomic64_fetch_xor_acquire arch_atomic64_fetch_xor_acquire +#define arch_atomic64_fetch_xor_release arch_atomic64_fetch_xor_release +#define arch_atomic64_fetch_xor arch_atomic64_fetch_xor + +#define arch_atomic64_xchg_relaxed arch_atomic_xchg_relaxed +#define arch_atomic64_xchg_acquire arch_atomic_xchg_acquire +#define arch_atomic64_xchg_release arch_atomic_xchg_release +#define arch_atomic64_xchg arch_atomic_xchg + +#define arch_atomic64_cmpxchg_relaxed arch_atomic_cmpxchg_relaxed +#define arch_atomic64_cmpxchg_acquire arch_atomic_cmpxchg_acquire +#define arch_atomic64_cmpxchg_release arch_atomic_cmpxchg_release +#define arch_atomic64_cmpxchg arch_atomic_cmpxchg + +#define arch_atomic64_andnot arch_atomic64_andnot + +#define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive + +#include <asm-generic/atomic-instrumented.h> #endif #endif
arch/arm64/include/asm/atomic_ll_sc.h +14 -14
@@ -39,7 +39,7 @@#define ATOMIC_OP (op, asm_op) \ __LL_SC_INLINE void \ -__LL_SC_PREFIX(atomic_##op(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_##op(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int result; \
@@ -53,11 +53,11 @@ __LL_SC_PREFIX(atomic_##op(int i, atomic_t *v)) \ : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) \ : "Ir" (i)); \ } \ -__LL_SC_EXPORT(atomic_##op); +__LL_SC_EXPORT(arch_atomic_##op);#define ATOMIC_OP_RETURN (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE int \ -__LL_SC_PREFIX(atomic_##op##_return##name(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_##op##_return##name(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int result; \
@@ -75,11 +75,11 @@ __LL_SC_PREFIX(atomic_##op##_return##name(int i, atomic_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic_##op##_return##name); +__LL_SC_EXPORT(arch_atomic_##op##_return##name);#define ATOMIC_FETCH_OP (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE int \ -__LL_SC_PREFIX(atomic_fetch_##op##name(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_fetch_##op##name(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int val, result; \
@@ -97,7 +97,7 @@ __LL_SC_PREFIX(atomic_fetch_##op##name(int i, atomic_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic_fetch_##op##name); +__LL_SC_EXPORT(arch_atomic_fetch_##op##name);#define ATOMIC_OPS (...) \ ATOMIC_OP(__VA_ARGS__) \
@@ -133,7 +133,7 @@ ATOMIC_OPS(xor, eor)#define ATOMIC64_OP (op, asm_op) \ __LL_SC_INLINE void \ -__LL_SC_PREFIX(atomic64_##op(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_##op(long i, atomic64_t *v)) \ { \ long result; \ unsigned long tmp; \
@@ -147,11 +147,11 @@ __LL_SC_PREFIX(atomic64_##op(long i, atomic64_t *v)) \ : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) \ : "Ir" (i)); \ } \ -__LL_SC_EXPORT(atomic64_##op); +__LL_SC_EXPORT(arch_atomic64_##op);#define ATOMIC64_OP_RETURN (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE long \ -__LL_SC_PREFIX(atomic64_##op##_return##name(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_##op##_return##name(long i, atomic64_t *v))\ { \ long result; \ unsigned long tmp; \
@@ -169,11 +169,11 @@ __LL_SC_PREFIX(atomic64_##op##_return##name(long i, atomic64_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic64_##op##_return##name); +__LL_SC_EXPORT(arch_atomic64_##op##_return##name);#define ATOMIC64_FETCH_OP (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE long \ -__LL_SC_PREFIX(atomic64_fetch_##op##name(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_fetch_##op##name(long i, atomic64_t *v)) \ { \ long result, val; \ unsigned long tmp; \
@@ -191,7 +191,7 @@ __LL_SC_PREFIX(atomic64_fetch_##op##name(long i, atomic64_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic64_fetch_##op##name); +__LL_SC_EXPORT(arch_atomic64_fetch_##op##name);#define ATOMIC64_OPS (...) \ ATOMIC64_OP(__VA_ARGS__) \
@@ -226,7 +226,7 @@ ATOMIC64_OPS(xor, eor)#undef ATOMIC64_OP__LL_SC_INLINE long -__LL_SC_PREFIX (atomic64_dec_if_positive (atomic64_t *v)) +__LL_SC_PREFIX (arch_atomic64_dec_if_positive (atomic64_t *v)) {long result;unsigned long tmp;
@@ -246,7 +246,7 @@ __LL_SC_PREFIX(atomic64_dec_if_positive(atomic64_t *v))return result; } -__LL_SC_EXPORT (atomic64_dec_if_positive); +__LL_SC_EXPORT (arch_atomic64_dec_if_positive);#define __CMPXCHG_CASE (w, sz, name, mb, acq, rel, cl) \ __LL_SC_INLINE unsigned long \
arch/arm64/include/asm/atomic_lse.h +19 -19
@@ -25,9 +25,9 @@#error "please don't include this file directly"#endif -#define __LL_SC_ATOMIC (op) __LL_SC_CALL(atomic_##op) +#define __LL_SC_ATOMIC (op) __LL_SC_CALL(arch_atomic_##op)#define ATOMIC_OP (op, asm_op) \ -static inline void atomic_##op(int i, atomic_t *v) \ +static inline void arch_atomic_##op(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -47,7 +47,7 @@ ATOMIC_OP(add, stadd)#undef ATOMIC_OP #define ATOMIC_FETCH_OP(name, mb, op, asm_op, cl...) \ -static inline int atomic_fetch_##op##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_##op##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -79,7 +79,7 @@ ATOMIC_FETCH_OPS(add, ldadd)#undef ATOMIC_FETCH_OPS #define ATOMIC_OP_ADD_RETURN(name, mb, cl...) \ -static inline int atomic_add_return##name(int i, atomic_t *v) \ +static inline int arch_atomic_add_return##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -105,7 +105,7 @@ ATOMIC_OP_ADD_RETURN( , al, "memory")#undef ATOMIC_OP_ADD_RETURN -static inline void atomic_and (int i,atomic_t *v) +static inline void arch_atomic_and (int i,atomic_t *v) { register int w0 asm ("w0") = i; register atomic_t *x1 asm ("x1") = v;
@@ -123,7 +123,7 @@ static inline void atomic_and(int i, atomic_t *v) } #define ATOMIC_FETCH_OP_AND(name, mb, cl...) \ -static inline int atomic_fetch_and##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_and##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -149,7 +149,7 @@ ATOMIC_FETCH_OP_AND( , al, "memory")#undef ATOMIC_FETCH_OP_AND -static inline void atomic_sub (int i,atomic_t *v) +static inline void arch_atomic_sub (int i,atomic_t *v) { register int w0 asm ("w0") = i; register atomic_t *x1 asm ("x1") = v;
@@ -167,7 +167,7 @@ static inline void atomic_sub(int i, atomic_t *v) } #define ATOMIC_OP_SUB_RETURN(name, mb, cl...) \ -static inline int atomic_sub_return##name(int i, atomic_t *v) \ +static inline int arch_atomic_sub_return##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -195,7 +195,7 @@ ATOMIC_OP_SUB_RETURN( , al, "memory")#undef ATOMIC_OP_SUB_RETURN #define ATOMIC_FETCH_OP_SUB(name, mb, cl...) \ -static inline int atomic_fetch_sub##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_sub##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -222,9 +222,9 @@ ATOMIC_FETCH_OP_SUB( , al, "memory")#undef ATOMIC_FETCH_OP_SUB#undef __LL_SC_ATOMIC -#define __LL_SC_ATOMIC64 (op) __LL_SC_CALL(atomic64_##op) +#define __LL_SC_ATOMIC64 (op) __LL_SC_CALL(arch_atomic64_##op)#define ATOMIC64_OP (op, asm_op) \ -static inline void atomic64_##op(long i, atomic64_t *v) \ +static inline void arch_atomic64_##op(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -244,7 +244,7 @@ ATOMIC64_OP(add, stadd)#undef ATOMIC64_OP #define ATOMIC64_FETCH_OP(name, mb, op, asm_op, cl...) \ -static inline long atomic64_fetch_##op##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_##op##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -276,7 +276,7 @@ ATOMIC64_FETCH_OPS(add, ldadd)#undef ATOMIC64_FETCH_OPS #define ATOMIC64_OP_ADD_RETURN(name, mb, cl...) \ -static inline long atomic64_add_return##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_add_return##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -302,7 +302,7 @@ ATOMIC64_OP_ADD_RETURN( , al, "memory")#undef ATOMIC64_OP_ADD_RETURN -static inline void atomic64_and (long i,atomic64_t *v) +static inline void arch_atomic64_and (long i,atomic64_t *v) { register long x0 asm ("x0") = i; register atomic64_t *x1 asm ("x1") = v;
@@ -320,7 +320,7 @@ static inline void atomic64_and(long i, atomic64_t *v) } #define ATOMIC64_FETCH_OP_AND(name, mb, cl...) \ -static inline long atomic64_fetch_and##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_and##name(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -346,7 +346,7 @@ ATOMIC64_FETCH_OP_AND( , al, "memory")#undef ATOMIC64_FETCH_OP_AND -static inline void atomic64_sub (long i,atomic64_t *v) +static inline void arch_atomic64_sub (long i,atomic64_t *v) { register long x0 asm ("x0") = i; register atomic64_t *x1 asm ("x1") = v;
@@ -364,7 +364,7 @@ static inline void atomic64_sub(long i, atomic64_t *v) } #define ATOMIC64_OP_SUB_RETURN(name, mb, cl...) \ -static inline long atomic64_sub_return##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_sub_return##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -392,7 +392,7 @@ ATOMIC64_OP_SUB_RETURN( , al, "memory")#undef ATOMIC64_OP_SUB_RETURN #define ATOMIC64_FETCH_OP_SUB(name, mb, cl...) \ -static inline long atomic64_fetch_sub##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_sub##name(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -418,7 +418,7 @@ ATOMIC64_FETCH_OP_SUB( , al, "memory")#undef ATOMIC64_FETCH_OP_SUB -static inline long atomic64_dec_if_positive (atomic64_t *v) +static inline long arch_atomic64_dec_if_positive (atomic64_t *v) { register long x0 asm ("x0") = (long)v;
arch/arm64/include/asm/cmpxchg.h +30 -30
82 lines not on this page · raw message
arch/arm64/include/asm/sync_bitops.h +8 -8
@@ -15,13 +15,13 @@* ops which are SMP safe even on a UP kernel. */ -#define sync_set_bit (nr, p) set_bit(nr, p) -#define sync_clear_bit (nr, p) clear_bit(nr, p) -#define sync_change_bit (nr, p) change_bit(nr, p) -#define sync_test_and_set_bit (nr, p) test_and_set_bit(nr, p) -#define sync_test_and_clear_bit (nr, p) test_and_clear_bit(nr, p) -#define sync_test_and_change_bit (nr, p) test_and_change_bit(nr, p) -#define sync_test_bit (nr, addr) test_bit(nr, addr) -#define sync_cmpxchg cmpxchg +#define sync_set_bit (nr, p) set_bit(nr, p) +#define sync_clear_bit (nr, p) clear_bit(nr, p) +#define sync_change_bit (nr, p) change_bit(nr, p) +#define sync_test_and_set_bit (nr, p) test_and_set_bit(nr, p) +#define sync_test_and_clear_bit (nr, p) test_and_clear_bit(nr, p) +#define sync_test_and_change_bit (nr, p) test_and_change_bit(nr, p) +#define sync_test_bit (nr, addr) test_bit(nr, addr) +#define arch_sync_cmpxchg arch_cmpxchg#endif
tip-bot for Mark Rutland
merge bot[tip:locking/core] arm64, locking/atomics: Use instrumented atomics
In reply to Mark Rutlandarm64, locking/atomics: Use instrumented atomics
Commit-ID: c0df10812835040e261b915f04887b0cf0411851 Gitweb: https://git.kernel.org/tip/c0df10812835040e261b915f04887b0cf0411851 Author: Mark Rutland <[email protected]> AuthorDate: Tue, 4 Sep 2018 11:48:30 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Thu, 1 Nov 2018 11:01:40 +0100
arm64, locking/atomics: Use instrumented atomics
Now that the generic atomic headers provide instrumented wrappers of all the atomics implemented by arm64, let's migrate arm64 over to these.
The additional instrumentation will help to find bugs (e.g. when fuzzing with Syzkaller).
Mostly this change involves adding an arch_ prefix to a number of function names and macro definitions. When LSE atomics are used, the out-of-line LL/SC atomics will be named __ll_sc_arch_atomic_${OP}.
Adding the arch_ prefix requires some whitespace fixups to keep things aligned. Some other unusual whitespace is fixed up at the same time (e.g. in the cmpxchg wrappers).
--- arch/arm64/include/asm/atomic.h | 237 +++++++++++++++++----------------- arch/arm64/include/asm/atomic_ll_sc.h | 28 ++-- arch/arm64/include/asm/atomic_lse.h | 38 +++--- arch/arm64/include/asm/cmpxchg.h | 60 ++++----- arch/arm64/include/asm/sync_bitops.h | 16 +-- 5 files changed, 193 insertions(+), 186 deletions(-)
arch/arm64/include/asm/atomic.h +122 -115
@@ -42,124 +42,131 @@#define ATOMIC_INIT (i) { (i) } -#define atomic_read (v) READ_ONCE((v)->counter) -#define atomic_set (v, i) WRITE_ONCE(((v)->counter), (i)) - -#define atomic_add_return_relaxed atomic_add_return_relaxed -#define atomic_add_return_acquire atomic_add_return_acquire -#define atomic_add_return_release atomic_add_return_release -#define atomic_add_return atomic_add_return - -#define atomic_sub_return_relaxed atomic_sub_return_relaxed -#define atomic_sub_return_acquire atomic_sub_return_acquire -#define atomic_sub_return_release atomic_sub_return_release -#define atomic_sub_return atomic_sub_return - -#define atomic_fetch_add_relaxed atomic_fetch_add_relaxed -#define atomic_fetch_add_acquire atomic_fetch_add_acquire -#define atomic_fetch_add_release atomic_fetch_add_release -#define atomic_fetch_add atomic_fetch_add - -#define atomic_fetch_sub_relaxed atomic_fetch_sub_relaxed -#define atomic_fetch_sub_acquire atomic_fetch_sub_acquire -#define atomic_fetch_sub_release atomic_fetch_sub_release -#define atomic_fetch_sub atomic_fetch_sub - -#define atomic_fetch_and_relaxed atomic_fetch_and_relaxed -#define atomic_fetch_and_acquire atomic_fetch_and_acquire -#define atomic_fetch_and_release atomic_fetch_and_release -#define atomic_fetch_and atomic_fetch_and - -#define atomic_fetch_andnot_relaxed atomic_fetch_andnot_relaxed -#define atomic_fetch_andnot_acquire atomic_fetch_andnot_acquire -#define atomic_fetch_andnot_release atomic_fetch_andnot_release -#define atomic_fetch_andnot atomic_fetch_andnot - -#define atomic_fetch_or_relaxed atomic_fetch_or_relaxed -#define atomic_fetch_or_acquire atomic_fetch_or_acquire -#define atomic_fetch_or_release atomic_fetch_or_release -#define atomic_fetch_or atomic_fetch_or - -#define atomic_fetch_xor_relaxed atomic_fetch_xor_relaxed -#define atomic_fetch_xor_acquire atomic_fetch_xor_acquire -#define atomic_fetch_xor_release atomic_fetch_xor_release -#define atomic_fetch_xor atomic_fetch_xor - -#define atomic_xchg_relaxed (v, new) xchg_relaxed(&((v)->counter), (new)) -#define atomic_xchg_acquire (v, new) xchg_acquire(&((v)->counter), (new)) -#define atomic_xchg_release (v, new) xchg_release(&((v)->counter), (new)) -#define atomic_xchg (v, new) xchg(&((v)->counter), (new)) - -#define atomic_cmpxchg_relaxed (v, old, new) \ - cmpxchg_relaxed(&((v)->counter), (old), (new)) -#define atomic_cmpxchg_acquire (v, old, new) \ - cmpxchg_acquire(&((v)->counter), (old), (new)) -#define atomic_cmpxchg_release (v, old, new) \ - cmpxchg_release(&((v)->counter), (old), (new)) -#define atomic_cmpxchg (v, old, new) cmpxchg(&((v)->counter), (old), (new)) - -#define atomic_andnot atomic_andnot +#define arch_atomic_read (v) READ_ONCE((v)->counter) +#define arch_atomic_set (v, i) WRITE_ONCE(((v)->counter), (i)) + +#define arch_atomic_add_return_relaxed arch_atomic_add_return_relaxed +#define arch_atomic_add_return_acquire arch_atomic_add_return_acquire +#define arch_atomic_add_return_release arch_atomic_add_return_release +#define arch_atomic_add_return arch_atomic_add_return + +#define arch_atomic_sub_return_relaxed arch_atomic_sub_return_relaxed +#define arch_atomic_sub_return_acquire arch_atomic_sub_return_acquire +#define arch_atomic_sub_return_release arch_atomic_sub_return_release +#define arch_atomic_sub_return arch_atomic_sub_return + +#define arch_atomic_fetch_add_relaxed arch_atomic_fetch_add_relaxed +#define arch_atomic_fetch_add_acquire arch_atomic_fetch_add_acquire +#define arch_atomic_fetch_add_release arch_atomic_fetch_add_release +#define arch_atomic_fetch_add arch_atomic_fetch_add + +#define arch_atomic_fetch_sub_relaxed arch_atomic_fetch_sub_relaxed +#define arch_atomic_fetch_sub_acquire arch_atomic_fetch_sub_acquire +#define arch_atomic_fetch_sub_release arch_atomic_fetch_sub_release +#define arch_atomic_fetch_sub arch_atomic_fetch_sub + +#define arch_atomic_fetch_and_relaxed arch_atomic_fetch_and_relaxed +#define arch_atomic_fetch_and_acquire arch_atomic_fetch_and_acquire +#define arch_atomic_fetch_and_release arch_atomic_fetch_and_release +#define arch_atomic_fetch_and arch_atomic_fetch_and + +#define arch_atomic_fetch_andnot_relaxed arch_atomic_fetch_andnot_relaxed +#define arch_atomic_fetch_andnot_acquire arch_atomic_fetch_andnot_acquire +#define arch_atomic_fetch_andnot_release arch_atomic_fetch_andnot_release +#define arch_atomic_fetch_andnot arch_atomic_fetch_andnot + +#define arch_atomic_fetch_or_relaxed arch_atomic_fetch_or_relaxed +#define arch_atomic_fetch_or_acquire arch_atomic_fetch_or_acquire +#define arch_atomic_fetch_or_release arch_atomic_fetch_or_release +#define arch_atomic_fetch_or arch_atomic_fetch_or + +#define arch_atomic_fetch_xor_relaxed arch_atomic_fetch_xor_relaxed +#define arch_atomic_fetch_xor_acquire arch_atomic_fetch_xor_acquire +#define arch_atomic_fetch_xor_release arch_atomic_fetch_xor_release +#define arch_atomic_fetch_xor arch_atomic_fetch_xor + +#define arch_atomic_xchg_relaxed (v, new) \ + arch_xchg_relaxed(&((v)->counter), (new)) +#define arch_atomic_xchg_acquire (v, new) \ + arch_xchg_acquire(&((v)->counter), (new)) +#define arch_atomic_xchg_release (v, new) \ + arch_xchg_release(&((v)->counter), (new)) +#define arch_atomic_xchg (v, new) \ + arch_xchg(&((v)->counter), (new)) + +#define arch_atomic_cmpxchg_relaxed (v, old, new) \ + arch_cmpxchg_relaxed(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg_acquire (v, old, new) \ + arch_cmpxchg_acquire(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg_release (v, old, new) \ + arch_cmpxchg_release(&((v)->counter), (old), (new)) +#define arch_atomic_cmpxchg (v, old, new) \ + arch_cmpxchg(&((v)->counter), (old), (new)) + +#define arch_atomic_andnot arch_atomic_andnot/* -* 64-bit atomic operations. +* 64-bit arch_atomic operations. */ -#define ATOMIC64_INIT ATOMIC_INIT -#define atomic64_read atomic_read -#define atomic64_set atomic_set - -#define atomic64_add_return_relaxed atomic64_add_return_relaxed -#define atomic64_add_return_acquire atomic64_add_return_acquire -#define atomic64_add_return_release atomic64_add_return_release -#define atomic64_add_return atomic64_add_return - -#define atomic64_sub_return_relaxed atomic64_sub_return_relaxed -#define atomic64_sub_return_acquire atomic64_sub_return_acquire -#define atomic64_sub_return_release atomic64_sub_return_release -#define atomic64_sub_return atomic64_sub_return - -#define atomic64_fetch_add_relaxed atomic64_fetch_add_relaxed -#define atomic64_fetch_add_acquire atomic64_fetch_add_acquire -#define atomic64_fetch_add_release atomic64_fetch_add_release -#define atomic64_fetch_add atomic64_fetch_add - -#define atomic64_fetch_sub_relaxed atomic64_fetch_sub_relaxed -#define atomic64_fetch_sub_acquire atomic64_fetch_sub_acquire -#define atomic64_fetch_sub_release atomic64_fetch_sub_release -#define atomic64_fetch_sub atomic64_fetch_sub - -#define atomic64_fetch_and_relaxed atomic64_fetch_and_relaxed -#define atomic64_fetch_and_acquire atomic64_fetch_and_acquire -#define atomic64_fetch_and_release atomic64_fetch_and_release -#define atomic64_fetch_and atomic64_fetch_and - -#define atomic64_fetch_andnot_relaxed atomic64_fetch_andnot_relaxed -#define atomic64_fetch_andnot_acquire atomic64_fetch_andnot_acquire -#define atomic64_fetch_andnot_release atomic64_fetch_andnot_release -#define atomic64_fetch_andnot atomic64_fetch_andnot - -#define atomic64_fetch_or_relaxed atomic64_fetch_or_relaxed -#define atomic64_fetch_or_acquire atomic64_fetch_or_acquire -#define atomic64_fetch_or_release atomic64_fetch_or_release -#define atomic64_fetch_or atomic64_fetch_or - -#define atomic64_fetch_xor_relaxed atomic64_fetch_xor_relaxed -#define atomic64_fetch_xor_acquire atomic64_fetch_xor_acquire -#define atomic64_fetch_xor_release atomic64_fetch_xor_release -#define atomic64_fetch_xor atomic64_fetch_xor - -#define atomic64_xchg_relaxed atomic_xchg_relaxed -#define atomic64_xchg_acquire atomic_xchg_acquire -#define atomic64_xchg_release atomic_xchg_release -#define atomic64_xchg atomic_xchg - -#define atomic64_cmpxchg_relaxed atomic_cmpxchg_relaxed -#define atomic64_cmpxchg_acquire atomic_cmpxchg_acquire -#define atomic64_cmpxchg_release atomic_cmpxchg_release -#define atomic64_cmpxchg atomic_cmpxchg - -#define atomic64_andnot atomic64_andnot - -#define atomic64_dec_if_positive atomic64_dec_if_positive +#define ATOMIC64_INIT ATOMIC_INIT +#define arch_atomic64_read arch_atomic_read +#define arch_atomic64_set arch_atomic_set + +#define arch_atomic64_add_return_relaxed arch_atomic64_add_return_relaxed +#define arch_atomic64_add_return_acquire arch_atomic64_add_return_acquire +#define arch_atomic64_add_return_release arch_atomic64_add_return_release +#define arch_atomic64_add_return arch_atomic64_add_return + +#define arch_atomic64_sub_return_relaxed arch_atomic64_sub_return_relaxed +#define arch_atomic64_sub_return_acquire arch_atomic64_sub_return_acquire +#define arch_atomic64_sub_return_release arch_atomic64_sub_return_release +#define arch_atomic64_sub_return arch_atomic64_sub_return + +#define arch_atomic64_fetch_add_relaxed arch_atomic64_fetch_add_relaxed +#define arch_atomic64_fetch_add_acquire arch_atomic64_fetch_add_acquire +#define arch_atomic64_fetch_add_release arch_atomic64_fetch_add_release +#define arch_atomic64_fetch_add arch_atomic64_fetch_add + +#define arch_atomic64_fetch_sub_relaxed arch_atomic64_fetch_sub_relaxed +#define arch_atomic64_fetch_sub_acquire arch_atomic64_fetch_sub_acquire +#define arch_atomic64_fetch_sub_release arch_atomic64_fetch_sub_release +#define arch_atomic64_fetch_sub arch_atomic64_fetch_sub + +#define arch_atomic64_fetch_and_relaxed arch_atomic64_fetch_and_relaxed +#define arch_atomic64_fetch_and_acquire arch_atomic64_fetch_and_acquire +#define arch_atomic64_fetch_and_release arch_atomic64_fetch_and_release +#define arch_atomic64_fetch_and arch_atomic64_fetch_and + +#define arch_atomic64_fetch_andnot_relaxed arch_atomic64_fetch_andnot_relaxed +#define arch_atomic64_fetch_andnot_acquire arch_atomic64_fetch_andnot_acquire +#define arch_atomic64_fetch_andnot_release arch_atomic64_fetch_andnot_release +#define arch_atomic64_fetch_andnot arch_atomic64_fetch_andnot + +#define arch_atomic64_fetch_or_relaxed arch_atomic64_fetch_or_relaxed +#define arch_atomic64_fetch_or_acquire arch_atomic64_fetch_or_acquire +#define arch_atomic64_fetch_or_release arch_atomic64_fetch_or_release +#define arch_atomic64_fetch_or arch_atomic64_fetch_or + +#define arch_atomic64_fetch_xor_relaxed arch_atomic64_fetch_xor_relaxed +#define arch_atomic64_fetch_xor_acquire arch_atomic64_fetch_xor_acquire +#define arch_atomic64_fetch_xor_release arch_atomic64_fetch_xor_release +#define arch_atomic64_fetch_xor arch_atomic64_fetch_xor + +#define arch_atomic64_xchg_relaxed arch_atomic_xchg_relaxed +#define arch_atomic64_xchg_acquire arch_atomic_xchg_acquire +#define arch_atomic64_xchg_release arch_atomic_xchg_release +#define arch_atomic64_xchg arch_atomic_xchg + +#define arch_atomic64_cmpxchg_relaxed arch_atomic_cmpxchg_relaxed +#define arch_atomic64_cmpxchg_acquire arch_atomic_cmpxchg_acquire +#define arch_atomic64_cmpxchg_release arch_atomic_cmpxchg_release +#define arch_atomic64_cmpxchg arch_atomic_cmpxchg + +#define arch_atomic64_andnot arch_atomic64_andnot + +#define arch_atomic64_dec_if_positive arch_atomic64_dec_if_positive + +#include <asm-generic/atomic-instrumented.h> #endif #endif
arch/arm64/include/asm/atomic_ll_sc.h +14 -14
@@ -39,7 +39,7 @@#define ATOMIC_OP (op, asm_op) \ __LL_SC_INLINE void \ -__LL_SC_PREFIX(atomic_##op(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_##op(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int result; \
@@ -53,11 +53,11 @@ __LL_SC_PREFIX(atomic_##op(int i, atomic_t *v)) \ : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) \ : "Ir" (i)); \ } \ -__LL_SC_EXPORT(atomic_##op); +__LL_SC_EXPORT(arch_atomic_##op);#define ATOMIC_OP_RETURN (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE int \ -__LL_SC_PREFIX(atomic_##op##_return##name(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_##op##_return##name(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int result; \
@@ -75,11 +75,11 @@ __LL_SC_PREFIX(atomic_##op##_return##name(int i, atomic_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic_##op##_return##name); +__LL_SC_EXPORT(arch_atomic_##op##_return##name);#define ATOMIC_FETCH_OP (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE int \ -__LL_SC_PREFIX(atomic_fetch_##op##name(int i, atomic_t *v)) \ +__LL_SC_PREFIX(arch_atomic_fetch_##op##name(int i, atomic_t *v)) \ { \ unsigned long tmp; \ int val, result; \
@@ -97,7 +97,7 @@ __LL_SC_PREFIX(atomic_fetch_##op##name(int i, atomic_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic_fetch_##op##name); +__LL_SC_EXPORT(arch_atomic_fetch_##op##name);#define ATOMIC_OPS (...) \ ATOMIC_OP(__VA_ARGS__) \
@@ -133,7 +133,7 @@ ATOMIC_OPS(xor, eor)#define ATOMIC64_OP (op, asm_op) \ __LL_SC_INLINE void \ -__LL_SC_PREFIX(atomic64_##op(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_##op(long i, atomic64_t *v)) \ { \ long result; \ unsigned long tmp; \
@@ -147,11 +147,11 @@ __LL_SC_PREFIX(atomic64_##op(long i, atomic64_t *v)) \ : "=&r" (result), "=&r" (tmp), "+Q" (v->counter) \ : "Ir" (i)); \ } \ -__LL_SC_EXPORT(atomic64_##op); +__LL_SC_EXPORT(arch_atomic64_##op);#define ATOMIC64_OP_RETURN (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE long \ -__LL_SC_PREFIX(atomic64_##op##_return##name(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_##op##_return##name(long i, atomic64_t *v))\ { \ long result; \ unsigned long tmp; \
@@ -169,11 +169,11 @@ __LL_SC_PREFIX(atomic64_##op##_return##name(long i, atomic64_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic64_##op##_return##name); +__LL_SC_EXPORT(arch_atomic64_##op##_return##name);#define ATOMIC64_FETCH_OP (name, mb, acq, rel, cl, op, asm_op) \ __LL_SC_INLINE long \ -__LL_SC_PREFIX(atomic64_fetch_##op##name(long i, atomic64_t *v)) \ +__LL_SC_PREFIX(arch_atomic64_fetch_##op##name(long i, atomic64_t *v)) \ { \ long result, val; \ unsigned long tmp; \
@@ -191,7 +191,7 @@ __LL_SC_PREFIX(atomic64_fetch_##op##name(long i, atomic64_t *v)) \ \return result; \ } \ -__LL_SC_EXPORT(atomic64_fetch_##op##name); +__LL_SC_EXPORT(arch_atomic64_fetch_##op##name);#define ATOMIC64_OPS (...) \ ATOMIC64_OP(__VA_ARGS__) \
@@ -226,7 +226,7 @@ ATOMIC64_OPS(xor, eor)#undef ATOMIC64_OP__LL_SC_INLINE long -__LL_SC_PREFIX (atomic64_dec_if_positive (atomic64_t *v)) +__LL_SC_PREFIX (arch_atomic64_dec_if_positive (atomic64_t *v)) {long result;unsigned long tmp;
@@ -246,7 +246,7 @@ __LL_SC_PREFIX(atomic64_dec_if_positive(atomic64_t *v))return result; } -__LL_SC_EXPORT (atomic64_dec_if_positive); +__LL_SC_EXPORT (arch_atomic64_dec_if_positive);#define __CMPXCHG_CASE (w, sz, name, mb, acq, rel, cl) \ __LL_SC_INLINE unsigned long \
arch/arm64/include/asm/atomic_lse.h +19 -19
@@ -25,9 +25,9 @@#error "please don't include this file directly"#endif -#define __LL_SC_ATOMIC (op) __LL_SC_CALL(atomic_##op) +#define __LL_SC_ATOMIC (op) __LL_SC_CALL(arch_atomic_##op)#define ATOMIC_OP (op, asm_op) \ -static inline void atomic_##op(int i, atomic_t *v) \ +static inline void arch_atomic_##op(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -47,7 +47,7 @@ ATOMIC_OP(add, stadd)#undef ATOMIC_OP #define ATOMIC_FETCH_OP(name, mb, op, asm_op, cl...) \ -static inline int atomic_fetch_##op##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_##op##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -79,7 +79,7 @@ ATOMIC_FETCH_OPS(add, ldadd)#undef ATOMIC_FETCH_OPS #define ATOMIC_OP_ADD_RETURN(name, mb, cl...) \ -static inline int atomic_add_return##name(int i, atomic_t *v) \ +static inline int arch_atomic_add_return##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -105,7 +105,7 @@ ATOMIC_OP_ADD_RETURN( , al, "memory")#undef ATOMIC_OP_ADD_RETURN -static inline void atomic_and (int i,atomic_t *v) +static inline void arch_atomic_and (int i,atomic_t *v) { register int w0 asm ("w0") = i; register atomic_t *x1 asm ("x1") = v;
@@ -123,7 +123,7 @@ static inline void atomic_and(int i, atomic_t *v) } #define ATOMIC_FETCH_OP_AND(name, mb, cl...) \ -static inline int atomic_fetch_and##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_and##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -149,7 +149,7 @@ ATOMIC_FETCH_OP_AND( , al, "memory")#undef ATOMIC_FETCH_OP_AND -static inline void atomic_sub (int i,atomic_t *v) +static inline void arch_atomic_sub (int i,atomic_t *v) { register int w0 asm ("w0") = i; register atomic_t *x1 asm ("x1") = v;
@@ -167,7 +167,7 @@ static inline void atomic_sub(int i, atomic_t *v) } #define ATOMIC_OP_SUB_RETURN(name, mb, cl...) \ -static inline int atomic_sub_return##name(int i, atomic_t *v) \ +static inline int arch_atomic_sub_return##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -195,7 +195,7 @@ ATOMIC_OP_SUB_RETURN( , al, "memory")#undef ATOMIC_OP_SUB_RETURN #define ATOMIC_FETCH_OP_SUB(name, mb, cl...) \ -static inline int atomic_fetch_sub##name(int i, atomic_t *v) \ +static inline int arch_atomic_fetch_sub##name(int i, atomic_t *v) \ { \ register int w0 asm ("w0") = i; \ register atomic_t *x1 asm ("x1") = v; \
@@ -222,9 +222,9 @@ ATOMIC_FETCH_OP_SUB( , al, "memory")#undef ATOMIC_FETCH_OP_SUB#undef __LL_SC_ATOMIC -#define __LL_SC_ATOMIC64 (op) __LL_SC_CALL(atomic64_##op) +#define __LL_SC_ATOMIC64 (op) __LL_SC_CALL(arch_atomic64_##op)#define ATOMIC64_OP (op, asm_op) \ -static inline void atomic64_##op(long i, atomic64_t *v) \ +static inline void arch_atomic64_##op(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -244,7 +244,7 @@ ATOMIC64_OP(add, stadd)#undef ATOMIC64_OP #define ATOMIC64_FETCH_OP(name, mb, op, asm_op, cl...) \ -static inline long atomic64_fetch_##op##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_##op##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -276,7 +276,7 @@ ATOMIC64_FETCH_OPS(add, ldadd)#undef ATOMIC64_FETCH_OPS #define ATOMIC64_OP_ADD_RETURN(name, mb, cl...) \ -static inline long atomic64_add_return##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_add_return##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -302,7 +302,7 @@ ATOMIC64_OP_ADD_RETURN( , al, "memory")#undef ATOMIC64_OP_ADD_RETURN -static inline void atomic64_and (long i,atomic64_t *v) +static inline void arch_atomic64_and (long i,atomic64_t *v) { register long x0 asm ("x0") = i; register atomic64_t *x1 asm ("x1") = v;
@@ -320,7 +320,7 @@ static inline void atomic64_and(long i, atomic64_t *v) } #define ATOMIC64_FETCH_OP_AND(name, mb, cl...) \ -static inline long atomic64_fetch_and##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_and##name(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -346,7 +346,7 @@ ATOMIC64_FETCH_OP_AND( , al, "memory")#undef ATOMIC64_FETCH_OP_AND -static inline void atomic64_sub (long i,atomic64_t *v) +static inline void arch_atomic64_sub (long i,atomic64_t *v) { register long x0 asm ("x0") = i; register atomic64_t *x1 asm ("x1") = v;
@@ -364,7 +364,7 @@ static inline void atomic64_sub(long i, atomic64_t *v) } #define ATOMIC64_OP_SUB_RETURN(name, mb, cl...) \ -static inline long atomic64_sub_return##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_sub_return##name(long i, atomic64_t *v)\ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -392,7 +392,7 @@ ATOMIC64_OP_SUB_RETURN( , al, "memory")#undef ATOMIC64_OP_SUB_RETURN #define ATOMIC64_FETCH_OP_SUB(name, mb, cl...) \ -static inline long atomic64_fetch_sub##name(long i, atomic64_t *v) \ +static inline long arch_atomic64_fetch_sub##name(long i, atomic64_t *v) \ { \ register long x0 asm ("x0") = i; \ register atomic64_t *x1 asm ("x1") = v; \
@@ -418,7 +418,7 @@ ATOMIC64_FETCH_OP_SUB( , al, "memory")#undef ATOMIC64_FETCH_OP_SUB -static inline long atomic64_dec_if_positive (atomic64_t *v) +static inline long arch_atomic64_dec_if_positive (atomic64_t *v) { register long x0 asm ("x0") = (long)v;
arch/arm64/include/asm/cmpxchg.h +30 -30
82 lines not on this page · raw message
arch/arm64/include/asm/sync_bitops.h +8 -8
@@ -15,13 +15,13 @@* ops which are SMP safe even on a UP kernel. */ -#define sync_set_bit (nr, p) set_bit(nr, p) -#define sync_clear_bit (nr, p) clear_bit(nr, p) -#define sync_change_bit (nr, p) change_bit(nr, p) -#define sync_test_and_set_bit (nr, p) test_and_set_bit(nr, p) -#define sync_test_and_clear_bit (nr, p) test_and_clear_bit(nr, p) -#define sync_test_and_change_bit (nr, p) test_and_change_bit(nr, p) -#define sync_test_bit (nr, addr) test_bit(nr, addr) -#define sync_cmpxchg cmpxchg +#define sync_set_bit (nr, p) set_bit(nr, p) +#define sync_clear_bit (nr, p) clear_bit(nr, p) +#define sync_change_bit (nr, p) change_bit(nr, p) +#define sync_test_and_set_bit (nr, p) test_and_set_bit(nr, p) +#define sync_test_and_clear_bit (nr, p) test_and_clear_bit(nr, p) +#define sync_test_and_change_bit (nr, p) test_and_change_bit(nr, p) +#define sync_test_bit (nr, addr) test_bit(nr, addr) +#define arch_sync_cmpxchg arch_cmpxchg#endif
Mark Rutland
reviewerQuoted 7 lines · Mark Rutland
Hi Ingo,
As previously requested, this is a (trivial) rebase of the remaining generated atomic patches atop of v4.19-rc2, avoiding any potential conflict with Peter's ldsem atomic cleanup patch that got taken through the tty tree.
Are you still happy to pick this up? Full blurb below.
Ping!
Do you have any comments, or would you be happy to queue this?
I'm happy to resend come rc1, if you'd prefer?
Thanks,
Mark.
Quoted 129 lines
This series scripts the generation of the various atomic headers, to ensure that the various atomic APIs remain consistent, reducing the risk of human error, and simplifying future rework. This fleshes out the instrumented atomics such that arm64 can be migrated over to them.
Since v1 [1]:
* Use 'p' instead of 'I' for pointer to base int type
* Use Peter's patch for ldsem
* Rename atomic acquire/release barriers
* Handle xchg/cmpxchg variants
* Typo fixes
* Migrate arm64 to instrumented atomicsSince v2 [4]:
* rebase to v4.19-rc2 to solve potential conflicts with ldsem patchThe series is based on my atomic API cleanup patches [2], which have been queued in the tip locking/core branch.
The first six patches clean up some issues with the existing atomic instrumentation, with patch six introducing the header generation infrastructure. The subsequent three patches migrate to each generated header in turn, with the final patch moving arm64 over to the instrumented atomics.
The scripts themselves are mostly POSIX sh (modulo local), without bashisms, and work in dash and bash.
Per Linus request that it is possible to use git grep to inspect the atomic headers [3], the headers are committed (and not generated by kbuild). Since we now expand the fallback definitions inline, each *should* be easier to find with grep. Each header also has a comment at the top with a path to the script used to generate it.
That scripting comes to ~900 lines, and replaces ~1700 lines of hand-written boilerplate with ~4700 lines of generated code. Some of that increase in line count is due to filling in missing portions of the API (e.g. adding all the ordering variants to the instrumented atomics), while some of that is due to expanding fallbacks in place, and consistently spreading these across multiple lines.
I've build-tested this for
x86_64and arm64 (with and without LSE), and given this some basic boot testing.I've pushed the series out to my atomics/generated branch [3], based atop of v4.19-rc2.
Thanks,
Mark.[1] https://lkml.kernel.org/r/20180529180746.29684-1-mark.rutland at arm.com
[2] https://lkml.kernel.org/r/20180621121321.4761-1-mark.rutland at arm.com
[3]git://git.kernel.org/pub/scm/linux/kernel/git/mark/linux.gitatomics/generated
[4] https://lkml.kernel.org/r/20180625105952.3756-1-mark.rutland at arm.comMark Rutland (6):
atomics: add common header generation files
atomics: switch to generated fallbacks
atomics: switch to generated atomic-long
atomics: switch to generated instrumentation
atomics: check generated headers are up-to-date
arm64: use instrumented atomicsKbuild | 18 +- MAINTAINERS | 1 + arch/arm64/include/asm/atomic.h | 237 +-- arch/arm64/include/asm/atomic_ll_sc.h | 28 +- arch/arm64/include/asm/atomic_lse.h | 38 +- arch/arm64/include/asm/cmpxchg.h | 60 +- arch/arm64/include/asm/sync_bitops.h | 16 +- include/asm-generic/atomic-instrumented.h | 1688 ++++++++++++++++--- include/asm-generic/atomic-long.h | 1173 ++++++++++--- include/linux/atomic-fallback.h | 2294 ++++++++++++++++++++++++++ include/linux/atomic.h | 1241 +------------- scripts/atomic/atomic-tbl.sh | 186 +++ scripts/atomic/atomics.tbl | 41 + scripts/atomic/check-atomics.sh | 19 + scripts/atomic/fallbacks/acquire | 9 + scripts/atomic/fallbacks/add_negative | 16 + scripts/atomic/fallbacks/add_unless | 16 + scripts/atomic/fallbacks/andnot | 7 + scripts/atomic/fallbacks/dec | 7 + scripts/atomic/fallbacks/dec_and_test | 15 + scripts/atomic/fallbacks/dec_if_positive | 15 + scripts/atomic/fallbacks/dec_unless_positive | 14 + scripts/atomic/fallbacks/fence | 11 + scripts/atomic/fallbacks/fetch_add_unless | 23 + scripts/atomic/fallbacks/inc | 7 + scripts/atomic/fallbacks/inc_and_test | 15 + scripts/atomic/fallbacks/inc_not_zero | 14 + scripts/atomic/fallbacks/inc_unless_negative | 14 + scripts/atomic/fallbacks/read_acquire | 7 + scripts/atomic/fallbacks/release | 8 + scripts/atomic/fallbacks/set_release | 7 + scripts/atomic/fallbacks/sub_and_test | 16 + scripts/atomic/fallbacks/try_cmpxchg | 11 + scripts/atomic/gen-atomic-fallback.sh | 181 ++ scripts/atomic/gen-atomic-instrumented.sh | 182 ++ scripts/atomic/gen-atomic-long.sh | 101 ++ 36 files changed, 5909 insertions(+), 1827 deletions(-) create mode 100644 include/linux/atomic-fallback.h create mode 100755 scripts/atomic/atomic-tbl.sh create mode 100644 scripts/atomic/atomics.tbl create mode 100755 scripts/atomic/check-atomics.sh create mode 100644 scripts/atomic/fallbacks/acquire create mode 100644 scripts/atomic/fallbacks/add_negative create mode 100644 scripts/atomic/fallbacks/add_unless create mode 100644 scripts/atomic/fallbacks/andnot create mode 100644 scripts/atomic/fallbacks/dec create mode 100644 scripts/atomic/fallbacks/dec_and_test create mode 100644 scripts/atomic/fallbacks/dec_if_positive create mode 100644 scripts/atomic/fallbacks/dec_unless_positive create mode 100644 scripts/atomic/fallbacks/fence create mode 100644 scripts/atomic/fallbacks/fetch_add_unless create mode 100644 scripts/atomic/fallbacks/inc create mode 100644 scripts/atomic/fallbacks/inc_and_test create mode 100644 scripts/atomic/fallbacks/inc_not_zero create mode 100644 scripts/atomic/fallbacks/inc_unless_negative create mode 100644 scripts/atomic/fallbacks/read_acquire create mode 100644 scripts/atomic/fallbacks/release create mode 100644 scripts/atomic/fallbacks/set_release create mode 100644 scripts/atomic/fallbacks/sub_and_test create mode 100644 scripts/atomic/fallbacks/try_cmpxchg create mode 100755 scripts/atomic/gen-atomic-fallback.sh create mode 100755 scripts/atomic/gen-atomic-instrumented.sh create mode 100755 scripts/atomic/gen-atomic-long.shSignature · 1 line
2.11.0
Hi Ingo,
Quoted 5 lines · Mark Rutland
Quoted 4 lines · Mark Rutland
As previously requested, this is a (trivial) rebase of the remaining generated atomic patches atop of v4.19-rc2, avoiding any potential conflict with Peter's ldsem atomic cleanup patch that got taken through the tty tree.
Quoted 7 lines
Quoted 1 line
Are you still happy to pick this up? Full blurb below.
Ping!
Do you have any comments, or would you be happy to queue this?
I'm happy to resend come rc1, if you'd prefer?
It would be really nice to see this merged. Any chance we could get this queued at -rc1 for 4.21, please? If not, what more needs to be done?
Cheers,
Will