From nobody Tue Jun 27 17:22:31 2023 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 4QrBNm0pswz4f6JF; Tue, 27 Jun 2023 17:22: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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QrBNm0JHtz3jyj; Tue, 27 Jun 2023 17:22:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687886552; 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=U8R8s+FsxLSy55NGmRA22UdXzSFFPzNJGdE0cDTFVrM=; b=b7m6gjZBnE8Xbvt9pW98XdiCPfA4DdJBT4Shz9yy+ywoyBgCvv08E4RLfvcJtsLEB6eSzx +nWygZ6rucG+rhC/4VAFVEfKt17Ouxn2mdfrwEau9O9/ovVwJ2Z5tJ9pFGI6lBD7dKhuet iOeVvg5avQnjkTMTU7n03E1bMk8ILxQLDBqITIdYe6X54O4SxwsuLuF7TIymQRvARluAzd FoKqXj+HpAFcaQ8+z0F3mct/XjaARmPovwarSJeHPtOSfTqK+cDTOJjRsrD+2pVgvKTMUE 89+Y1Ekp7t7CvstDDrLXjEJHwDw0rhmRMz+6vt3NBsxRllhtgCKIs9vasaZSxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687886552; 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=U8R8s+FsxLSy55NGmRA22UdXzSFFPzNJGdE0cDTFVrM=; b=LjNvaxin9Cf+NJK7KJayh62OB2ouIoZxbb+pjzarhLSqJPrlWj+YrJul3TWRcqFsgrCLFp NtNGJUADklxtyTy3R1cmW76kYrGkN3BQ57UVUtXyRdx97W9FGJjWIXfJTqGkZH1h8qR/6S Z8UfJFluozHW4R1aXX6yTw+JQ6wHVwgQzheqApCfw8cpxerdK+dap6r7p6H6gg9neP7DQ4 i7JKj/d0t+SNz3WGyZx9B1agxlmTAk0zdyKm5WYLwlpk7lzwSgWb8m8gNNHMvc6RMPeOkc RDYMa7lfMHH88C0Okz3tk9QLbWykbhax78sieaORF74+bnX4ybGCKjQLkkdb8Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687886552; a=rsa-sha256; cv=none; b=EsP/9+VI4lZIUTmYgCGXnZaauZfThh5R8jy97XK/w/cz5GZf5aJqKH3oeAv5hkL9BYjk08 S1DsqE0Opn6PwjiJaTgfwoGBFqsiQN6bmi1WopHVQ9ozGVc99v/KpUZo4CA5Ve0S45TxJW PuDi9TH34KzaJCAUQkB2sHiMBe/WgzXtjc6VUmziEC7cOPYuTueUe0m15OXfOGUJODL5xJ oS7/I4l0CwjYnF+JIw+VcgSG2+rj2X7QinTmIXAqXxVmTA6FK8l1aHggQU5Z/D/OSa3Ttx H6l6fvbvCALK/jSRKVjTStaIJ//1AfZ37BHLiC0PLdljQNsJoi0QUQzyi1k7mg== 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 4QrBNl6TGfz11MJ; Tue, 27 Jun 2023 17:22:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 35RHMV8N022208; Tue, 27 Jun 2023 17:22:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35RHMVT6022207; Tue, 27 Jun 2023 17:22:31 GMT (envelope-from git) Date: Tue, 27 Jun 2023 17:22:31 GMT Message-Id: <202306271722.35RHMVT6022207@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: da72505f9c6a - main - radix_trie: pass fewer params to node_get 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da72505f9c6a95009ef710fb1c2b4f2c63cce509 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=da72505f9c6a95009ef710fb1c2b4f2c63cce509 commit da72505f9c6a95009ef710fb1c2b4f2c63cce509 Author: Doug Moore AuthorDate: 2023-06-27 17:21:11 +0000 Commit: Doug Moore CommitDate: 2023-06-27 17:21:11 +0000 radix_trie: pass fewer params to node_get Let node_get calculate it's own owner value. Don't pass the count parameter, since it's always 2. Save 16 bytes in insert(). Move, without modifying, slot and trimkey to handle use-before-declaration problem. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D40723 --- sys/kern/subr_pctrie.c | 47 ++++++++++++++++++++++------------------------- sys/vm/vm_radix.c | 44 +++++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 48 deletions(-) diff --git a/sys/kern/subr_pctrie.c b/sys/kern/subr_pctrie.c index b5dee2163a40..0f28e5ebb2f1 100644 --- a/sys/kern/subr_pctrie.c +++ b/sys/kern/subr_pctrie.c @@ -92,13 +92,29 @@ enum pctrie_access { PCTRIE_SMR, PCTRIE_LOCKED, PCTRIE_UNSERIALIZED }; static __inline void pctrie_node_store(smr_pctnode_t *p, void *val, enum pctrie_access access); +/* + * Return the position in the array for a given level. + */ +static __inline int +pctrie_slot(uint64_t index, uint16_t level) +{ + return ((index >> (level * PCTRIE_WIDTH)) & PCTRIE_MASK); +} + +/* Computes the key (index) with the low-order 'level' radix-digits zeroed. */ +static __inline uint64_t +pctrie_trimkey(uint64_t index, uint16_t level) +{ + return (index & -PCTRIE_UNITLEVEL(level)); +} + /* * Allocate a node. Pre-allocation should ensure that the request * will always be satisfied. */ static struct pctrie_node * -pctrie_node_get(struct pctrie *ptree, pctrie_alloc_t allocfn, uint64_t owner, - uint16_t count, uint16_t clevel) +pctrie_node_get(struct pctrie *ptree, pctrie_alloc_t allocfn, uint64_t index, + uint16_t clevel) { struct pctrie_node *node; @@ -116,8 +132,8 @@ pctrie_node_get(struct pctrie *ptree, pctrie_alloc_t allocfn, uint64_t owner, PCTRIE_UNSERIALIZED); node->pn_last = 0; } - node->pn_owner = owner; - node->pn_count = count; + node->pn_owner = pctrie_trimkey(index, clevel + 1); + node->pn_count = 2; node->pn_clev = clevel; return (node); } @@ -146,23 +162,6 @@ pctrie_node_put(struct pctrie *ptree, struct pctrie_node *node, freefn(ptree, node); } -/* - * Return the position in the array for a given level. - */ -static __inline int -pctrie_slot(uint64_t index, uint16_t level) -{ - - return ((index >> (level * PCTRIE_WIDTH)) & PCTRIE_MASK); -} - -/* Computes the key (index) with the low-order 'level' radix-digits zeroed. */ -static __inline uint64_t -pctrie_trimkey(uint64_t index, uint16_t level) -{ - return (index & -PCTRIE_UNITLEVEL(level)); -} - /* * Fetch a node pointer from a slot. */ @@ -376,8 +375,7 @@ pctrie_insert(struct pctrie *ptree, uint64_t *val, pctrie_alloc_t allocfn) panic("%s: key %jx is already present", __func__, (uintmax_t)index); clev = pctrie_keydiff(*m, index); - tmp = pctrie_node_get(ptree, allocfn, - pctrie_trimkey(index, clev + 1), 2, clev); + tmp = pctrie_node_get(ptree, allocfn, index, clev); if (tmp == NULL) return (ENOMEM); /* These writes are not yet visible due to ordering. */ @@ -408,8 +406,7 @@ pctrie_insert(struct pctrie *ptree, uint64_t *val, pctrie_alloc_t allocfn) */ newind = node->pn_owner; clev = pctrie_keydiff(newind, index); - tmp = pctrie_node_get(ptree, allocfn, - pctrie_trimkey(index, clev + 1), 2, clev); + tmp = pctrie_node_get(ptree, allocfn, index, clev); if (tmp == NULL) return (ENOMEM); slot = pctrie_slot(newind, clev); diff --git a/sys/vm/vm_radix.c b/sys/vm/vm_radix.c index a34de9e6ff92..b3d0d92f9969 100644 --- a/sys/vm/vm_radix.c +++ b/sys/vm/vm_radix.c @@ -119,11 +119,27 @@ static smr_t vm_radix_smr; static void vm_radix_node_store(smrnode_t *p, struct vm_radix_node *v, enum vm_radix_access access); +/* + * Return the position in the array for a given level. + */ +static __inline int +vm_radix_slot(vm_pindex_t index, uint16_t level) +{ + return ((index >> (level * VM_RADIX_WIDTH)) & VM_RADIX_MASK); +} + +/* Computes the key (index) with the low-order 'level' radix-digits zeroed. */ +static __inline vm_pindex_t +vm_radix_trimkey(vm_pindex_t index, uint16_t level) +{ + return (index & -VM_RADIX_UNITLEVEL(level)); +} + /* * Allocate a radix node. */ static struct vm_radix_node * -vm_radix_node_get(vm_pindex_t owner, uint16_t count, uint16_t clevel) +vm_radix_node_get(vm_pindex_t index, uint16_t clevel) { struct vm_radix_node *rnode; @@ -141,8 +157,8 @@ vm_radix_node_get(vm_pindex_t owner, uint16_t count, uint16_t clevel) NULL, UNSERIALIZED); rnode->rn_last = 0; } - rnode->rn_owner = owner; - rnode->rn_count = count; + rnode->rn_owner = vm_radix_trimkey(index, clevel + 1); + rnode->rn_count = 2; rnode->rn_clev = clevel; return (rnode); } @@ -171,23 +187,6 @@ vm_radix_node_put(struct vm_radix_node *rnode, int8_t last) uma_zfree_smr(vm_radix_node_zone, rnode); } -/* - * Return the position in the array for a given level. - */ -static __inline int -vm_radix_slot(vm_pindex_t index, uint16_t level) -{ - - return ((index >> (level * VM_RADIX_WIDTH)) & VM_RADIX_MASK); -} - -/* Computes the key (index) with the low-order 'level' radix-digits zeroed. */ -static __inline vm_pindex_t -vm_radix_trimkey(vm_pindex_t index, uint16_t level) -{ - return (index & -VM_RADIX_UNITLEVEL(level)); -} - /* * Fetch a node pointer from a slot in another node. */ @@ -416,8 +415,7 @@ vm_radix_insert(struct vm_radix *rtree, vm_page_t page) panic("%s: key %jx is already present", __func__, (uintmax_t)index); clev = vm_radix_keydiff(m->pindex, index); - tmp = vm_radix_node_get(vm_radix_trimkey(index, - clev + 1), 2, clev); + tmp = vm_radix_node_get(index, clev); if (tmp == NULL) return (ENOMEM); /* These writes are not yet visible due to ordering. */ @@ -447,7 +445,7 @@ vm_radix_insert(struct vm_radix *rtree, vm_page_t page) */ newind = rnode->rn_owner; clev = vm_radix_keydiff(newind, index); - tmp = vm_radix_node_get(vm_radix_trimkey(index, clev + 1), 2, clev); + tmp = vm_radix_node_get(index, clev); if (tmp == NULL) return (ENOMEM); slot = vm_radix_slot(newind, clev);