]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r368461: kern: cpuset: resolve race between cpuset_lookup/cpuset_rel
authorKyle Evans <kevans@FreeBSD.org>
Tue, 15 Dec 2020 21:52:31 +0000 (21:52 +0000)
committerKyle Evans <kevans@FreeBSD.org>
Tue, 15 Dec 2020 21:52:31 +0000 (21:52 +0000)
commit878170c334dfd246835f9a8baf7a579817a02b30
treeaa6bdc05fbecdac5c45c863cc2941c596df8caf7
parent64b4d0ba0b4e35589a88c6035d6675ce1770c01d
MFC r368461: kern: cpuset: resolve race between cpuset_lookup/cpuset_rel

The race plays out like so between threads A and B:

1. A ref's cpuset 10
2. B does a lookup of cpuset 10, grabs the cpuset lock and searches
   cpuset_ids
3. A rel's cpuset 10 and observes the last ref, waits on the cpuset lock
   while B is still searching and not yet ref'd
4. B ref's cpuset 10 and drops the cpuset lock
5. A proceeds to free the cpuset out from underneath B

Resolve the race by only releasing the last reference under the cpuset lock.
Thread A now picks up the spinlock and observes that the cpuset has been
revived, returning immediately for B to deal with later.
sys/kern/kern_cpuset.c