diff options
| author | Dongsheng Yang <yangds.fnst@cn.fujitsu.com> | 2014-01-27 22:00:45 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2014-02-09 09:28:23 -0500 |
| commit | d0ea026808ad81de2af14938448419a95211b938 (patch) | |
| tree | 217b1467d99ea3b5dbffe9754979ff4d033ef44c /include | |
| parent | 6b6350f155afdfdf888e18c7bf26950a6d10b0c2 (diff) | |
sched: Implement task_nice() as static inline function
As patch "sched: Move the priority specific bits into a new header file" exposes
the priority related macros in linux/sched/prio.h, we don't have to implement
task_nice() in kernel/sched/core.c any more.
This patch implements it in linux/sched/sched.h as static inline function,
saving the kernel stack and enhancing performance a bit.
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: clark.williams@gmail.com
Cc: rostedt@goodmis.org
Cc: raistlin@linux.it
Cc: juri.lelli@gmail.com
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1390878045-7096-1-git-send-email-yangds.fnst@cn.fujitsu.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/sched.h | 11 | ||||
| -rw-r--r-- | include/linux/sched/prio.h | 1 |
2 files changed, 10 insertions, 2 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index d97d0a8e87dc..e3d556427b2e 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -2094,7 +2094,16 @@ static inline void sched_autogroup_exit(struct signal_struct *sig) { } | |||
| 2094 | extern bool yield_to(struct task_struct *p, bool preempt); | 2094 | extern bool yield_to(struct task_struct *p, bool preempt); |
| 2095 | extern void set_user_nice(struct task_struct *p, long nice); | 2095 | extern void set_user_nice(struct task_struct *p, long nice); |
| 2096 | extern int task_prio(const struct task_struct *p); | 2096 | extern int task_prio(const struct task_struct *p); |
| 2097 | extern int task_nice(const struct task_struct *p); | 2097 | /** |
| 2098 | * task_nice - return the nice value of a given task. | ||
| 2099 | * @p: the task in question. | ||
| 2100 | * | ||
| 2101 | * Return: The nice value [ -20 ... 0 ... 19 ]. | ||
| 2102 | */ | ||
| 2103 | static inline int task_nice(const struct task_struct *p) | ||
| 2104 | { | ||
| 2105 | return PRIO_TO_NICE((p)->static_prio); | ||
| 2106 | } | ||
| 2098 | extern int can_nice(const struct task_struct *p, const int nice); | 2107 | extern int can_nice(const struct task_struct *p, const int nice); |
| 2099 | extern int task_curr(const struct task_struct *p); | 2108 | extern int task_curr(const struct task_struct *p); |
| 2100 | extern int idle_cpu(int cpu); | 2109 | extern int idle_cpu(int cpu); |
diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h index 13216f16762e..410ccb74c9e6 100644 --- a/include/linux/sched/prio.h +++ b/include/linux/sched/prio.h | |||
| @@ -27,7 +27,6 @@ | |||
| 27 | */ | 27 | */ |
| 28 | #define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20) | 28 | #define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20) |
| 29 | #define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20) | 29 | #define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20) |
| 30 | #define TASK_NICE(p) PRIO_TO_NICE((p)->static_prio) | ||
| 31 | 30 | ||
| 32 | /* | 31 | /* |
| 33 | * 'User priority' is the nice value converted to something we | 32 | * 'User priority' is the nice value converted to something we |
