From nobody Mon Dec 20 00:15:19 2021 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 37D1918EB50B; Mon, 20 Dec 2021 00:15:21 +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 4JHKqD6nGdz3nSG; Mon, 20 Dec 2021 00:15:20 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 BFDE940D5; Mon, 20 Dec 2021 00:15:20 +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 1BK0FJBb032768; Mon, 20 Dec 2021 00:15:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BK0FJgC032767; Mon, 20 Dec 2021 00:15:19 GMT (envelope-from git) Date: Mon, 20 Dec 2021 00:15:19 GMT Message-Id: <202112200015.1BK0FJgC032767@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Rick Macklem Subject: git: cd37afd8b6dd - main - vm_object: Make is_object_active() global 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: rmacklem X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: cd37afd8b6ddc38fe2441e37a8bf5f8cdce50bc6 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639959321; 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=PiBuQWeTUFbEP1iN7uHQfL9FNCnnWh7LBBO9q25kmOc=; b=T8MK5vYfOXi6PFAKc9w3xqP1EnLpkW3VzjApwwHIn/2SCZRORwSutijhe0EB+a8C4K3fkF 23g6tenPAELahqmoEplDiTMUY4wsnVR8FLzZh7FtiigWRlgvgqfDqT9pr/vkeQJCm/n1Nk FqWTqjZiYH5GEtAs5XDcuGm8xEclg1vAnaXVQnSByZnolhzTlVuhseowx/FkM4TzPYcBFA zFn67EzDW1cyltQ5B+TPecmBJTNkhvIqxlPjo87kThpwkuPp08hi5bwp2FMa8Qd91lIa1Y nH3Ebct0XKGYwS6DU0sBHqFVz4AkyICD6O+ffLOSQQMcwfT1qheEb1+fWMu6sA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639959321; a=rsa-sha256; cv=none; b=oXYp7yVpKg4G8F3tj2CtHP5aYmn6l29VlaZCpkDDbis4phXqnCEljwSPYNUPbWzuVTOl1i sAUkRrF5qgwU/JyGw9b+jIdF9YpY1Qm756TOFGe/yq/AMw7kWcnnYWIWTZUAsqF0I39adV ji8UVnUM9pr2NYqcp5iJmW7dV+pz8I9E/oaMJSG14jWs1tpoFO0EHCeiVLq43/wrQnQPoz b8iPQs5F5ID7kfScfKTByiZ2+PNJ5qGZEi/SZGJIfo1utsZVVmpvGKeg8sZhrLgSjBuGtA 4zsq5bujD7GR1cJ4HY2GuS6l67MoQtHfvyKv/svqwVvkCxG5Khb6jSjojj8V7g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rmacklem: URL: https://cgit.FreeBSD.org/src/commit/?id=cd37afd8b6ddc38fe2441e37a8bf5f8cdce50bc6 commit cd37afd8b6ddc38fe2441e37a8bf5f8cdce50bc6 Author: Rick Macklem AuthorDate: 2021-12-20 00:11:44 +0000 Commit: Rick Macklem CommitDate: 2021-12-20 00:11:44 +0000 vm_object: Make is_object_active() global Commit 867c27c23a5c modified the NFS client so that it does IO_APPEND writes directly to the NFS server, bypassing the buffer cache. However, this could result in stale data in client pages when the file is mmap(2)'d. As such, the NFS client needs to call is_object_active() to check if the file is mmap(2)'d. This patch renames is_object_active() to vm_object_is_active(), moves it to sys/vm/vm_object.c and makes it global, so that the NFS client can call it in a future commit. Reviewed by: kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D33520 --- sys/vm/vm_meter.c | 19 ++----------------- sys/vm/vm_object.c | 15 +++++++++++++++ sys/vm/vm_object.h | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c index f9e2b0c66cc8..f6ce0cfe39e3 100644 --- a/sys/vm/vm_meter.c +++ b/sys/vm/vm_meter.c @@ -142,21 +142,6 @@ SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT | CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history"); -/* - * This function aims to determine if the object is mapped, - * specifically, if it is referenced by a vm_map_entry. Because - * objects occasionally acquire transient references that do not - * represent a mapping, the method used here is inexact. However, it - * has very low overhead and is good enough for the advisory - * vm.vmtotal sysctl. - */ -static bool -is_object_active(vm_object_t obj) -{ - - return (obj->ref_count > obj->shadow_count); -} - #if defined(COMPAT_FREEBSD11) struct vmtotal11 { int16_t t_rq; @@ -268,7 +253,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) } total.t_vm += object->size; total.t_rm += object->resident_page_count; - if (is_object_active(object)) { + if (vm_object_is_active(object)) { total.t_avm += object->size; total.t_arm += object->resident_page_count; } @@ -276,7 +261,7 @@ vmtotal(SYSCTL_HANDLER_ARGS) /* shared object */ total.t_vmshr += object->size; total.t_rmshr += object->resident_page_count; - if (is_object_active(object)) { + if (vm_object_is_active(object)) { total.t_avmshr += object->size; total.t_armshr += object->resident_page_count; } diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c index c465a2cf76dd..9bcf810df744 100644 --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -2498,6 +2498,21 @@ vm_object_busy_wait(vm_object_t obj, const char *wmesg) (void)blockcount_sleep(&obj->busy, NULL, wmesg, PVM); } +/* + * This function aims to determine if the object is mapped, + * specifically, if it is referenced by a vm_map_entry. Because + * objects occasionally acquire transient references that do not + * represent a mapping, the method used here is inexact. However, it + * has very low overhead and is good enough for the advisory + * vm.vmtotal sysctl. + */ +bool +vm_object_is_active(vm_object_t obj) +{ + + return (obj->ref_count > obj->shadow_count); +} + static int vm_object_list_handler(struct sysctl_req *req, bool swap_only) { diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h index 3b280228de13..ef8245c266d5 100644 --- a/sys/vm/vm_object.h +++ b/sys/vm/vm_object.h @@ -391,6 +391,7 @@ boolean_t vm_object_sync(vm_object_t, vm_ooffset_t, vm_size_t, boolean_t, void vm_object_unwire(vm_object_t object, vm_ooffset_t offset, vm_size_t length, uint8_t queue); struct vnode *vm_object_vnode(vm_object_t object); +bool vm_object_is_active(vm_object_t obj); #endif /* _KERNEL */ #endif /* _VM_OBJECT_ */