Skip to content

Commit 944bc9c

Browse files
melverpaulmckrcu
authored andcommitted
asm-generic/atomic: Use __always_inline for fallback wrappers
Use __always_inline for atomic fallback wrappers. When building for size (CC_OPTIMIZE_FOR_SIZE), some compilers appear to be less inclined to inline even relatively small static inline functions that are assumed to be inlinable such as atomic ops. This can cause problems, for example in UACCESS regions. While the fallback wrappers aren't pure wrappers, they are trivial nonetheless, and the function they wrap should determine the final inlining policy. For x86 tinyconfig we observe: - vmlinux baseline: 1315988 - vmlinux with patch: 1315928 (-60 bytes) Suggested-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Marco Elver <elver@google.com> Acked-by: Mark Rutland <mark.rutland@arm.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent c020395 commit 944bc9c

21 files changed

Lines changed: 192 additions & 188 deletions

‎include/linux/atomic-fallback.h‎

Lines changed: 171 additions & 169 deletions
Large diffs are not rendered by default.

‎scripts/atomic/fallbacks/acquire‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cat <<EOF
2-
static inline ${ret}
2+
static __always_inline ${ret}
33
${atomic}_${pfx}${name}${sfx}_acquire(${params})
44
{
55
${ret} ret = ${atomic}_${pfx}${name}${sfx}_relaxed(${args});

‎scripts/atomic/fallbacks/add_negative‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cat <<EOF
88
* if the result is negative, or false when
99
* result is greater than or equal to zero.
1010
*/
11-
static inline bool
11+
static __always_inline bool
1212
${atomic}_add_negative(${int} i, ${atomic}_t *v)
1313
{
1414
return ${atomic}_add_return(i, v) < 0;

‎scripts/atomic/fallbacks/add_unless‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cat << EOF
88
* Atomically adds @a to @v, if @v was not already @u.
99
* Returns true if the addition was done.
1010
*/
11-
static inline bool
11+
static __always_inline bool
1212
${atomic}_add_unless(${atomic}_t *v, ${int} a, ${int} u)
1313
{
1414
return ${atomic}_fetch_add_unless(v, a, u) != u;

‎scripts/atomic/fallbacks/andnot‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cat <<EOF
2-
static inline ${ret}
2+
static __always_inline ${ret}
33
${atomic}_${pfx}andnot${sfx}${order}(${int} i, ${atomic}_t *v)
44
{
55
${retstmt}${atomic}_${pfx}and${sfx}${order}(~i, v);

‎scripts/atomic/fallbacks/dec‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cat <<EOF
2-
static inline ${ret}
2+
static __always_inline ${ret}
33
${atomic}_${pfx}dec${sfx}${order}(${atomic}_t *v)
44
{
55
${retstmt}${atomic}_${pfx}sub${sfx}${order}(1, v);

‎scripts/atomic/fallbacks/dec_and_test‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ cat <<EOF
77
* returns true if the result is 0, or false for all other
88
* cases.
99
*/
10-
static inline bool
10+
static __always_inline bool
1111
${atomic}_dec_and_test(${atomic}_t *v)
1212
{
1313
return ${atomic}_dec_return(v) == 0;

‎scripts/atomic/fallbacks/dec_if_positive‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cat <<EOF
2-
static inline ${ret}
2+
static __always_inline ${ret}
33
${atomic}_dec_if_positive(${atomic}_t *v)
44
{
55
${int} dec, c = ${atomic}_read(v);

‎scripts/atomic/fallbacks/dec_unless_positive‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cat <<EOF
2-
static inline bool
2+
static __always_inline bool
33
${atomic}_dec_unless_positive(${atomic}_t *v)
44
{
55
${int} c = ${atomic}_read(v);

‎scripts/atomic/fallbacks/fence‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cat <<EOF
2-
static inline ${ret}
2+
static __always_inline ${ret}
33
${atomic}_${pfx}${name}${sfx}(${params})
44
{
55
${ret} ret;

0 commit comments

Comments
 (0)