Messages in this thread Patch in this message | | | From | Dongsheng Yang <> | Subject | [PATCH 3/3] sched: Implement task_nice and task_prio as static inline functions. | Date | Mon, 27 Jan 2014 17:15:39 -0500 |
| |
As commit 0e0c0797 expose the priority related macros in linux/sched/prio.h, we don't have to implement task_nice and task_prio in kernel/sched/core.c any more.
This patch implement them in linux/sched/sched.h as static inline functions, saving the kernel stack and enhancing the performance.
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com> --- include/linux/sched.h | 26 ++++++++++++++++++++++++-- kernel/sched/core.c | 25 ------------------------- 2 files changed, 24 insertions(+), 27 deletions(-)
diff --git a/include/linux/sched.h b/include/linux/sched.h index ba1b732..125145b 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2082,8 +2082,30 @@ static inline void sched_autogroup_exit(struct signal_struct *sig) { } extern bool yield_to(struct task_struct *p, bool preempt); extern void set_user_nice(struct task_struct *p, long nice); -extern int task_prio(const struct task_struct *p); -extern int task_nice(const struct task_struct *p); +/** + * task_prio - return the priority value of a given task. + * @p: the task in question. + * + * Return: The priority value as seen by users in /proc. + * RT tasks are offset by -200. Normal tasks are centered + * around 0, value goes from -16 to +15. + */ +static inline int task_prio(const struct task_struct *p) +{ + return p->prio - MAX_RT_PRIO; +} + +/** + * task_nice - return the nice value of a given task. + * @p: the task in question. + * + * Return: The nice value [ -20 ... 0 ... 19 ]. + */ +static inline int task_nice(const struct task_struct *p) +{ + return TASK_NICE(p); +} + extern int can_nice(const struct task_struct *p, const int nice); extern int task_curr(const struct task_struct *p); extern int idle_cpu(int cpu); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 7fea865..a8d6150 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -3096,31 +3096,6 @@ SYSCALL_DEFINE1(nice, int, increment) #endif /** - * task_prio - return the priority value of a given task. - * @p: the task in question. - * - * Return: The priority value as seen by users in /proc. - * RT tasks are offset by -200. Normal tasks are centered - * around 0, value goes from -16 to +15. - */ -int task_prio(const struct task_struct *p) -{ - return p->prio - MAX_RT_PRIO; -} - -/** - * task_nice - return the nice value of a given task. - * @p: the task in question. - * - * Return: The nice value [ -20 ... 0 ... 19 ]. - */ -int task_nice(const struct task_struct *p) -{ - return TASK_NICE(p); -} -EXPORT_SYMBOL(task_nice); - -/** * idle_cpu - is a given cpu idle currently? * @cpu: the processor in question. * -- 1.8.2.1
| |