git: b3fb4c60c50c - stable/13 - sched_ule(4): Fix interactive threads stealing.

From: Alexander Motin <mav_at_FreeBSD.org>
Date: Tue, 05 Oct 2021 02:28:36 UTC
The branch stable/13 has been updated by mav:

URL: https://cgit.FreeBSD.org/src/commit/?id=b3fb4c60c50c217e64069e6fd3f1d2bb3915b43a

commit b3fb4c60c50c217e64069e6fd3f1d2bb3915b43a
Author:     Alexander Motin <mav@FreeBSD.org>
AuthorDate: 2021-09-21 19:56:49 +0000
Commit:     Alexander Motin <mav@FreeBSD.org>
CommitDate: 2021-10-05 02:28:33 +0000

    sched_ule(4): Fix interactive threads stealing.
    
    In scenarios when first thread in the queue can migrate to specified
    CPU, but later ones can't runq_steal_from() incorrectly returned NULL.
    
    MFC after:      2 weeks
    
    (cherry picked from commit bd84094a51c4648a7c97ececdaccfb30bc832096)
---
 sys/kern/sched_ule.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index 60f92a16f2e9..53d5a59a3605 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -1110,10 +1110,12 @@ again:
 				continue;
 			rqh = &rq->rq_queues[bit + (i << RQB_L2BPW)];
 			TAILQ_FOREACH(td, rqh, td_runq) {
-				if (first && THREAD_CAN_MIGRATE(td) &&
-				    THREAD_CAN_SCHED(td, cpu))
-					return (td);
-				first = td;
+				if (first) {
+					if (THREAD_CAN_MIGRATE(td) &&
+					    THREAD_CAN_SCHED(td, cpu))
+						return (td);
+				} else
+					first = td;
 			}
 		}
 	}