From nobody Sun Jul 17 11:24:15 2022 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 4Lm2mb3JYXz4T1xD; Sun, 17 Jul 2022 11:24:15 +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 4Lm2mb2jX9z3PBf; Sun, 17 Jul 2022 11:24:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658057055; 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=Cit8iYhH+Yw75GyPWky/Fn222kTazItP8d3ClN+1eBo=; b=AZXyzJlzVtv2daxWMRq/AngP8L1E+EO60Kx+DEg10qga/h19oKn+gI6W6IOEP73w6FEKhf IxeqKQKQUsG5o36sCrGonBsC+9k0+wCIHYfpZOarkPPQevnt2cq2s/7oY9MhYhL1eSujbp 4TfRiJsEhhNw9jRg6KserZD+Ru3HMfEsaD2Gmj8VFAIMiNWuqzLD1SQb/c9ihanMEX8XSk PsTx0iL/J/bZbWOSoIshSSO9w56vRXztExpRzh3CyTUxh6005gVfsKUGgaA/+E0mmL4S+y zJ01neNeEYvsgy+mHN5aOWTMNi+RjOP9s5wGufR84M8oaxEkj4WsVjddUVZaTw== 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 4Lm2mb1k7xzy4d; Sun, 17 Jul 2022 11:24:15 +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 26HBOFbK014177; Sun, 17 Jul 2022 11:24:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26HBOFmv014176; Sun, 17 Jul 2022 11:24:15 GMT (envelope-from git) Date: Sun, 17 Jul 2022 11:24:15 GMT Message-Id: <202207171124.26HBOFmv014176@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: 5d32157d4e5c - main - vm_object: Modify vm_object_allocate_anon() to return OBJT_SWAP objects 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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: 5d32157d4e5c2dfda5ca39d40bf4620b04fc2b29 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1658057055; 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=Cit8iYhH+Yw75GyPWky/Fn222kTazItP8d3ClN+1eBo=; b=ve8fonLJLDSgd9i3nuD/7dnKua6NnJ6qyGa5n9AtIhST/P7ms4jm6QeVd6DToHrLkcLZLx 1Qvm5/9xcNORBVDfPL/20MURyQReHh2C+nRKlwRxJApvy5GlQcjRbLeHEIk2kKBQiATnow 8wknfStVciFzrM24yS3VcGR+5hTKb0CLHRvVmvdCuDqtwyoRVdtRLRPZpmzyHWYNTdILmc Sxm9GCiHVRnC6w3zvgXHaHkTfqBJu/KvyEfWwluTpS9fyQb1kUjSI9knxGvczC+xW3VqAR T0G7YPisIAUvQtZ9DUgWTKyjVxwhlBVdlmxpj9irW8tmDMbVQlC6DBGzVUAtMw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1658057055; a=rsa-sha256; cv=none; b=cfI1fjI+Jj03gdRFzzEbfMx8Ys2XYnaly/h8/WAE4Eu7JAHkhy6fj104yb6dSbh0et9IGk pzQNtqiwtLE3BNGtJXjK3ydbUYzSLCYjY0XhprEl2nWIw6DfO9d2RjIQE8oV8av6OV3+Qs WVw6Onuts/qoPb5aoJHddi0QsnbEbf5tdaULAJ26bZ2lQH+KWUmV4QcTeGpZG5+Yz2WhTy F+46V13XBdQJG0A028V9OjpVVfOfwe818XdW1kcoxYb7JFkbM/DgDYqaAUv/lIKHV0h0vC lYoEQs/aKVV1kuY0hgoO8lEcJ0JvFJ/ZtnjsLsbvOPuM8yofArVAdmRGrV5UGA== 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=5d32157d4e5c2dfda5ca39d40bf4620b04fc2b29 commit 5d32157d4e5c2dfda5ca39d40bf4620b04fc2b29 Author: Mark Johnston AuthorDate: 2022-07-16 15:27:27 +0000 Commit: Mark Johnston CommitDate: 2022-07-17 11:09:48 +0000 vm_object: Modify vm_object_allocate_anon() to return OBJT_SWAP objects With this change, OBJT_DEFAULT objects are no longer allocated. Instead, anonymous objects are always of type OBJT_SWAP and always have OBJ_SWAP set. Modify the page fault handler to check the swap block radix tree in places where it checked for objects of type OBJT_DEFAULT. In particular, there's no need to invoke getpages for an OBJT_SWAP object with no swap blocks assigned. Reviewed by: alc, kib Tested by: pho Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35785 --- sys/vm/vm_fault.c | 25 ++++++++++++++++++++----- sys/vm/vm_object.c | 8 +++++--- sys/vm/vm_object.h | 3 ++- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index c379301f866f..d398be941e84 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -85,6 +85,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -220,6 +221,21 @@ fault_page_free(vm_page_t *mp) } } +/* + * Return true if a vm_pager_get_pages() call is needed in order to check + * whether the pager might have a particular page, false if it can be determined + * immediately that the pager can not have a copy. For swap objects, this can + * be checked quickly. + */ +static inline bool +fault_object_needs_getpages(vm_object_t object) +{ + VM_OBJECT_ASSERT_LOCKED(object); + + return ((object->flags & OBJ_SWAP) == 0 || + !pctrie_is_empty(&object->un_pager.swp.swp_blks)); +} + static inline void unlock_map(struct faultstate *fs) { @@ -1406,10 +1422,9 @@ vm_fault_object(struct faultstate *fs, int *behindp, int *aheadp) /* * Page is not resident. If the pager might contain the page * or this is the beginning of the search, allocate a new - * page. (Default objects are zero-fill, so there is no real - * pager for them.) + * page. */ - if (fs->m == NULL && (fs->object->type != OBJT_DEFAULT || + if (fs->m == NULL && (fault_object_needs_getpages(fs->object) || fs->object == fs->first_object)) { res = vm_fault_allocate(fs); if (res != FAULT_CONTINUE) @@ -1422,7 +1437,7 @@ vm_fault_object(struct faultstate *fs, int *behindp, int *aheadp) * object without dropping the lock to preserve atomicity of * shadow faults. */ - if (fs->object->type != OBJT_DEFAULT) { + if (fault_object_needs_getpages(fs->object)) { /* * At this point, we have either allocated a new page * or found an existing page that is only partially @@ -1841,7 +1856,7 @@ vm_fault_prefault(const struct faultstate *fs, vm_offset_t addra, if (!obj_locked) VM_OBJECT_RLOCK(lobject); while ((m = vm_page_lookup(lobject, pindex)) == NULL && - lobject->type == OBJT_DEFAULT && + !fault_object_needs_getpages(lobject) && (backing_object = lobject->backing_object) != NULL) { KASSERT((lobject->backing_object_offset & PAGE_MASK) == 0, ("vm_fault_prefault: unaligned object offset")); diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index 4272a734b233..57904454eff7 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -244,8 +244,10 @@ _vm_object_allocate(objtype_t type, vm_pindex_t size, u_short flags, object->type = type; object->flags = flags; - if ((flags & OBJ_SWAP) != 0) + if ((flags & OBJ_SWAP) != 0) { pctrie_init(&object->un_pager.swp.swp_blks); + object->un_pager.swp.writemappings = 0; + } /* * Ensure that swap_pager_swapoff() iteration over object_list @@ -473,8 +475,8 @@ vm_object_allocate_anon(vm_pindex_t size, vm_object_t backing_object, else handle = backing_object; object = uma_zalloc(obj_zone, M_WAITOK); - _vm_object_allocate(OBJT_DEFAULT, size, OBJ_ANON | OBJ_ONEMAPPING, - object, handle); + _vm_object_allocate(OBJT_SWAP, size, + OBJ_ANON | OBJ_ONEMAPPING | OBJ_SWAP, object, handle); object->cred = cred; object->charge = cred != NULL ? charge : 0; return (object); diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 80e84dcabf98..719198637726 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -202,7 +202,8 @@ struct vm_object { #define OBJ_SIZEVNLOCK 0x0040 /* lock vnode to check obj size */ #define OBJ_PG_DTOR 0x0080 /* dont reset object, leave that for dtor */ #define OBJ_SHADOWLIST 0x0100 /* Object is on the shadow list. */ -#define OBJ_SWAP 0x0200 /* object swaps */ +#define OBJ_SWAP 0x0200 /* object swaps, type will be OBJT_SWAP + or dynamically registered */ #define OBJ_SPLIT 0x0400 /* object is being split */ #define OBJ_COLLAPSING 0x0800 /* Parent of collapse. */ #define OBJ_COLORED 0x1000 /* pg_color is defined */