From nobody Sun Jul 17 11:24:16 2022 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 4Lm2mc4mbCz4T2BJ; Sun, 17 Jul 2022 11:24:16 +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 4Lm2mc49yVz3PRS; Sun, 17 Jul 2022 11:24:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658057056; 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=ljiXyoL9mHA5MeQKx7y7A1uT5HnW7LShSR/ly6QvC6M=; b=uF9jX8t0zPMBKgYNK7klK3HrjrFfUoT/GnGkmxwGZJbBhjCBAjq77x5n5Sef/Rh+djHTWa +tLJeaCjfOJ4ImOWIL2sgPnsnlsUQ5p2e32EqaPc+j+zWAk0bHntJrRqZT5ElPtLt88n0K M1ZEfJWDypl6Cu2w/9Qozr6UuWhDo6iTmZ7CZMzDE2zMfGImbUPc18kVhl0UBpFjoEWyV7 LwUApA6z7edT9yvFdSa8ITQ4nedP5s1Bk2d9uPqZFqnqoF8/OdePpHcRtsz+yl3uJJLRBu MrVk7YwQSsFcwS/fSB6YbJRXb8keoOkI0N7t1rXyM9j2z41kmjCQmG9FMPgBEQ== 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 4Lm2mc2jY5zy1p; Sun, 17 Jul 2022 11:24:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 26HBOGOa014203; Sun, 17 Jul 2022 11:24:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26HBOGuc014202; Sun, 17 Jul 2022 11:24:16 GMT (envelope-from git) Date: Sun, 17 Jul 2022 11:24:16 GMT Message-Id: <202207171124.26HBOGuc014202@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: cb6757c0a60a - main - swap_pager: Removing handling for objects with OBJ_SWAP clear 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org 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: cb6757c0a60a02d41bed4a47f1e74cf7ac336a6a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658057056; 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=ljiXyoL9mHA5MeQKx7y7A1uT5HnW7LShSR/ly6QvC6M=; b=aLk0GH/PRJ2zutk9xTpqOrJh/Ylxs3/V56Oi1Cu9ctjTZea2WKLxkKPwAX2Yj6P+a71zzp x7GdSCOgO3NlyzOAUY6pm0gHaHbNWxrtGRWjVRZYtFhsj5RlpuEny4w0pbx2VP8J7Tz2XB cFDKoZEBMg+D6vwC0uGkrURsDjFulrZbGFK/syiWAvF/XWaKbQ3rZE4ST1RYOiH6QbtH5s 7PvJxtpgab3MuiN2hyHEZ7wJcAyKBV7O3SXrvqSVyyurGly+B1J6CjV2xqbP34qM+Pg/2Q HsOj9YZjtf1jrXBOjKIicOjplT8m+wezPrM/MPqvYToV+u+LnCf8A0vZ2Jgw0A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658057056; a=rsa-sha256; cv=none; b=UZ6eV93ljR8Ld770TMa+RrFaGRoPQ94yZVDWnauT+dmxifjgkg5JW7OoO3xSE6eYOGD5PH xO895t5W4cjY91pBN+17+1dObQs7VFUtmokfoDOnsksafqn+Ya5cVEZkE3anF8HywECiyg uDlZYYH9nyxvxl5kB96kB8hAvK7gAprUZ1uCY3BpS9YP4OHTTcvZAUNCUplqb0DfSHcIPt +JusW9lRlBbXXOgfQfuf74Kh+RUZMMGYydc4S/Vme7wQyRKdJxWVNB8OgLGWE3rr8zzLu7 1qR6734hwROWEaVnLSlBfEbNOfSA0Er65t9ipLcYbStzgAveGUTmI3BLTVscvw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=cb6757c0a60a02d41bed4a47f1e74cf7ac336a6a commit cb6757c0a60a02d41bed4a47f1e74cf7ac336a6a Author: Mark Johnston AuthorDate: 2022-07-16 15:28:09 +0000 Commit: Mark Johnston CommitDate: 2022-07-17 11:09:48 +0000 swap_pager: Removing handling for objects with OBJ_SWAP clear With the removal of OBJT_DEFAULT, we can assume that pager operations provide an object with OBJ_SWAP set. Also, we do not need to convert objects from type OBJT_DEFAULT. Thus, remove checks for OBJ_SWAP and remove code which modifies the object type. In some places, replace the check for OBJ_SWAP with a check for whether any swap blocks are assigned. Reviewed by: alc, kib Tested by: pho Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35786 --- sys/vm/swap_pager.c | 76 +++++++++-------------------------------------------- 1 file changed, 13 insertions(+), 63 deletions(-) diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index b1acaeb04bd8..931659f1891b 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -1018,9 +1018,11 @@ swp_pager_xfer_source(vm_object_t srcobject, vm_object_t dstobject, daddr_t dstaddr __diagused; KASSERT((srcobject->flags & OBJ_SWAP) != 0, - ("%s: Srcobject not swappable", __func__)); - if ((dstobject->flags & OBJ_SWAP) != 0 && - swp_pager_meta_lookup(dstobject, pindex) != SWAPBLK_NONE) { + ("%s: srcobject not swappable", __func__)); + KASSERT((dstobject->flags & OBJ_SWAP) != 0, + ("%s: dstobject not swappable", __func__)); + + if (swp_pager_meta_lookup(dstobject, pindex) != SWAPBLK_NONE) { /* Caller should destroy the source block. */ return (false); } @@ -1051,8 +1053,6 @@ swp_pager_xfer_source(vm_object_t srcobject, vm_object_t dstobject, * * The source object contains no vm_page_t's (which is just as well) * - * The source object is of type OBJT_SWAP. - * * The source and destination objects must be locked. * Both object locks may temporarily be released. */ @@ -1060,7 +1060,6 @@ void swap_pager_copy(vm_object_t srcobject, vm_object_t dstobject, vm_pindex_t offset, int destroysource) { - VM_OBJECT_ASSERT_WLOCKED(srcobject); VM_OBJECT_ASSERT_WLOCKED(dstobject); @@ -1087,21 +1086,9 @@ swap_pager_copy(vm_object_t srcobject, vm_object_t dstobject, /* * Free left over swap blocks in source. - * - * We have to revert the type to OBJT_DEFAULT so we do not accidentally - * double-remove the object from the swap queues. */ - if (destroysource) { + if (destroysource) swp_pager_meta_free_all(srcobject); - /* - * Reverting the type is not necessary, the caller is going - * to destroy srcobject directly, but I'm doing it here - * for consistency since we've removed the object from its - * queues. - */ - srcobject->type = OBJT_DEFAULT; - vm_object_clear_flag(srcobject, OBJ_SWAP); - } } /* @@ -1454,9 +1441,6 @@ swap_pager_getpages_async(vm_object_t object, vm_page_t *ma, int count, * * Assign swap (if necessary) and initiate I/O on the specified pages. * - * We support both OBJT_DEFAULT and OBJT_SWAP objects. DEFAULT objects - * are automatically converted to SWAP objects. - * * In a low memory situation we may block in VOP_STRATEGY(), but the new * vm_page reservation system coupled with properly written VFS devices * should ensure that no low-memory deadlock occurs. This is an area @@ -1485,23 +1469,11 @@ swap_pager_putpages(vm_object_t object, vm_page_t *ma, int count, ("%s: object mismatch %p/%p", __func__, object, ma[0]->object)); - /* - * Step 1 - * - * Turn object into OBJT_SWAP. Force sync if not a pageout process. - */ - if ((object->flags & OBJ_SWAP) == 0) { - addr = swp_pager_meta_build(object, 0, SWAPBLK_NONE); - KASSERT(addr == SWAPBLK_NONE, - ("unexpected object swap block")); - } VM_OBJECT_WUNLOCK(object); async = curproc == pageproc && (flags & VM_PAGER_PUT_SYNC) == 0; swp_pager_init_freerange(&s_free, &n_free); /* - * Step 2 - * * Assign swap blocks and issue I/O. We reallocate swap on the fly. * The page is left dirty until the pageout operation completes * successfully. @@ -1795,7 +1767,8 @@ swap_pager_swapped_pages(vm_object_t object) int i; VM_OBJECT_ASSERT_LOCKED(object); - if ((object->flags & OBJ_SWAP) == 0) + + if (pctrie_is_empty(&object->un_pager.swp.swp_blks)) return (0); for (res = 0, pi = 0; (sb = SWAP_PCTRIE_LOOKUP_GE( @@ -2025,9 +1998,6 @@ swp_pager_free_empty_swblk(vm_object_t object, struct swblk *sb) /* * SWP_PAGER_META_BUILD() - add swap block to swap meta data for object * - * We first convert the object to a swap object if it is a default - * object. - * * The specified swapblk is added to the object's swap metadata. If * the swapblk is not valid, it is freed instead. Any previously * assigned swapblk is returned. @@ -2043,27 +2013,6 @@ swp_pager_meta_build(vm_object_t object, vm_pindex_t pindex, daddr_t swapblk) VM_OBJECT_ASSERT_WLOCKED(object); - /* - * Convert default object to swap object if necessary - */ - if ((object->flags & OBJ_SWAP) == 0) { - pctrie_init(&object->un_pager.swp.swp_blks); - - /* - * Ensure that swap_pager_swapoff()'s iteration over - * object_list does not see a garbage pctrie. - */ - atomic_thread_fence_rel(); - - object->type = OBJT_SWAP; - vm_object_set_flag(object, OBJ_SWAP); - object->un_pager.swp.writemappings = 0; - KASSERT((object->flags & OBJ_ANON) != 0 || - object->handle == NULL, - ("default pager %p with handle %p", - object, object->handle)); - } - rdpi = rounddown(pindex, SWAP_META_PAGES); sb = SWAP_PCTRIE_LOOKUP(&object->un_pager.swp.swp_blks, rdpi); if (sb == NULL) { @@ -2165,7 +2114,7 @@ swp_pager_meta_transfer(vm_object_t srcobject, vm_object_t dstobject, int i, limit, start; VM_OBJECT_ASSERT_WLOCKED(srcobject); - if ((srcobject->flags & OBJ_SWAP) == 0 || count == 0) + if (count == 0 || pctrie_is_empty(&srcobject->un_pager.swp.swp_blks)) return; swp_pager_init_freerange(&s_free, &n_free); @@ -2232,7 +2181,8 @@ swp_pager_meta_free_all(vm_object_t object) int i; VM_OBJECT_ASSERT_WLOCKED(object); - if ((object->flags & OBJ_SWAP) == 0) + + if (pctrie_is_empty(&object->un_pager.swp.swp_blks)) return; swp_pager_init_freerange(&s_free, &n_free); @@ -2296,9 +2246,9 @@ swap_pager_find_least(vm_object_t object, vm_pindex_t pindex) int i; VM_OBJECT_ASSERT_LOCKED(object); - if ((object->flags & OBJ_SWAP) == 0) - return (object->size); + if (pctrie_is_empty(&object->un_pager.swp.swp_blks)) + return (object->size); sb = SWAP_PCTRIE_LOOKUP_GE(&object->un_pager.swp.swp_blks, rounddown(pindex, SWAP_META_PAGES)); if (sb == NULL)