From nobody Fri Dec 19 09:19:15 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 4dXhn00yhkz6LBGC for ; Fri, 19 Dec 2025 09:19:16 +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 4dXhmz0n9Gz44wn for ; Fri, 19 Dec 2025 09:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766135955; 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=qnmsEmNWSIOU5feUbc6LIqqwspwbtqT7Mg7Trn93AVw=; b=agyKIfzBLmEGp7j+GpK12r2aymNMd0w3S2lqdgOURCNgrgqCQAjy6bA2L9zcMoR+6q79wH xBexBIhbbvi7g0lPtjExC3t6FVkAGHklfoHQwQVSLOnOkTv6HTqju0aYwdoFGswcvho2bI /1P8/956M6J2rzuT0qgJGjJpofZo/JitzyOt8M95VXEKGdqt6j0EHlb0ZxwWz8BNL5h8eR KSfP+Ns9Mw/7jXQsEurM/NvINDAxYlOzow/TTV7svKXmlA0VnVQcKwxc65HACbkF5zUwgi owied2Tf4KB1JYTuHCVYbH4LC3hdEi8IEz01Lr4/rGnmAbx2PjxvQikIEsB3Jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766135955; 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=qnmsEmNWSIOU5feUbc6LIqqwspwbtqT7Mg7Trn93AVw=; b=YL/iMgEt/GcD4OmRSPplHcE5HRBGTnzMTr8yzO1/MhO7mCUMApTcaeE3ZojxYxxy5t3R0i gZOlu1dLlRPnAJ92Cqfu73eB/Ai8HwE4HTgjz/U+MT6uxr6cGt78F4KhaeWz5dU/32mT07 dSp0Jh1fhOkf5tAw9Xn60NcqanMuEzM5mHbVWalFxh8+BtmJnRYFKl4Nu6ABk96TTwJxG6 IyCaGqRYpenM17Mb2XNiTcZBoYdbHpkw1JBoNG4erHa7azMTvqxuJsIFrQB883aqoUQ2Fq eDm/ecSwywT2ojMxrJVEXr8JiyTJFw+BbW2PVNd8ycJM7+KMtkMlw0p+VJbMdg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766135955; a=rsa-sha256; cv=none; b=bvvx3JKu1lQ/d8MdQq4+y7bJDD7FWTGIkLYAoT+j89I2/AgKssPXhp+Xf6tHOahwPkB3yt 34Ps113bV2pqC/KTFgyMqB3MxHsLBaoj/R+nE3dbGFqv7+v4eRUKzfNzTh+9tfd6MQBXX5 zrEFKiaG9zSBJKaGjOojJTU7jdU782hqTToPejcEAhnm7/dGY7jKFtPBVt6vqvoN6g7MRi wL/6eHUInNhMRWiK1XZ769xAj2s90OctJKFLdqITFWuNLHLQdgd/PqkIroXV9SlnyG/hTZ M8USHmQ92wqR+ZqLHEPPNXPKOZ2CevyznKjBEJSSo8mFHoEMuph8XrJcDC38Rw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4dXhmz0KyVz1Gwf for ; Fri, 19 Dec 2025 09:19:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 3dd54 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 19 Dec 2025 09:19:15 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Olivier Certner Subject: git: 12b613efb4c6 - stable/14 - 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: olce X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 12b613efb4c670959ce540354db353bfb06e72a8 Auto-Submitted: auto-generated Date: Fri, 19 Dec 2025 09:19:15 +0000 Message-Id: <69451893.3dd54.1be5d59d@gitrepo.freebsd.org> The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=12b613efb4c670959ce540354db353bfb06e72a8 commit 12b613efb4c670959ce540354db353bfb06e72a8 Author: Olivier Certner AuthorDate: 2025-09-25 14:40:30 +0000 Commit: Olivier Certner CommitDate: 2025-12-19 09:16:46 +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 (cherry picked from commit 7b0fe2d405ae09b1247bccc6fa45a6d2755cbe4c) In stable/14, all page allocations with object have the latter locked for writing. Contrary to what happened in main (and stable/15), the offender mentioned in the original commit message never appeared in stable/14 because it was introduced in main by commit 7a79d0669761 ("vm: improve kstack_object pindex calculation to avoid pindex holes") and later fixed by commit 3b9b64457676 ("vm: Fix iterator usage in vm_thread_stack_create()"), both of which were never MFCed. So, the following part of the original commit message: "The only offender was thread stack allocation, which has just been fixed in commit 3b9b64457676 ("vm: Fix iterator usage in vm_thread_stack_create()")." does not apply here. --- 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 e10cf2540919..6ec2d893fc7d 100644 --- a/sys/vm/vm_domainset.c +++ b/sys/vm/vm_domainset.c @@ -109,7 +109,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]; } @@ -256,9 +255,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);