jump_label_ratelimit.h 1.12 KB
Newer Older
1
/* SPDX-License-Identifier: GPL-2.0 */
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#ifndef _LINUX_JUMP_LABEL_RATELIMIT_H
#define _LINUX_JUMP_LABEL_RATELIMIT_H

#include <linux/jump_label.h>
#include <linux/workqueue.h>

#if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL)
struct static_key_deferred {
	struct static_key key;
	unsigned long timeout;
	struct delayed_work work;
};
#endif

#ifdef HAVE_JUMP_LABEL
extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
18
extern void static_key_deferred_flush(struct static_key_deferred *key);
19 20 21 22 23 24 25 26 27
extern void
jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);

#else	/* !HAVE_JUMP_LABEL */
struct static_key_deferred {
	struct static_key  key;
};
static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
{
28
	STATIC_KEY_CHECK_USE(key);
29 30
	static_key_slow_dec(&key->key);
}
31 32
static inline void static_key_deferred_flush(struct static_key_deferred *key)
{
33
	STATIC_KEY_CHECK_USE(key);
34
}
35 36 37 38
static inline void
jump_label_rate_limit(struct static_key_deferred *key,
		unsigned long rl)
{
39
	STATIC_KEY_CHECK_USE(key);
40 41 42
}
#endif	/* HAVE_JUMP_LABEL */
#endif	/* _LINUX_JUMP_LABEL_RATELIMIT_H */