jump_label_ratelimit.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_JUMP_LABEL_RATELIMIT_H
  3. #define _LINUX_JUMP_LABEL_RATELIMIT_H
  4. #include <linux/jump_label.h>
  5. #include <linux/workqueue.h>
  6. #if defined(CONFIG_JUMP_LABEL)
  7. struct static_key_deferred {
  8. struct static_key key;
  9. unsigned long timeout;
  10. struct delayed_work work;
  11. };
  12. extern void static_key_slow_dec_deferred(struct static_key_deferred *key);
  13. extern void static_key_deferred_flush(struct static_key_deferred *key);
  14. extern void
  15. jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl);
  16. #else /* !CONFIG_JUMP_LABEL */
  17. struct static_key_deferred {
  18. struct static_key key;
  19. };
  20. static inline void static_key_slow_dec_deferred(struct static_key_deferred *key)
  21. {
  22. STATIC_KEY_CHECK_USE(key);
  23. static_key_slow_dec(&key->key);
  24. }
  25. static inline void static_key_deferred_flush(struct static_key_deferred *key)
  26. {
  27. STATIC_KEY_CHECK_USE(key);
  28. }
  29. static inline void
  30. jump_label_rate_limit(struct static_key_deferred *key,
  31. unsigned long rl)
  32. {
  33. STATIC_KEY_CHECK_USE(key);
  34. }
  35. #endif /* CONFIG_JUMP_LABEL */
  36. #endif /* _LINUX_JUMP_LABEL_RATELIMIT_H */