The branch main has been updated by markj:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=84c3922243a7b7fd510dcfb100aec59c878c57d0

commit 84c3922243a7b7fd510dcfb100aec59c878c57d0
Author:     Mark Johnston <ma...@freebsd.org>
AuthorDate: 2021-10-20 00:25:04 +0000
Commit:     Mark Johnston <ma...@freebsd.org>
CommitDate: 2021-10-20 01:22:56 +0000

    Convert consumers to vm_page_alloc_noobj_contig()
    
    Remove now-unneeded page zeroing.  No functional change intended.
    
    Reviewed by:    alc, hselasky, kib
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D32006
---
 sys/amd64/amd64/mp_machdep.c                |  3 +--
 sys/amd64/amd64/pmap.c                      | 28 ++++++----------------------
 sys/arm/nvidia/drm2/tegra_bo.c              | 12 ++++--------
 sys/compat/linuxkpi/common/src/linux_page.c | 17 +++--------------
 sys/dev/drm2/ttm/ttm_bo.c                   | 11 +++++------
 sys/dev/drm2/ttm/ttm_page_alloc.c           |  6 +++---
 sys/kern/uipc_ktls.c                        |  7 +++----
 sys/powerpc/aim/mmu_radix.c                 |  8 ++++----
 sys/powerpc/aim/slb.c                       |  9 +++------
 sys/riscv/riscv/pmap.c                      |  2 --
 sys/vm/uma_core.c                           | 19 +++++++------------
 sys/vm/vm_page.c                            | 28 ++++++++++++++--------------
 12 files changed, 53 insertions(+), 97 deletions(-)

diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c
index 33defe79c8b9..e954e8cebbb9 100644
--- a/sys/amd64/amd64/mp_machdep.c
+++ b/sys/amd64/amd64/mp_machdep.c
@@ -334,8 +334,7 @@ start_all_aps(void)
        mtx_init(&ap_boot_mtx, "ap boot", NULL, MTX_SPIN);
 
        MPASS(bootMP_size <= PAGE_SIZE);
