From owner-svn-src-all@freebsd.org Thu Jan 23 02:39:38 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 1FD5322904D; Thu, 23 Jan 2020 02:39:38 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) 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 48361P2Kn9z3QHK; Thu, 23 Jan 2020 02:39:37 +0000 (UTC) (envelope-from rlibby@gmail.com) Received: by mail-qk1-f195.google.com with SMTP id k6so1994521qki.5; Wed, 22 Jan 2020 18:39:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=zBc7jTpQzdafMT8ECcTPxzQ1SvH8ezY6BBuaQ3Zz948=; b=WMcCGcPixmM7v0qWBQB2U7EQxEw0Zv9ILvVi4WMB+YcVpBBQQVVnQynzSRBvTaIcKo 4dP2KetrsBgMy1vPnhupgMIxJ0lHKEnEz0u1344XAQsxbL+eZpMSh5FyQY6UKXG3jJ9K 0lUy+EfN9sZJJ1kU0YzG6JAEevglYLH+2HRKFcxOVew9IrKTCmc8ECNugzH9bwsou48W gmRR+LsN4Y/5onIXQKTcgnftGXCoIjSYnBNTj91gkwh0SvTp0bFjob/5yFT8TpF46sy/ hhmTwbBeD/12vxTKDUwOCd6M6QywMWtmqT5oGxIjioqS+C657r7BuJiUOlflZSG9Xnqm cY2w== X-Gm-Message-State: APjAAAXSK4pLpEWJqbCdxwyBTaOx39CToP7IZecwuMeWKPJ+7dzzGTdN xZxfAc9jPi48mbHb/KPsMqi9AX3WpsQ= X-Google-Smtp-Source: APXvYqxyn4EXnB4oOdSDl1VvvyY+xpaOtPYoyJAOuoEGB/63LhuRF6yn8PWbw5l2/bpNqR90gNTmgQ== X-Received: by 2002:a37:6241:: with SMTP id w62mr4512132qkb.197.1579747175531; Wed, 22 Jan 2020 18:39:35 -0800 (PST) Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com. [209.85.222.170]) by smtp.gmail.com with ESMTPSA id g15sm295102qts.19.2020.01.22.18.39.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2020 18:39:35 -0800 (PST) Received: by mail-qk1-f170.google.com with SMTP id d10so2019761qke.1; Wed, 22 Jan 2020 18:39:35 -0800 (PST) X-Received: by 2002:a37:9ed3:: with SMTP id h202mr10946047qke.456.1579747175016; Wed, 22 Jan 2020 18:39:35 -0800 (PST) MIME-Version: 1.0 References: <202001201723.00KHN3tX093432@repo.freebsd.org> In-Reply-To: <202001201723.00KHN3tX093432@repo.freebsd.org> From: Ryan Libby Date: Wed, 22 Jan 2020 18:39:22 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: svn commit: r356919 - head/sys/x86/x86 To: Konstantin Belousov Cc: src-committers , svn-src-all , svn-src-head , Mark Johnston Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 48361P2Kn9z3QHK X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of rlibby@gmail.com designates 209.85.222.195 as permitted sender) smtp.mailfrom=rlibby@gmail.com X-Spamd-Result: default: False [-3.84 / 15.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RCVD_TLS_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:209.85.128.0/17]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; RCPT_COUNT_FIVE(0.00)[5]; RCVD_COUNT_THREE(0.00)[4]; IP_SCORE(-1.84)[ip: (-4.24), ipnet: 209.85.128.0/17(-3.07), asn: 15169(-1.82), country: US(-0.05)]; TO_DN_ALL(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[195.222.85.209.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; FORGED_SENDER(0.30)[rlibby@freebsd.org,rlibby@gmail.com]; RWL_MAILSPIKE_POSSIBLE(0.00)[195.222.85.209.rep.mailspike.net : 127.0.0.17]; MIME_TRACE(0.00)[0:+]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:209.85.128.0/17, country:US]; FROM_NEQ_ENVFROM(0.00)[rlibby@freebsd.org,rlibby@gmail.com] 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 02:39:38 -0000 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. Ryan