From owner-freebsd-current@freebsd.org Mon Oct 19 20:39:59 2020 Return-Path: Delivered-To: freebsd-current@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 DC499434481; Mon, 19 Oct 2020 20:39:59 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-io1-xd41.google.com (mail-io1-xd41.google.com [IPv6:2607:f8b0:4864:20::d41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CFTCL3Ff9z48j6; Mon, 19 Oct 2020 20:39:58 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: by mail-io1-xd41.google.com with SMTP id q25so1457485ioh.4; Mon, 19 Oct 2020 13:39:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=CmoJc3Se4kYJ4D0w5hM+bPiL1uZ+22dXmJZbpjxT7vQ=; b=OXs8+RCGtOxL6n/WkVwq+3dFEm11mniP+nIDtdarmI0oKMzgxvw27ijbhfwG0J84tS sGfy9D6f0P+pBdHct5OKsfyOAMzifNGFrP2iE6n2GY1H+kBRLcf8hPyJnIBYeNAdkiwJ ce/1G18kNjvDTtyrSQ/hJOw7E1v75W+WUK1ej60FmPHuVYsJgtn/p8c8jcA1OE/9AQ2L nTR+FlqNtdKzi2ng+LqUm5A7n0xtAdE8vCny46vQdsv3+JiaHabZJnA+/GoPnePXt8SZ 9p6UdZRDTRaqBnBqIZCyGcqjw3DSVVZI6N2LcmDQyMqbQHPGPrpI0K5vc/QDCz8V1i85 b87Q== X-Gm-Message-State: AOAM530cDf5fdgyUJFzgG9YUP5/CFJgF1kakrEwcxEogHdHRbm4nfMwc CqZqo/LRjNtslPEerPcyWmQHrold4PM= X-Google-Smtp-Source: ABdhPJxj18hsbo193UotBMD0F8QtF4mwEBjjIO6XZobfvfqfP17Z8P67HgDEGKXfs5BEYZpZrzGbcQ== X-Received: by 2002:a02:a798:: with SMTP id e24mr1531280jaj.105.1603139997051; Mon, 19 Oct 2020 13:39:57 -0700 (PDT) Received: from raichu (toroon0560w-lp130-01-174-88-77-103.dsl.bell.ca. [174.88.77.103]) by smtp.gmail.com with ESMTPSA id h14sm766399ilc.38.2020.10.19.13.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Oct 2020 13:39:56 -0700 (PDT) Sender: Mark Johnston Date: Mon, 19 Oct 2020 16:39:54 -0400 From: Mark Johnston To: mmel@freebsd.org Cc: bob prohaska , freebsd-current@freebsd.org, freebsd-arm@freebsd.org Subject: Re: panic: non-current pmap 0xffffa00020eab8f0 on Rpi3 Message-ID: <20201019203954.GC46122@raichu> References: <20201006021029.GA13260@www.zefox.net> <20201006133743.GA96285@raichu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspamd-Queue-Id: 4CFTCL3Ff9z48j6 X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.62 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36:c]; NEURAL_HAM_LONG(-1.02)[-1.020]; MIME_GOOD(-0.10)[text/plain]; MID_RHS_NOT_FQDN(0.50)[]; DMARC_NA(0.00)[freebsd.org]; TO_DN_SOME(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; NEURAL_HAM_SHORT(-0.89)[-0.893]; RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::d41:from]; NEURAL_HAM_MEDIUM(-1.01)[-1.009]; FORGED_SENDER(0.30)[markj@freebsd.org,markjdb@gmail.com]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[markj@freebsd.org,markjdb@gmail.com]; MAILMAN_DEST(0.00)[freebsd-current,freebsd-arm] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Oct 2020 20:39:59 -0000 On Fri, Oct 16, 2020 at 11:53:56AM +0200, Michal Meloun wrote: > > > On 06.10.2020 15:37, Mark Johnston wrote: > > On Mon, Oct 05, 2020 at 07:10:29PM -0700, bob prohaska wrote: > >> Still seeing non-current pmap panics on the Pi3, this time a B+ running > >> 13.0-CURRENT (GENERIC-MMCCAM) #0 71e02448ffb-c271826(master) > >> during a -j4 buildworld. The backtrace reports > >> > >> panic: non-current pmap 0xffffa00020eab8f0 > > > > Could you show the output of "show procvm" from the debugger? > > I see same panic too, in my case its very rare - typical scenario is > rebuild of kf5 ports (~250, 2 days of full load). Any idea how to debug > this? > Michal I suspect that there is some race involving the pmap switching in vmspace_exit(), but I can't see it. In the example below, presumably process 22604 on CPU 0 is also exiting? Could you show the backtrace? It would also be useful to see the value of PCPU_GET(curpmap) at the time of the panic. I'm not sure if there's a way to get that from DDB, but I suspect it should be equal to &vmspace0->vm_pmap. I think vmspace_exit() should issue a release fence with the cmpset and an acquire fence when handling the refcnt == 1 case, but I don't see why that would make a difference here. So, if you can test a debug patch, this one will yield a bit more debug info. If you can provide access to a vmcore and kernel debug symbols, that'd be even better. diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c index 284f00b3cc0d..3c53ae3b4c1e 100644 --- a/sys/arm64/arm64/pmap.c +++ b/sys/arm64/arm64/pmap.c @@ -4838,7 +4838,8 @@ pmap_remove_pages(pmap_t pmap) int allfree, field, freed, idx, lvl; vm_paddr_t pa; - KASSERT(pmap == PCPU_GET(curpmap), ("non-current pmap %p", pmap)); + KASSERT(pmap == PCPU_GET(curpmap), + ("non-current pmap %p %p", pmap, PCPU_GET(curpmap))); lock = NULL; diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index c20005ae64cf..0ad415e3b88c 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -358,7 +358,10 @@ vmspace_exit(struct thread *td) p = td->td_proc; vm = p->p_vmspace; atomic_add_int(&vmspace0.vm_refcnt, 1); - refcnt = vm->vm_refcnt; + refcnt = atomic_load_int(&vm->vm_refcnt); + + KASSERT(vmspace_pmap(vm) == PCPU_GET(curpmap), + ("non-current pmap %p %p", pmap, PCPU_GET(curpmap))); do { if (refcnt > 1 && p->p_vmspace != &vmspace0) { /* Switch now since other proc might free vmspace */