lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 27 Jan 2014 17:15:39 -0500
From:	Dongsheng Yang <yangds.fnst@...fujitsu.com>
To:	linux-kernel@...r.kernel.org, peterz@...radead.org
Cc:	raistlin@...ux.it, juri.lelli@...il.com, clark.williams@...il.com,
	mingo@...hat.com, rostedt@...dmis.org,
	Dongsheng Yang <yangds.fnst@...fujitsu.com>
Subject: [PATCH 3/3] sched: Implement task_nice and task_prio as static inline functions.

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@...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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