From nobody Fri Oct 17 15:19:11 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4cp7lN0zLSz6CBwN; Fri, 17 Oct 2025 15:19:12 +0000 (UTC) (envelope-from git@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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cp7lN0SFHz43Nn; Fri, 17 Oct 2025 15:19:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760714352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aUXFIDn5Cbs2H/eBr9YzkO10uFzrWXyrHaOm8KytwOw=; b=Q0ij+3SIe9duF1lVCm5u2iC2EzPBrGayRHp7Ag0isCIB8DxIeAUxEtnlIQ+bMx3pE3FeeK RhbIZtO4ZhX9+3vnCb9fClZuGc7qkyvHy/lVGLjav9U+um6sHIJ1wf1GseCDHLGA7DD9U/ TZah1b8Szttrwg4/SaGusMpXZFucq3Nb45nrFLg0qDuCuzy+8WCq+8BHxorHukNjd9ET9S L5C2t0BgEjC8uWkM/nfE5tKYm9VbDTY/KPSGB2MZadj0ZeaTrVd5EGnX8Ntt5DhcNYxF0B DisfS4E5P1Nn1hQDJIEfFJiOyvZdJJz5rbnWmzn8bzmo6wMfCCaRvcFTz+4Xrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760714352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=aUXFIDn5Cbs2H/eBr9YzkO10uFzrWXyrHaOm8KytwOw=; b=JHPhmgGdzFPC/DdmlXzbjwA5YFfxvluO/WYCL8fcZGmXNl+N54oYGLWKMQ89e6rABHpQpj fggcW+8Td6cSAWm+m4LcysJ9vQ9TzCaKzIpAQ02wqBn9QdWxu51v5you9QdEJanGDHyZvs jjhUf3Rnf/F/PC22jJEG27WimH2YPjZHhhfXZ/8Rxu9kQLjaSIndBneLSPfDhHEj8EvhiH ZR/+w/+DYkMNMQS3/fVIujM+gx6NKm6bQ61Gy+XVw+IKFK48FevjRs9A+X8NDd/a3aqChf q8VAPdlQBQZS2CKLrcX+rXgjZAr+19YAMS2u95GriL6vA5GsCLmJtd0W8GDI3Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760714352; a=rsa-sha256; cv=none; b=OO1h6xtz+41r4xuLw3nIsoE2b1FsJq9tczkVmRtCYTAhCTpoVvTKqMqmdAvPLfcvnJ3TZC nF2d44MEEsHswzaqunuU8M5TGVjJm03bRf6KCTh8s21Vdz+kHMRMUlGA23DPw0ok5rVHD3 qOlksIUsvPYMtT+ss9sMcACqGsc96dqV9omLUIQ30tGQn6mJwA9Z6eliqjnMCFmTzBD0C6 +QvO/KfOnlBu9g0s9vn3MLuHGssr02tDS9if0v2znEwHsZju+33hcmfaDcr62oMmpfgIaB h8FTcWPca44kCt0hCqQer2crHNYIv8vQ3SZY5GdxIlIVYFeZf6i+kP9vsnD6vg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4cp7lM6SZ1z10Yg; Fri, 17 Oct 2025 15:19:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 59HFJBa1083846; Fri, 17 Oct 2025 15:19:11 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59HFJBvl083843; Fri, 17 Oct 2025 15:19:11 GMT (envelope-from git) Date: Fri, 17 Oct 2025 15:19:11 GMT Message-Id: <202510171519.59HFJBvl083843@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 7b0fe2d405ae - main - vm_domainset: Ensure round-robin works properly List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7b0fe2d405ae09b1247bccc6fa45a6d2755cbe4c Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=7b0fe2d405ae09b1247bccc6fa45a6d2755cbe4c commit 7b0fe2d405ae09b1247bccc6fa45a6d2755cbe4c Author: Olivier Certner AuthorDate: 2025-09-25 14:40:30 +0000 Commit: Olivier Certner CommitDate: 2025-10-17 15:18:53 +0000 vm_domainset: Ensure round-robin works properly All iterators that rely on an object's 'struct domainset_ref' (field 'domain' on 'struct vm_object'), which is the case for page allocations with objects, are used with the corresponding object locked for writing, so cannot lose concurrent iterator index's increases even if those are made without atomic operations. The only offender was thread stack allocation, which has just been fixed in commit 3b9b64457676 ("vm: Fix iterator usage in vm_thread_stack_create()"). However, the interleaved policy would still reset the iterator index when restarting, losing track of the next domain to allocate from when applying round-robin, which all allocation policies do if allocation from the first domain fails. Fix this last round-robin problem by not resetting the shared index at iterator's phase init on DOMAINSET_POLICY_INTERLEAVE. Add an assertion to check that, when passed, an object is write-locked in order to prevent the problem mentioned in the first paragraph from reappearing. Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52733 --- sys/vm/vm_domainset.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sys/vm/vm_domainset.c b/sys/vm/vm_domainset.c index 9fa17da954f7..c25ed0cc2267 100644 --- a/sys/vm/vm_domainset.c +++ b/sys/vm/vm_domainset.c @@ -113,7 +113,6 @@ vm_domainset_iter_interleave(struct vm_domainset_iter *di, int *domain) int d; d = di->di_offset % di->di_domain->ds_cnt; - *di->di_iter = d; *domain = di->di_domain->ds_order[d]; } @@ -260,9 +259,14 @@ vm_domainset_iter_page_init(struct vm_domainset_iter *di, struct vm_object *obj, * are immutable and unsynchronized. Updates can race but pointer * loads are assumed to be atomic. */ - if (obj != NULL && obj->domain.dr_policy != NULL) + if (obj != NULL && obj->domain.dr_policy != NULL) { + /* + * This write lock protects non-atomic increments of the + * iterator index in vm_domainset_iter_rr(). + */ + VM_OBJECT_ASSERT_WLOCKED(obj); dr = &obj->domain; - else + } else dr = &curthread->td_domain; vm_domainset_iter_init(di, dr->dr_policy, &dr->dr_iter, obj, pindex);