-       m_boottramp = vm_page_alloc_contig(NULL, 0, VM_ALLOC_NORMAL |
-           VM_ALLOC_NOBUSY | VM_ALLOC_NOOBJ, 1, 0,
+       m_boottramp = vm_page_alloc_noobj_contig(0, 1, 0,
            (1ULL << 20), /* Trampoline should be below 1M for real mode */
            PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
        boot_address = VM_PAGE_TO_PHYS(m_boottramp);
diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 8d6c81a5459b..f8bb384afdaf 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -2110,14 +2110,8 @@ pmap_init_pat(void)
 vm_page_t
 pmap_page_alloc_below_4g(bool zeroed)
 {
-       vm_page_t m;
-
-       m = vm_page_alloc_contig(NULL, 0, (zeroed ? VM_ALLOC_ZERO : 0) |
-           VM_ALLOC_NORMAL | VM_ALLOC_NOBUSY | VM_ALLOC_NOOBJ,
-           1, 0, (1ULL << 32), PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
-       if (m != NULL && zeroed && (m->flags & PG_ZERO) == 0)
-               pmap_zero_page(m);
-       return (m);
+       return (vm_page_alloc_noobj_contig((zeroed ? VM_ALLOC_ZERO : 0),
+           1, 0, (1ULL << 32), PAGE_SIZE, 0, VM_MEMATTR_DEFAULT));
 }
 
 extern const char la57_trampoline[], la57_trampoline_gdt_desc[],
@@ -11411,13 +11405,8 @@ pmap_kasan_enter_alloc_4k(void)
 static vm_page_t
 pmap_kasan_enter_alloc_2m(void)
 {
-       vm_page_t m;
-
-       m = vm_page_alloc_contig(NULL, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ |
-           VM_ALLOC_WIRED, NPTEPG, 0, ~0ul, NBPDR, 0, VM_MEMATTR_DEFAULT);
-       if (m != NULL)
-               memset((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)), 0, NBPDR);
-       return (m);
+       return (vm_page_alloc_noobj_contig(VM_ALLOC_WIRED | VM_ALLOC_ZERO,
+           NPTEPG, 0, ~0ul, NBPDR, 0, VM_MEMATTR_DEFAULT));
 }
 
 /*
@@ -11479,13 +11468,8 @@ pmap_kmsan_enter_alloc_4k(void)
 static vm_page_t
 pmap_kmsan_enter_alloc_2m(void)
 {
-       vm_page_t m;
-
-       m = vm_page_alloc_contig(NULL, 0, VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ |
-           VM_ALLOC_WIRED, NPTEPG, 0, ~0ul, NBPDR, 0, VM_MEMATTR_DEFAULT);
-       if (m != NULL)
-               memset((void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m)), 0, NBPDR);
-       return (m);
+       return (vm_page_alloc_noobj_contig(VM_ALLOC_ZERO | VM_ALLOC_WIRED,
+           NPTEPG, 0, ~0ul, NBPDR, 0, VM_MEMATTR_DEFAULT));
 }
 
 /*
diff --git a/sys/arm/nvidia/drm2/tegra_bo.c b/sys/arm/nvidia/drm2/tegra_bo.c
index 7479fd8bc8da..be5177973f4f 100644
--- a/sys/arm/nvidia/drm2/tegra_bo.c
+++ b/sys/arm/nvidia/drm2/tegra_bo.c
@@ -97,21 +97,19 @@ tegra_bo_alloc_contig(size_t npages, u_long alignment, 
vm_memattr_t memattr,
     vm_page_t **ret_page)
 {
        vm_page_t m;
-       int pflags, tries, i;
+       int tries, i;
        vm_paddr_t low, high, boundary;
 
        low = 0;
        high = -1UL;
        boundary = 0;
-       pflags = VM_ALLOC_NORMAL  | VM_ALLOC_NOOBJ | VM_ALLOC_NOBUSY |
-           VM_ALLOC_WIRED | VM_ALLOC_ZERO;
        tries = 0;
 retry:
-       m = vm_page_alloc_contig(NULL, 0, pflags, npages, low, high, alignment,
-           boundary, memattr);
+       m = vm_page_alloc_noobj_contig(VM_ALLOC_WIRE | VM_ALLOC_ZERO, npages,
+           low, high, alignment, boundary, memattr);
        if (m == NULL) {
                if (tries < 3) {
-                       if (!vm_page_reclaim_contig(pflags, npages, low, high,
+                       if (!vm_page_reclaim_contig(0, npages, low, high,
                            alignment, boundary))
                                vm_wait(NULL);
                        tries++;
@@ -121,8 +119,6 @@ retry:
        }
 
        for (i = 0; i < npages; i++, m++) {
-               if ((m->flags & PG_ZERO) == 0)
-                       pmap_zero_page(m);
                m->valid = VM_PAGE_BITS_ALL;
                (*ret_page)[i] = m;
        }
diff --git a/sys/compat/linuxkpi/common/src/linux_page.c 
b/sys/compat/linuxkpi/common/src/linux_page.c
index f712c0c155a4..3c8bc2bd3c5b 100644
--- a/sys/compat/linuxkpi/common/src/linux_page.c
+++ b/sys/compat/linuxkpi/common/src/linux_page.c
@@ -92,7 +92,7 @@ linux_alloc_pages(gfp_t flags, unsigned int order)
 
        if (PMAP_HAS_DMAP) {
                unsigned long npages = 1UL << order;
-               int req = VM_ALLOC_NOOBJ | VM_ALLOC_WIRED | VM_ALLOC_NORMAL;
+               int req = VM_ALLOC_WIRED;
 
                if ((flags & M_ZERO) != 0)
                        req |= VM_ALLOC_ZERO;
@@ -104,9 +104,8 @@ linux_alloc_pages(gfp_t flags, unsigned int order)
                        vm_paddr_t pmax = (flags & GFP_DMA32) ?
                            BUS_SPACE_MAXADDR_32BIT : BUS_SPACE_MAXADDR;
                retry:
-                       page = vm_page_alloc_contig(NULL, 0, req,
-                           npages, 0, pmax, PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
-
+                       page = vm_page_alloc_noobj_contig(req, npages, 0, pmax,
+                           PAGE_SIZE, 0, VM_MEMATTR_DEFAULT);
                        if (page == NULL) {
                                if (flags & M_WAITOK) {
                                        if (!vm_page_reclaim_contig(req,
@@ -119,16 +118,6 @@ linux_alloc_pages(gfp_t flags, unsigned int order)
                                return (NULL);
                        }
                }
-               if (flags & M_ZERO) {
-                       unsigned long x;
-
-                       for (x = 0; x != npages; x++) {
-                               vm_page_t pgo = page + x;
-
-                               if ((pgo->flags & PG_ZERO) == 0)
-                                       pmap_zero_page(pgo);
-                       }
-               }
        } else {
                vm_offset_t vaddr;
 
diff --git a/sys/dev/drm2/ttm/ttm_bo.c b/sys/dev/drm2/ttm/ttm_bo.c
index 010afe6d8b3b..d5c11ecff25d 100644
--- a/sys/dev/drm2/ttm/ttm_bo.c
+++ b/sys/dev/drm2/ttm/ttm_bo.c
@@ -1488,21 +1488,20 @@ int ttm_bo_global_init(struct drm_global_reference *ref)
        struct ttm_bo_global_ref *bo_ref =
                container_of(ref, struct ttm_bo_global_ref, ref);
        struct ttm_bo_global *glob = ref->object;
-       int req, ret;
+       int ret;
        int tries;
 
        sx_init(&glob->device_list_mutex, "ttmdlm");
        mtx_init(&glob->lru_lock, "ttmlru", NULL, MTX_DEF);
        glob->mem_glob = bo_ref->mem_glob;
-       req = VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ;
        tries = 0;
 retry:
-       glob->dummy_read_page = vm_page_alloc_contig(NULL, 0, req,
-           1, 0, VM_MAX_ADDRESS, PAGE_SIZE, 0, VM_MEMATTR_UNCACHEABLE);
+       glob->dummy_read_page = vm_page_alloc_noobj_contig(0, 1, 0,
+           VM_MAX_ADDRESS, PAGE_SIZE, 0, VM_MEMATTR_UNCACHEABLE);
 
        if (unlikely(glob->dummy_read_page == NULL)) {
-               if (tries < 1 && vm_page_reclaim_contig(req, 1,
-                   0, VM_MAX_ADDRESS, PAGE_SIZE, 0)) {
+               if (tries < 1 && vm_page_reclaim_contig(0, 1, 0,
+                   VM_MAX_ADDRESS, PAGE_SIZE, 0)) {
                        tries++;
                        goto retry;
                }
diff --git a/sys/dev/drm2/ttm/ttm_page_alloc.c 
b/sys/dev/drm2/ttm/ttm_page_alloc.c
index b35a06520e07..6fc12cad121f 100644
--- a/sys/dev/drm2/ttm/ttm_page_alloc.c
+++ b/sys/dev/drm2/ttm/ttm_page_alloc.c
@@ -163,8 +163,8 @@ ttm_vm_page_alloc_dma32(int req, vm_memattr_t memattr)
        int tries;
 
        for (tries = 0; ; tries++) {
-               p = vm_page_alloc_contig(NULL, 0, req, 1, 0, 0xffffffff,
-                   PAGE_SIZE, 0, memattr);
+               p = vm_page_alloc_noobj_contig(req, 1, 0, 0xffffffff, PAGE_SIZE,
+                   0, memattr);
                if (p != NULL || tries > 2)
                        return (p);
                if (!vm_page_reclaim_contig(req, 1, 0, 0xffffffff,
@@ -191,7 +191,7 @@ ttm_vm_page_alloc(int flags, enum ttm_caching_state cstate)
        int req;
 
        memattr = ttm_caching_state_to_vm(cstate);
-       req = VM_ALLOC_NORMAL | VM_ALLOC_WIRED | VM_ALLOC_NOOBJ;
+       req = VM_ALLOC_WIRED;
        if ((flags & TTM_PAGE_FLAG_ZERO_ALLOC) != 0)
                req |= VM_ALLOC_ZERO;
 
diff --git a/sys/kern/uipc_ktls.c b/sys/kern/uipc_ktls.c
index f6179592fb11..1d3321fd4ff6 100644
--- a/sys/kern/uipc_ktls.c
+++ b/sys/kern/uipc_ktls.c
@@ -341,16 +341,15 @@ static int
 ktls_buffer_import(void *arg, void **store, int count, int domain, int flags)
 {
        vm_page_t m;
-       int i;
+       int i, req;
 
        KASSERT((ktls_maxlen & PAGE_MASK) == 0,
            ("%s: ktls max length %d is not page size-aligned",
            __func__, ktls_maxlen));
 
+       req = VM_ALLOC_WIRED | VM_ALLOC_NODUMP | malloc2vm_flags(flags);
        for (i = 0; i < count; i++) {
-               m = vm_page_alloc_contig_domain(NULL, 0, domain,
-                   VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
-                   VM_ALLOC_NODUMP | malloc2vm_flags(flags),
+               m = vm_page_alloc_noobj_contig_domain(domain, req,
                    atop(ktls_maxlen), 0, ~0ul, PAGE_SIZE, 0,
                    VM_MEMATTR_DEFAULT);
                if (m == NULL)
diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c
index d29ca730d7d6..95c3f5f009e4 100644
--- a/sys/powerpc/aim/mmu_radix.c
+++ b/sys/powerpc/aim/mmu_radix.c
@@ -3570,14 +3570,14 @@ static int
 radix_pgd_import(void *arg __unused, void **store, int count, int domain 
__unused,
     int flags)
 {
+       int req;
 
+       req = VM_ALLOC_WIRED | malloc2vm_flags(flags);
        for (int i = 0; i < count; i++) {
-               vm_page_t m = vm_page_alloc_contig(NULL, 0,
-                   VM_ALLOC_NORMAL | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED |
-                   VM_ALLOC_ZERO | VM_ALLOC_WAITOK, RADIX_PGD_SIZE/PAGE_SIZE,
+               vm_page_t m = vm_page_alloc_noobj_contig(req,
+                   RADIX_PGD_SIZE / PAGE_SIZE,
                    0, (vm_paddr_t)-1, RADIX_PGD_SIZE, L1_PAGE_SIZE,
                    VM_MEMATTR_DEFAULT);
-               /* XXX zero on alloc here so we don't have to later */
                store[i] = (void *)PHYS_TO_DMAP(VM_PAGE_TO_PHYS(m));
        }
        return (count);
diff --git a/sys/powerpc/aim/slb.c b/sys/powerpc/aim/slb.c
index 886e11c9b356..c107fcbcfc43 100644
--- a/sys/powerpc/aim/slb.c
+++ b/sys/powerpc/aim/slb.c
@@ -500,9 +500,9 @@ slb_uma_real_alloc(uma_zone_t zone, vm_size_t bytes, int 
domain,
                realmax = platform_real_maxaddr();
 
        *flags = UMA_SLAB_PRIV;
-       m = vm_page_alloc_contig_domain(NULL, 0, domain,
-           malloc2vm_flags(wait) | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED,
-           1, 0, realmax, PAGE_SIZE, PAGE_SIZE, VM_MEMATTR_DEFAULT);
+       m = vm_page_alloc_noobj_contig_domain(domain, malloc2vm_flags(wait) |
+           VM_ALLOC_WIRED, 1, 0, realmax, PAGE_SIZE, PAGE_SIZE,
+           VM_MEMATTR_DEFAULT);
        if (m == NULL)
                return (NULL);
 
@@ -513,9 +513,6 @@ slb_uma_real_alloc(uma_zone_t zone, vm_size_t bytes, int 
domain,
                pmap_kenter((vm_offset_t)va, VM_PAGE_TO_PHYS(m));
        }
 
-       if ((wait & M_ZERO) && (m->flags & PG_ZERO) == 0)
-               bzero(va, PAGE_SIZE);
-
        return (va);
 }
 
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index e1ff056117eb..9abf75a731f5 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -2757,8 +2757,6 @@ pmap_enter(pmap_t pmap, vm_offset_t va, vm_page_t m, 
vm_prot_t prot,
                            VM_ALLOC_ZERO);
                        if (l3_m == NULL)
                                panic("pmap_enter: l3 pte_m == NULL");
-                       if ((l3_m->flags & PG_ZERO) == 0)
-                               pmap_zero_page(l3_m);
 
                        l3_pa = VM_PAGE_TO_PHYS(l3_m);
                        l3_pn = (l3_pa / PAGE_SIZE);
diff --git a/sys/vm/uma_core.c b/sys/vm/uma_core.c
index a510295b3c65..68553bda2249 100644
--- a/sys/vm/uma_core.c
+++ b/sys/vm/uma_core.c
@@ -1885,17 +1885,15 @@ startup_alloc(uma_zone_t zone, vm_size_t bytes, int 
domain, uint8_t *pflag,
 {
        vm_paddr_t pa;
        vm_page_t m;
-       void *mem;
-       int pages;
-       int i;
+       int i, pages;
 
        pages = howmany(bytes, PAGE_SIZE);
        KASSERT(pages > 0, ("%s can't reserve 0 pages", __func__));
 
        *pflag = UMA_SLAB_BOOT;
-       m = vm_page_alloc_contig_domain(NULL, 0, domain,
-           malloc2vm_flags(wait) | VM_ALLOC_NOOBJ | VM_ALLOC_WIRED, pages, 
-           (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0, VM_MEMATTR_DEFAULT);
+       m = vm_page_alloc_noobj_contig_domain(domain, malloc2vm_flags(wait) |
+           VM_ALLOC_WIRED, pages, (vm_paddr_t)0, ~(vm_paddr_t)0, 1, 0,
+           VM_MEMATTR_DEFAULT);
        if (m == NULL)
                return (NULL);
 
@@ -1907,13 +1905,10 @@ startup_alloc(uma_zone_t zone, vm_size_t bytes, int 
domain, uint8_t *pflag,
                        dump_add_page(pa);
 #endif
        }
-       /* Allocate KVA and indirectly advance bootmem. */
-       mem = (void *)pmap_map(&bootmem, m->phys_addr,
-           m->phys_addr + (pages * PAGE_SIZE), VM_PROT_READ | VM_PROT_WRITE);
-        if ((wait & M_ZERO) != 0)
-                bzero(mem, pages * PAGE_SIZE);
 
-        return (mem);
+       /* Allocate KVA and indirectly advance bootmem. */
+       return ((void *)pmap_map(&bootmem, m->phys_addr,
+           m->phys_addr + (pages * PAGE_SIZE), VM_PROT_READ | VM_PROT_WRITE));
 }
 
 static void
diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index 6927d7af4409..0644c1167984 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -2883,32 +2883,32 @@ vm_page_reclaim_run(int req_class, int domain, u_long 
npages, vm_page_t m_run,
                                         * "m_run" and "high" only as a last
                                         * resort.
                                         */
-                                       req = req_class | VM_ALLOC_NOOBJ;
+                                       req = req_class;
                                        if ((m->flags & PG_NODUMP) != 0)
                                                req |= VM_ALLOC_NODUMP;
                                        if (trunc_page(high) !=
                                            ~(vm_paddr_t)PAGE_MASK) {
-                                               m_new = vm_page_alloc_contig(
-                                                   NULL, 0, req, 1,
-                                                   round_page(high),
-                                                   ~(vm_paddr_t)0,
-                                                   PAGE_SIZE, 0,
-                                                   VM_MEMATTR_DEFAULT);
+                                               m_new =
+                                                   vm_page_alloc_noobj_contig(
+                                                   req, 1, round_page(high),
+                                                   ~(vm_paddr_t)0, PAGE_SIZE,
+                                                   0, VM_MEMATTR_DEFAULT);
                                        } else
                                                m_new = NULL;
                                        if (m_new == NULL) {
                                                pa = VM_PAGE_TO_PHYS(m_run);
-                                               m_new = vm_page_alloc_contig(
-                                                   NULL, 0, req, 1,
-                                                   0, pa - 1, PAGE_SIZE, 0,
+                                               m_new =
+                                                   vm_page_alloc_noobj_contig(
+                                                   req, 1, 0, pa - 1,
+                                                   PAGE_SIZE, 0,
                                                    VM_MEMATTR_DEFAULT);
                                        }
                                        if (m_new == NULL) {
                                                pa += ptoa(npages);
-                                               m_new = vm_page_alloc_contig(
-                                                   NULL, 0, req, 1,
-                                                   pa, high, PAGE_SIZE, 0,
-                                                   VM_MEMATTR_DEFAULT);
+                                               m_new =
+                                                   vm_page_alloc_noobj_contig(
+                                                   req, 1, pa, high, PAGE_SIZE,
+                                                   0, VM_MEMATTR_DEFAULT);
                                        }
                                        if (m_new == NULL) {
                                                vm_page_xunbusy(m);

Reply via email to