Skip to content

Commit fe7de49

Browse files
kosakiIngo Molnar
authored andcommitted
sched: Make sched_param argument static in sched_setscheduler() callers
Andrew Morton pointed out almost all sched_setscheduler() callers are using fixed parameters and can be converted to static. It reduces runtime memory use a little. Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> Reported-by: Andrew Morton <akpm@linux-foundation.org> Acked-by: James Morris <jmorris@namei.org> Cc: Ingo Molnar <mingo@elte.hu> Cc: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Ingo Molnar <mingo@elte.hu>
1 parent d4429f6 commit fe7de49

7 files changed

Lines changed: 15 additions & 10 deletions

File tree

‎include/linux/sched.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1942,9 +1942,10 @@ extern int task_nice(const struct task_struct *p);
19421942
extern int can_nice(const struct task_struct *p, const int nice);
19431943
extern int task_curr(const struct task_struct *p);
19441944
extern int idle_cpu(int cpu);
1945-
extern int sched_setscheduler(struct task_struct *, int, struct sched_param *);
1945+
extern int sched_setscheduler(struct task_struct *, int,
1946+
const struct sched_param *);
19461947
extern int sched_setscheduler_nocheck(struct task_struct *, int,
1947-
struct sched_param *);
1948+
const struct sched_param *);
19481949
extern struct task_struct *idle_task(int cpu);
19491950
extern struct task_struct *curr_task(int cpu);
19501951
extern void set_curr_task(int cpu, struct task_struct *p);

‎kernel/irq/manage.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,9 @@ irq_thread_check_affinity(struct irq_desc *desc, struct irqaction *action) { }
573573
*/
574574
static int irq_thread(void *data)
575575
{
576-
struct sched_param param = { .sched_priority = MAX_USER_RT_PRIO/2, };
576+
static struct sched_param param = {
577+
.sched_priority = MAX_USER_RT_PRIO/2,
578+
};
577579
struct irqaction *action = data;
578580
struct irq_desc *desc = irq_to_desc(action->irq);
579581
int wake, oneshot = desc->status & IRQ_ONESHOT;

‎kernel/kthread.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ struct task_struct *kthread_create(int (*threadfn)(void *data),
148148
wait_for_completion(&create.done);
149149

150150
if (!IS_ERR(create.result)) {
151-
struct sched_param param = { .sched_priority = 0 };
151+
static struct sched_param param = { .sched_priority = 0 };
152152
va_list args;
153153

154154
va_start(args, namefmt);

‎kernel/sched.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4701,7 +4701,7 @@ static bool check_same_owner(struct task_struct *p)
47014701
}
47024702

47034703
static int __sched_setscheduler(struct task_struct *p, int policy,
4704-
struct sched_param *param, bool user)
4704+
const struct sched_param *param, bool user)
47054705
{
47064706
int retval, oldprio, oldpolicy = -1, on_rq, running;
47074707
unsigned long flags;
@@ -4856,7 +4856,7 @@ static int __sched_setscheduler(struct task_struct *p, int policy,
48564856
* NOTE that the task may be already dead.
48574857
*/
48584858
int sched_setscheduler(struct task_struct *p, int policy,
4859-
struct sched_param *param)
4859+
const struct sched_param *param)
48604860
{
48614861
return __sched_setscheduler(p, policy, param, true);
48624862
}
@@ -4874,7 +4874,7 @@ EXPORT_SYMBOL_GPL(sched_setscheduler);
48744874
* but our caller might not have that capability.
48754875
*/
48764876
int sched_setscheduler_nocheck(struct task_struct *p, int policy,
4877-
struct sched_param *param)
4877+
const struct sched_param *param)
48784878
{
48794879
return __sched_setscheduler(p, policy, param, false);
48804880
}

‎kernel/softirq.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -851,7 +851,9 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
851851
cpumask_any(cpu_online_mask));
852852
case CPU_DEAD:
853853
case CPU_DEAD_FROZEN: {
854-
struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
854+
static struct sched_param param = {
855+
.sched_priority = MAX_RT_PRIO-1
856+
};
855857

856858
p = per_cpu(ksoftirqd, hotcpu);
857859
per_cpu(ksoftirqd, hotcpu) = NULL;

‎kernel/trace/trace_selftest.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ trace_selftest_startup_nop(struct tracer *trace, struct trace_array *tr)
558558
static int trace_wakeup_test_thread(void *data)
559559
{
560560
/* Make this a RT thread, doesn't need to be too high */
561-
struct sched_param param = { .sched_priority = 5 };
561+
static struct sched_param param = { .sched_priority = 5 };
562562
struct completion *x = data;
563563

564564
sched_setscheduler(current, SCHED_FIFO, &param);

‎kernel/watchdog.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static enum hrtimer_restart watchdog_timer_fn(struct hrtimer *hrtimer)
307307
*/
308308
static int watchdog(void *unused)
309309
{
310-
struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
310+
static struct sched_param param = { .sched_priority = MAX_RT_PRIO-1 };
311311
struct hrtimer *hrtimer = &__raw_get_cpu_var(watchdog_hrtimer);
312312

313313
sched_setscheduler(current, SCHED_FIFO, &param);

0 commit comments

Comments
 (0)