Skip to content

Commit dbefa1f

Browse files
committed
Rename .data.once to .data..once to fix resetting WARN*_ONCE
Commit b1fca27 ("kernel debug: support resetting WARN*_ONCE") added support for clearing the state of once warnings. However, it is not functional when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION or CONFIG_LTO_CLANG is enabled, because .data.once matches the .data.[0-9a-zA-Z_]* pattern in the DATA_MAIN macro. Commit cb87481 ("kbuild: linker script do not match C names unless LD_DEAD_CODE_DATA_ELIMINATION is configured") was introduced to suppress the issue for the default CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=n case, providing a minimal fix for stable backporting. We were aware this did not address the issue for CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y. The plan was to apply correct fixes and then revert cb87481. [1] Seven years have passed since then, yet the #ifdef workaround remains in place. Meanwhile, commit b1fca27 introduced the .data.once section, and commit dc5723b ("kbuild: add support for Clang LTO") extended the #ifdef. Using a ".." separator in the section name fixes the issue for CONFIG_LD_DEAD_CODE_DATA_ELIMINATION and CONFIG_LTO_CLANG. [1]: https://lore.kernel.org/linux-kbuild/CAK7LNASck6BfdLnESxXUeECYL26yUDm0cwRZuM4gmaWUkxjL5g@mail.gmail.com/ Fixes: b1fca27 ("kernel debug: support resetting WARN*_ONCE") Fixes: dc5723b ("kbuild: add support for Clang LTO") Signed-off-by: Masahiro Yamada <[email protected]>
1 parent bb43a59 commit dbefa1f

File tree

6 files changed

+9
-9
lines changed

6 files changed

+9
-9
lines changed

include/asm-generic/vmlinux.lds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ defined(CONFIG_AUTOFDO_CLANG) || defined(CONFIG_PROPELLER_CLANG)
359359
*(.data..shared_aligned) /* percpu related */ \
360360
*(.data..unlikely) \
361361
__start_once = .; \
362-
*(.data.once) \
362+
*(.data..once) \
363363
__end_once = .; \
364364
STRUCT_ALIGN(); \
365365
*(__tracepoints) \

include/linux/mmdebug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi);
4646
} \
4747
} while (0)
4848
#define VM_WARN_ON_ONCE_PAGE(cond, page) ({ \
49-
static bool __section(".data.once") __warned; \
49+
static bool __section(".data..once") __warned; \
5050
int __ret_warn_once = !!(cond); \
5151
\
5252
if (unlikely(__ret_warn_once && !__warned)) { \
@@ -66,7 +66,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi);
6666
unlikely(__ret_warn); \
6767
})
6868
#define VM_WARN_ON_ONCE_FOLIO(cond, folio) ({ \
69-
static bool __section(".data.once") __warned; \
69+
static bool __section(".data..once") __warned; \
7070
int __ret_warn_once = !!(cond); \
7171
\
7272
if (unlikely(__ret_warn_once && !__warned)) { \
@@ -77,7 +77,7 @@ void vma_iter_dump_tree(const struct vma_iterator *vmi);
7777
unlikely(__ret_warn_once); \
7878
})
7979
#define VM_WARN_ON_ONCE_MM(cond, mm) ({ \
80-
static bool __section(".data.once") __warned; \
80+
static bool __section(".data..once") __warned; \
8181
int __ret_warn_once = !!(cond); \
8282
\
8383
if (unlikely(__ret_warn_once && !__warned)) { \

include/linux/once.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void __do_once_sleepable_done(bool *done, struct static_key_true *once_key,
4646
#define DO_ONCE(func, ...) \
4747
({ \
4848
bool ___ret = false; \
49-
static bool __section(".data.once") ___done = false; \
49+
static bool __section(".data..once") ___done = false; \
5050
static DEFINE_STATIC_KEY_TRUE(___once_key); \
5151
if (static_branch_unlikely(&___once_key)) { \
5252
unsigned long ___flags; \
@@ -64,7 +64,7 @@ void __do_once_sleepable_done(bool *done, struct static_key_true *once_key,
6464
#define DO_ONCE_SLEEPABLE(func, ...) \
6565
({ \
6666
bool ___ret = false; \
67-
static bool __section(".data.once") ___done = false; \
67+
static bool __section(".data..once") ___done = false; \
6868
static DEFINE_STATIC_KEY_TRUE(___once_key); \
6969
if (static_branch_unlikely(&___once_key)) { \
7070
___ret = __do_once_sleepable_start(&___done); \

include/linux/once_lite.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
#define __ONCE_LITE_IF(condition) \
1414
({ \
15-
static bool __section(".data.once") __already_done; \
15+
static bool __section(".data..once") __already_done; \
1616
bool __ret_cond = !!(condition); \
1717
bool __ret_once = false; \
1818
\

include/net/net_debug.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void netdev_info(const struct net_device *dev, const char *format, ...);
2727

2828
#define netdev_level_once(level, dev, fmt, ...) \
2929
do { \
30-
static bool __section(".data.once") __print_once; \
30+
static bool __section(".data..once") __print_once; \
3131
\
3232
if (!__print_once) { \
3333
__print_once = true; \

mm/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ struct folio_batch;
4848
* when we specify __GFP_NOWARN.
4949
*/
5050
#define WARN_ON_ONCE_GFP(cond, gfp) ({ \
51-
static bool __section(".data.once") __warned; \
51+
static bool __section(".data..once") __warned; \
5252
int __ret_warn_once = !!(cond); \
5353
\
5454
if (unlikely(!(gfp & __GFP_NOWARN) && __ret_warn_once && !__warned)) { \

0 commit comments

Comments
 (0)