Magellan Linux

Contents of /trunk/kernel26-magellan/patches-2.6.17-r6/0006-2.6.17-sched-range.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 105 - (show annotations) (download)
Sun Mar 11 16:17:56 2007 UTC (17 years, 7 months ago) by niro
File size: 2708 byte(s)
2.6.17-magellan-r6

1 Add SCHED_RANGE and SCHED_RT wrappers for easy policy management.
2
3 Signed-off-by: Con Kolivas <kernel@kolivas.org>
4
5 include/linux/sched.h | 7 +++++++
6 kernel/sched.c | 13 +++++--------
7 2 files changed, 12 insertions(+), 8 deletions(-)
8
9 Index: linux-ck-dev/include/linux/sched.h
10 ===================================================================
11 --- linux-ck-dev.orig/include/linux/sched.h 2006-06-18 15:23:21.000000000 +1000
12 +++ linux-ck-dev/include/linux/sched.h 2006-06-18 15:23:35.000000000 +1000
13 @@ -165,6 +165,13 @@ extern unsigned long weighted_cpuload(co
14 #define SCHED_RR 2
15 #define SCHED_BATCH 3
16
17 +#define SCHED_MIN 0
18 +#define SCHED_MAX 3
19 +
20 +#define SCHED_RANGE(policy) ((policy) <= SCHED_MAX)
21 +#define SCHED_RT(policy) ((policy) == SCHED_FIFO || \
22 + (policy) == SCHED_RR)
23 +
24 struct sched_param {
25 int sched_priority;
26 };
27 Index: linux-ck-dev/kernel/sched.c
28 ===================================================================
29 --- linux-ck-dev.orig/kernel/sched.c 2006-06-18 15:23:21.000000000 +1000
30 +++ linux-ck-dev/kernel/sched.c 2006-06-18 15:23:35.000000000 +1000
31 @@ -3548,7 +3548,7 @@ static void __setscheduler(struct task_s
32 BUG_ON(task_queued(p));
33 p->policy = policy;
34 p->rt_priority = prio;
35 - if (policy != SCHED_NORMAL && policy != SCHED_BATCH) {
36 + if (SCHED_RT(policy)) {
37 p->prio = MAX_RT_PRIO-1 - p->rt_priority;
38 } else
39 p->prio = p->static_prio;
40 @@ -3574,8 +3574,7 @@ recheck:
41 /* double check policy once rq lock held */
42 if (policy < 0)
43 policy = oldpolicy = p->policy;
44 - else if (policy != SCHED_FIFO && policy != SCHED_RR &&
45 - policy != SCHED_NORMAL && policy != SCHED_BATCH)
46 + else if (!SCHED_RANGE(policy))
47 return -EINVAL;
48 /*
49 * Valid priorities for SCHED_FIFO and SCHED_RR are
50 @@ -3586,8 +3585,7 @@ recheck:
51 (p->mm && param->sched_priority > MAX_USER_RT_PRIO-1) ||
52 (!p->mm && param->sched_priority > MAX_RT_PRIO-1))
53 return -EINVAL;
54 - if ((policy == SCHED_NORMAL || policy == SCHED_BATCH)
55 - != (param->sched_priority == 0))
56 + if ((!SCHED_RT(policy)) != (param->sched_priority == 0))
57 return -EINVAL;
58
59 /*
60 @@ -3598,12 +3596,11 @@ recheck:
61 * can't change policy, except between SCHED_NORMAL
62 * and SCHED_BATCH:
63 */
64 - if (((policy != SCHED_NORMAL && p->policy != SCHED_BATCH) &&
65 - (policy != SCHED_BATCH && p->policy != SCHED_NORMAL)) &&
66 + if (SCHED_RT(policy) && policy != p->policy &&
67 !p->signal->rlim[RLIMIT_RTPRIO].rlim_cur)
68 return -EPERM;
69 /* can't increase priority */
70 - if ((policy != SCHED_NORMAL && policy != SCHED_BATCH) &&
71 + if (SCHED_RT(policy) &&
72 param->sched_priority > p->rt_priority &&
73 param->sched_priority >
74 p->signal->rlim[RLIMIT_RTPRIO].rlim_cur)