public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Dongsheng Yang <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
	peterz@infradead.org, tglx@linutronix.de,
	yangds.fnst@cn.fujitsu.com
Subject: [tip:sched/core] sched/prio: Add two inline function named nice_to_rlimit() and rlimit_to_nice() in prio.h.
Date: Mon, 19 May 2014 06:10:14 -0700	[thread overview]
Message-ID: <tip-b482e5f5c22ef95ffe7c4d86fc9719455fb24bca@git.kernel.org> (raw)
In-Reply-To: <e1f9c9f2023719e0738e16cd6807c74c68b08fad.1399532322.git.yangds.fnst@cn.fujitsu.com>

Commit-ID:  b482e5f5c22ef95ffe7c4d86fc9719455fb24bca
Gitweb:     http://git.kernel.org/tip/b482e5f5c22ef95ffe7c4d86fc9719455fb24bca
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Thu, 8 May 2014 18:33:48 +0900
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Mon, 19 May 2014 22:02:42 +0900

sched/prio: Add two inline function named nice_to_rlimit() and rlimit_to_nice() in prio.h.

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

Cc: mingo@redhat.com
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/e1f9c9f2023719e0738e16cd6807c74c68b08fad.1399532322.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 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 */

      parent reply	other threads:[~2014-05-19 13:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-bot for Dongsheng Yang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=tip-b482e5f5c22ef95ffe7c4d86fc9719455fb24bca@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --cc=yangds.fnst@cn.fujitsu.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox