From nobody Fri Dec 26 22:08:53 2025 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 4ddKWn3s37z6MCn1 for ; Fri, 26 Dec 2025 22:08:53 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ddKWn1dJKz3bdk for ; Fri, 26 Dec 2025 22:08:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766786933; 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=E0tyNavNGo9lHQFjOa5qdnPWDd3ItDCf/UAf5DOYCUk=; b=xkoVmemMbRgHJX4H/N2poo0VkWNk+Tk+rVjEbFcQuCKXMta1oqUcj+zASnRPQ+2wp63p8x 1W932ebKzpeImuYFS/RpB01XOdVBi27q0b4c9Woh9d6rLXuur90VRZsBfmmwmt/OZeDGOy XSYUxetclVWflfc9waGcEZnuUrPr+Ajlpu+ljaDQwqKQpLkgOX+EmpbgjdGMHfy5x1NG03 9+C2ET52M88u7LUE3k+gBAIk9aAkb6zvTxX5DJYZWQAPjBm0Cw6IN3zR3KfQujCPpnXaTK beN8iuSgbQel/RJGyqJ5KCTgO8bHqUC597QZhuOR0IHhKyf0/KLQCAfhvhL5vA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1766786933; 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=E0tyNavNGo9lHQFjOa5qdnPWDd3ItDCf/UAf5DOYCUk=; b=wxVZDTEllAP1JYuNxLVw1+fI7aw2M6oAkTrCkxQ8B1lVUYbyGna0Da++M1HjUt+S9LbqFL t57Qz7ug9NcnSgL8izCwjpkjNfkPvBhVXSOerocTEfg3fwqqv+Fi+mTYVyd5zw8OgmxsJX owQPpZPwjLtItMeUhzxJf21TID0tIzFaK0k23vHBNipyYZG0tuS9dJi2UtmIheN9wySjR4 olUr/6wa/7sldSE4eDu1S47qEt6X2icSm4eyth1RNSPPHbLGFXmxTXtP/kn9fP5Yh4phqU fMItdG+hV87y68wDeRIqkcQEh6f4so8y2Xf6rMB3X9emVoxPbp+jT3ckaFTzeQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1766786933; a=rsa-sha256; cv=none; b=Oy7/wC/mjgej9cTbQyI1L7EbzyZ6PsK6uoXizn/gg4X2hFN7SpCBPP4/lBko8BAEGJYJ26 hHZ0Vp461hQaPiNWu8ZJ46Ntv8WnXI8tylG7cgj7NC0OVqgxbmJthfbkXwOBkIi5wNpAF2 S/rqghbl4UzfUdGEB3k8RX9xLuNwZ6OsiMTI6rmSOUFQsIS6jJGo6oZC0qIsAZQAX0EUyG mhCEMRlYpd295fLj/4cjWg8ZLMNZNzumQFigFngDzl4pHddtqUqyUeY+pBBN23dZ7Cu9nA 6/JvbVSnnHnBcDfDpIfMMD4fxQVjbeWoiZqinFmHvRI8dflLx0Bz7DsED4N0+w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4ddKWn19kMzXdD for ; Fri, 26 Dec 2025 22:08:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id a291 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 26 Dec 2025 22:08:53 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Doug Moore Subject: git: 939ac0c8fde2 - main - vnode_pager: clean up undirty_pages() 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: 939ac0c8fde22a4ad9cb9bfb5d94f29cad6ea040 Auto-Submitted: auto-generated Date: Fri, 26 Dec 2025 22:08:53 +0000 Message-Id: <694f0775.a291.3c7343ca@gitrepo.freebsd.org> The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=939ac0c8fde22a4ad9cb9bfb5d94f29cad6ea040 commit 939ac0c8fde22a4ad9cb9bfb5d94f29cad6ea040 Author: Doug Moore AuthorDate: 2025-12-26 22:07:34 +0000 Commit: Doug Moore CommitDate: 2025-12-26 22:07:34 +0000 vnode_pager: clean up undirty_pages() The first (second) loop of vnode_pager_undirty_pages() includes an if-test to test whether an iteration is the last (first). Move those if-tests out of their loops. That allows the compiler to unroll the loops. Reviewed by: alc, kib Differential Revision: https://reviews.freebsd.org/D54353 --- sys/vm/vnode_pager.c | 76 +++++++++++++++++++++++++--------------------------- 1 file changed, 37 insertions(+), 39 deletions(-) diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 040b4037df15..3504c90821e5 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -1523,49 +1523,47 @@ void vnode_pager_undirty_pages(vm_page_t *ma, int *rtvals, int written, off_t eof, int lpos) { - int i, pos, pos_devb; + int i, npages, pos; - if (written == 0 && eof >= lpos) - return; - for (i = 0, pos = 0; pos < written; i++, pos += PAGE_SIZE) { - if (pos < trunc_page(written)) { - rtvals[i] = VM_PAGER_OK; - vm_page_undirty(ma[i]); - } else { - /* Partially written page. */ - rtvals[i] = VM_PAGER_AGAIN; - vm_page_clear_dirty(ma[i], 0, written & PAGE_MASK); - } + /* Process pages up to round_page(written) */ + pos = written & PAGE_MASK; + npages = atop(written); + for (i = 0; i < npages; i++) { + rtvals[i] = VM_PAGER_OK; + vm_page_undirty(ma[i]); + } + if (pos != 0) { + /* Partially written page. */ + rtvals[i] = VM_PAGER_AGAIN; + vm_page_clear_dirty(ma[i], 0, pos); } - if (eof >= lpos) /* avoid truncation */ - return; - for (pos = eof, i = OFF_TO_IDX(trunc_page(pos)); pos < lpos; i++) { - if (pos != trunc_page(pos)) { - /* - * The page contains the last valid byte in - * the vnode, mark the rest of the page as - * clean, potentially making the whole page - * clean. - */ - pos_devb = roundup2(pos & PAGE_MASK, DEV_BSIZE); - vm_page_clear_dirty(ma[i], pos_devb, PAGE_SIZE - - pos_devb); - /* - * If the page was cleaned, report the pageout - * on it as successful. msync() no longer - * needs to write out the page, endlessly - * creating write requests and dirty buffers. - */ - if (ma[i]->dirty == 0) - rtvals[i] = VM_PAGER_OK; + /* Process pages from trunc_page(eof) to round_page(lpos) */ + pos = eof & PAGE_MASK; + i = atop(eof); + npages = atop(lpos); + if (i < npages && pos != 0) { + /* + * The page contains the last valid byte in the + * vnode, mark the rest of the page as clean, + * potentially making the whole page clean. + */ + pos = roundup2(pos, DEV_BSIZE); + vm_page_clear_dirty(ma[i], pos, PAGE_SIZE - pos); - pos = round_page(pos); - } else { - /* vm_pageout_flush() clears dirty */ - rtvals[i] = VM_PAGER_BAD; - pos += PAGE_SIZE; - } + /* + * If the page was cleaned, report the pageout on it + * as successful. msync() no longer needs to write + * out the page, endlessly creating write requests + * and dirty buffers. + */ + if (ma[i]->dirty == 0) + rtvals[i] = VM_PAGER_OK; + i++; + } + for (; i < npages; i++) { + /* vm_pageout_flush() clears dirty */ + rtvals[i] = VM_PAGER_BAD; } }