Skip to contentSkip to conversation

sched/dl: Add necessary dl_{task,prio}

PATCH Superseded Kirill Tkhai 1 participant 4 messages Jun 4, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): 20140604124735.3951.61242.stgit@tkhai

#1 lore raw

PATCH 1/2 sched/dl: Add necessary dl_{task,prio}

Add some symmetric to rt checks.

---
 kernel/locking/mutex.c |    8 +++++---
 kernel/sched/core.c    |    4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
kernel/locking/mutex.c +5 -3
index bc73d33..cb9f381 100644
@@ -21,6 +21,7 @@
 #include <linux/ww_mutex.h>
 #include <linux/sched.h>
 #include <linux/sched/rt.h>
+#include <linux/sched/deadline.h>
 #include <linux/export.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
@@ -459,10 +460,11 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		/*
 		 * When there's no owner, we might have preempted between the
 		 * owner acquiring the lock and setting the owner field. If
-		 * we're an RT task that will live-lock because we won't let
-		 * the owner complete.
+		 * we're an RT or DL task that will live-lock because we won't
+		 * let the owner complete.
 		 */
-		if (!owner && (need_resched() || rt_task(task)))
+		if (!owner &&
+		    (need_resched() || rt_task(task) || dl_task(task)))
 			break;
 
 		/*
kernel/sched/core.c +2 -2
index 240aa83..ba7617a 100644
@@ -962,11 +962,11 @@ static int effective_prio(struct task_struct *p)
 {
 	p->normal_prio = normal_prio(p);
 	/*
-	 * If we are RT tasks or we were boosted to RT priority,
+	 * If we are RT or DL tasks or we were boosted to RT or DL priority,
 	 * keep the priority unchanged. Otherwise, update priority
 	 * to the normal priority:
 	 */
-	if (!rt_prio(p->prio))
+	if (!rt_prio(p->prio) && !dl_prio(p->prio))
 		return p->normal_prio;
 	return p->prio;
 }
#2 lore raw

PATCH 2/2 sched/rt: Fix rt_prio()

In reply to a message not in the archive

The set of rt_prio() contains dl_prio() subset. Fix that.

---
 include/linux/sched/deadline.h |    8 +-------
 include/linux/sched/prio.h     |    8 +++++---
 include/linux/sched/rt.h       |    2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)
include/linux/sched/deadline.h +1 -7
index 9d303b8..e529305 100644
@@ -1,13 +1,7 @@
 #ifndef _SCHED_DEADLINE_H
 #define _SCHED_DEADLINE_H
 
-/*
- * SCHED_DEADLINE tasks has negative priorities, reflecting
- * the fact that any of them has higher prio than RT and
- * NORMAL/BATCH tasks.
- */
-
-#define MAX_DL_PRIO		0
+#include <linux/sched/prio.h>
 
 static inline int dl_prio(int prio)
 {
include/linux/sched/prio.h +5 -3
index d9cf5a5..0d6c552 100644
@@ -6,18 +6,20 @@
 #define NICE_WIDTH	(MAX_NICE - MIN_NICE + 1)
 
 /*
- * Priority of a process goes from 0..MAX_PRIO-1, valid RT
- * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
+ * Priority of a process goes from MAX_DL_PRIO-1..MAX_PRIO-1,
+ * SCHED_DEADLINE tasks have negative priorities, valid RT
+ * value is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
  * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
  * values are inverted: lower p->prio value means higher priority.
  *
  * The MAX_USER_RT_PRIO value allows the actual maximum
  * RT priority to be separate from the value exported to
  * user-space.  This allows kernel threads to set their
- * priority to a value higher than any user task. Note:
+ * priority to a value higher than any user RT task. Note:
  * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
  */
 
+#define MAX_DL_PRIO		0
 #define MAX_USER_RT_PRIO	100
 #define MAX_RT_PRIO		MAX_USER_RT_PRIO
 
include/linux/sched/rt.h +1 -1
index 6341f5b..dca43ed 100644
@@ -5,7 +5,7 @@
 
 static inline int rt_prio(int prio)
 {
-	if (unlikely(prio < MAX_RT_PRIO))
+	if (unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO))
 		return 1;
 	return 0;
 }
#3 lore raw

PATCH RESEND 1/2 sched/dl: Add necessary dl_{task,prio}

In reply to a message not in the archive

Add some symmetric to rt checks.

