aboutsummaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/compiler.h2
-rw-r--r--include/linux/sched/rt.h22
2 files changed, 24 insertions, 0 deletions
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index c6d06e91f..4b13e0cb2 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -437,6 +437,8 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
* handlers, all running on the same CPU.
*/
#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
+#define READ_ONCE(x) ACCESS_ONCE(x)
+#define WRITE_ONCE(x, val) ACCESS_ONCE(x) = val
/* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
#ifdef CONFIG_KPROBES
diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h
index 440434df3..d926ad5b2 100644
--- a/include/linux/sched/rt.h
+++ b/include/linux/sched/rt.h
@@ -20,6 +20,18 @@
#define MAX_PRIO (MAX_RT_PRIO + 40)
#define DEFAULT_PRIO (MAX_RT_PRIO + 20)
+#define MAX_NICE 19
+#define MIN_NICE -20
+
+/*
+ * Convert user-nice values [ -20 ... 0 ... 19 ]
+ * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
+ * and back.
+ */
+#define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20)
+#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
+#define TASK_NICE(p) PRIO_TO_NICE((p)->static_prio)
+
static inline int rt_prio(int prio)
{
if (unlikely(prio < MAX_RT_PRIO))
@@ -61,4 +73,14 @@ extern void normalize_rt_tasks(void);
*/
#define RR_TIMESLICE (100 * HZ / 1000)
+/*
+ * Convert nice value [19,-20] to rlimit style value [1,40].
+ */
+#define nice_to_rlimit(nice) (MAX_NICE - nice + 1)
+
+/*
+ * Convert rlimit style value [1,40] to nice value [-20, 19].
+ */
+#define rlimit_to_nice(prio) (MAX_NICE - prio + 1)
+
#endif /* _SCHED_RT_H */