From nobody Mon Jul 29 18:02:32 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 4WXmRD2H6yz5RhGn; Mon, 29 Jul 2024 18:02: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 4WXmRD1mftz4QR9; Mon, 29 Jul 2024 18:02:32 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722276152; 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=VvewLn8LFCzmYOttrrzatU9JqhAkzf97Q9HBz7ca9mo=; b=wX6ay/LSRPO3uVK9+6u5IMdUIKEz9GlYGnC9a/sPQK3F4Pk1LDzDoGtDKOCxlFHx7SWsvK zHCaI+f54jjUKcHjI/yTP96LwMiupyJwwghXMiFykiacX/vsioAL+aqe5+rOBSnW3bYeL/ Fv5b+iAOoQaE8Huef7p5w8XeQr0KKjWNH90XQx8+/6QnQnkKpVZSp4eMXNFbA5kxDUxBNp /BKd3GQJMsRjSiWNx258qmlWTY98uvDPEbyg9DqmT/tGyH8HatLbM98D6OiFpDQZafkPxF IrR1xL+hT9C52baXtlCqH/EcC4oYQBfzDe5e/yZ6eo63A/s4BMvPQ/QrIa7ZnA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722276152; a=rsa-sha256; cv=none; b=B1BSWo8r7W/3y4zJdgPGHeIJy9DBdBHJY7fm776YjweBYKNvMSSuIkwtPutuXHetPrFpgI 2d76S4MVhPasmVKLnNSZFMFVXca1VyclI6UbR3TChiPJ9OZQB7ZUcILH46/p44qQ4752Os +XmyQOrpJoYxpwAFB29MaBawdvmVjBqymS3BMsiBGE4wyppWQmmCdhFLUwGYIMBdfdYYM7 SNoHDi9YGptpaf1uv2h/j8bWgktxT9+XLuwONqd6VFB6CqtT52X+nB8b/b7aox6FVNGCfB JkM79UEirH/S7XvWftZplGILhYSXXkVERO4QnG4oSvQUbTpodNv+3wbre+HLGQ== 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=1722276152; 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=VvewLn8LFCzmYOttrrzatU9JqhAkzf97Q9HBz7ca9mo=; b=xI/SCWj+EAsA6CsIfT6Ryq3j0DP1Rj2SfepfQiBUkDEtYUj0Bf60ScRRTvw89PIqAGozmv uKocNcRrvHvM0t5uucM9fTIG1wb3DFcxVC+hA4IwY7/QxIqEp65m+lcjZ5UTJSNY2XsqHL goQJviNjOCY+9Wyzj+/JrVor1K5nGIezamiAvM6z3qbfVm4Meth4VAnaI7s/IztwvadRWp jhOlxWqU1OuQMtogaQoUPxRjMZXd+/58ookCAhu0he6aRvd0XUE7Vfg8AyoP6TgmI2RQ0R 22Bg+82v2uEHpkWccx7EHxTgIMO5E4TzoHPNKIcl/fydIwhLBzb/5phAkc3Shg== 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 4WXmRD1Mvxzl4G; Mon, 29 Jul 2024 18:02:32 +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 46TI2W2U057721; Mon, 29 Jul 2024 18:02:32 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46TI2WA8057718; Mon, 29 Jul 2024 18:02:32 GMT (envelope-from git) Date: Mon, 29 Jul 2024 18:02:32 GMT Message-Id: <202407291802.46TI2WA8057718@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: 4113ea3403fc - main - vm_object: speed up page collect flush 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: dougm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4113ea3403fc6abc5e3c51eb027ccef714c89270 Auto-Submitted: auto-generated The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=4113ea3403fc6abc5e3c51eb027ccef714c89270 commit 4113ea3403fc6abc5e3c51eb027ccef714c89270 Author: Doug Moore AuthorDate: 2024-07-29 17:59:24 +0000 Commit: Doug Moore CommitDate: 2024-07-29 18:02:13 +0000 vm_object: speed up page collect flush vm_pageout_cluster prepares an array for passing to vm_pageout_flush by starting in the middle of a double-sized array and working out from the middle. Using the same technique in vm_object_page_collect_flush saves one loop that traverses a piece of linked list, and 80 bytes of amd64 binary code. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D46173 --- sys/vm/vm_object.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 0af4402938ba..be21081255c2 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -1115,17 +1115,14 @@ static int vm_object_page_collect_flush(vm_object_t object, vm_page_t p, int pagerflags, int flags, boolean_t *allclean, boolean_t *eio) { - vm_page_t ma[vm_pageout_page_count], p_first, tp; - int count, i, mreq, runlen; + vm_page_t ma[2 * vm_pageout_page_count], tp; + int count, mreq, runlen; vm_page_lock_assert(p, MA_NOTOWNED); vm_page_assert_xbusied(p); VM_OBJECT_ASSERT_WLOCKED(object); - - count = 1; - mreq = 0; - - for (tp = p; count < vm_pageout_page_count; count++) { + ma[vm_pageout_page_count] = p; + for (count = 1, tp = p; count < vm_pageout_page_count; count++) { tp = vm_page_next(tp); if (tp == NULL || vm_page_tryxbusy(tp) == 0) break; @@ -1133,24 +1130,22 @@ vm_object_page_collect_flush(vm_object_t object, vm_page_t p, int pagerflags, vm_page_xunbusy(tp); break; } + ma[vm_pageout_page_count + count] = tp; } - for (p_first = p; count < vm_pageout_page_count; count++) { - tp = vm_page_prev(p_first); + for (mreq = 0, tp = p; count < vm_pageout_page_count; count++, mreq++) { + tp = vm_page_prev(tp); if (tp == NULL || vm_page_tryxbusy(tp) == 0) break; if (!vm_object_page_remove_write(tp, flags, allclean)) { vm_page_xunbusy(tp); break; } - p_first = tp; - mreq++; + ma[vm_pageout_page_count - 1 - mreq] = tp; } - for (tp = p_first, i = 0; i < count; tp = TAILQ_NEXT(tp, listq), i++) - ma[i] = tp; - - vm_pageout_flush(ma, count, pagerflags, mreq, &runlen, eio); + vm_pageout_flush(&ma[vm_pageout_page_count - mreq], count, pagerflags, + mreq, &runlen, eio); return (runlen); }