git: 06ff5c4c600a - stable/12 - sched_ule(4): Fix interactive threads stealing.

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

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

commit 06ff5c4c600a28c8c317aea3ca6c669bb8c50cf7
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:58 +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 50f037076f46..20835a0b2c5f 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -1127,10 +1127,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;
 			}
 		}
 	}