PERFORCE change 104493 for review
Chris Jones
cdjones at FreeBSD.org
Fri Aug 18 15:52:37 UTC 2006
http://perforce.freebsd.org/chv.cgi?CH=104493
Change 104493 by cdjones at cdjones-impulse on 2006/08/18 15:52:06
Unlock some things that didn't need locking (which caused sleepable-after-non-sleepable panics anyways) and switch to a system where we throw you to the back of the line on the basis of ratio between (cpu used / total cpu) and (shares held / total shares), rather than the difference between the two. It works better.
Affected files ...
.. //depot/projects/soc2006/cdjones_jail/src/sys/kern/sched_hier.c#17 edit
Differences ...
==== //depot/projects/soc2006/cdjones_jail/src/sys/kern/sched_hier.c#17 (text+ko) ====
@@ -295,7 +295,7 @@
&sched_kgfollowons, 0,
"number of followons done in a ksegrp");
-static int sched_unjailedProcessShares = 50;
+static int sched_unjailedProcessShares = 0;
SYSCTL_INT(_kern_sched, OID_AUTO, unjailedprocessshares,
CTLTYPE_INT | CTLFLAG_RW,
&sched_unjailedProcessShares, 0,
@@ -460,7 +460,6 @@
mtx_lock(&allprison_mtx);
if (prisoncount) {
LIST_FOREACH(pr, &allprison, pr_list) {
- mtx_lock(&pr->pr_mtx);
pr->pr_estcpu = 0;
}
}
@@ -553,7 +552,7 @@
if (NULL != kg->kg_proc->p_ucred &&
NULL != kg->kg_proc->p_ucred->cr_prison)
kg->kg_proc->p_ucred->cr_prison->pr_estcpu +=
- kg->kg_estcpu;
+ kg->kg_estcpu;
resetpriority(kg);
FOREACH_THREAD_IN_GROUP(kg, td) {
resetpriority_thread(td, kg);
@@ -561,11 +560,6 @@
} /* end of ksegrp loop */
mtx_unlock_spin(&sched_lock);
} /* end of process loop */
- if (prisoncount) {
- LIST_FOREACH(pr, &allprison, pr_list) {
- mtx_unlock(&pr->pr_mtx);
- }
- }
mtx_unlock(&allprison_mtx);
sx_sunlock(&allproc_lock);
}
@@ -649,7 +643,10 @@
if (kg->kg_pri_class == PRI_TIMESHARE) {
newpriority = PUSER + kg->kg_estcpu / INVERSE_ESTCPU_WEIGHT +
NICE_WEIGHT * (kg->kg_proc->p_nice - PRIO_MIN);
- if (NULL != pr) {
+ if (NULL == pr) {
+ newpriority = min(max(newpriority, PRI_MIN_TIMESHARE),
+ PRI_MAX_TIMESHARE);
+ } else {
/*
* Skew the priority by the jail's share of CPU resources.
* The unjailed processes get half the CPU time.
@@ -659,21 +656,36 @@
* reserved to unjailed processes really should be sysctl'd.
*/
register unsigned int np = newpriority;
- register unsigned int skew = PRI_MAX_TIMESHARE;
- skew -= PRI_MIN_TIMESHARE;
- skew /= 16;
-
+ register unsigned int skew;
+ skew = pr->pr_estcpu * total_jail_sched_shares;
+ skew /= max(total_est_cpu, 1) * max(pr->pr_sched_shares, 1);
+ if (skew > 0) {
+ /* wait your turn until your cpu usage's proportionate */
+ newpriority = PRI_MAX_IDLE;
+ } else {
+ newpriority = min(max(newpriority, PRI_MIN_TIMESHARE),
+ PRI_MAX_TIMESHARE);
+ }
+/*
+ a = skew;
skew *= pr->pr_sched_shares;
+ b = skew;
skew *= pr->pr_estcpu;
+ c = skew; */
/* avoid divide-by-zero hazards */
- skew /= max(total_jail_sched_shares, 1);
+/* skew /= max(total_jail_sched_shares, 1);
+ d = skew;
skew /= max(total_est_cpu, 1);
+ e = skew;
+*/
- printf("resetpriority: skewing KSE %p to %d from %d\n",
- &kg, np + skew, np);
+/* newpriority += skew; */
+ printf("skew KSE %p (%d / %d cpu, %d / %d shares) from %d to %d\n",
+ &kg, pr->pr_estcpu, total_est_cpu,
+ pr->pr_sched_shares,
+ total_jail_sched_shares,
+ np, newpriority);
}
- newpriority = min(max(newpriority, PRI_MIN_TIMESHARE),
- PRI_MAX_TIMESHARE);
kg->kg_user_pri = newpriority;
}
}
More information about the p4-projects
mailing list