proc_yield() will abort if they want the core
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 12 Mar 2012 20:09:29 +0000 (13:09 -0700)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 12 Mar 2012 20:09:29 +0000 (13:09 -0700)
This saves the kernel scheduler the effort of reallocating the core.
This could trigger if there was a concurrent vcore_requester, though it
should be pretty rare.

kern/src/process.c

index 39d527f..c64fce9 100644 (file)
@@ -915,6 +915,10 @@ void proc_yield(struct proc *SAFE p, bool being_nice)
         * posting). */
        if (vcpd->notif_pending)
                goto out_failed;
+       /* Optional: check to see if we are putting them below amt_wanted (help with
+        * correctness-benign user races) and bail */
+       if (p->procdata->res_req[RES_CORES].amt_wanted >= p->procinfo->num_vcores)
+               goto out_failed;
        /* Now we'll actually try to yield */
        printd("[K] Process %d (%p) is yielding on vcore %d\n", p->pid, p,
               get_vcoreid(p, coreid));