lkml.org 
[lkml]   [2013]   [Oct]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/7] static_key: add static_key_slow_inc_deferred()
Date
We can cancel deferred static_key_slow_dec() instead of increasing
.enabled.counter.

Timer now won't fire before 'timeout' since last increase, so this patch
further stabilizes the case of frequent switching.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
include/linux/jump_label_ratelimit.h | 5 +++++
kernel/jump_label.c | 7 +++++++
2 files changed, 12 insertions(+)

diff --git a/include/linux/jump_label_ratelimit.h b/include/linux/jump_label_ratelimit.h
index 1137883..e2fa2e7 100644
--- a/include/linux/jump_label_ratelimit.h
+++ b/include/linux/jump_label_ratelimit.h
@@ -13,6 +13,7 @@ struct static_key_deferred {
#endif

#ifdef HAVE_JUMP_LABEL
+extern void static_key_slow_inc_deferred(struct static_key_deferred *key);
extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
extern void
jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
@@ -21,6 +22,10 @@ jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
struct static_key_deferred {
struct static_key key;
};
+static inline void static_key_slow_inc_deferred(struct static_key_deferred *key)
+{
+ static_key_slow_inc(&key->key);
+}
static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
{
static_key_slow_dec(&key->key);
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 7018042..ff67257 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -73,6 +73,13 @@ void static_key_slow_inc(struct static_key *key)
}
EXPORT_SYMBOL_GPL(static_key_slow_inc);

+void static_key_slow_inc_deferred(struct static_key_deferred *key)
+{
+ if (!cancel_delayed_work(&key->work))
+ static_key_slow_inc(&key->key);
+}
+EXPORT_SYMBOL_GPL(static_key_slow_inc_deferred);
+
static void __static_key_slow_dec(struct static_key *key,
unsigned long rate_limit, struct delayed_work *work)
{
--
1.8.3.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2013-10-17 12:41    [W:0.070 / U:10.540 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site