From owner-svn-src-all@freebsd.org Tue Aug 27 14:06:35 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 43601D6B74; Tue, 27 Aug 2019 14:06:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46HrJq0zW5z3Qrd; Tue, 27 Aug 2019 14:06:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 03CC81FCF3; Tue, 27 Aug 2019 14:06:35 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x7RE6YR7079323; Tue, 27 Aug 2019 14:06:34 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x7RE6Ynj079322; Tue, 27 Aug 2019 14:06:34 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201908271406.x7RE6Ynj079322@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Tue, 27 Aug 2019 14:06:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r351547 - head/sys/kern X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: head/sys/kern X-SVN-Commit-Revision: 351547 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Aug 2019 14:06:35 -0000 Author: markj Date: Tue Aug 27 14:06:34 2019 New Revision: 351547 URL: https://svnweb.freebsd.org/changeset/base/351547 Log: Fix several logic issues in domainset_empty_vm(). - Don't add 1 to the result of DOMAINSET_FLS. - Do not modify domainsets containing only empty domains. - Always flatten a _PREFER policy to _ROUNDROBIN if the preferred domain is empty. Previously we were doing this only when ds_cnt > 1. These bugs could cause hangs during boot if a VM domain is empty. Tested by: hselasky Reviewed by: hselasky, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21420 Modified: head/sys/kern/kern_cpuset.c Modified: head/sys/kern/kern_cpuset.c ============================================================================== --- head/sys/kern/kern_cpuset.c Tue Aug 27 14:04:32 2019 (r351546) +++ head/sys/kern/kern_cpuset.c Tue Aug 27 14:06:34 2019 (r351547) @@ -500,25 +500,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); } /*