MCPcopy Create free account
hub / github.com/F-Stack/f-stack / sched_balance_pair

Function sched_balance_pair

freebsd/kern/sched_ule.c:921–944  ·  view source on GitHub ↗

* Transfer load between two imbalanced thread queues. */

Source from the content-addressed store, hash-verified

919 * Transfer load between two imbalanced thread queues.
920 */
921static int
922sched_balance_pair(struct tdq *high, struct tdq *low)
923{
924 struct thread *td;
925 int cpu;
926
927 tdq_lock_pair(high, low);
928 td = NULL;
929 /*
930 * Transfer a thread from high to low.
931 */
932 if (high->tdq_transferable != 0 && high->tdq_load > low->tdq_load &&
933 (td = tdq_move(high, low)) != NULL) {
934 /*
935 * In case the target isn't the current cpu notify it of the
936 * new load, possibly sending an IPI to force it to reschedule.
937 */
938 cpu = TDQ_ID(low);
939 if (cpu != PCPU_GET(cpuid))
940 tdq_notify(low, td);
941 }
942 tdq_unlock_pair(high, low);
943 return (td != NULL);
944}
945
946/*
947 * Move a thread from one thread queue to another.

Callers 1

sched_balance_groupFunction · 0.85

Calls 4

tdq_lock_pairFunction · 0.85
tdq_moveFunction · 0.85
tdq_notifyFunction · 0.85
tdq_unlock_pairFunction · 0.85

Tested by

no test coverage detected