From owner-svn-src-head@freebsd.org Wed Sep 2 18:16:45 2020 Return-Path: Delivered-To: svn-src-head@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 896CD3C3C04; Wed, 2 Sep 2020 18:16:45 +0000 (UTC) (envelope-from markj@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 "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BhXFn376cz40fb; Wed, 2 Sep 2020 18:16:45 +0000 (UTC) (envelope-from markj@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 4F6C2E82F; Wed, 2 Sep 2020 18:16:45 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 082IGjZW005537; Wed, 2 Sep 2020 18:16:45 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 082IGhml005525; Wed, 2 Sep 2020 18:16:43 GMT (envelope-from markj@FreeBSD.org) Message-Id: <202009021816.082IGhml005525@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 2 Sep 2020 18:16:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r365267 - in head: lib/libc/sys sys/amd64/amd64 sys/arm/arm sys/arm64/arm64 sys/i386/i386 sys/powerpc/aim sys/riscv/riscv sys/sys sys/vm X-SVN-Group: head X-SVN-Commit-Author: markj X-SVN-Commit-Paths: in head: lib/libc/sys sys/amd64/amd64 sys/arm/arm sys/arm64/arm64 sys/i386/i386 sys/powerpc/aim sys/riscv/riscv sys/sys sys/vm X-SVN-Commit-Revision: 365267 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Sep 2020 18:16:45 -0000 Author: markj Date: Wed Sep 2 18:16:43 2020 New Revision: 365267 URL: https://svnweb.freebsd.org/changeset/base/365267 Log: Include the psind in data returned by mincore(2). Currently we use a single bit to indicate whether the virtual page is part of a superpage. To support a forthcoming implementation of non-transparent 1GB superpages, it is useful to provide more detailed information about large page sizes. The change converts MINCORE_SUPER into a mask for MINCORE_PSIND(psind) values, indicating a mapping of size psind, where psind is an index into the pagesizes array returned by getpagesizes(3), which in turn comes from the hw.pagesizes sysctl. MINCORE_PSIND(1) is equal to the old value of MINCORE_SUPER. For now, two bits are used to record the page size, permitting values of MAXPAGESIZES up to 4. Reviewed by: alc, kib Sponsored by: Juniper Networks, Inc. Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D26238 Modified: head/lib/libc/sys/mincore.2 head/sys/amd64/amd64/pmap.c head/sys/arm/arm/pmap-v6.c head/sys/arm64/arm64/pmap.c head/sys/i386/i386/pmap.c head/sys/powerpc/aim/mmu_radix.c head/sys/riscv/riscv/pmap.c head/sys/sys/mman.h head/sys/vm/vm_mmap.c Modified: head/lib/libc/sys/mincore.2 ============================================================================== --- head/lib/libc/sys/mincore.2 Wed Sep 2 18:15:57 2020 (r365266) +++ head/lib/libc/sys/mincore.2 Wed Sep 2 18:16:43 2020 (r365267) @@ -28,7 +28,7 @@ .\" @(#)mincore.2 8.1 (Berkeley) 6/9/93 .\" $FreeBSD$ .\" -.Dd January 7, 2019 +.Dd August 23, 2020 .Dt MINCORE 2 .Os .Sh NAME @@ -73,9 +73,19 @@ Page has been modified by us. Page has been referenced. .It Dv MINCORE_MODIFIED_OTHER Page has been modified. -.It Dv MINCORE_SUPER +.It Dv MINCORE_PSIND(i) Page is part of a large .Pq Dq super +page with size given by index +.Dv i +in the array returned by +.Xr getpagesizes 3 . +.It Dv MINCORE_SUPER +A mask of the valid +.Dv MINCORE_PSIND() +values. +If any bits in this mask are set, the page is part of a large +.Pq Dq super page. .El .Pp @@ -98,6 +108,17 @@ and statuses. Otherwise, if the sysctl value is zero, all resident pages backing the specified address range are examined, regardless of the mapping state. +.Sh IMPLEMENTATION NOTES +Prior to the introduction of +.Dv MINCORE_PSIND() +in +.Fx 13.0 , +.Dv MINCORE_SUPER +consisted of a single bit equal to +.Dv MINCORE_PSIND(1) . +In particular, applications compiled using the old value of +.Dv MINCORE_SUPER +will not identify large pages with size index 2 as being large pages. .Sh RETURN VALUES .Rv -std mincore .Sh ERRORS @@ -122,7 +143,8 @@ argument points to an illegal address. .Xr mprotect 2 , .Xr msync 2 , .Xr munmap 2 , -.Xr getpagesize 3 +.Xr getpagesize 3 , +.Xr getpagesizes 3 .Sh HISTORY The .Fn mincore Modified: head/sys/amd64/amd64/pmap.c ============================================================================== --- head/sys/amd64/amd64/pmap.c Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/amd64/amd64/pmap.c Wed Sep 2 18:16:43 2020 (r365267) @@ -9149,7 +9149,7 @@ pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t /* Compute the physical address of the 4KB page. */ pa = ((*pdep & PG_PS_FRAME) | (addr & PDRMASK)) & PG_FRAME; - val = MINCORE_SUPER; + val = MINCORE_PSIND(1); } else { pte = *pmap_pde_to_pte(pdep, addr); pa = pte & PG_FRAME; Modified: head/sys/arm/arm/pmap-v6.c ============================================================================== --- head/sys/arm/arm/pmap-v6.c Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/arm/arm/pmap-v6.c Wed Sep 2 18:16:43 2020 (r365267) @@ -6235,7 +6235,7 @@ pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t if (pte1_is_section(pte1)) { pa = trunc_page(pte1_pa(pte1) | (addr & PTE1_OFFSET)); managed = pte1_is_managed(pte1); - val = MINCORE_SUPER | MINCORE_INCORE; + val = MINCORE_PSIND(1) | MINCORE_INCORE; if (pte1_is_dirty(pte1)) val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER; if (pte1 & PTE1_A) Modified: head/sys/arm64/arm64/pmap.c ============================================================================== --- head/sys/arm64/arm64/pmap.c Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/arm64/arm64/pmap.c Wed Sep 2 18:16:43 2020 (r365267) @@ -5956,7 +5956,7 @@ pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t managed = (tpte & ATTR_SW_MANAGED) != 0; val = MINCORE_INCORE; if (lvl != 3) - val |= MINCORE_SUPER; + val |= MINCORE_PSIND(3 - lvl); if ((managed && pmap_pte_dirty(pmap, tpte)) || (!managed && (tpte & ATTR_S1_AP_RW_BIT) == ATTR_S1_AP(ATTR_S1_AP_RW))) val |= MINCORE_MODIFIED | MINCORE_MODIFIED_OTHER; Modified: head/sys/i386/i386/pmap.c ============================================================================== --- head/sys/i386/i386/pmap.c Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/i386/i386/pmap.c Wed Sep 2 18:16:43 2020 (r365267) @@ -5755,7 +5755,7 @@ __CONCAT(PMTYPE, mincore)(pmap_t pmap, vm_offset_t add /* Compute the physical address of the 4KB page. */ pa = ((pde & PG_PS_FRAME) | (addr & PDRMASK)) & PG_FRAME; - val = MINCORE_SUPER; + val = MINCORE_PSIND(1); } else { pte = pmap_pte_ufast(pmap, addr, pde); pa = pte & PG_FRAME; Modified: head/sys/powerpc/aim/mmu_radix.c ============================================================================== --- head/sys/powerpc/aim/mmu_radix.c Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/powerpc/aim/mmu_radix.c Wed Sep 2 18:16:43 2020 (r365267) @@ -5689,7 +5689,7 @@ mmu_radix_mincore(pmap_t pmap, vm_offset_t addr, vm_pa /* Compute the physical address of the 4KB page. */ pa = ((*l3ep & PG_PS_FRAME) | (addr & L3_PAGE_MASK)) & PG_FRAME; - val = MINCORE_SUPER; + val = MINCORE_PSIND(1); } else { pte = *pmap_l3e_to_pte(l3ep, addr); pa = pte & PG_FRAME; Modified: head/sys/riscv/riscv/pmap.c ============================================================================== --- head/sys/riscv/riscv/pmap.c Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/riscv/riscv/pmap.c Wed Sep 2 18:16:43 2020 (r365267) @@ -4217,7 +4217,7 @@ pmap_mincore(pmap_t pmap, vm_offset_t addr, vm_paddr_t if (l2 != NULL && ((tpte = pmap_load(l2)) & PTE_V) != 0) { if ((tpte & PTE_RWX) != 0) { pa = PTE_TO_PHYS(tpte) | (addr & L2_OFFSET); - val = MINCORE_INCORE | MINCORE_SUPER; + val = MINCORE_INCORE | MINCORE_PSIND(1); } else { l3 = pmap_l2_to_l3(l2, addr); tpte = pmap_load(l3); Modified: head/sys/sys/mman.h ============================================================================== --- head/sys/sys/mman.h Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/sys/mman.h Wed Sep 2 18:16:43 2020 (r365267) @@ -179,7 +179,8 @@ #define MINCORE_MODIFIED 0x4 /* Page has been modified by us */ #define MINCORE_REFERENCED_OTHER 0x8 /* Page has been referenced */ #define MINCORE_MODIFIED_OTHER 0x10 /* Page has been modified */ -#define MINCORE_SUPER 0x20 /* Page is a "super" page */ +#define MINCORE_SUPER 0x60 /* Page is a "super" page */ +#define MINCORE_PSIND(i) (((i) << 5) & MINCORE_SUPER) /* Page size */ /* * Anonymous object constant for shm_open(). Modified: head/sys/vm/vm_mmap.c ============================================================================== --- head/sys/vm/vm_mmap.c Wed Sep 2 18:15:57 2020 (r365266) +++ head/sys/vm/vm_mmap.c Wed Sep 2 18:16:43 2020 (r365267) @@ -112,6 +112,8 @@ SYSCTL_INT(_vm, OID_AUTO, imply_prot_max, CTLFLAG_RWTU #define MAP_32BIT_MAX_ADDR ((vm_offset_t)1 << 31) #endif +_Static_assert(MAXPAGESIZES <= 4, "MINCORE_SUPER too narrow"); + #ifndef _SYS_SYSPROTO_H_ struct sbrk_args { int incr;