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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1474060148-13171-2-git-send-email-jdesfossez@efficios.com>
Date:   Fri, 16 Sep 2016 17:09:04 -0400
From:   Julien Desfossez <jdesfossez@...icios.com>
To:     peterz@...radead.org, tglx@...utronix.de, rostedt@...dmis.org,
        mingo@...hat.com, daolivei@...hat.com
Cc:     mathieu.desnoyers@...icios.com, linux-kernel@...r.kernel.org,
        Julien Desfossez <jdesfossez@...icios.com>
Subject: [RFC PATCH 2/6] sched: get effective policy and rt_prio

Helper functions to get the effective policy and rt_priority from the
prio and policy values. This is useful in PI situations because these
fields are not updated in the task, only the sched_class is temporarily
modified.

Cc: Peter Zijlstra <peterz@...radead.org>
Cc: Steven Rostedt (Red Hat) <rostedt@...dmis.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...hat.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Signed-off-by: Julien Desfossez <jdesfossez@...icios.com>
---
 include/linux/sched/rt.h | 10 ++++++++++
 kernel/locking/rtmutex.c | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h
index a30b172..42b37ce 100644
--- a/include/linux/sched/rt.h
+++ b/include/linux/sched/rt.h
@@ -25,6 +25,8 @@ static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
 {
 	return tsk->pi_blocked_on != NULL;
 }
+extern int rt_mutex_get_effective_policy(int policy, int prio);
+extern int rt_mutex_get_effective_rt_prio(int prio);
 #else
 static inline int rt_mutex_getprio(struct task_struct *p)
 {
@@ -46,6 +48,14 @@ static inline bool tsk_is_pi_blocked(struct task_struct *tsk)
 {
 	return false;
 }
+static inline int rt_mutex_get_effective_policy(int policy, int prio);
+{
+	return policy;
+}
+static inline int rt_mutex_get_effective_rt_prio(int prio)
+{
+	return task->rt_priority;
+}
 #endif
 
 extern void normalize_rt_tasks(void);
diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c
index 1ec0f48..b66954f 100644
--- a/kernel/locking/rtmutex.c
+++ b/kernel/locking/rtmutex.c
@@ -294,6 +294,42 @@ int rt_mutex_get_effective_prio(struct task_struct *task, int newprio)
 }
 
 /*
+ * Get the effective policy based on the current prio value.
+ */
+int rt_mutex_get_effective_policy(int policy, int prio)
+{
+	if (dl_prio(prio))
+		return SCHED_DEADLINE;
+
+	/* With RT, the default class is SCHED_FIFO. */
+	if (rt_prio(prio)) {
+		if (policy == SCHED_RR)
+			return SCHED_RR;
+		return SCHED_FIFO;
+	}
+
+	/* With fair, the default class is SCHED_NORMAL. */
+	switch (policy) {
+	case SCHED_NORMAL:
+	case SCHED_IDLE:
+	case SCHED_BATCH:
+		return policy;
+	}
+	return SCHED_NORMAL;
+}
+
+/*
+ * Get the effective rt priority based on the current prio value.
+ */
+int rt_mutex_get_effective_rt_prio(int prio)
+{
+	if (!rt_prio(prio))
+		return 0;
+
+	return MAX_RT_PRIO - 1 - prio;
+}
+
+/*
  * Adjust the priority of a task, after its pi_waiters got modified.
  *
  * This can be both boosting and unboosting. task->pi_lock must be held.
-- 
1.9.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