lkml.org 
[lkml]   [2014]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 08/17] ioprio: Add a macro named NICE_TO_IOPRIO.
Date
As the task nice value is in [-20, 19] and the io priority is in [0, 7],
and the convert method from niceval to ioprio is implemented with an
opened code in task_nice_ioprio().

This patch move the implementation to a macro NICE_TO_IOPRIO, making
it more readable and modular.

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

diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
index beb9ce1..c0faa0b 100644
--- a/include/linux/ioprio.h
+++ b/include/linux/ioprio.h
@@ -18,6 +18,11 @@
#define ioprio_valid(mask) (IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)

/*
+ * Convert the nice value [19,-20] to io priority value [0,7].
+ */
+#define NICE_TO_IOPRIO(nice) (nice_to_rlimit(nice) / 5)
+
+/*
* These are the io priority groups as implemented by CFQ. RT is the realtime
* class, it always gets premium service. BE is the best-effort scheduling
* class, the default for any process. IDLE is the idle scheduling class, it
@@ -52,7 +57,7 @@ enum {
*/
static inline int task_nice_ioprio(struct task_struct *task)
{
- return (task_nice(task) + 20) / 5;
+ return NICE_TO_IOPRIO(task_nice(task));
}

/*
--
1.8.2.1


\
 
 \ /
  Last update: 2014-03-11 12:02    [W:0.332 / U:2.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site