Setting tag linux-2.6-22-50
[linux-2.6.git] / linux-2.6-210-vserver-cpu-sched.patch
1 diff -Nurp linux-2.6.22-200/kernel/sched_hard.h linux-2.6.22-210/kernel/sched_hard.h
2 --- linux-2.6.22-200/kernel/sched_hard.h        2008-04-24 09:48:57.000000000 -0400
3 +++ linux-2.6.22-210/kernel/sched_hard.h        2008-04-24 09:59:21.000000000 -0400
4 @@ -179,8 +179,8 @@ void vx_try_unhold(struct rq *rq, int cp
5         int minskip = 0;
6  
7         /* nothing to do? what about pause? */
8 -       if (list_empty(&rq->hold_queue))
9 -               return;
10 +       //if (list_empty(&rq->hold_queue))
11 +       //      return;
12  
13         list_for_each_safe(l, n, &rq->hold_queue) {
14                 int ret, delta_min[2];
15 diff -Nurp linux-2.6.22-200/kernel/vserver/sched.c linux-2.6.22-210/kernel/vserver/sched.c
16 --- linux-2.6.22-200/kernel/vserver/sched.c     2008-04-24 09:48:57.000000000 -0400
17 +++ linux-2.6.22-210/kernel/vserver/sched.c     2008-04-24 09:49:00.000000000 -0400
18 @@ -18,7 +18,6 @@
19  
20  #include <asm/uaccess.h>
21  
22 -
23  #define vxd_check_range(val, min, max) do {            \
24         vxlprintk((val < min) || (val > max),           \
25                 "check_range(%ld,%ld,%ld)",             \
26 @@ -78,6 +77,11 @@ int vx_tokens_recalc(struct _vx_sched_pc
27         /* how much time did pass? */
28         delta = *norm_time - sched_pc->norm_time;
29         vxd_check_range(delta, 0, INT_MAX);
30 +       if (delta < 0) {
31 +               /* vserver is new or idle for a really long time */
32 +               sched_pc->norm_time = *norm_time;
33 +               delta = 0;
34 +       }
35  
36         if (delta >= sched_pc->interval[0]) {
37                 long tokens, integral;
38 @@ -91,7 +95,7 @@ int vx_tokens_recalc(struct _vx_sched_pc
39                 vxd_check_range(delta_min[0], 0, sched_pc->interval[0]);
40  #endif
41                 /* advance time */
42 -               sched_pc->norm_time += delta;
43 +               sched_pc->norm_time += integral;
44  
45                 /* add tokens */
46                 sched_pc->tokens += tokens;
47 @@ -106,7 +110,12 @@ int vx_tokens_recalc(struct _vx_sched_pc
48         /* how much was the idle skip? */
49         delta = *idle_time - sched_pc->idle_time;
50         vxd_check_range(delta, 0, INT_MAX);
51 -
52 +       if (delta < 0) {
53 +               /* vserver is new or idle for a really long time */
54 +               sched_pc->idle_time = *idle_time;
55 +               delta = 0;
56 +       }
57 +       
58         if (delta >= sched_pc->interval[1]) {
59                 long tokens, integral;
60  
61 @@ -161,10 +170,12 @@ on_hold:
62         /* next interval? */
63         if (!sched_pc->fill_rate[0])
64                 delta_min[0] = HZ;
65 -       else if (tokens > sched_pc->fill_rate[0])
66 -               delta_min[0] += sched_pc->interval[0] *
67 -                       tokens / sched_pc->fill_rate[0];
68 -       else
69 +       else if (tokens > sched_pc->fill_rate[0]) { 
70 +               delta_min[0] = sched_pc->interval[0] * 
71 +                       (tokens / sched_pc->fill_rate[0]) - delta_min[0]; 
72 +               if (tokens % sched_pc->fill_rate[0]) 
73 +                       delta_min[0] += sched_pc->interval[0]; 
74 +       } else 
75                 delta_min[0] = sched_pc->interval[0] - delta_min[0];
76         vxd_check_range(delta_min[0], 0, INT_MAX);
77  
78 @@ -175,10 +186,12 @@ on_hold:
79         /* next interval? */
80         if (!sched_pc->fill_rate[1])
81                 delta_min[1] = HZ;
82 -       else if (tokens > sched_pc->fill_rate[1])
83 -               delta_min[1] += sched_pc->interval[1] *
84 -                       tokens / sched_pc->fill_rate[1];
85 -       else
86 +       else if (tokens > sched_pc->fill_rate[1]) {
87 +               delta_min[1] = sched_pc->interval[1] *
88 +                       (tokens / sched_pc->fill_rate[1]) - delta_min[1];
89 +               if (tokens % sched_pc->fill_rate[1]) 
90 +                       delta_min[1] += sched_pc->interval[1];
91 +       } else
92                 delta_min[1] = sched_pc->interval[1] - delta_min[1];
93         vxd_check_range(delta_min[1], 0, INT_MAX);
94