CC Juri Lelli <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 kernel/locking/mutex.c |    8 +++++---
 kernel/sched/core.c    |    4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
kernel/locking/mutex.c +5 -3
index bc73d33..cb9f381 100644
@@ -21,6 +21,7 @@
 #include <linux/ww_mutex.h>
 #include <linux/sched.h>
 #include <linux/sched/rt.h>
+#include <linux/sched/deadline.h>
 #include <linux/export.h>
 #include <linux/spinlock.h>
 #include <linux/interrupt.h>
@@ -459,10 +460,11 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass,
 		/*
 		 * When there's no owner, we might have preempted between the
 		 * owner acquiring the lock and setting the owner field. If
-		 * we're an RT task that will live-lock because we won't let
-		 * the owner complete.
+		 * we're an RT or DL task that will live-lock because we won't
+		 * let the owner complete.
 		 */
-		if (!owner && (need_resched() || rt_task(task)))
+		if (!owner &&
+		    (need_resched() || rt_task(task) || dl_task(task)))
 			break;
 
 		/*
kernel/sched/core.c +2 -2
index 240aa83..ba7617a 100644
@@ -962,11 +962,11 @@ static int effective_prio(struct task_struct *p)
 {
 	p->normal_prio = normal_prio(p);
 	/*
-	 * If we are RT tasks or we were boosted to RT priority,
+	 * If we are RT or DL tasks or we were boosted to RT or DL priority,
 	 * keep the priority unchanged. Otherwise, update priority
 	 * to the normal priority:
 	 */
-	if (!rt_prio(p->prio))
+	if (!rt_prio(p->prio) && !dl_prio(p->prio))
 		return p->normal_prio;
 	return p->prio;
 }
#4 lore raw

PATCH RESEND 2/2 sched/rt: Fix rt_prio()

In reply to a message not in the archive

The set of rt_prio() contains dl_prio() subset. Fix that.

CC Juri Lelli <[email protected]>
CC Peter Zijlstra <[email protected]>
CC Ingo Molnar <[email protected]>
---
 include/linux/sched/deadline.h |    8 +-------
 include/linux/sched/prio.h     |    8 +++++---
 include/linux/sched/rt.h       |    2 +-
 3 files changed, 7 insertions(+), 11 deletions(-)
include/linux/sched/deadline.h +1 -7
index 9d303b8..e529305 100644
@@ -1,13 +1,7 @@
 #ifndef _SCHED_DEADLINE_H
 #define _SCHED_DEADLINE_H
 
-/*
- * SCHED_DEADLINE tasks has negative priorities, reflecting
- * the fact that any of them has higher prio than RT and
- * NORMAL/BATCH tasks.
- */
-
-#define MAX_DL_PRIO		0
+#include <linux/sched/prio.h>
 
 static inline int dl_prio(int prio)
 {
include/linux/sched/prio.h +5 -3
index d9cf5a5..0d6c552 100644
@@ -6,18 +6,20 @@
 #define NICE_WIDTH	(MAX_NICE - MIN_NICE + 1)
 
 /*
- * Priority of a process goes from 0..MAX_PRIO-1, valid RT
- * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
+ * Priority of a process goes from MAX_DL_PRIO-1..MAX_PRIO-1,
+ * SCHED_DEADLINE tasks have negative priorities, valid RT
+ * value is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
  * tasks are in the range MAX_RT_PRIO..MAX_PRIO-1. Priority
  * values are inverted: lower p->prio value means higher priority.
  *
  * The MAX_USER_RT_PRIO value allows the actual maximum
  * RT priority to be separate from the value exported to
  * user-space.  This allows kernel threads to set their
- * priority to a value higher than any user task. Note:
+ * priority to a value higher than any user RT task. Note:
  * MAX_RT_PRIO must not be smaller than MAX_USER_RT_PRIO.
  */
 
+#define MAX_DL_PRIO		0
 #define MAX_USER_RT_PRIO	100
 #define MAX_RT_PRIO		MAX_USER_RT_PRIO
 
include/linux/sched/rt.h +1 -1
index 6341f5b..dca43ed 100644
@@ -5,7 +5,7 @@
 
 static inline int rt_prio(int prio)
 {
-	if (unlikely(prio < MAX_RT_PRIO))
+	if (unlikely(prio < MAX_RT_PRIO && prio >= MAX_DL_PRIO))
 		return 1;
 	return 0;
 }