Skip to content

Commit

Permalink
locking/refcount: Consolidate REFCOUNT_{MAX,SATURATED} definitions
Browse files Browse the repository at this point in the history
The definitions of REFCOUNT_MAX and REFCOUNT_SATURATED are the same,
regardless of CONFIG_REFCOUNT_FULL, so consolidate them into a single
pair of definitions.

Signed-off-by: Will Deacon <will@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Hanjun Guo <guohanjun@huawei.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Elena Reshetova <elena.reshetova@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: https://lkml.kernel.org/r/20191121115902.2551-8-will@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Will Deacon authored and Ingo Molnar committed Nov 25, 2019
1 parent 1eb085d commit 65b0085
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions include/linux/refcount.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ typedef struct refcount_struct {
} refcount_t;

#define REFCOUNT_INIT(n) { .refs = ATOMIC_INIT(n), }
#define REFCOUNT_MAX INT_MAX
#define REFCOUNT_SATURATED (INT_MIN / 2)

enum refcount_saturation_type {
REFCOUNT_ADD_NOT_ZERO_OVF,
Expand Down Expand Up @@ -57,9 +59,6 @@ static inline unsigned int refcount_read(const refcount_t *r)
#ifdef CONFIG_REFCOUNT_FULL
#include <linux/bug.h>

#define REFCOUNT_MAX INT_MAX
#define REFCOUNT_SATURATED (INT_MIN / 2)

/*
* Variant of atomic_t specialized for reference counts.
*
Expand Down Expand Up @@ -300,10 +299,6 @@ static inline void refcount_dec(refcount_t *r)
refcount_warn_saturate(r, REFCOUNT_DEC_LEAK);
}
#else /* CONFIG_REFCOUNT_FULL */

#define REFCOUNT_MAX INT_MAX
#define REFCOUNT_SATURATED (INT_MIN / 2)

# ifdef CONFIG_ARCH_HAS_REFCOUNT
# include <asm/refcount.h>
# else
Expand Down

0 comments on commit 65b0085

Please sign in to comment.