From nobody Wed Aug 17 19:11:07 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4M7Hfz34Mrz4Z1nK; Wed, 17 Aug 2022 19:11:07 +0000 (UTC) (envelope-from git@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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4M7Hfz1gWQz4L8L; Wed, 17 Aug 2022 19:11:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660763467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/ATGC1bRRho1TWuPohd9lBD0B/AEVa+iYl2JPiALBhw=; b=Irh8XZPpn7ukWb/c9nVsA95VPHZtaK39jlOKr0J6m49ysSLrDJVvnkPvnbiLJ1UOiXAeyk NbT9vEL7Y3HGdNDxmsB+51bXj6DsHqcrUDG+h4v1LVKo68phSMOUK4CSn7pyRx4AVZIT/J 5kWZeU9+FGpRhdrCfCmuuG0XtBBdUtusALo1nuxnHJ0QuXhbl2thpnVMg4Sgg1+K5rdhTf pbLJR0XzJPGioNcrHyZ13Ha4sRyjByfuHdq3e1i1IAYMX6B7sS1qzDFjToFMzslW3sMb41 QxHD9cclzHa/tMB7W3WK+ezuLytBV+HdDpGHKU1JlsYu/JWr8BRb6uZXdleZSQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4M7Hfz0m3yz11SZ; Wed, 17 Aug 2022 19:11:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 27HJB7Lf040518; Wed, 17 Aug 2022 19:11:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 27HJB7B3040502; Wed, 17 Aug 2022 19:11:07 GMT (envelope-from git) Date: Wed, 17 Aug 2022 19:11:07 GMT Message-Id: <202208171911.27HJB7B3040502@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 5567d6b4419b - main - arm64 pmap: Simplify logic around pv_chunk sizes. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 5567d6b4419b02a2099527228b1a51cc55a5b47d Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1660763467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/ATGC1bRRho1TWuPohd9lBD0B/AEVa+iYl2JPiALBhw=; b=ZtwcuobAgwMyS4gA4z4Qry4w6lPDcMqlA78QVJPKqhYNnfO83wl+KWpJrNiaevaEVikb4Y Sa9E5hThmt7m+eXz8Mplo+cOuvtNMW7sUM0eNtMiBt+gKRt9AIcNShmO1Gk5FR/pqA/1sI G7xqP71VbCVn4nMyGuGId3VqO7udbeVicLGGQ4ZGLiXsGC01IN2eGaizJvH1CWG6nt5j5R Y1Ios/fGpGtM+XbEHsbry0gqR3yxgSXg5VVnfZQZhdFApcHDFs089Feqkdtq0Nml8uASM8 Cfp8itr0Pt/cZEIN5YMFlQWFb9S2ErqBuzFPlufH+6gJHQAOmtRnDY9W3WY1UA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1660763467; a=rsa-sha256; cv=none; b=hoWilYmHDB4bn7md7UMX/SEo4nZrPwCFJ8fn32xBBBarrAYWlS2RlcSKdUPCTl+kYuQdpI V2apWqubHLal1RN7K3uHVAlaAMtrBCl7KeBvbX3UlJJn6IuhWaTjAECMuiJaT9j3vrhxET 7PqVYhDqdorCp3VjPulxpsL/hfi7DPoDIsu76wLIciAKZiibi+O4F5WugGapyPXqCA87cR EslKDb4H8C8y6SXuTfGJLXlz8NuY+hL2s45YiGZJ9UHcE4hzkys5mBheVgyCLCn8pUCq0+ eFBhaGltVInKssNITC/fSSqIYSCONwqL0A8fwwj2HhUtDtDOqeQFagj8GGIpag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=5567d6b4419b02a2099527228b1a51cc55a5b47d commit 5567d6b4419b02a2099527228b1a51cc55a5b47d Author: John Baldwin AuthorDate: 2022-08-17 19:10:12 +0000 Commit: John Baldwin CommitDate: 2022-08-17 19:10:12 +0000 arm64 pmap: Simplify logic around pv_chunk sizes. - Define PC_FREEL and _NPCM in terms of _NPCPV rather than via magic numbers. - Remove assertions about _NPC* values from pmap.c. This is less relevant now that PC_FREEL and _NPCM are derived from _NPCPV. - Add a helper inline function pc_is_full() which uses a loop to check if pc_map is all zeroes. Use this to replace three places that check for a full mask assuming there are only 3 entries in pc_map. Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D36217 --- sys/arm64/arm64/pmap.c | 30 +++++++++++++----------------- sys/arm64/include/pmap.h | 3 +-- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 62276c024212..9c47c043d251 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -2449,13 +2449,6 @@ pmap_growkernel(vm_offset_t addr) ***************************************************/ CTASSERT(sizeof(struct pv_chunk) == PAGE_SIZE); -#if PAGE_SIZE == PAGE_SIZE_4K -CTASSERT(_NPCM == 3); -CTASSERT(_NPCPV == 168); -#else -CTASSERT(_NPCM == 11); -CTASSERT(_NPCPV == 677); -#endif static __inline struct pv_chunk * pv_to_chunk(pv_entry_t pv) @@ -2467,11 +2460,7 @@ pv_to_chunk(pv_entry_t pv) #define PV_PMAP(pv) (pv_to_chunk(pv)->pc_pmap) #define PC_FREEN 0xfffffffffffffffful -#if _NPCM == 3 -#define PC_FREEL 0x000000fffffffffful -#elif _NPCM == 11 -#define PC_FREEL 0x0000001ffffffffful -#endif +#define PC_FREEL ((1ul << (_NPCPV % 64)) - 1) #if _NPCM == 3 #define PC_IS_FREE(pc) ((pc)->pc_map[0] == PC_FREEN && \ @@ -2491,6 +2480,15 @@ static const uint64_t pc_freemask[] = { PC_FREEN, PC_FREEN, CTASSERT(nitems(pc_freemask) == _NPCM); +static __inline bool +pc_is_full(struct pv_chunk *pc) +{ + for (u_int i = 0; i < _NPCM; i++) + if (pc->pc_map[i] != 0) + return (false); + return (true); +} + #ifdef PV_STATS static int pc_chunk_count, pc_chunk_allocs, pc_chunk_frees, pc_chunk_tryfail; @@ -2785,8 +2783,7 @@ retry: pv = &pc->pc_pventry[field * 64 + bit]; pc->pc_map[field] &= ~(1ul << bit); /* If this was the last item, move it to tail */ - if (pc->pc_map[0] == 0 && pc->pc_map[1] == 0 && - pc->pc_map[2] == 0) { + if (pc_is_full(pc)) { TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); @@ -2953,8 +2950,7 @@ pmap_pv_demote_l2(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, va_last = va + L2_SIZE - PAGE_SIZE; for (;;) { pc = TAILQ_FIRST(&pmap->pm_pvchunk); - KASSERT(pc->pc_map[0] != 0 || pc->pc_map[1] != 0 || - pc->pc_map[2] != 0, ("pmap_pv_demote_l2: missing spare")); + KASSERT(!pc_is_full(pc), ("pmap_pv_demote_l2: missing spare")); for (field = 0; field < _NPCM; field++) { while (pc->pc_map[field]) { bit = ffsl(pc->pc_map[field]) - 1; @@ -2975,7 +2971,7 @@ pmap_pv_demote_l2(pmap_t pmap, vm_offset_t va, vm_paddr_t pa, TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); } out: - if (pc->pc_map[0] == 0 && pc->pc_map[1] == 0 && pc->pc_map[2] == 0) { + if (pc_is_full(pc)) { TAILQ_REMOVE(&pmap->pm_pvchunk, pc, pc_list); TAILQ_INSERT_TAIL(&pmap->pm_pvchunk, pc, pc_list); } diff --git a/sys/arm64/include/pmap.h b/sys/arm64/include/pmap.h index f36b081ea869..9605c813285b 100644 --- a/sys/arm64/include/pmap.h +++ b/sys/arm64/include/pmap.h @@ -107,16 +107,15 @@ typedef struct pv_entry { * need to track per-pmap assignments. */ #if PAGE_SIZE == PAGE_SIZE_4K -#define _NPCM 3 #define _NPCPV 168 #define _NPAD 0 #elif PAGE_SIZE == PAGE_SIZE_16K -#define _NPCM 11 #define _NPCPV 677 #define _NPAD 1 #else #error Unsupported page size #endif +#define _NPCM howmany(_NPCPV, 64) #define PV_CHUNK_HEADER \ pmap_t pc_pmap; \