* Handle migration from sched_switch(). This happens only for * cpu binding. */
| 1999 | * cpu binding. |
| 2000 | */ |
| 2001 | static struct mtx * |
| 2002 | sched_switch_migrate(struct tdq *tdq, struct thread *td, int flags) |
| 2003 | { |
| 2004 | struct tdq *tdn; |
| 2005 | |
| 2006 | KASSERT(THREAD_CAN_MIGRATE(td) || |
| 2007 | (td_get_sched(td)->ts_flags & TSF_BOUND) != 0, |
| 2008 | ("Thread %p shouldn't migrate", td)); |
| 2009 | KASSERT(!CPU_ABSENT(td_get_sched(td)->ts_cpu), ("sched_switch_migrate: " |
| 2010 | "thread %s queued on absent CPU %d.", td->td_name, |
| 2011 | td_get_sched(td)->ts_cpu)); |
| 2012 | tdn = TDQ_CPU(td_get_sched(td)->ts_cpu); |
| 2013 | #ifdef SMP |
| 2014 | tdq_load_rem(tdq, td); |
| 2015 | /* |
| 2016 | * Do the lock dance required to avoid LOR. We have an |
| 2017 | * extra spinlock nesting from sched_switch() which will |
| 2018 | * prevent preemption while we're holding neither run-queue lock. |
| 2019 | */ |
| 2020 | TDQ_UNLOCK(tdq); |
| 2021 | TDQ_LOCK(tdn); |
| 2022 | tdq_add(tdn, td, flags); |
| 2023 | tdq_notify(tdn, td); |
| 2024 | TDQ_UNLOCK(tdn); |
| 2025 | TDQ_LOCK(tdq); |
| 2026 | #endif |
| 2027 | return (TDQ_LOCKPTR(tdn)); |
| 2028 | } |
| 2029 | |
| 2030 | /* |
| 2031 | * thread_lock_unblock() that does not assume td_lock is blocked. |
no test coverage detected