Date: Sun, 8 Sep 2019 20:28:07 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r352038 - stable/12/sys/kern Message-ID: <201909082028.x88KS7Gv028279@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Sun Sep 8 20:28:06 2019 New Revision: 352038 URL: https://svnweb.freebsd.org/changeset/base/352038 Log: MFC r351547, r351549: Fix several logic issues in domainset_empty_vm(). 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 Sun Sep 8 19:54:28 2019 (r352037) +++ stable/12/sys/kern/kern_cpuset.c Sun Sep 8 20:28:06 2019 (r352038) @@ -457,7 +457,7 @@ static struct domainset * _domainset_create(struct domainset *domain, struct domainlist *freelist) { struct domainset *ndomain; - int i, j, max; + int i, j; KASSERT(domain->ds_cnt <= vm_ndomains, ("invalid domain count in domainset %p", domain)); @@ -476,8 +476,7 @@ _domainset_create(struct domainset *domain, struct dom if (ndomain == NULL) { LIST_INSERT_HEAD(&cpuset_domains, domain, ds_link); domain->ds_cnt = DOMAINSET_COUNT(&domain->ds_mask); - max = DOMAINSET_FLS(&domain->ds_mask) + 1; - for (i = 0, j = 0; i < max; i++) + for (i = 0, j = 0; i < DOMAINSET_FLS(&domain->ds_mask); i++) if (DOMAINSET_ISSET(i, &domain->ds_mask)) domain->ds_order[j++] = i; } @@ -500,25 +499,31 @@ _domainset_create(struct domainset *domain, struct dom static bool domainset_empty_vm(struct domainset *domain) { - int i, j, max; + domainset_t empty; + int i, j; - max = DOMAINSET_FLS(&domain->ds_mask) + 1; - for (i = 0; i < max; i++) - if (DOMAINSET_ISSET(i, &domain->ds_mask) && VM_DOMAIN_EMPTY(i)) - DOMAINSET_CLR(i, &domain->ds_mask); + DOMAINSET_ZERO(&empty); + for (i = 0; i < vm_ndomains; i++) + if (VM_DOMAIN_EMPTY(i)) + DOMAINSET_SET(i, &empty); + if (DOMAINSET_SUBSET(&empty, &domain->ds_mask)) + return (true); + + /* Remove empty domains from the set and recompute. */ + DOMAINSET_NAND(&domain->ds_mask, &empty); domain->ds_cnt = DOMAINSET_COUNT(&domain->ds_mask); - max = DOMAINSET_FLS(&domain->ds_mask) + 1; - for (i = j = 0; i < max; i++) { + for (i = j = 0; i < DOMAINSET_FLS(&domain->ds_mask); i++) if (DOMAINSET_ISSET(i, &domain->ds_mask)) domain->ds_order[j++] = i; - else if (domain->ds_policy == DOMAINSET_POLICY_PREFER && - domain->ds_prefer == i && domain->ds_cnt > 1) { - domain->ds_policy = DOMAINSET_POLICY_ROUNDROBIN; - domain->ds_prefer = -1; - } + + /* Convert a PREFER policy referencing an empty domain to RR. */ + if (domain->ds_policy == DOMAINSET_POLICY_PREFER && + DOMAINSET_ISSET(domain->ds_prefer, &empty)) { + domain->ds_policy = DOMAINSET_POLICY_ROUNDROBIN; + domain->ds_prefer = -1; } - return (DOMAINSET_EMPTY(&domain->ds_mask)); + return (false); } /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201909082028.x88KS7Gv028279>