lkml.org 
[lkml]   [2021]   [Dec]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[RFC][PATCH 3/5] refcount: Improve out-of-line code-gen
Allow a number of ops to tail-call refcount_warn_saturate() in order
to generate smaller out-of-line code.

text data bss dec hex filename
97341 4985 1116 103442 19412 defconfig-build/kernel/events/core.o
97299 4985 1116 103400 193e8 defconfig-build/kernel/events/core.o

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
include/linux/refcount.h | 9 ++++-----
lib/refcount.c | 4 +++-
2 files changed, 7 insertions(+), 6 deletions(-)

--- a/include/linux/refcount.h
+++ b/include/linux/refcount.h
@@ -124,7 +124,7 @@ enum refcount_saturation_type {
REFCOUNT_DEC_LEAK,
};

-void refcount_warn_saturate(refcount_t *r, enum refcount_saturation_type t);
+bool refcount_warn_saturate(refcount_t *r, enum refcount_saturation_type t);

/**
* refcount_set - set a refcount's value
@@ -160,7 +160,7 @@ static inline __must_check bool __refcou
*oldp = old;

if (unlikely(old < 0 || old + i < 0))
- refcount_warn_saturate(r, REFCOUNT_ADD_NOT_ZERO_OVF);
+ return refcount_warn_saturate(r, REFCOUNT_ADD_NOT_ZERO_OVF);

return old;
}
@@ -283,7 +283,7 @@ static inline __must_check bool __refcou
}

if (unlikely(old < 0 || old - i < 0))
- refcount_warn_saturate(r, REFCOUNT_SUB_UAF);
+ return refcount_warn_saturate(r, REFCOUNT_SUB_UAF);

return false;
}
@@ -335,8 +335,7 @@ static inline __must_check bool refcount
{
return atomic_dec_and_test_ofl(&r->refs, Eoverflow);
Eoverflow:
- refcount_warn_saturate(r, REFCOUNT_SUB_UAF);
- return false;
+ return refcount_warn_saturate(r, REFCOUNT_SUB_UAF);
}

static inline void __refcount_dec(refcount_t *r, int *oldp)
--- a/lib/refcount.c
+++ b/lib/refcount.c
@@ -10,7 +10,7 @@

#define REFCOUNT_WARN(str) WARN_ONCE(1, "refcount_t: " str ".\n")

-void refcount_warn_saturate(refcount_t *r, enum refcount_saturation_type t)
+bool refcount_warn_saturate(refcount_t *r, enum refcount_saturation_type t)
{
int old = refcount_read(r);
refcount_set(r, REFCOUNT_SATURATED);
@@ -38,6 +38,8 @@ void refcount_warn_saturate(refcount_t *
default:
REFCOUNT_WARN("unknown saturation event!?");
}
+
+ return false;
}
EXPORT_SYMBOL(refcount_warn_saturate);


\
 
 \ /
  Last update: 2021-12-08 19:41    [W:0.871 / U:0.192 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site