Bug 197921

Summary: scheduler: Allow non-migratable threads to bind to their current CPU
Product: Base System Reporter: Harrison Grundy <harrison.grundy>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me CC: agh, current, emaste, koobs, zlei
Priority: --- Keywords: needs-patch, needs-qa
Version: CURRENT   
Hardware: Any   
OS: Any   
URL: https://github.com/AstrodogInc/freebsd_schedulers/blob/master/ule_patches/bind_nonmigratable_to_same_cpu.diff
Attachments:
Description Flags
Allow threads to bind to the local CPU even if marked unmigratable. none

Description Harrison Grundy 2015-02-22 15:00:48 UTC
Created attachment 153316 [details]
Allow threads to bind to the local CPU even if marked unmigratable.

ULE currently prohibits sched_bind()'ing to the current CPU if a thread as marked as un-migratable. This should only apply to threads attempting to bind to other CPUs (as no migration is necessary to bind them to the existing local CPU.)
Comment 1 Ed Maste freebsd_committer freebsd_triage 2019-05-29 20:59:08 UTC
+	}
+	else {	

should be:

} else {

but, what about just moving the KASSERT after the `if (PCPU_GET(cpuid) == cpu)` test?
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2024-01-05 22:43:58 UTC
^Triage: remove OBE flags.
Comment 3 Zhenlei Huang freebsd_committer freebsd_triage 2024-01-09 09:42:34 UTC
It seems we do not have usage that bind a thread to local CPU, otherwise `KASSERT(THREAD_CAN_MIGRATE(td), ("%p must be migratable", td))` will complain (when kernel built with option INVARIANTS).

(In reply to Ed Maste from comment #1)
> but, what about just moving the KASSERT after the `if (PCPU_GET(cpuid) == cpu)` test?
I think that is much simpler.