The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=92db9f3bb7623883231214e74ec38788c3dffc6a

commit 92db9f3bb7623883231214e74ec38788c3dffc6a
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2021-10-20 00:24:21 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2021-10-20 01:22:56 +0000

    Introduce vm_page_alloc_noobj_contig()
    
    This is the same as vm_page_alloc_noobj(), but allocates physically
    contiguous runs of memory.  For now it is implemented in terms of
    vm_page_alloc_contig(), with the difference that
    vm_page_alloc_noobj_contig() implements VM_ALLOC_ZERO by zeroing the
    page.
    
    Reviewed by:    alc, kib
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D32005
---
 sys/vm/vm_page.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 sys/vm/vm_page.h |  6 ++++++
 2 files changed, 49 insertions(+)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 0190f67dd7da..6927d7af4409 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2509,6 +2509,49 @@ vm_page_alloc_noobj_domain(int domain, int req)
        return (_vm_page_alloc_noobj_domain(domain, VM_NFREELIST, req));
 }
 
+vm_page_t
+vm_page_alloc_noobj_contig(int req, u_long npages, vm_paddr_t low,
+    vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
+    vm_memattr_t memattr)
+{
+       struct vm_domainset_iter di;
+       vm_page_t m;
+       int domain;
+
+       vm_domainset_iter_page_init(&di, NULL, 0, &domain, &req);
+       do {
+               m = vm_page_alloc_noobj_contig_domain(domain, req, npages, low,
+                   high, alignment, boundary, memattr);
+               if (m != NULL)
+                       break;
+       } while (vm_domainset_iter_page(&di, NULL, &domain) == 0);
+
+       return (m);
+}
+
+vm_page_t
+vm_page_alloc_noobj_contig_domain(int domain, int req, u_long npages,
+    vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
+    vm_memattr_t memattr)
+{
+       vm_page_t m;
+       u_long i;
+
+       KASSERT((req & (VM_ALLOC_SBUSY | VM_ALLOC_IGN_SBUSY |
+           VM_ALLOC_NOOBJ)) == 0,
+           ("%s: invalid req %#x", __func__, req));
+
+       m = vm_page_alloc_contig_domain(NULL, 0, domain, req | VM_ALLOC_NOOBJ,
+           npages, low, high, alignment, boundary, memattr);
+       if (m != NULL && (req & VM_ALLOC_ZERO) != 0) {
+               for (i = 0; i < npages; i++) {
+                       if ((m[i].flags & PG_ZERO) == 0)
+                               pmap_zero_page(&m[i]);
+               }
+       }
+       return (m);
+}
+
 /*
  * Check a page that has been freshly dequeued from a freelist.
  */
diff --git a/sys/vm/vm_page.h b/sys/vm/vm_page.h
index 600619b00eaf..b31ea0241cc7 100644
--- a/sys/vm/vm_page.h
+++ b/sys/vm/vm_page.h
@@ -616,6 +616,12 @@ vm_page_t vm_page_alloc_freelist(int, int);
 vm_page_t vm_page_alloc_freelist_domain(int, int, int);
 vm_page_t vm_page_alloc_noobj(int);
 vm_page_t vm_page_alloc_noobj_domain(int, int);
+vm_page_t vm_page_alloc_noobj_contig(int req, u_long npages, vm_paddr_t low,
+    vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
+    vm_memattr_t memattr);
+vm_page_t vm_page_alloc_noobj_contig_domain(int domain, int req, u_long npages,
+    vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
+    vm_memattr_t memattr);
 void vm_page_bits_set(vm_page_t m, vm_page_bits_t *bits, vm_page_bits_t set);
 bool vm_page_blacklist_add(vm_paddr_t pa, bool verbose);
 vm_page_t vm_page_grab(vm_object_t, vm_pindex_t, int);

Reply via email to