Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
Andrew Jones | 851cf6e | 2013-08-09 19:51:57 +0530 | [diff] [blame] | 2 | #ifndef _LINUX_JUMP_LABEL_RATELIMIT_H |
| 3 | #define _LINUX_JUMP_LABEL_RATELIMIT_H |
| 4 | |
| 5 | #include <linux/jump_label.h> |
| 6 | #include <linux/workqueue.h> |
| 7 | |
| 8 | #if defined(CC_HAVE_ASM_GOTO) && defined(CONFIG_JUMP_LABEL) |
| 9 | struct static_key_deferred { |
| 10 | struct static_key key; |
| 11 | unsigned long timeout; |
| 12 | struct delayed_work work; |
| 13 | }; |
| 14 | #endif |
| 15 | |
| 16 | #ifdef HAVE_JUMP_LABEL |
| 17 | extern void static_key_slow_dec_deferred(struct static_key_deferred *key); |
David Matlack | b6416e6 | 2016-12-16 14:30:35 -0800 | [diff] [blame] | 18 | extern void static_key_deferred_flush(struct static_key_deferred *key); |
Andrew Jones | 851cf6e | 2013-08-09 19:51:57 +0530 | [diff] [blame] | 19 | extern void |
| 20 | jump_label_rate_limit(struct static_key_deferred *key, unsigned long rl); |
| 21 | |
| 22 | #else /* !HAVE_JUMP_LABEL */ |
| 23 | struct static_key_deferred { |
| 24 | struct static_key key; |
| 25 | }; |
| 26 | static inline void static_key_slow_dec_deferred(struct static_key_deferred *key) |
| 27 | { |
Borislav Petkov | 5cdda51 | 2017-10-18 17:24:28 +0200 | [diff] [blame] | 28 | STATIC_KEY_CHECK_USE(key); |
Andrew Jones | 851cf6e | 2013-08-09 19:51:57 +0530 | [diff] [blame] | 29 | static_key_slow_dec(&key->key); |
| 30 | } |
David Matlack | b6416e6 | 2016-12-16 14:30:35 -0800 | [diff] [blame] | 31 | static inline void static_key_deferred_flush(struct static_key_deferred *key) |
| 32 | { |
Borislav Petkov | 5cdda51 | 2017-10-18 17:24:28 +0200 | [diff] [blame] | 33 | STATIC_KEY_CHECK_USE(key); |
David Matlack | b6416e6 | 2016-12-16 14:30:35 -0800 | [diff] [blame] | 34 | } |
Andrew Jones | 851cf6e | 2013-08-09 19:51:57 +0530 | [diff] [blame] | 35 | static inline void |
| 36 | jump_label_rate_limit(struct static_key_deferred *key, |
| 37 | unsigned long rl) |
| 38 | { |
Borislav Petkov | 5cdda51 | 2017-10-18 17:24:28 +0200 | [diff] [blame] | 39 | STATIC_KEY_CHECK_USE(key); |
Andrew Jones | 851cf6e | 2013-08-09 19:51:57 +0530 | [diff] [blame] | 40 | } |
| 41 | #endif /* HAVE_JUMP_LABEL */ |
| 42 | #endif /* _LINUX_JUMP_LABEL_RATELIMIT_H */ |