On Sat, Apr 11, 2026 at 08:43:57PM +0200, Mark Kettenis wrote:
[...]
> Lightly tested by building some kernels and libc with make -j24. I've
> never been able to trigger the db_enter() on my t5120, so I don't
> expect to ever hit this code myself.
>
> ok?
A bit late to the party, yes, LGTM.
I'm restarting an experiment with your latest version and moving the
mtx_enter() call before the for loop. The previous run didn't trigger
since Fri 10, 1pm, running perl subprocesses and building libc in a
loop.
> ? arch/sparc64/compile/GENERIC.MP/obj
> Index: arch/sparc64/sparc64/pmap.c
> ===================================================================
> RCS file: /cvs/src/sys/arch/sparc64/sparc64/pmap.c,v
> diff -u -p -r1.127 pmap.c
> --- arch/sparc64/sparc64/pmap.c 14 Dec 2025 12:37:22 -0000 1.127
> +++ arch/sparc64/sparc64/pmap.c 11 Apr 2026 18:43:27 -0000
> @@ -2579,6 +2579,7 @@ ctx_free(struct pmap *pm)
> {
> int oldctx;
> #ifdef DIAGNOSTIC
> + u_int64_t tag, data;
> int i;
> #endif
>
> @@ -2597,10 +2598,25 @@ ctx_free(struct pmap *pm)
> db_enter();
> }
> for (i = 0; i < TSBENTS; i++) {
> - if (TSB_TAG_CTX(tsb_dmmu[i].tag) == oldctx ||
> - TSB_TAG_CTX(tsb_immu[i].tag) == oldctx) {
> - printf("ctx_free: context %d still active\n", oldctx);
> - db_enter();
> + tag = READ_ONCE(tsb_dmmu[i].tag);
> + if (TSB_TAG_CTX(tag) == oldctx) {
> + data = READ_ONCE(tsb_dmmu[i].data);
> + atomic_cas_ulong((unsigned long *)&tsb_dmmu[i].tag,
> + tag, TSB_TAG_INVALID);
> + printf("%s: context %d still active in DMMU TSB\n",
> + __func__, oldctx);
> + printf("%s: tag 0x%016llx data 0x%016llx\n",
> + __func__, tag, data);
> + }
> + tag = READ_ONCE(tsb_immu[i].tag);
> + if (TSB_TAG_CTX(tag) == oldctx) {
> + data = READ_ONCE(tsb_immu[i].data);
> + atomic_cas_ulong((unsigned long *)&tsb_immu[i].tag,
> + tag, TSB_TAG_INVALID);
> + printf("%s: context %d still active in IMMU TSB\n",
> + __func__, oldctx);
> + printf("%s: tag 0x%016llx data 0x%016llx\n",
> + __func__, tag, data);
> }
> }
> #endif
>
--
jca