Skip to content

Commit 7ccaba5

Browse files
jbeulichtorvalds
authored andcommitted
consolidate WARN_...ONCE() static variables
Due to the alignment of following variables, these typically consume more than just the single byte that 'bool' requires, and as there are a few hundred instances, the cache pollution (not so much the waste of memory) sums up. Put these variables into their own section, outside of any half way frequently used memory range. Do the same also to the __warned variable of rcu_lockdep_assert(). (Don't, however, include the ones used by printk_once() and alike, as they can potentially be hot.) Signed-off-by: Jan Beulich <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 10db4e1 commit 7ccaba5

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

include/asm-generic/bug.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ extern void warn_slowpath_null(const char *file, const int line);
134134
#endif
135135

136136
#define WARN_ON_ONCE(condition) ({ \
137-
static bool __warned; \
137+
static bool __section(.data.unlikely) __warned; \
138138
int __ret_warn_once = !!(condition); \
139139
\
140140
if (unlikely(__ret_warn_once)) \
@@ -144,7 +144,7 @@ extern void warn_slowpath_null(const char *file, const int line);
144144
})
145145

146146
#define WARN_ONCE(condition, format...) ({ \
147-
static bool __warned; \
147+
static bool __section(.data.unlikely) __warned; \
148148
int __ret_warn_once = !!(condition); \
149149
\
150150
if (unlikely(__ret_warn_once)) \
@@ -154,7 +154,7 @@ extern void warn_slowpath_null(const char *file, const int line);
154154
})
155155

156156
#define WARN_TAINT_ONCE(condition, taint, format...) ({ \
157-
static bool __warned; \
157+
static bool __section(.data.unlikely) __warned; \
158158
int __ret_warn_once = !!(condition); \
159159
\
160160
if (unlikely(__ret_warn_once)) \

include/asm-generic/vmlinux.lds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@
167167
CPU_KEEP(exit.data) \
168168
MEM_KEEP(init.data) \
169169
MEM_KEEP(exit.data) \
170+
*(.data.unlikely) \
170171
STRUCT_ALIGN(); \
171172
*(__tracepoints) \
172173
/* implement dynamic printk debug */ \

include/linux/rcupdate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ extern int rcu_my_thread_group_empty(void);
418418
*/
419419
#define rcu_lockdep_assert(c, s) \
420420
do { \
421-
static bool __warned; \
421+
static bool __section(.data.unlikely) __warned; \
422422
if (debug_lockdep_rcu_enabled() && !__warned && !(c)) { \
423423
__warned = true; \
424424
lockdep_rcu_suspicious(__FILE__, __LINE__, s); \

0 commit comments

Comments
 (0)