1 /* kernel/ckrm_sched.c - Supporting functions for ckrm scheduling
3 * Copyright (C) Haoqiang Zheng, IBM Corp. 2004
4 * (C) Hubertus Franke, IBM Corp. 2004
6 * Latest version, more details at http://ckrm.sf.net
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
15 #include <linux/init.h>
16 #include <linux/ckrm_sched.h>
18 /*******************************************************/
20 /*******************************************************/
21 #define CVT_WINDOW_SIZE (CLASSQUEUE_SIZE << CLASS_BONUS_RATE)
22 static CVT_t max_CVT = CVT_WINDOW_SIZE;
25 * Also ensure that the classes global cvt is upgraded to the
26 * minimum CVT in the system, as a class might not have run for a while
28 static void update_global_cvt(struct ckrm_cpu_class *cpu_class, int cpu)
30 struct ckrm_local_runqueue *class_queue =
31 get_ckrm_local_runqueue(cpu_class, cpu);
33 CVT_t local_cvt_old = class_queue->local_cvt;
36 if (class_queue->uncounted_cvt) {
37 cpu_class->global_cvt += class_queue->uncounted_cvt;
38 class_queue->uncounted_cvt = 0;
40 min_cvt = max_CVT - CVT_WINDOW_SIZE;
41 if (cpu_class->global_cvt < min_cvt)
42 cpu_class->global_cvt = min_cvt;
43 else if (cpu_class->global_cvt > max_CVT)
44 max_CVT = cpu_class->global_cvt;
46 /* update local cvt from global cvt*/
48 class_queue->local_cvt = cpu_class->global_cvt;
50 spin_unlock(&cvt_lock);
52 if (class_queue->local_cvt != local_cvt_old)
53 update_class_priority(class_queue);
57 * class_list_lock must have been acquired
59 void update_global_cvts(int this_cpu)
61 struct ckrm_cpu_class *clsptr;
62 struct ckrm_local_runqueue *class_queue;
65 list_for_each_entry(clsptr, &active_cpu_classes, links) {
66 update_global_cvt(clsptr, this_cpu);
67 class_queue = get_ckrm_local_runqueue(clsptr, this_cpu);
68 clsptr->stat.total_ns += class_queue->uncounted_ns;
69 class_queue->uncounted_ns = 0;