From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8091EDE983 for ; Thu, 14 Sep 2023 07:14:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EDF3D6B02C6; Thu, 14 Sep 2023 03:14:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E67A86B02C7; Thu, 14 Sep 2023 03:14:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D08496B02C8; Thu, 14 Sep 2023 03:14:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B95756B02C6 for ; Thu, 14 Sep 2023 03:14:08 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 65048C10D2 for ; Thu, 14 Sep 2023 07:14:08 +0000 (UTC) X-FDA: 81234338976.25.DAA415C Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) by imf02.hostedemail.com (Postfix) with ESMTP id C8A6F8000C for ; Thu, 14 Sep 2023 07:14:04 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=KvQ0nsXm; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694675646; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tpyNEwfTuAdC2bVWoAh1ZSf7Py2GtvsENTWVWqeeKaU=; b=kudtX6uuuzEptbSTvdDTS6wiP/SB/Vi4zh5i5NlYJQxHd06SoUoy1jvpSZkId0n5J5ly0+ 6JiQ1uIR8KOBKH0LwEfmw5KORYhbydO6kzHU3XhXszkjEbuk6651BRu/kM/wx8ZrRjOhpf 6tNGgLHTdXVD5QKoleOzUY27OiF4d2k= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=desiato.20200630 header.b=KvQ0nsXm; dmarc=none; spf=none (imf02.hostedemail.com: domain of peterz@infradead.org has no SPF policy when checking 90.155.92.199) smtp.mailfrom=peterz@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694675646; a=rsa-sha256; cv=none; b=WCBukm3JAOR46xmNTqevN2R5iUe57GT6NMuzUJ0PQXR6WGL1mlHoaUhdvCPqayczjDIzWj i/k2OENF8KAXwRC0n/g56m8IPZokSciy2iil6OerRBkRat2iE5lQtXslc58GVQi4M+lxeB tnCRluuBDTjCO1ZajteoVsONpfciUkM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=tpyNEwfTuAdC2bVWoAh1ZSf7Py2GtvsENTWVWqeeKaU=; b=KvQ0nsXmAW6D0O1+Wxlj+piemx IZf7VMClkW1PF0SNayQK5nU0tVeofjYB1OsOCEIdPY1bUGPu8BqP3PiLqeSaxeP71AZPMxcrUVR82 dQmJgmP1G9luTQwDaqjctpBoUE7AyLHd4qTsAVtZGZCpVrX3EwFgTgo9oVnbviCfzsvkl0NFLZl/c RgRwzk+dUn9+eipb8cbq+/3ZSTqdFqbbr1AarSvvoKBX0blQktDo8v8zKjcnruPUMH7cJFYVks22h 8tMMjH5/jT+Q3S4CXon51eUayvjB4h6shKBGTZ9pVgn77jgua5d0skFCFsS6Aoez1C5LfPOWT9td1 qMvIsaqA==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.96 #2 (Red Hat Linux)) id 1qggXp-007hW1-2E; Thu, 14 Sep 2023 07:13:47 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id C2C9030036C; Thu, 14 Sep 2023 09:13:46 +0200 (CEST) Date: Thu, 14 Sep 2023 09:13:46 +0200 From: Peter Zijlstra To: "Liam R. Howlett" , Andrew Morton , maple-tree@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Geert Uytterhoeven , "Paul E. McKenney" , Christophe Leroy , Andreas Schwab , Matthew Wilcox , Peng Zhang , Ingo Molnar , Juri Lelli , Vincent Guittot , "Mike Rapoport (IBM)" , Vlastimil Babka Subject: Re: [PATCH] init/main: Clear boot task idle flag Message-ID: <20230914071346.GA16631@noisy.programming.kicks-ass.net> References: <20230913005647.1534747-1-Liam.Howlett@oracle.com> <20230913135246.GH692@noisy.programming.kicks-ass.net> <20230913145125.xssion4ygykunzrc@revolver> <20230913161236.GI692@noisy.programming.kicks-ass.net> <20230913173238.h6tj4lwsbdxcuswo@revolver> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230913173238.h6tj4lwsbdxcuswo@revolver> X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: C8A6F8000C X-Stat-Signature: jzfkrwtutfhpjiu7apbptmjkej4ersgg X-HE-Tag: 1694675644-167334 X-HE-Meta: U2FsdGVkX19Tf1kXAeQPSquSq8g7atBrGI7pg/XzjmenwQ8pXHZXCqS11v0Dhr+pnkIMzcd+lu+tEn9+x6LHqkJrHdIOg+m3unGri1BK3q+OteKv2NS7ZJkIPTRTwx87MfUxktq1al9D1zoKS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4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Sep 13, 2023 at 01:32:38PM -0400, Liam R. Howlett wrote: > * Peter Zijlstra [230913 12:13]: > > On Wed, Sep 13, 2023 at 10:51:25AM -0400, Liam R. Howlett wrote: > > > * Peter Zijlstra [230913 09:53]: > > > > On Tue, Sep 12, 2023 at 08:56:47PM -0400, Liam R. Howlett wrote: > > > > > > > > > diff --git a/init/main.c b/init/main.c > > > > > index ad920fac325c..f74772acf612 100644 > > > > > --- a/init/main.c > > > > > +++ b/init/main.c > > > > > @@ -696,7 +696,7 @@ noinline void __ref __noreturn rest_init(void) > > > > > */ > > > > > rcu_read_lock(); > > > > > tsk = find_task_by_pid_ns(pid, &init_pid_ns); > > > > > - tsk->flags |= PF_NO_SETAFFINITY; > > > > > + tsk->flags |= PF_NO_SETAFFINITY | PF_IDLE; > > > > > set_cpus_allowed_ptr(tsk, cpumask_of(smp_processor_id())); > > > > > rcu_read_unlock(); > > > > > > > > > > > > > Hmm, isn't that pid-1 you're setting PF_IDLE on? > > > > > > Yes, thanks. I think that is what Geert is hitting with my patch. > > > > > > debug __might_resched() in kernel/sched/core.c is failing to return in > > > that first (complex) if statement. His report says pid 1 so this is > > > likely the issue. > > > > > > > > > > > The task becoming idle is 'current' at this point, see the > > > > cpu_startup_entry() call below. > > > > > > > > Would not something like so be the right thing? > > > > > > > > > > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > > > index 2299a5cfbfb9..802551e0009b 100644 > > > > --- a/kernel/sched/core.c > > > > +++ b/kernel/sched/core.c > > > > @@ -9269,7 +9269,7 @@ void __init init_idle(struct task_struct *idle, int cpu) > > > > * PF_KTHREAD should already be set at this point; regardless, make it > > > > * look like a proper per-CPU kthread. > > > > */ > > > > - idle->flags |= PF_IDLE | PF_KTHREAD | PF_NO_SETAFFINITY; > > > > + idle->flags |= PF_KTHREAD | PF_NO_SETAFFINITY; > > > > > > I am concerned this will alter more than just the current task, which > > > would mean more modifications later. There is a comment about it being > > > called 'more than once' and 'per cpu' so I am hesitant to change the > > > function itself. > > > > > > Although I am unsure of the call path.. fork_idle() -> init_idle() I > > > guess? > > > > There's only 2 ways to get into do_idle(), through cpu_startup_entry() > > and play_idle_precise(). The latter already frobs PF_IDLE since it is > > the forced idle path, this then leaves cpu_startup_entry() which is the > > regular idle path. > > > > All idle threads will end up calling into it, the boot CPU through the > > rest_init() and the SMP cpus through arch SMP bringup. > > > > IOW, this ensures all idle loops will have PF_IDLE set but not the > > pre-idle loop setup code these threads run. > > Thanks for the information. This does leave the init_idle() function in > the odd state of not setting PF_IDLE, but I guess that's okay? Yep, the few things that care about PF_IDLE seem to really only care about do_idle() and very much not (per the rcutiny thing) any code that comes before it.