mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 01:55:51 +02:00
sched: Use {READ,WRITE}_ONCE() for preempt_dynamic_mode
Robots figured out you can read and write this concurrently and got 'upset'. Gemini even noted sched_dynamic_show() can generate 'confusing' output if it observed different values during the printing. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20260511120627.176946327@infradead.org
This commit is contained in:
parent
333f6f0e11
commit
7755700223
|
|
@ -7979,7 +7979,7 @@ static void __sched_dynamic_update(int mode)
|
|||
break;
|
||||
}
|
||||
|
||||
preempt_dynamic_mode = mode;
|
||||
WRITE_ONCE(preempt_dynamic_mode, mode);
|
||||
}
|
||||
|
||||
void sched_dynamic_update(int mode)
|
||||
|
|
@ -8020,12 +8020,13 @@ static void __init preempt_dynamic_init(void)
|
|||
}
|
||||
}
|
||||
|
||||
# define PREEMPT_MODEL_ACCESSOR(mode) \
|
||||
bool preempt_model_##mode(void) \
|
||||
{ \
|
||||
WARN_ON_ONCE(preempt_dynamic_mode == preempt_dynamic_undefined); \
|
||||
return preempt_dynamic_mode == preempt_dynamic_##mode; \
|
||||
} \
|
||||
# define PREEMPT_MODEL_ACCESSOR(mode) \
|
||||
bool preempt_model_##mode(void) \
|
||||
{ \
|
||||
int mode = READ_ONCE(preempt_dynamic_mode); \
|
||||
WARN_ON_ONCE(mode == preempt_dynamic_undefined); \
|
||||
return mode == preempt_dynamic_##mode; \
|
||||
} \
|
||||
EXPORT_SYMBOL_GPL(preempt_model_##mode)
|
||||
|
||||
PREEMPT_MODEL_ACCESSOR(none);
|
||||
|
|
|
|||
|
|
@ -281,6 +281,7 @@ static ssize_t sched_dynamic_write(struct file *filp, const char __user *ubuf,
|
|||
static int sched_dynamic_show(struct seq_file *m, void *v)
|
||||
{
|
||||
int i = (IS_ENABLED(CONFIG_PREEMPT_RT) || IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY)) * 2;
|
||||
int mode = READ_ONCE(preempt_dynamic_mode);
|
||||
int j;
|
||||
|
||||
/* Count entries in NULL terminated preempt_modes */
|
||||
|
|
@ -289,10 +290,10 @@ static int sched_dynamic_show(struct seq_file *m, void *v)
|
|||
j -= !IS_ENABLED(CONFIG_ARCH_HAS_PREEMPT_LAZY);
|
||||
|
||||
for (; i < j; i++) {
|
||||
if (preempt_dynamic_mode == i)
|
||||
if (mode == i)
|
||||
seq_puts(m, "(");
|
||||
seq_puts(m, preempt_modes[i]);
|
||||
if (preempt_dynamic_mode == i)
|
||||
if (mode == i)
|
||||
seq_puts(m, ")");
|
||||
|
||||
seq_puts(m, " ");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user