From nobody Mon Oct 20 18:02:49 2025 X-Original-To: dev-commits-src-all@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 4cr3Dn2BGDz6Cs3C; Mon, 20 Oct 2025 18:02:49 +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 4cr3Dn1jLdz3yvH; Mon, 20 Oct 2025 18:02:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760983369; 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=ksG/u94TCVnGEWdGgC8AlUKxIoFwWj8issZa0ZoKajU=; b=wPgpX0XQF1QZ6s6R/TgNLWjdzt3Wy2weHA5qFGa9xuq6pnN+xDNLUEn0f5zmlxVChrBV9f Ghrm1tgo7q9FY2+e8gtr4If5FayNxwTfdZ/huyK0/yEHWP9Bm0Z95b0erJaJS2ubR9AoJQ BwRMbuHwwfYBWMG+C/U83sypGWNmiB/VkJRJr59Kq+hyC0jkp6P/KNXKhXNZ/up5cb3wq9 W5M86GuhZ1nSncp2OYOuhfUiPMUWzJuKEUdevS8h2zo743Yo2tmrT3V4tB/KxMai9RFQHt 53bEpTxx76BfFqgAJnLSZXtKyaRLsBJQGeHyRyS55+D0BHSW89YxOeMMoqEyFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1760983369; 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=ksG/u94TCVnGEWdGgC8AlUKxIoFwWj8issZa0ZoKajU=; b=dOoXJ70dbgEAWoQWIFhzhxZ/kuoA02aVS/kDXaFZaBXh9q/3fZGI2eGBcD2dd6NuPXxrp+ zgYGcN7CVBQcecg6NBcBNETjSSuUeRVfLe6cOv5D3FvrZrQc4C/oz91BVB9cxcL3b/yx37 YljQrxU9OEkHJqv+DdZ9asA5P6XVaCsnC8rVSz1k7PrDdCPXjM1xhtuPt6oIsvri3KWyZA kLCYmY6zvdeY08amHbE7/LrsXj+q6kgps7x0Fwfop4705gFiajQjEm3AANOvLb7Aq05vx3 zzTCiTamhXwBqDYGgsYgUrq2XOSA8C/3lPFdYTme0bOmqjf6xXpZP2dszi8q9Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1760983369; a=rsa-sha256; cv=none; b=UIu8JJyERn1/Hfa6nYDYE5sCO3cJuEmMt83p5302DDt61jZlKco+AIGlh8AlgngWY3Fvrf dUN2soLB1gqTN5WqQrGRHXj03NaBFVU8hvld9vdhMPe85vr2740zbj025Kvihpklwd6s/i rVSMH+lA735ViYgbQYWAt0kLjkwUoPXAhoTW5QA+LX+BdFwKbLcxuHKzXdLBYNwWy9T7ld W6njFNO5zteDsCJgtJAfR0jpqIUc5gPetfACyp0P/2I4nhsFbhB03dUG8rugnaUyc7bpQV DqztIyaPMQV4MI8xobpjqb5tm7e1+trSgKVwur/NVhWhjzoIWMPcD1hELpqjqQ== 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 4cr3Dn1Jn5z8JY; Mon, 20 Oct 2025 18:02:49 +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 59KI2ngQ050014; Mon, 20 Oct 2025 18:02:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 59KI2n2S050011; Mon, 20 Oct 2025 18:02:49 GMT (envelope-from git) Date: Mon, 20 Oct 2025 18:02:49 GMT Message-Id: <202510201802.59KI2n2S050011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Colin Percival Subject: git: b15ff7214020 - releng/15.0 - vm_domainset: Ensure round-robin works properly List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: cperciva X-Git-Repository: src X-Git-Refname: refs/heads/releng/15.0 X-Git-Reftype: branch X-Git-Commit: b15ff72140204b416f067a75ac9fa189c0387f7d Auto-Submitted: auto-generated The branch releng/15.0 has been updated by cperciva: URL: https://cgit.FreeBSD.org/src/commit/?id=b15ff72140204b416f067a75ac9fa189c0387f7d commit b15ff72140204b416f067a75ac9fa189c0387f7d Author: Olivier Certner AuthorDate: 2025-09-25 14:40:30 +0000 Commit: Colin Percival CommitDate: 2025-10-20 18:02:37 +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. Approved by: re (cperciva) Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D52733 (cherry picked from commit 7b0fe2d405ae09b1247bccc6fa45a6d2755cbe4c) (cherry picked from commit d7226d1858c188475b12b0c4dff5bc794e42be6d) --- 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);