From owner-svn-src-all@freebsd.org Mon Feb 17 01:59:57 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D28024921A; Mon, 17 Feb 2020 01:59:57 +0000 (UTC) (envelope-from jeff@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48LRy4323Pz4H0h; Mon, 17 Feb 2020 01:59:56 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 62AD62F51F; Mon, 17 Feb 2020 01:59:56 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 01H1xuZN094851; Mon, 17 Feb 2020 01:59:56 GMT (envelope-from jeff@FreeBSD.org) Received: (from jeff@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 01H1xuKf094850; Mon, 17 Feb 2020 01:59:56 GMT (envelope-from jeff@FreeBSD.org) Message-Id: <202002170159.01H1xuKf094850@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jeff set sender to jeff@FreeBSD.org using -f From: Jeff Roberson Date: Mon, 17 Feb 2020 01:59:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r358012 - head/sys/vm X-SVN-Group: head X-SVN-Commit-Author: jeff X-SVN-Commit-Paths: head/sys/vm X-SVN-Commit-Revision: 358012 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Feb 2020 01:59:57 -0000 Author: jeff Date: Mon Feb 17 01:59:55 2020 New Revision: 358012 URL: https://svnweb.freebsd.org/changeset/base/358012 Log: Add a simple accessor that returns the bytes of memory consumed by a zone. Modified: head/sys/vm/uma.h head/sys/vm/uma_core.c Modified: head/sys/vm/uma.h ============================================================================== --- head/sys/vm/uma.h Mon Feb 17 01:08:00 2020 (r358011) +++ head/sys/vm/uma.h Mon Feb 17 01:59:55 2020 (r358012) @@ -671,6 +671,11 @@ void uma_prealloc(uma_zone_t zone, int itemcnt); int uma_zone_exhausted(uma_zone_t zone); /* + * Returns the bytes of memory consumed by the zone. + */ +size_t uma_zone_memory(uma_zone_t zone); + +/* * Common UMA_ZONE_PCPU zones. */ extern uma_zone_t pcpu_zone_int; Modified: head/sys/vm/uma_core.c ============================================================================== --- head/sys/vm/uma_core.c Mon Feb 17 01:08:00 2020 (r358011) +++ head/sys/vm/uma_core.c Mon Feb 17 01:59:55 2020 (r358012) @@ -4681,6 +4681,27 @@ uma_prealloc(uma_zone_t zone, int items) } } +/* + * Returns a snapshot of memory consumption in bytes. + */ +size_t +uma_zone_memory(uma_zone_t zone) +{ + size_t sz; + int i; + + sz = 0; + if (zone->uz_flags & UMA_ZFLAG_CACHE) { + for (i = 0; i < vm_ndomains; i++) + sz += zone->uz_domain[i].uzd_nitems; + return (sz * zone->uz_size); + } + for (i = 0; i < vm_ndomains; i++) + sz += zone->uz_keg->uk_domain[i].ud_pages; + + return (sz * PAGE_SIZE); +} + /* See uma.h */ void uma_reclaim(int req)