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

Function sched_affinity

freebsd/kern/sched_ule.c:2681–2707  ·  view source on GitHub ↗

* Enforce affinity settings for a thread. Called after adjustments to * cpumask. */

Source from the content-addressed store, hash-verified

2679 * cpumask.
2680 */
2681void
2682sched_affinity(struct thread *td)
2683{
2684#ifdef SMP
2685 struct td_sched *ts;
2686
2687 THREAD_LOCK_ASSERT(td, MA_OWNED);
2688 ts = td_get_sched(td);
2689 if (THREAD_CAN_SCHED(td, ts->ts_cpu))
2690 return;
2691 if (TD_ON_RUNQ(td)) {
2692 sched_rem(td);
2693 sched_add(td, SRQ_BORING | SRQ_HOLDTD);
2694 return;
2695 }
2696 if (!TD_IS_RUNNING(td))
2697 return;
2698 /*
2699 * Force a switch before returning to userspace. If the
2700 * target thread is not running locally send an ipi to force
2701 * the issue.
2702 */
2703 td->td_flags |= TDF_NEEDRESCHED;
2704 if (td != curthread)
2705 ipi_cpu(ts->ts_cpu, IPI_PREEMPT);
2706#endif
2707}
2708
2709/*
2710 * Bind a thread to a target cpu.

Callers 1

cpuset_update_threadFunction · 0.70

Calls 4

td_get_schedFunction · 0.85
sched_remFunction · 0.70
sched_addFunction · 0.70
ipi_cpuFunction · 0.50

Tested by

no test coverage detected