Module Name: src Committed By: skrll Date: Fri Oct 6 08:48:16 UTC 2023
Modified Files: src/sys/uvm/pmap: pmap_tlb.c pmap_tlb.h Log Message: Support CPUs that might not have ASIDs in the common pmap. To generate a diff of this commit: cvs rdiff -u -r1.60 -r1.61 src/sys/uvm/pmap/pmap_tlb.c cvs rdiff -u -r1.16 -r1.17 src/sys/uvm/pmap/pmap_tlb.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/uvm/pmap/pmap_tlb.c diff -u src/sys/uvm/pmap/pmap_tlb.c:1.60 src/sys/uvm/pmap/pmap_tlb.c:1.61 --- src/sys/uvm/pmap/pmap_tlb.c:1.60 Tue Aug 1 08:17:26 2023 +++ src/sys/uvm/pmap/pmap_tlb.c Fri Oct 6 08:48:16 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_tlb.c,v 1.60 2023/08/01 08:17:26 skrll Exp $ */ +/* $NetBSD: pmap_tlb.c,v 1.61 2023/10/06 08:48:16 skrll Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.60 2023/08/01 08:17:26 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.61 2023/10/06 08:48:16 skrll Exp $"); /* * Manages address spaces in a TLB. @@ -830,6 +830,22 @@ pmap_tlb_asid_alloc(struct pmap_tlb_info KASSERT(ti->ti_asids_free > 0); KASSERT(ti->ti_asid_hint > KERNEL_PID); + if (__predict_false(!tlbinfo_asids_p(ti))) { +#if defined(MULTIPROCESSOR) + /* + * Mark that we are active for all CPUs sharing this TLB. + * The bits in pm_active belonging to this TLB can only + * be changed while this TLBs lock is held. + */ +#if PMAP_TLB_MAX == 1 + kcpuset_copy(pm->pm_active, kcpuset_running); +#else + kcpuset_merge(pm->pm_active, ti->ti_kcpuset); +#endif +#endif + return; + } + /* * If the last ASID allocated was the maximum ASID, then the * hint will be out of range. Reset the hint to first @@ -937,7 +953,7 @@ pmap_tlb_asid_acquire(pmap_t pm, struct /* * If we've run out ASIDs, reinitialize the ASID space. */ - if (__predict_false(tlbinfo_noasids_p(ti))) { + if (__predict_false(tlbinfo_asids_p(ti) && tlbinfo_noasids_p(ti))) { KASSERT(l == curlwp); UVMHIST_LOG(maphist, " asid reinit", 0, 0, 0, 0); pmap_tlb_asid_reinitialize(ti, TLBINV_NOBODY); Index: src/sys/uvm/pmap/pmap_tlb.h diff -u src/sys/uvm/pmap/pmap_tlb.h:1.16 src/sys/uvm/pmap/pmap_tlb.h:1.17 --- src/sys/uvm/pmap/pmap_tlb.h:1.16 Wed Oct 26 07:35:20 2022 +++ src/sys/uvm/pmap/pmap_tlb.h Fri Oct 6 08:48:16 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap_tlb.h,v 1.16 2022/10/26 07:35:20 skrll Exp $ */ +/* $NetBSD: pmap_tlb.h,v 1.17 2023/10/06 08:48:16 skrll Exp $ */ /* * Copyright (c) 1992, 1993 @@ -86,6 +86,10 @@ # endif #endif +#if !defined(PMAP_TLB_ALWAYS_ASIDS) +#define PMAP_TLB_ALWAYS_ASIDS true +#endif + /* * Per TLB (normally same as CPU) asid info */ @@ -97,7 +101,7 @@ struct pmap_asid_info { #define TLBINFO_LOCK(ti) mutex_spin_enter((ti)->ti_lock) #define TLBINFO_UNLOCK(ti) mutex_spin_exit((ti)->ti_lock) #define TLBINFO_OWNED(ti) mutex_owned((ti)->ti_lock) -#define PMAP_PAI_ASIDVALID_P(pai, ti) ((pai)->pai_asid != 0) +#define PMAP_PAI_ASIDVALID_P(pai, ti) (!tlbinfo_asids_p(ti) || (pai)->pai_asid != 0) #define PMAP_PAI(pmap, ti) (&(pmap)->pm_pai[tlbinfo_index(ti)]) #define PAI_PMAP(pai, ti) \ ((pmap_t)((intptr_t)(pai) \ @@ -188,5 +192,11 @@ void pmap_tlb_asid_check(void); /* for ddb */ void pmap_db_tlb_print(struct pmap *, void (*)(const char *, ...) __printflike(1, 2)); +static inline bool +tlbinfo_asids_p(struct pmap_tlb_info *ti) +{ + return PMAP_TLB_ALWAYS_ASIDS || (ti)->ti_asid_max != 0; +} + #endif /* _KERNEL */ #endif /* _UVM_PMAP_PMAP_TLB_H_ */