From nobody Mon Nov 23 01:21:06 2026 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 4jXp6q3spZz71V62 for ; Mon, 23 Nov 2026 01:21:07 +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) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jXp6p6nVPz4gF1 for ; Mon, 23 Nov 2026 01:21:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795396867; 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=kZaq16cKffD8XD0xhEOjLuEhq2TQI49kAkxI/uOUdsI=; b=jSdRmSaGEELb/ckBodsH1yHbeyu2CguPXbkPP/jdmA5eFQd86f5ivYiaY/51zUEIF7636p 24G94FLwM6M4v/MINQiFLnj3/482f06rQJ8Pihfg8tfhq+OZY0aSewVKadFMNG9hPieYUS 1WEQJOSCpWs6DZlfMHvuChZy6JH8o05k25a45Vj+Rq8YfqjJBSko+7gQaQShEL9/4bCov1 yA8Vjjej5hOBQnUfizd47oDpfKrABlJ3QxYMeqr0013jOAVyKnTr/durUob20ewIkCb4TY FsE5wimt8fq1iKRwQRxIIqyYR/mY/MFtltmT7BPTyjUvr2g29H/mEYl7Ls7ANg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795396867; b=bZEp0t3P/RU2HS8XpY73YrDAc1AHCm4ogJMayih2MgUPwP7E6chg4oatGljUb4cr9uu/Qu U3alcM7MkXUx6kUyPIv5+zzdYNJmSFWv4CN8D5BpW9E0Wr2dWHptOpyts6c5ypRn4M4DBa UdZyaGueggPFOD9y4I+mJOp8xD7iATTW9KxvIlfv28zRNSe8aZerX00DQ+4mM2V9npxbgP BfFBGeDui4O1JkWAkfbCwSmOpWTerCy3VjWTuYXaNbK+MlKOM+q4UL3fxvW+VSiEbpom+S 1NBzj0R4vnhAOKt6phJt89Jl+A+AU+KTR1G6pFdoAZbmb6iuC02cxmMVaKHP3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795396867; 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=kZaq16cKffD8XD0xhEOjLuEhq2TQI49kAkxI/uOUdsI=; b=gOObDjniZyeFM/mlCcqGvXshmrTYuVRZQinl8+cSXolvBPFQTy5GnC5aeRWgu0tpBNu5jE HubjKHNz8sIhqqHWXRVGaNHV/dlUqSUiA1qT847BpMSe4qqQje9BQPWRh8SBoGO9b9TXr0 /hpiZncV1H30k8jLlAn1UayTvLpsS0lY7sSf+LR75SYuhMgJRM4BKrusk5TeFUZJT3OT/j 2kDGGNJiSy1ib2lBtYu9Jtb0ErcbeRQja9kA3fh1g3or7QFXbgZ+7RcGtPEWkKjX4NbV4f 1QzWotiH2Vqi2tPesdBv6hx9KfulrXn+swOfzBN74Vg6Rzz94MhDE7qrkY+PMw== 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 4jXp6p5hjQzSHL for ; Mon, 23 Nov 2026 01:21:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 4928 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 23 Nov 2026 01:21:06 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 24e09265f924 - main - swap_pager: Keep the object stable in swap_pager_swapoff_object() List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main X-BeenThere: dev-commits-src-main@freebsd.org List-Id: Commit messages for the main branch of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 24e09265f9242965180c6c8b03f3c5c79acf1006 Auto-Submitted: auto-generated Date: Mon, 23 Nov 2026 01:21:06 +0000 Message-Id: <6b039502.4928.63a49d90@gitrepo.freebsd.org> The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=24e09265f9242965180c6c8b03f3c5c79acf1006 commit 24e09265f9242965180c6c8b03f3c5c79acf1006 Author: Mark Johnston AuthorDate: 2026-11-23 01:19:56 +0000 Commit: Mark Johnston CommitDate: 2026-11-23 01:19:56 +0000 swap_pager: Keep the object stable in swap_pager_swapoff_object() Several operations in the inner loop may drop the object lock, with nothing preventing the object from being freed and recycled in that window. Fix this: bump the paging-in-progress counter across the whole operation. Don't bother freeing swap blocks from a dead object: the terminating thread deals with that, and swap_pager_swapoff_object()'s caller will retry if needed. Reported by: llm-postcr Reviewed by: alc, kib MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D61932 --- sys/vm/swap_pager.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index ff29d93c552a..29d01b97f4a4 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -1923,6 +1923,12 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object, KASSERT((sp->sw_flags & SW_CLOSING) != 0, ("%s: Device not blocking further allocations", __func__)); + /* + * Make sure that the object doesn't get freed while paging or + * allocating memory. + */ + vm_object_pip_add(object, 1); + vm_page_iter_init(&pages, object); swp_pager_init_freerange(&range); sb = swblk_iter_init(&blks, object, 0); @@ -1972,7 +1978,6 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object, } /* Get the page from swap, and restart the scan. */ - vm_object_pip_add(object, 1); rahead = SWAP_META_PAGES; rv = swap_pager_getpages_locked(&blks, object, &m, 1, NULL, &rahead, *bp); @@ -1981,7 +1986,6 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object, __func__, rv); *bp = uma_zalloc(swrbuf_zone, M_WAITOK); VM_OBJECT_WLOCK(object); - vm_object_pip_wakeupn(object, 1); KASSERT(vm_page_all_valid(m), ("%s: Page %p not all valid", __func__, m)); vm_page_deactivate_noreuse(m); @@ -1991,17 +1995,11 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object, if (i < SWAP_META_PAGES) { /* * The object lock has been released and regained. - * Perhaps the object is now dead. + * Perhaps the object is now dead. If so, the + * terminating thread will free its swap blocks. */ - if ((object->flags & OBJ_DEAD) != 0) { - /* - * Make sure that pending writes finish before - * returning. - */ - vm_object_pip_wait(object, "swpoff"); - swp_pager_meta_free_all(object); + if ((object->flags & OBJ_DEAD) != 0) break; - } /* * The swapblk could have been freed, so reset the pages @@ -2025,6 +2023,8 @@ swap_pager_swapoff_object(struct swdevt *sp, vm_object_t object, sb = swblk_iter_next(&blks); } swp_pager_freeswapspace(&range); + + vm_object_pip_wakeupn(object, 1); } /*