* Transfer load between two imbalanced thread queues. */
| 919 | * Transfer load between two imbalanced thread queues. |
| 920 | */ |
| 921 | static int |
| 922 | sched_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. |
no test coverage detected