From owner-svn-src-all@freebsd.org Thu Jan 23 11:20:24 2020 Return-Path: Delivered-To: svn-src-all@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 D5170235BC9; Thu, 23 Jan 2020 11:20:24 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 483KZJ47rgz4TtK; Thu, 23 Jan 2020 11:20:24 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id 00NBKG1i010406 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 23 Jan 2020 13:20:20 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 00NBKG1i010406 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id 00NBKG9K010341; Thu, 23 Jan 2020 13:20:16 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 23 Jan 2020 13:20:16 +0200 From: Konstantin Belousov To: Ryan Libby Cc: src-committers , svn-src-all , svn-src-head , Mark Johnston Subject: Re: svn commit: r356919 - head/sys/x86/x86 Message-ID: <20200123112016.GS4808@kib.kiev.ua> References: <202001201723.00KHN3tX093432@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.3 X-Spam-Checker-Version: SpamAssassin 3.4.3 (2019-12-06) on tom.home X-Rspamd-Queue-Id: 483KZJ47rgz4TtK X-Spamd-Bar: ----- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-5.99 / 15.00]; NEURAL_HAM_MEDIUM(-0.99)[-0.995,0]; NEURAL_HAM_LONG(-0.99)[-0.992,0]; REPLY(-4.00)[] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Jan 2020 11:20:24 -0000 On Wed, Jan 22, 2020 at 06:39:22PM -0800, Ryan Libby wrote: > On Mon, Jan 20, 2020 at 9:23 AM Konstantin Belousov wrote: > > > > Author: kib > > Date: Mon Jan 20 17:23:03 2020 > > New Revision: 356919 > > URL: https://svnweb.freebsd.org/changeset/base/356919 > > > > Log: > > x86: Wait for curthread to be set up as an indicator that the boot stack > > is no longer used. > > > > pc_curthread is set by cpu_switch after it stopped using the old > > thread (or boot) stack. This makes the smp_after_idle_runnable() > > function not dependent on the internals of the scheduler operations. > > > > Reviewed by: markj > > Sponsored by: The FreeBSD Foundation > > MFC after: 1 week > > Differential revision: https://reviews.freebsd.org/D23276 > > > > Modified: > > head/sys/x86/x86/mp_x86.c > > > > Modified: head/sys/x86/x86/mp_x86.c > > ============================================================================== > > --- head/sys/x86/x86/mp_x86.c Mon Jan 20 16:59:39 2020 (r356918) > > +++ head/sys/x86/x86/mp_x86.c Mon Jan 20 17:23:03 2020 (r356919) > > @@ -1092,13 +1092,12 @@ init_secondary_tail(void) > > static void > > smp_after_idle_runnable(void *arg __unused) > > { > > - struct thread *idle_td; > > + struct pcpu *pc; > > int cpu; > > > > for (cpu = 1; cpu < mp_ncpus; cpu++) { > > - idle_td = pcpu_find(cpu)->pc_idlethread; > > - while (atomic_load_int(&idle_td->td_lastcpu) == NOCPU && > > - atomic_load_int(&idle_td->td_oncpu) == NOCPU) > > + pc = pcpu_find(cpu); > > + while (atomic_load_ptr(&pc->pc_curthread) == (uintptr_t)NULL) > > cpu_spinwait(); > > kmem_free((vm_offset_t)bootstacks[cpu], kstack_pages * > > PAGE_SIZE); > > _______________________________________________ > > svn-src-all@freebsd.org mailing list > > https://lists.freebsd.org/mailman/listinfo/svn-src-all > > To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org" > > I'm hitting a boot panic on a KVM VM that I think is because of this. > I don't think this works as advertised, because init_secondary_tail sets > curthread to its idlethread *itself* before it calls sched_switch. So I > think the current check is not enough to know that we're actually off > the bootstack. > > My panic is an AP page faults in the middle of init_secondary_tail, > after curthread is set. Weirdly, I only seem to hit it when I have > disabled some CPUs (to test D23318). I think this must just be > affecting some aspect of the timing. Supposed fix is https://reviews.freebsd.org/D23330