svn commit: r368321 - stable/12/sys/kern
Kyle Evans
kevans at FreeBSD.org
Fri Dec 4 02:18:40 UTC 2020
Author: kevans
Date: Fri Dec 4 02:18:40 2020
New Revision: 368321
URL: https://svnweb.freebsd.org/changeset/base/368321
Log:
MFC r368116: kern: cpuset: drop the lock to allocate domainsets
Restructure the loop a little bit to make it a little more clear how it
really operates: we never allocate any domains at the beginning of the first
iteration, and it will run until we've satisfied the amount we need or we
encounter an error.
The lock is now taken outside of the loop to make stuff inside the loop
easier to evaluate w.r.t. locking.
This fixes it to not try and allocate any domains for the freelist under the
spinlock, which would have happened before if we needed any new domains.
Modified:
stable/12/sys/kern/kern_cpuset.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/kern/kern_cpuset.c
==============================================================================
--- stable/12/sys/kern/kern_cpuset.c Fri Dec 4 01:11:09 2020 (r368320)
+++ stable/12/sys/kern/kern_cpuset.c Fri Dec 4 02:18:40 2020 (r368321)
@@ -784,14 +784,11 @@ cpuset_modify_domain(struct cpuset *set, struct domain
return (EPERM);
domainset_freelist_init(&domains, 0);
domain = domainset_create(domain);
- ndomains = needed = 0;
- do {
- if (ndomains < needed) {
- domainset_freelist_add(&domains, needed - ndomains);
- ndomains = needed;
- }
+ ndomains = 0;
+
+ mtx_lock_spin(&cpuset_lock);
+ for (;;) {
root = cpuset_getroot(set);
- mtx_lock_spin(&cpuset_lock);
dset = root->cs_domain;
/*
* Verify that we have access to this set of domains.
@@ -816,7 +813,15 @@ cpuset_modify_domain(struct cpuset *set, struct domain
&needed, 0);
if (error)
goto out;
- } while (ndomains < needed);
+ if (ndomains >= needed)
+ break;
+
+ /* Dropping the lock; we'll need to re-evaluate again. */
+ mtx_unlock_spin(&cpuset_lock);
+ domainset_freelist_add(&domains, needed - ndomains);
+ ndomains = needed;
+ mtx_lock_spin(&cpuset_lock);
+ }
dset = set->cs_domain;
cpuset_update_domain(set, domain, dset, &domains);
out:
More information about the svn-src-all
mailing list