Commit c9b5f501ef1580faa30c40c644b7691870462201

Authored by Peter Zijlstra
Committed by Ingo Molnar
1 parent 524429c31b

sched: Constify function scope static struct sched_param usage

Function-scope statics are discouraged because they are
easily overlooked and can cause subtle bugs/races due to
their global (non-SMP safe) nature.

Linus noticed that we did this for sched_param - at minimum
make the const.

Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
LKML-Reference: Message-ID: <AANLkTinotRxScOHEb0HgFgSpGPkq_6jKTv5CfvnQM=ee@mail.gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 4 changed files with 4 additions and 4 deletions Side-by-side Diff

... ... @@ -577,7 +577,7 @@
577 577 */
578 578 static int irq_thread(void *data)
579 579 {
580   - static struct sched_param param = {
  580 + static const struct sched_param param = {
581 581 .sched_priority = MAX_USER_RT_PRIO/2,
582 582 };
583 583 struct irqaction *action = data;
... ... @@ -148,7 +148,7 @@
148 148 wait_for_completion(&create.done);
149 149  
150 150 if (!IS_ERR(create.result)) {
151   - static struct sched_param param = { .sched_priority = 0 };
  151 + static const struct sched_param param = { .sched_priority = 0 };
152 152 va_list args;
153 153  
154 154 va_start(args, namefmt);
... ... @@ -853,7 +853,7 @@
853 853 cpumask_any(cpu_online_mask));
854 854 case CPU_DEAD:
855 855 case CPU_DEAD_FROZEN: {
856   - static struct sched_param param = {
  856 + static const struct sched_param param = {
857 857 .sched_priority = MAX_RT_PRIO-1
858 858 };
859 859  
kernel/trace/trace_selftest.c
... ... @@ -558,7 +558,7 @@
558 558 static int trace_wakeup_test_thread(void *data)
559 559 {
560 560 /* Make this a RT thread, doesn't need to be too high */
561   - static struct sched_param param = { .sched_priority = 5 };
  561 + static const struct sched_param param = { .sched_priority = 5 };
562 562 struct completion *x = data;
563 563  
564 564 sched_setscheduler(current, SCHED_FIFO, &param);