From nobody Mon Oct 07 20:52:31 2024 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 4XMrv40S8qz5YSGt; Mon, 07 Oct 2024 20:52:32 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XMrv402H6z53Tk; Mon, 7 Oct 2024 20:52:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728334352; 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=TLuaj+yLjTKhL4ATm7I9yBZ2xlaOWv75UoRAOtmt5wg=; b=GKAe1UiqmDABXV/VAKevvWBhu7IbsPYRPTG3zWxo6YGlTP5yA6GJCppf5ZqMbVhXtQmVe/ ZC2DTQbuBxQR075x/+tzVxrLrZJMNYgWDsgPchNbXz52o/mwQs02Bza2IWjmhC0xB8KNrx 8S0GsNuT/SXlYSSDZX5p3hrtcgEiY2tD4pLwG4ah4X/yYME2cTFbjamHdve8ixfiBAg/bL 638K4qJAM13raithmRMMq+rd+v5CjwJDGvlabvQemzXGrqVf8PzlD4pVZ9U/rkYZqeDcrC tAe+ha+pI7zugl0rSztmLxeJ05Spfy1i7rmEp7sNwYgbWHfvP3CH4sZhASOqJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728334352; 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=TLuaj+yLjTKhL4ATm7I9yBZ2xlaOWv75UoRAOtmt5wg=; b=d96LgC8YbCFq6LyAqcjjVeil3eHGJDIJub+OnORO5dGoqIWAHc9mQWd1qmlSVAcO/NyXIl ecczyzXs91chxAJOqrjh+oDoLvEzzzYjBhwoGn5e/YcWBw8XEexC/ovEUFZBfTKLodE9rT iFQSRgy9jwMB9WmopKmE0Vdu9Rf5KpRvnQ47wfEuFihlCj3/KCVP9zMmP40kUieofLg5lP OqP879vyTBrZdkUqEvBgjskF70wSfdk3RVgEJWgLUa2oZS3pE/7Fhc0bq8yERf/4zz7/Mj 8e3MwN1F4AiUIHZ1UgPqtRa+jfJcuoHS+pqS5+m/krs4oiWrnVXH9peQ3zF3fw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728334352; a=rsa-sha256; cv=none; b=O1kjfNlp8Sqrt8urNRT85yguIbrRPShYc5bn9IAMGMvEpgj8vBA8aiCe/gcUq97MDDZBnt kOh29gFm04SP2IAICQcSU4cFLHCXrv9oeu4AfGhLcj1fDI09gsSXXAkTmm17s2941PSqlD 64epAGnWb9Lhe3K3HOSN37wiK4HM2NCywX8kkBraHOhWf5f6qGixjfHTvphhhvafj+gBA/ 01HTiO72hL94YUF3IJB9s3Xe7mnWD3npIhO7s3rgX18Wzjttz84HvrxGIQsPzM9mGCol7W 4YH6g90pE4ZeboIByrIikDcXumFeYPKInc8S8mHFSWq886C6+LDOFsKTC7Y9lw== 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 4XMrv36l1bz12Wn; Mon, 7 Oct 2024 20:52:31 +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 497KqVpo011314; Mon, 7 Oct 2024 20:52:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 497KqV5r011311; Mon, 7 Oct 2024 20:52:31 GMT (envelope-from git) Date: Mon, 7 Oct 2024 20:52:31 GMT Message-Id: <202410072052.497KqV5r011311@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: d8b32da2354d - main - vm_page: Use atomic loads for cmpset loops 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: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d8b32da2354d2fd72ae017fd63affa3684786e1f Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d8b32da2354d2fd72ae017fd63affa3684786e1f commit d8b32da2354d2fd72ae017fd63affa3684786e1f Author: Mark Johnston AuthorDate: 2024-10-07 20:50:36 +0000 Commit: Mark Johnston CommitDate: 2024-10-07 20:52:08 +0000 vm_page: Use atomic loads for cmpset loops Make sure that the compiler loads the initial value value only once. Because atomic_fcmpset is used to load the value for subsequent iterations, this is probably not needed, but we should not rely on that. I verified that code generated for an amd64 GENERIC kernel does not change. Reviewed by: dougm, alc, kib Tested by: pho MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D46943 --- sys/vm/vm_page.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 67a9c2119ab8..3a8d8d137dc1 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -2097,7 +2097,7 @@ _vm_domain_allocate(struct vm_domain *vmd, int req_class, int npages) * Attempt to reserve the pages. Fail if we're below the limit. */ limit += npages; - old = vmd->vmd_free_count; + old = atomic_load_int(&vmd->vmd_free_count); do { if (old < limit) return (0); @@ -4239,7 +4239,7 @@ vm_page_wire_mapped(vm_page_t m) { u_int old; - old = m->ref_count; + old = atomic_load_int(&m->ref_count); do { KASSERT(old > 0, ("vm_page_wire_mapped: wiring unreferenced page %p", m)); @@ -4273,7 +4273,7 @@ vm_page_unwire_managed(vm_page_t m, uint8_t nqueue, bool noreuse) * Use a release store when updating the reference count to * synchronize with vm_page_free_prep(). */ - old = m->ref_count; + old = atomic_load_int(&m->ref_count); do { KASSERT(VPRC_WIRE_COUNT(old) > 0, ("vm_page_unwire: wire count underflow for page %p", m)); @@ -4568,7 +4568,7 @@ vm_page_try_blocked_op(vm_page_t m, void (*op)(vm_page_t)) ("vm_page_try_blocked_op: page %p is not busy", m)); VM_OBJECT_ASSERT_LOCKED(m->object); - old = m->ref_count; + old = atomic_load_int(&m->ref_count); do { KASSERT(old != 0, ("vm_page_try_blocked_op: page %p has no references", m));