forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
once: implement DO_ONCE_LITE for non-fast-path "do once" functionality
Certain uses of "do once" functionality reside outside of fast path, and so do not require jump label patching via static keys, making existing DO_ONCE undesirable in such cases. Replace uses of __section(".data.once") with DO_ONCE_LITE(_IF)? This patch changes the return values of xfs_printk_once, printk_once, and printk_deferred_once. Before, they returned whether the print was performed, but now, they always return true. This is okay because the return values of the following macros are entirely ignored throughout the kernel: - xfs_printk_once - xfs_warn_once - xfs_notice_once - xfs_info_once - printk_once - pr_emerg_once - pr_alert_once - pr_crit_once - pr_err_once - pr_warn_once - pr_notice_once - pr_info_once - pr_devel_once - pr_debug_once - printk_deferred_once - orc_warn Changes v3: - Expand commit message to explain why changing return values of xfs_printk_once, printk_once, printk_deferred_once is benign v2: - Fix i386 build warnings Signed-off-by: Tanner Love <[email protected]> Acked-by: Eric Dumazet <[email protected]> Acked-by: Mahesh Bandewar <[email protected]> Acked-by: Steven Rostedt (VMware) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
- Loading branch information
1 parent
b74ef9f
commit a358f40
Showing
5 changed files
with
40 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _LINUX_ONCE_LITE_H | ||
#define _LINUX_ONCE_LITE_H | ||
|
||
#include <linux/types.h> | ||
|
||
/* Call a function once. Similar to DO_ONCE(), but does not use jump label | ||
* patching via static keys. | ||
*/ | ||
#define DO_ONCE_LITE(func, ...) \ | ||
DO_ONCE_LITE_IF(true, func, ##__VA_ARGS__) | ||
#define DO_ONCE_LITE_IF(condition, func, ...) \ | ||
({ \ | ||
static bool __section(".data.once") __already_done; \ | ||
bool __ret_do_once = !!(condition); \ | ||
\ | ||
if (unlikely(__ret_do_once && !__already_done)) { \ | ||
__already_done = true; \ | ||
func(__VA_ARGS__); \ | ||
} \ | ||
unlikely(__ret_do_once); \ | ||
}) | ||
|
||
#endif /* _LINUX_ONCE_LITE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters