From nobody Wed Nov 17 23:10:17 2021 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id D973C18964CB; Wed, 17 Nov 2021 23:10:25 +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) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Hvdv54gY0z3JBW; Wed, 17 Nov 2021 23:10:25 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.16.1/8.16.1) with ESMTPS id 1AHNAHuB059197 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Thu, 18 Nov 2021 01:10:20 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua 1AHNAHuB059197 Received: (from kostik@localhost) by tom.home (8.16.1/8.16.1/Submit) id 1AHNAHUi059196; Thu, 18 Nov 2021 01:10:17 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Thu, 18 Nov 2021 01:10:17 +0200 From: Konstantin Belousov To: Kyle Evans Cc: src-committers , "" , dev-commits-src-main@freebsd.org Subject: Re: git: 589aed00e36c - main - sched: separate out schedinit_ap() Message-ID: References: <202111032055.1A3KtLQX071805@gitrepo.freebsd.org> List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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.5 X-Spam-Checker-Version: SpamAssassin 3.4.5 (2021-03-20) on tom.home X-Rspamd-Queue-Id: 4Hvdv54gY0z3JBW X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[] X-ThisMailContainsUnwantedMimeParts: N On Wed, Nov 17, 2021 at 04:44:29PM -0600, Kyle Evans wrote: > On Wed, Nov 3, 2021 at 3:55 PM Kyle Evans wrote: > > > > The branch main has been updated by kevans: > > > > URL: https://cgit.FreeBSD.org/src/commit/?id=589aed00e36c22733d3fd9c9016deccf074830b1 > > > > commit 589aed00e36c22733d3fd9c9016deccf074830b1 > > Author: Kyle Evans > > AuthorDate: 2021-11-02 18:06:47 +0000 > > Commit: Kyle Evans > > CommitDate: 2021-11-03 20:54:59 +0000 > > > > sched: separate out schedinit_ap() > > > > schedinit_ap() sets up an AP for a later call to sched_throw(NULL). > > > > Currently, ULE sets up some pcpu bits and fixes the idlethread lock with > > a call to sched_throw(NULL); this results in a window where curthread is > > setup in platforms' init_secondary(), but it has the wrong td_lock. > > Typical platform AP startup procedure looks something like: > > > > - Setup curthread > > - ... other stuff, including cpu_initclocks_ap() > > - Signal smp_started > > - sched_throw(NULL) to enter the scheduler > > > > cpu_initclocks_ap() may have callouts to process (e.g., nvme) and > > attempt to sched_add() for this AP, but this attempt fails because > > of the noted violated assumption leading to locking heartburn in > > sched_setpreempt(). > > > > Interrupts are still disabled until cpu_throw() so we're not really at > > risk of being preempted -- just let the scheduler in on it a little > > earlier as part of setting up curthread. > > > > What's the general consensus on potential out-of-tree archs maintained > on stable branches? I'd like to MFC this at least to stable/13 to > avoid it being in the way of the nvme change that spurred it, and I'm > trying to decide if it should have something like this added to make > it safe: I do not believe that we even think of guaranteeing this level of source stability. > > diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c > index 217d685b8587..f07f5e91d8f3 100644 > --- a/sys/kern/sched_ule.c > +++ b/sys/kern/sched_ule.c > @@ -2995,6 +2995,11 @@ sched_throw(struct thread *td) > > tdq = TDQ_SELF(); > if (__predict_false(td == NULL)) { > + if (tdq == NULL || PCPU_GET(idlethread)->td_lock != > + TDQ_LOCKPTR(tdq)) { > + schedinit_ap(); > + tdq = TDQ_SELF(); > + } > TDQ_LOCK(tdq); > /* Correct spinlock nesting. */ > spinlock_exit(); >