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

Function sched_switch_migrate

freebsd/kern/sched_ule.c:2001–2028  ·  view source on GitHub ↗

* Handle migration from sched_switch(). This happens only for * cpu binding. */

Source from the content-addressed store, hash-verified

1999 * cpu binding.
2000 */
2001static struct mtx *
2002sched_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.

Callers 1

sched_switchFunction · 0.85

Calls 4

td_get_schedFunction · 0.85
tdq_load_remFunction · 0.85
tdq_addFunction · 0.85
tdq_notifyFunction · 0.85

Tested by

no test coverage detected