Skip to content

Commit

Permalink
sched: Constify function scope static struct sched_param usage
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Zijlstra authored and Ingo Molnar committed Jan 7, 2011
1 parent 524429c commit c9b5f50
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kernel/irq/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action) { }
*/
static int irq_thread(void *data)
{
static struct sched_param param = {
static const struct sched_param param = {
.sched_priority = MAX_USER_RT_PRIO/2,
};
struct irqaction *action = data;
Expand Down
2 changes: 1 addition & 1 deletion kernel/kthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
wait_for_completion(&create.done);

if (!IS_ERR(create.result)) {
static struct sched_param param = { .sched_priority = 0 };
static const struct sched_param param = { .sched_priority = 0 };
va_list args;

va_start(args, namefmt);
Expand Down
2 changes: 1 addition & 1 deletion kernel/softirq.c
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
cpumask_any(cpu_online_mask));
case CPU_DEAD:
case CPU_DEAD_FROZEN: {
static struct sched_param param = {
static const struct sched_param param = {
.sched_priority = MAX_RT_PRIO-1
};

Expand Down
2 changes: 1 addition & 1 deletion kernel/trace/trace_selftest.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr)
static int trace_wakeup_test_thread(void *data)
{
/* Make this a RT thread, doesn't need to be too high */
static struct sched_param param = { .sched_priority = 5 };
static const struct sched_param param = { .sched_priority = 5 };
struct completion *x = data;

sched_setscheduler(current, SCHED_FIFO, &param);
Expand Down

0 comments on commit c9b5f50

Please sign in to comment.