From nobody Mon Jul 11 19:58:58 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 52C4912AE550; Mon, 11 Jul 2022 19:58:58 +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 4LhZTG1yHwz3h4M; Mon, 11 Jul 2022 19:58:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657569538; 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=E7WVhDR4xFEV7dNv8GDGD0cYvE9+M6nk2+m3/pT1WG8=; b=NTyy0d0+5d3iIp9RzWSW09uvxbMAATjf0bghc3u1JUnszhHP+opUtyxNE7zmCuqzptt4JT +VlRSj7XyfQ4USXxqP1QFXUUup3VpyBKqnQgmaMjEGUsjCuoPgcSESxiO43lB60j2995wL m7c9Bfv5kG7Nn3e5COhnb1bNZTXge2/o0yzD38pFkRe6MfKm6nSVhvtpfQfQbGntc5kBY2 gRe7ECE3sUZtFz+mD9fNhceP6uO4Jhkqz0S3I4qCTcEP59ofZhr5JQfkqbP6yGrQVernIM I/0O1kfogtH4Z3c3UF/XxZ4f6EmKZboaOsTE2ZAAJZKn0fyuySdP3rnGrVuB2A== 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 4LhZTG11n3zGtk; Mon, 11 Jul 2022 19:58:58 +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 26BJww9N003160; Mon, 11 Jul 2022 19:58:58 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 26BJww80003159; Mon, 11 Jul 2022 19:58:58 GMT (envelope-from git) Date: Mon, 11 Jul 2022 19:58:58 GMT Message-Id: <202207111958.26BJww80003159@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: b57be759d079 - main - vm_fault: Fix some nits in vm_fault_copy_entry() 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: b57be759d079d40aa6ec75207faadce5ae1484a2 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1657569538; 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=E7WVhDR4xFEV7dNv8GDGD0cYvE9+M6nk2+m3/pT1WG8=; b=MJMstbHaYjhFUQSmRh1mU4VaiyW96m73ejn7x8gnFFl7guDU31J8UdYRMjzwNrWjQDFtav KKLOof75y9JFmZ8nS5uen1OzwMDKuJPPdKJfuPNYi57HUPhEBattjL0/FMoUXbKGhOAyEo HEALbpPboCyAGAxbTZQjsG3ap0EtiOzHtCJAfbgZ+NdJ6aaGXGXsmGZwbx3Sv2sqVLybvd KbG+p7MfZu28ZjR4UbAnIc7xZEYzbTNdfgqBWYd/UonJ0XERSCFwEfPCfvXD/rjSmk9hD8 IYdWGJYq332eZewPq7siLnKMX9o4DdZFCtV00M2W/h93DFl6klZZJhoFxvR62g== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1657569538; a=rsa-sha256; cv=none; b=l8jivEyGFQeswNEe4y5A7hPm8d9fyIkDCMaIrI52Vobiy/HX6/jn2jIOrhYhgmyJlF/oUS WoGxoINJ/R1SFbuvtAnJsjpieuSwkmUjP9CZ/ApHpBpwqBZ03RON7LJUAP3AaWU9IQ3f2u vluscCt3utS6ydBKqx6RIDXokhS31lAv5Ld/FAzRisAr1knXeKP0iQJiYIJcV5oMZubCxv fEHvFl9SfCcfrsfWa+la4U8UF0z5HgNVHKlKehWRJyIpWY7wBIa0BqLACJqAPzdn5AINfq CkdZflvF8YYI8N3QkfJywTO5T6OuQCgMWRdYAx3D3rfxGk6I9mahCao5c9B2Yw== 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=b57be759d079d40aa6ec75207faadce5ae1484a2 commit b57be759d079d40aa6ec75207faadce5ae1484a2 Author: Mark Johnston AuthorDate: 2022-07-11 19:27:54 +0000 Commit: Mark Johnston CommitDate: 2022-07-11 19:58:42 +0000 vm_fault: Fix some nits in vm_fault_copy_entry() - Correct the description (vm_fault_copy_entry() does not create a shadow object). - Move some initialization and assertions out of the scope of the object locks, when doing so makes sense. - Merge a pair of conditional blocks. - Use __unused when appropriate. No functional change intended. Reviewed by: alc MFC after: 2 weeks Sponsored by: The FreeBSD Foundation --- sys/vm/vm_fault.c | 51 +++++++++++++++++++++++---------------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c index ba6f2ebfc730..c379301f866f 100644 --- a/sys/vm/vm_fault.c +++ b/sys/vm/vm_fault.c @@ -1951,10 +1951,10 @@ error: * Routine: * vm_fault_copy_entry * Function: - * Create new shadow object backing dst_entry with private copy of - * all underlying pages. When src_entry is equal to dst_entry, - * function implements COW for wired-down map entry. Otherwise, - * it forks wired entry into dst_map. + * Create new object backing dst_entry with private copy of all + * underlying pages. When src_entry is equal to dst_entry, function + * implements COW for wired-down map entry. Otherwise, it forks + * wired entry into dst_map. * * In/out conditions: * The source and destination maps must be locked for write. @@ -1962,7 +1962,7 @@ error: * entry corresponding to a main map entry that is wired down). */ void -vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map, +vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map __unused, vm_map_entry_t dst_entry, vm_map_entry_t src_entry, vm_ooffset_t *fork_charge) { @@ -1972,14 +1972,25 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map, vm_offset_t vaddr; vm_page_t dst_m; vm_page_t src_m; - boolean_t upgrade; - -#ifdef lint - src_map++; -#endif /* lint */ + bool upgrade; upgrade = src_entry == dst_entry; + KASSERT(upgrade || dst_entry->object.vm_object == NULL, + ("vm_fault_copy_entry: vm_object not NULL")); + + /* + * If not an upgrade, then enter the mappings in the pmap as + * read and/or execute accesses. Otherwise, enter them as + * write accesses. + * + * A writeable large page mapping is only created if all of + * the constituent small page mappings are modified. Marking + * PTEs as modified on inception allows promotion to happen + * without taking potentially large number of soft faults. + */ access = prot = dst_entry->protection; + if (!upgrade) + access &= ~VM_PROT_WRITE; src_object = src_entry->object.vm_object; src_pindex = OFF_TO_IDX(src_entry->offset); @@ -2001,16 +2012,13 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map, #endif dst_object->domain = src_object->domain; dst_object->charge = dst_entry->end - dst_entry->start; - } - VM_OBJECT_WLOCK(dst_object); - KASSERT(upgrade || dst_entry->object.vm_object == NULL, - ("vm_fault_copy_entry: vm_object not NULL")); - if (src_object != dst_object) { dst_entry->object.vm_object = dst_object; dst_entry->offset = 0; dst_entry->eflags &= ~MAP_ENTRY_VN_EXEC; } + + VM_OBJECT_WLOCK(dst_object); if (fork_charge != NULL) { KASSERT(dst_entry->cred == NULL, ("vm_fault_copy_entry: leaked swp charge")); @@ -2026,19 +2034,6 @@ vm_fault_copy_entry(vm_map_t dst_map, vm_map_t src_map, dst_entry->cred = NULL; } - /* - * If not an upgrade, then enter the mappings in the pmap as - * read and/or execute accesses. Otherwise, enter them as - * write accesses. - * - * A writeable large page mapping is only created if all of - * the constituent small page mappings are modified. Marking - * PTEs as modified on inception allows promotion to happen - * without taking potentially large number of soft faults. - */ - if (!upgrade) - access &= ~VM_PROT_WRITE; - /* * Loop through all of the virtual pages within the entry's * range, copying each page from the source object to the