From: Keith Owens Several scheduler macros only read from the task struct, mark them const. It can generate better code. Signed-off-by: Andrew Morton --- 25-akpm/include/linux/sched.h | 10 +++++----- 25-akpm/kernel/exit.c | 6 +++--- 25-akpm/kernel/sched.c | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff -puN include/linux/sched.h~add-const-to-some-scheduling-functions include/linux/sched.h --- 25/include/linux/sched.h~add-const-to-some-scheduling-functions 2004-06-01 00:10:14.529352656 -0700 +++ 25-akpm/include/linux/sched.h 2004-06-01 00:10:14.538351288 -0700 @@ -726,9 +726,9 @@ extern void sched_balance_exec(void); extern void sched_idle_next(void); extern void set_user_nice(task_t *p, long nice); -extern int task_prio(task_t *p); -extern int task_nice(task_t *p); -extern int task_curr(task_t *p); +extern int task_prio(const task_t *p); +extern int task_nice(const task_t *p); +extern int task_curr(const task_t *p); extern int idle_cpu(int cpu); void yield(void); @@ -955,7 +955,7 @@ extern void wait_task_inactive(task_t * #define while_each_thread(g, t) \ while ((t = next_thread(t)) != g) -extern task_t * FASTCALL(next_thread(task_t *p)); +extern task_t * FASTCALL(next_thread(const task_t *p)); #define thread_group_leader(p) (p->pid == p->tgid) @@ -1097,7 +1097,7 @@ extern void signal_wake_up(struct task_s */ #ifdef CONFIG_SMP -static inline unsigned int task_cpu(struct task_struct *p) +static inline unsigned int task_cpu(const struct task_struct *p) { return p->thread_info->cpu; } diff -puN kernel/exit.c~add-const-to-some-scheduling-functions kernel/exit.c --- 25/kernel/exit.c~add-const-to-some-scheduling-functions 2004-06-01 00:10:14.531352352 -0700 +++ 25-akpm/kernel/exit.c 2004-06-01 00:10:14.539351136 -0700 @@ -826,10 +826,10 @@ asmlinkage long sys_exit(int error_code) do_exit((error_code&0xff)<<8); } -task_t fastcall *next_thread(task_t *p) +task_t fastcall *next_thread(const task_t *p) { - struct pid_link *link = p->pids + PIDTYPE_TGID; - struct list_head *tmp, *head = &link->pidptr->task_list; + const struct pid_link *link = p->pids + PIDTYPE_TGID; + const struct list_head *tmp, *head = &link->pidptr->task_list; #ifdef CONFIG_SMP if (!p->sighand) diff -puN kernel/sched.c~add-const-to-some-scheduling-functions kernel/sched.c --- 25/kernel/sched.c~add-const-to-some-scheduling-functions 2004-06-01 00:10:14.533352048 -0700 +++ 25-akpm/kernel/sched.c 2004-06-01 00:10:14.549349616 -0700 @@ -652,7 +652,7 @@ static inline void resched_task(task_t * * task_curr - is this task currently executing on a CPU? * @p: the task in question. */ -inline int task_curr(task_t *p) +inline int task_curr(const task_t *p) { return cpu_curr(task_cpu(p)) == p; } @@ -2812,7 +2812,7 @@ asmlinkage long sys_nice(int increment) * RT tasks are offset by -200. Normal tasks are centered * around 0, value goes from -16 to +15. */ -int task_prio(task_t *p) +int task_prio(const task_t *p) { return p->prio - MAX_RT_PRIO; } @@ -2821,7 +2821,7 @@ int task_prio(task_t *p) * task_nice - return the nice value of a given task. * @p: the task in question. */ -int task_nice(task_t *p) +int task_nice(const task_t *p) { return TASK_NICE(p); } _