From nobody Tue May 21 23:56:23 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 4VkWYM52FVz5L6L7; Tue, 21 May 2024 23:56:23 +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 4VkWYM2Yt6z4jC4; Tue, 21 May 2024 23:56:23 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716335783; 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=1V2XoKVh85r6j0/qqMvbXx1HmxozgljMge+E4Tg7Grg=; b=ogSqjB/6fuu8LVk3Md9UPS9DJFAQbYXg5wKQDw5Z4L1xKlqOP4LV1/6urvdwHp+tP3+jYc 6Tv3q8iMeLnVzLRZN1proj95/hwI7EBjDdvm41wVYPvvqY6FgcCjfcJ9d5fueDvY6acvwF LiFdO2RpGIWOy1TU1WmErtletj8ADSWqfh6XrVsBAwNkLECu4BLuT15QQZhXt1vLogXlVq 6e7f9PAT53hOmYFiFG0pc8gwNzwwwEOyl53O2/Qt107W/MBe90j7Q4ZQ4Y/lu9Jn8lNmnc cbZUZnc6GS8Yxr5TG73lIJ6PVbTuJ36LjNgLIxPhdfzUCIn7P6SMeaeEsLSLDg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716335783; a=rsa-sha256; cv=none; b=xXD2u/BHTDEA10lNZfSUvbm6pzVneQSy8MiBOy8ho5UDdlRQwUDkl9Wdda28psuu4vNmv2 nJGkBWTHaodrBmuoKrWZO/CRHaOPXvbS9ahBsuL0dJnBMQzhcInOvKZCDcj6vx8cq6o1Zg J9f7z48ecat8XoYZpFMUOmfB1GPPShuMBbjnm3E+vczS+Rcpdo3T1qOM4s2eAXuWZY1BRa 8arJFO9Hc65bO9eQ+PIdSqUnif8G+PdMuu6JsWRPKVxQ8KcaaKGOdrKzPL6KCdc4hpr3ri 4jYrK3JtpYuATSvJOr4n4HG1Slx9J+bBKgON1vuKvO66AqhHQ4xkCpv9ESzczQ== 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=1716335783; 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=1V2XoKVh85r6j0/qqMvbXx1HmxozgljMge+E4Tg7Grg=; b=GZXOLsfFdnlN+KEPG18XQwbY4Jtyh7qLtIrD5+W8xMb1SctLa3WauYjW1G+jYIdSE6Qf7w r9QhI0CnQxvsbhD/Y/W+UeMlI+7XJTymnNg8RD//3Hw4dR4gjuSrWB08u8Tv52DZH4TsqK SUKRjSP1rRQYF60cWPVGlnFxr5u5K7lBB3P4i8ktpRtvUGSGhzu2+IHLLrcjiGCe8xZlsA /AvVwS+DfqDAxqX6nyG5WtlPNc4MY8ciu3XtLPDwmCm9hFPj3YIFL2dOVQplqIszxGB+wF sSvXE/8LInyvsmZGjsoUZDk0rg2ptRPGuzrHrUkWlDFbs76jmpryKXw6mkx7wA== 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 4VkWYM1xxvzjTv; Tue, 21 May 2024 23:56:23 +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 44LNuN4l032259; Tue, 21 May 2024 23:56:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44LNuN8B032256; Tue, 21 May 2024 23:56:23 GMT (envelope-from git) Date: Tue, 21 May 2024 23:56:23 GMT Message-Id: <202405212356.44LNuN8B032256@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 996fa9fb4ec4 - main - kern/rman: update rman_make_alignment_flags() 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 996fa9fb4ec47995e89d2089e6084d37dcb1033c Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=996fa9fb4ec47995e89d2089e6084d37dcb1033c commit 996fa9fb4ec47995e89d2089e6084d37dcb1033c Author: Elliott Mitchell AuthorDate: 2024-05-09 04:47:09 +0000 Commit: Warner Losh CommitDate: 2024-05-21 23:52:27 +0000 kern/rman: update rman_make_alignment_flags() The flsl() function makes use of hardware functionality to compute the value faster than this loop. The only deviation from flsl() is at 0. Reviewed by: imp,jhb Pull Request: https://github.com/freebsd/freebsd-src/pull/1224 --- sys/kern/subr_rman.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/sys/kern/subr_rman.c b/sys/kern/subr_rman.c index 2019e19090c0..508152f74002 100644 --- a/sys/kern/subr_rman.c +++ b/sys/kern/subr_rman.c @@ -776,19 +776,14 @@ rman_release_resource(struct resource *re) uint32_t rman_make_alignment_flags(uint32_t size) { - int i; /* * Find the hightest bit set, and add one if more than one bit * set. We're effectively computing the ceil(log2(size)) here. */ - for (i = 31; i > 0; i--) - if ((1 << i) & size) - break; - if (~(1 << i) & size) - i++; - - return(RF_ALIGNMENT_LOG2(i)); + if (__predict_false(size == 0)) + return (0); + return (RF_ALIGNMENT_LOG2(flsl(size - 1))); } rman_res_t