Re: [PATCH 1/2] core scheduler changes



On Fri, Jan 26, 2007 at 11:33:17AM +0530, Srivatsa Vaddagiri wrote:

This patch does several things:

- Introduces the notion of control window (current set at 1
sec - ideally the window size should be adjusted based on
number of users to avoid rapid context switches). Bandwidth of each
user is controlled within this window. rq->last_update tracks where
are in the current window.

The patch below makes the control window size configurable (as a macro),
sets the default window size at 10 sec and also fixes a compile error (for
!CONFIG_FAIRSCHED case).

Ideally the window size needs to be determined at run time (based on number of
users). I will address that if there is sufficient interest on a patch
like this ..

Signed-off-by : Srivatsa Vaddagiri <vatsa@xxxxxxxxxx>

---


diff -puN kernel/sched.c~window-fix kernel/sched.c
--- linux-2.6.20-rc5/kernel/sched.c~window-fix 2007-01-31 19:59:48.000000000 +0530
+++ linux-2.6.20-rc5-vatsa/kernel/sched.c 2007-01-31 20:08:57.000000000 +0530
@@ -769,17 +769,24 @@ static inline int is_user_starving(struc
return 0;
}

-/* Are we past the 1-sec control window? If so, all groups get to renew their
+#define WINDOW_SIZE (10*HZ)
+
+/* Are we past the control window? If so, all groups get to renew their
* expired tokens.
*/
-static inline void adjust_control_window(void)
+static inline void adjust_control_window(int force)
{
struct rq *rq = this_rq();
unsigned long delta;

+ if (force) {
+ rq->last_update = jiffies;
+ return;
+ }
+
delta = jiffies - rq->last_update;
- if (delta >= HZ)
- rq->last_update += (delta/HZ) * HZ;
+ if (delta >= WINDOW_SIZE)
+ rq->last_update += (delta/WINDOW_SIZE) * WINDOW_SIZE;
}

/* Account group's cpu usage */
@@ -788,7 +795,7 @@ static inline void inc_cpu_usage(struct
struct user_struct *user = p->user;
struct cpu_usage *cu;

- adjust_control_window();
+ adjust_control_window(0);

if (!user->cpu_limit)
return;
@@ -803,7 +810,7 @@ static inline int task_over_cpu_limit(st
struct user_struct *user = p->user;
struct cpu_usage *cu;

- adjust_control_window();
+ adjust_control_window(0);

if (!user->cpu_limit)
return 0;
@@ -811,7 +818,7 @@ static inline int task_over_cpu_limit(st
cu = per_cpu_ptr(user->cpu_usage, task_cpu(p));
if (cu->last_update != rq->last_update) {
/* Replenish tokens */
- cu->tokens += user->cpu_limit * HZ / 100;
+ cu->tokens += user->cpu_limit * WINDOW_SIZE / 100;
cu->last_update = rq->last_update;
}

@@ -830,6 +837,7 @@ static int task_over_cpu_limit(struct ta
static void set_tsk_starving(struct task_struct *p) { }
static void clear_tsk_starving(struct task_struct *p) { }
static int is_user_starving(struct task_struct *p) { return 0;}
+static inline void adjust_control_window(int force) { }

#endif /* CONFIG_FAIRSCHED */

@@ -3668,7 +3676,7 @@ pick_next_task:
}

if (task_over_cpu_limit(next))
- rq->last_update = jiffies;
+ adjust_control_window(1);
if (!next->time_slice)
next->time_slice = task_timeslice(next);
clear_tsk_starving(next);
_


--
Regards,
vatsa
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: Windows Task Manager problem
    ... but the Volume Control window has a hidden feature: ... > Double click on the outside border of the window to regain the tabs. ... > Task Manager Menu Bar and Tabs Are Not Visible in Windows XP ...
    (microsoft.public.windowsxp.general)
  • Re: Windows Task Manager problem
    ... but the Volume Control window has a hidden ... >> Double click on the outside border of the window to regain the tabs. ... >> Task Manager Menu Bar and Tabs Are Not Visible in Windows XP ...
    (microsoft.public.windowsxp.general)
  • Setting/Locking a Windows size and location
    ... I have been looking for a reg hack to control window size and location. ... the administrator for the school district with over 38 schools. ... this down via GPO so I would not have to physically visit every PC in the ...
    (microsoft.public.windowsxp.customize)
  • Re: Does anyone run VNC with 64-bit FreeBSD (amd64)?
    ... My users need up to 20 instances of a graphical analysis package ... which has a text-based control window that spawns two graphical ... They run a window manager with 24 virtual desktops, ...
    (freebsd-questions)
  • Re: Lost
    ... It is likely that the window is opening very small or off the screen (perhaps behind the ... - Press Alt/Space to get the control window for that application ... - Now you can use the arrow keys to move the window around the screen to get it properly ... If you need to resize a window, but can't use the mouse, try this: ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)