All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] sched/prio: Add two inline function named nice_to_rlimit() and rlimit_to_nice() in prio.h.
@ 2014-05-08  9:33 Dongsheng Yang
  2014-05-08  9:33 ` [PATCH 2/2] treewide: remove all open implementation of nice_to_rlimit()/rlimit_to_nice() Dongsheng Yang
  2014-05-19 13:10 ` [tip:sched/core] sched/prio: Add two inline function named nice_to_rlimit() and rlimit_to_nice() in prio.h tip-bot for Dongsheng Yang
  0 siblings, 2 replies; 8+ messages in thread
From: Dongsheng Yang @ 2014-05-08  9:33 UTC (permalink / raw)
  To: mingo, peterz; +Cc: linux-kernel, Dongsheng Yang

This patch add two inline functions named nice_to_rlimit() and rlimit_to_nice() in prio.h.
They are handle the convertion between nice value [19,-20] and rlimit style value [1,40].

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 include/linux/sched/prio.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index ac32258..d9cf5a5 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -41,4 +41,20 @@
 #define TASK_USER_PRIO(p)	USER_PRIO((p)->static_prio)
 #define MAX_USER_PRIO		(USER_PRIO(MAX_PRIO))
 
+/*
+ * Convert nice value [19,-20] to rlimit style value [1,40].
+ */
+static inline long nice_to_rlimit(long nice)
+{
+	return (MAX_NICE - nice + 1);
+}
+
+/*
+ * Convert rlimit style value [1,40] to nice value [-20, 19].
+ */
+static inline long rlimit_to_nice(long prio)
+{
+	return (MAX_NICE - prio + 1);
+}
+
 #endif /* _SCHED_PRIO_H */
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2014-05-22 12:29 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-08  9:33 [PATCH 1/2] sched/prio: Add two inline function named nice_to_rlimit() and rlimit_to_nice() in prio.h Dongsheng Yang
2014-05-08  9:33 ` [PATCH 2/2] treewide: remove all open implementation of nice_to_rlimit()/rlimit_to_nice() Dongsheng Yang
2014-05-08 14:34   ` Peter Zijlstra
     [not found]     ` <CA+qeAOqCo9g=tNARWf4JESLZU6sAoSKYDvmfGE6OOmJQhajyDw@mail.gmail.com>
2014-05-08 15:26       ` Peter Zijlstra
2014-05-09  0:10         ` Dongsheng Yang
2014-05-19 13:10   ` [tip:sched/core] sched: Remove " tip-bot for Dongsheng Yang
2014-05-22 12:28   ` [tip:sched/core] sched: Consolidate open coded implementations of nice level frobbing into nice_to_rlimit () and rlimit_to_nice() tip-bot for Dongsheng Yang
2014-05-19 13:10 ` [tip:sched/core] sched/prio: Add two inline function named nice_to_rlimit() and rlimit_to_nice() in prio.h tip-bot for Dongsheng Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.