linux/include/linux/jump_label_ratelimit.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_JUMP_LABEL_RATELIMIT_H
#define _LINUX_JUMP_LABEL_RATELIMIT_H

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

#if defined(CONFIG_JUMP_LABEL)
struct static_key_deferred {};

struct static_key_true_deferred {};

struct static_key_false_deferred {};

#define static_key_slow_dec_deferred(x)
#define static_branch_slow_dec_deferred(x)

#define static_key_deferred_flush(x)

extern void
__static_key_slow_dec_deferred(struct static_key *key,
			       struct delayed_work *work,
			       unsigned long timeout);
extern void __static_key_deferred_flush(void *key, struct delayed_work *work);
extern void
jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);

extern void jump_label_update_timeout(struct work_struct *work);

#define DEFINE_STATIC_KEY_DEFERRED_TRUE(name, rl)

#define DEFINE_STATIC_KEY_DEFERRED_FALSE(name, rl)

#else	/* !CONFIG_JUMP_LABEL */
struct static_key_deferred {
	struct static_key  key;
};
struct static_key_true_deferred {
	struct static_key_true key;
};
struct static_key_false_deferred {
	struct static_key_false key;
};
#define DEFINE_STATIC_KEY_DEFERRED_TRUE
#define DEFINE_STATIC_KEY_DEFERRED_FALSE

#define static_branch_slow_dec_deferred

static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
{
	STATIC_KEY_CHECK_USE(key);
	static_key_slow_dec(&key->key);
}
static inline void static_key_deferred_flush(void *key)
{
	STATIC_KEY_CHECK_USE(key);
}
static inline void
jump_label_rate_limit(struct static_key_deferred *key,
		unsigned long rl)
{
	STATIC_KEY_CHECK_USE(key);
}
#endif	/* CONFIG_JUMP_LABEL */

#define static_branch_deferred_inc(x)

#endif	/* _LINUX_JUMP_LABEL_RATELIMIT_H */