Module Name: src Committed By: snj Date: Mon Feb 26 00:43:23 UTC 2018
Modified Files: src/sys/kern [netbsd-8]: kern_synch.c Log Message: Pull up following revision(s) (requested by ozaki-r in ticket #573): sys/kern/kern_synch.c: 1.314 Avoid a race condition between an LWP migration and curlwp_bind curlwp_bind sets the LP_BOUND flag to l_pflags of the current LWP, which prevents it from migrating to another CPU until curlwp_bindx is called. Meanwhile, there are several ways that an LWP is migrated to another CPU and in any cases the scheduler postpones a migration if a target LWP is running. One example of LWP migrations is a load balancing; the scheduler periodically explores CPU-hogging LWPs and schedule them to migrate (see sched_lwp_stats). At that point the scheduler checks the LP_BOUND flag and if it's set to a LWP, the scheduler doesn't schedule the LWP. A scheduled LWP is tried to be migrated when it is leaving a running CPU, i.e., mi_switch. And mi_switch does NOT check the LP_BOUND flag. So if an LWP is scheduled first and then it sets the LP_BOUND flag, the LWP can be migrated regardless of the flag. To avoid this race condition, we need to check the flag in mi_switch too. For more details see https://mail-index.netbsd.org/tech-kern/2018/02/13/msg023079.html To generate a diff of this commit: cvs rdiff -u -r1.311 -r1.311.10.1 src/sys/kern/kern_synch.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.