Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1490315
| From | Julien Desfossez <jdesfossez@efficios.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [RFC PATCH v2 1/5] sched: get effective policy and rt_prio |
| Date | 2016-09-23 18:50 +0200 |
| Message-ID | <skBPI-6j6-15@gated-at.bofh.it> (permalink) |
| References | <skBPI-6j6-17@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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@infradead.org>
Cc: Steven Rostedt (Red Hat) <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Reviewed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
---
include/linux/sched.h | 2 ++
kernel/sched/core.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index af39baf..0c03595 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2594,6 +2594,8 @@ static inline bool is_idle_task(const struct task_struct *p)
struct thread_info thread_info;
unsigned long stack[THREAD_SIZE/sizeof(long)];
};
+extern int effective_policy(int policy, int prio);
+extern int effective_rt_prio(int prio);
#ifndef __HAVE_ARCH_KSTACK_END
static inline int kstack_end(void *addr)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f5f7b3c..f3817b5 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -916,6 +916,42 @@ static int effective_prio(struct task_struct *p)
return p->prio;
}
+/*
+ * Get the effective policy based on the current prio value.
+ */
+int 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 effective_rt_prio(int prio)
+{
+ if (!rt_prio(prio))
+ return 0;
+
+ return MAX_RT_PRIO - 1 - prio;
+}
+
/**
* task_curr - is this task currently executing on a CPU?
* @p: the task in question.
--
1.9.1
Back to linux.kernel | Previous | Next | Find similar | Unroll thread
[RFC PATCH v2 1/5] sched: get effective policy and rt_prio Julien Desfossez <jdesfossez@efficios.com> - 2016-09-23 18:50 +0200
csiph-web