runtime/sched.c change shouldn't have been included
@@ -147,6 +147,12 @@ static void drain_overflow(struct kthread *l)
}
}
+static bool work_available(struct kthread *k)
+{
+ return ACCESS_ONCE(k->rq_tail) != ACCESS_ONCE(k->rq_head) ||
+ !list_empty(&k->rq_overflow) || softirq_work_available(k);
+}
+
static bool steal_work(struct kthread *l, struct kthread *r)
{
thread_t *th;
@@ -155,8 +161,7 @@ static bool steal_work(struct kthread *l, struct kthread *r)
assert_spin_lock_held(&l->lock);
assert(l->rq_head == 0 && l->rq_tail == 0);
- if (ACCESS_ONCE(r->rq_tail) == ACCESS_ONCE(r->rq_head) &&
- list_empty(&r->rq_overflow))
+ if (!work_available(r))
return false;
if (!spin_try_lock(&r->lock))
return false;
@@ -187,35 +192,18 @@ static bool steal_work(struct kthread *l, struct kthread *r)
goto done;
}
-done:
- if (th) {
- l->rq[l->rq_head++] = th;
- ACCESS_ONCE(l->q_ptrs->rq_head)++;
- STAT(THREADS_STOLEN)++;
- }
-
- spin_unlock(&r->lock);
- return th != NULL;
-}
-
-static bool steal_softirq(struct kthread *l, struct kthread *r)
-{
- thread_t *th;
-
- assert_spin_lock_held(&l->lock);
- assert(l->rq_head == 0 && l->rq_tail == 0);
-
- if (!softirq_work_available(r))
- return false;
- if (!spin_try_lock(&r->lock))
- return false;
-
/* check for softirqs */
th = softirq_run_thread(r, RUNTIME_SOFTIRQ_REMOTE_BUDGET);
if (th) {
STAT(SOFTIRQS_STOLEN)++;
+ goto done;
+ }
+
+done:
+ if (th) {
l->rq[l->rq_head++] = th;
ACCESS_ONCE(l->q_ptrs->rq_head)++;
+ STAT(THREADS_STOLEN)++;
}
spin_unlock(&r->lock);
@@ -312,19 +300,6 @@ again:
goto done;
}
- /* then try to steal from a sibling kthread */
- r = cpu_map[sibling].recent_kthread;
- if (r && r != l && steal_softirq(l, r))
- goto done;
-
- /* try to steal from every kthread */
- start_idx = rand_crc32c((uintptr_t)l);
- for (i = 0; i < nrks; i++) {
- int idx = (start_idx + i) % nrks;
- if (ks[idx] != l && steal_softirq(l, ks[idx]))
- goto done;
- }
-
/* recheck for local softirqs one last time */
th = softirq_run_thread(l, RUNTIME_SOFTIRQ_LOCAL_BUDGET);
if (th) {
