From nobody Thu Jun 06 17:35:46 2024 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 4VwBLp2Xh2z5NMQ9; Thu, 06 Jun 2024 17:35:46 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VwBLp22Qvz4NsD; Thu, 6 Jun 2024 17:35:46 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717695346; 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=H5TXIa+vHH1K347c7d7+b9TgFp6QPqIZggQLFbkDMuc=; b=ZjnAtBw0aDTrm7V93Xe8w/FH8AxbMhbFnoXTgu4rpZ/+UhoF39GJRTu/UU9vfVcuo885Gb Tuj5zfRQQrkwUlSPtO+vAh9m54DgnnRzDFHBXXlCwhvRAZU6F588HfGzcS8Efs8W2lnP7l tt2fODKGqYEFSPtE6LzhXr+pJ9Dgharp03CswmXoIJf3TPomWjXsf4V8boPt8XLP2ZWSkK nEanqrvJEyImjagEDGER810PuUdDtK/apwzRCtcigK+YT73Ew/EPTNCAZZZ3pBOGVQcTUP qaMirlGnQgDcn/SJa2Ck0ZOHWgtdy2sJqP5m9Zi9DdyCsDSy51D2NXErjd/AMw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717695346; a=rsa-sha256; cv=none; b=nAmpjbbI6iDtzWDVGidMYCpAPKzrT+VyQB9WRYMg7vk+Vee2ph6yb2obzAE5BTQK6PTIJ8 SV/F5xs1Aao+iaUHZQ03w0WYkIigtidp+Gk9SaUooSkDSQ4o1fQWkOZaiPIT0tpxTbWMGG VlX/93ez62KJMz38SgXRtlMbS4BBXBsdph8p+pj0oBFZchmJc3BrzmbVbXhfjHz4Zf/svJ g4BuZDQr2XuKkwieqhP6dR60xfO1kSd8IFvNaJFD7pFhQdj5jkqtIk5t122aB+omXpD7Py P9FnJ1pCe6IaBwLTqz+dRRu2xDUBEHgFeJoNvzI2Cc9NmpV64Y8vYtwLXStMHA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717695346; 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=H5TXIa+vHH1K347c7d7+b9TgFp6QPqIZggQLFbkDMuc=; b=NrrzcitXOIh7Ta3U0FnwUGdmJDAQ+kmQPDIO7GPjN9+pfZBJ8iMwIxg/7b8L3iIE4yTY3E Um6PdRFrcCeMICYTLxsAZJs8oo4kfZA8lTj0Q6el+Dxr5ElYHLaDWe9uFIbHuJy/fapIIE OhcOmoeyKhymsEL5ZrsTlyKwRbES0FDwQPvwwmOPUwMB1TPi3/htsWJoVmUpCLb5NKzlPi kIdrLnGi8Ve5n4RCXs2GLkm2sTZv2p75G96WWoC3cDV1ViOTaN1zw9PHwRqNo5Y11AO+la qAjMqCDFqkWkmcuKKWXs71idet+tdIDrMA75EKpGkVXW0w3ayitW2KIb6aqcgw== 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 4VwBLp1dt4zvwL; Thu, 6 Jun 2024 17:35:46 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 456HZkOJ024154; Thu, 6 Jun 2024 17:35:46 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 456HZkv0024151; Thu, 6 Jun 2024 17:35:46 GMT (envelope-from git) Date: Thu, 6 Jun 2024 17:35:46 GMT Message-Id: <202406061735.456HZkv0024151@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ryan Libby Subject: git: 7658d1532caa - main - vm_radix: define vm_radix_insert_lookup_lt and use in vm_page_rename 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: rlibby X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 7658d1532caa47deafa20e4af902e0e26dd0b34c Auto-Submitted: auto-generated The branch main has been updated by rlibby: URL: https://cgit.FreeBSD.org/src/commit/?id=7658d1532caa47deafa20e4af902e0e26dd0b34c commit 7658d1532caa47deafa20e4af902e0e26dd0b34c Author: Ryan Libby AuthorDate: 2024-06-06 17:26:50 +0000 Commit: Ryan Libby CommitDate: 2024-06-06 17:26:50 +0000 vm_radix: define vm_radix_insert_lookup_lt and use in vm_page_rename Use the new pctrie combined lookup/insert. This is an easy application of the new facility. There are other places where we do this for pages that may need more plumbing to use combined lookup/insert. Reviewed by: kib (previous version), dougm, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D45396 --- sys/vm/vm_page.c | 5 +---- sys/vm/vm_radix.h | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c index 9ba31cb9e1b3..b41439045205 100644 --- a/sys/vm/vm_page.c +++ b/sys/vm/vm_page.c @@ -1851,9 +1851,6 @@ vm_page_rename(vm_page_t m, vm_object_t new_object, vm_pindex_t new_pindex) VM_OBJECT_ASSERT_WLOCKED(new_object); KASSERT(m->ref_count != 0, ("vm_page_rename: page %p has no refs", m)); - mpred = vm_radix_lookup_le(&new_object->rtree, new_pindex); - KASSERT(mpred == NULL || mpred->pindex != new_pindex, - ("vm_page_rename: pindex already renamed")); /* * Create a custom version of vm_page_insert() which does not depend @@ -1862,7 +1859,7 @@ vm_page_rename(vm_page_t m, vm_object_t new_object, vm_pindex_t new_pindex) */ opidx = m->pindex; m->pindex = new_pindex; - if (vm_radix_insert(&new_object->rtree, m)) { + if (vm_radix_insert_lookup_lt(&new_object->rtree, m, &mpred) != 0) { m->pindex = opidx; return (1); } diff --git a/sys/vm/vm_radix.h b/sys/vm/vm_radix.h index 815c915b5fb1..dcacf1a5d3fc 100644 --- a/sys/vm/vm_radix.h +++ b/sys/vm/vm_radix.h @@ -69,6 +69,26 @@ vm_radix_insert(struct vm_radix *rtree, vm_page_t page) return (VM_RADIX_PCTRIE_INSERT(&rtree->rt_trie, page)); } +/* + * Insert the page into the vm_radix tree with its pindex as the key. Panic if + * the pindex already exists. Return zero on success or a non-zero error on + * memory allocation failure. Set the out parameter mpred to the previous page + * in the tree as if found by a previous call to vm_radix_lookup_le with the + * new page pindex. + */ +static __inline int +vm_radix_insert_lookup_lt(struct vm_radix *rtree, vm_page_t page, + vm_page_t *mpred) +{ + int error; + + error = VM_RADIX_PCTRIE_INSERT_LOOKUP_LE(&rtree->rt_trie, page, mpred); + if (__predict_false(error == EEXIST)) + panic("vm_radix_insert_lookup_lt: page already present, %p", + *mpred); + return (error); +} + /* * Returns the value stored at the index assuming there is an external lock. *