Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Apr 2024 17:29:20 GMT
From:      Doug Moore <dougm@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 1526667bc6e2 - main - vm_reserv: Add vm_reserv_is_populated
Message-ID:  <202404071729.437HTKXB077459@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by dougm:

URL: https://cgit.FreeBSD.org/src/commit/?id=1526667bc6e2c1042010de25e7a0226c0f1b44be

commit 1526667bc6e2c1042010de25e7a0226c0f1b44be
Author:     Doug Moore <dougm@FreeBSD.org>
AuthorDate: 2024-04-07 17:19:41 +0000
Commit:     Doug Moore <dougm@FreeBSD.org>
CommitDate: 2024-04-07 17:28:52 +0000

    vm_reserv: Add vm_reserv_is_populated
    
    Add a function to check whether an aligned block of vm pages are
    allocated, for use with impending changes to arm64 superpage
    managment.
    
    Reviewed by:    alc
    Differential Revision:  http://reviews.freebsd.org/D44575
---
 sys/vm/vm_reserv.c | 21 +++++++++++++++++++++
 sys/vm/vm_reserv.h |  1 +
 2 files changed, 22 insertions(+)

diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c
index 7b4a39a34906..b3b1dc62f14e 100644
--- a/sys/vm/vm_reserv.c
+++ b/sys/vm/vm_reserv.c
@@ -1058,6 +1058,27 @@ vm_reserv_is_page_free(vm_page_t m)
 	return (!bit_test(rv->popmap, m - rv->pages));
 }
 
+/*
+ * Returns true if the given page is part of a block of npages, starting at a
+ * multiple of npages, that are all allocated.  Otherwise, returns false.
+ */
+bool
+vm_reserv_is_populated(vm_page_t m, int npages)
+{
+	vm_reserv_t rv;
+	int index;
+
+	KASSERT(npages <= VM_LEVEL_0_NPAGES,
+	    ("%s: npages %d exceeds VM_LEVEL_0_NPAGES", __func__, npages));
+	KASSERT(powerof2(npages),
+	    ("%s: npages %d is not a power of 2", __func__, npages));
+	rv = vm_reserv_from_page(m);
+	if (rv->object == NULL)
+		return (false);
+	index = rounddown2(m - rv->pages, npages);
+	return (bit_ntest(rv->popmap, index, index + npages - 1, 1));
+}
+
 /*
  * If the given page belongs to a reservation, returns the level of that
  * reservation.  Otherwise, returns -1.
diff --git a/sys/vm/vm_reserv.h b/sys/vm/vm_reserv.h
index 44e8a939d165..98780efc9d37 100644
--- a/sys/vm/vm_reserv.h
+++ b/sys/vm/vm_reserv.h
@@ -55,6 +55,7 @@ void		vm_reserv_break_all(vm_object_t object);
 boolean_t	vm_reserv_free_page(vm_page_t m);
 void		vm_reserv_init(void);
 bool		vm_reserv_is_page_free(vm_page_t m);
+bool		vm_reserv_is_populated(vm_page_t m, int npages);
 int		vm_reserv_level(vm_page_t m);
 int		vm_reserv_level_iffullpop(vm_page_t m);
 vm_page_t	vm_reserv_reclaim_contig(int domain, u_long npages,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202404071729.437HTKXB077459>