From nobody Mon Nov 23 01:21:06 2026 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 4jXp6q3Httz71Tyh 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 4jXp6p6TwNz4gNL 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=1795396866; 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=NuuathuSfhNcvrSStjSQB194rUN31SxQQ6Bxds6+YSTDjP6ZBWVG0w50Eonx2IcD4MboM6 83h+42mm9kYrrk66bT4Ira5K8hrKWBCc8J4ZD7tocL5tKW91EyeO98Ksx8RE8waIwMf+0H LSrlHsbQA4gYySDtktzTikMFSrIxoG8aqH+gqMa4FM1VQ7rnhJub3D55izulUF6NVDL5kK 1yx9SFCLuqFWQMcFUi2vfFiRWjAb62m81FqzihdAhg23VmSjdBg9YWYmk950rw8xT2MUpl kS5fUwtZV82b9noRnZv5VVkyHy5wTDayI9o76JcGa0ofFzYmKaaKxLU1GivmFg== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1795396866; b=BhaA9MYqEqb7q6o9lTApsQb9Q9IcOmoUBDmq215MPRCSxzKvuG+QNOpUB3hQ3RMwfxgkhg 6ke8pdBG753y74Ef6ODJyEMPYoZGOW8tTEloIXiTv9ZaEsQ3uVdFLTz2lWTcSTEl5cJaXT bTtZNkzSYa69bXhyLvzEoiYEYrjIp5fu/ciz5kmU+jHWxwT4UI5woMhQeaGc/EpucZ9KqZ bpqfd6eSVarjYTMEH5/ujBcCYuNc2ewYyeH+eFhDnwpIuAqPQDCDmWm7947EtR+PMmk+E2 0ic6pCR/pemfUECXmwif1I4i6uJ8avYLqeiOeH0nb/YY/KePSLe8TM0g4nWiEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1795396866; 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=F4gYnSlTnWzqfLkpA46i3teLdx/AnaDYUSszmY+vit042erm/p4qHE34GCgWhZ1or/kzns 5XejPYXv9myJM2tpRXNTX+vIIKCqP78ojX5AAKBNXY861QbWtk3i7HBi91LJ7L8Ll1eSYi ydmdWxPOxyNwpae5Hcmz8KKMmC08pUEzowQhcPgIVny4fuVHAeRzCbjcQOiZJH435CArEV e6HOIc/PHZ5Wq8F3Tb+iBd+UuEDByE4FFToQM0DAjvmeDwrLSWcaGeWHlznaXgqRQyG93D BKQIzdGMrXvyz7BKf8+xgJ5T4OHK5f+8Nti5OwNB8AlOtO4XIHomrdbgTIBkIA== 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 4jXp6p5hclzSHK 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-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches 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); } /*