From patchwork Wed Sep 20 07:21:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 142283 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3971447vqi; Wed, 20 Sep 2023 01:33:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHGz9LAv4KpbPnJDMwb/6dtqi07NDeVwdKKRKq4ji1EYA+D/qKw5BcKiub/KV32TS5x+uY8 X-Received: by 2002:a17:90a:d58e:b0:276:a08e:a871 with SMTP id v14-20020a17090ad58e00b00276a08ea871mr2020920pju.47.1695198781535; Wed, 20 Sep 2023 01:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695198781; cv=none; d=google.com; s=arc-20160816; b=DRWnvV+7zl3LROW4aEhhGBG82v4sMdYWK2GR0Yh894iFC6zjZC3hIJPTKqyIaNBv0b MZbQtIGkHH/jQjVNIpMQS8hocGLVgnWV35Yu8RtbpZWYVZOR2TWslGpmjhpT9F4A9wEM Ow4YZDxWRNiHEtsqdl7vq0WlwEi8iwNeq005rpD41yY+dGekYCY497YUJVD/I7Ffn5tz gSAiDHHEFeDfzFBPCqEzLaGgp+Ifu6s//p55QGainAoXU9FGajH/YNLjO0Sna7Vz9PNf uFVE+yYRq4AOYlTA1QRS2Cw/Gt7i9CZRjSRGgnPZgDJBFLhDnYtL+zVFj9aKsc0oR+be rcoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=/5KJNffF9+5nflASRQLuduWKw+t4/oBUSb/rEqjysqg=; fh=j9BaSnWgVcSoSwadcSq+0FSfwDFxAhjSvVUfW9cGYFc=; b=EA/t/JDJSOO9H5P0IhY8W67GajqSfWvP7CkNkca3FugCtGDllr8JYJIMbTgfLXC7Tj GqmY40BOBu85+NdyCh2l2VaM6NmIb0SXa/illfMxR+t//5p38IQJzK7VgrX8uxSwOGJI 7sZv2wSmP1ZF6wX2ewBHwMErrLWy4ft/mxdRIl4IHp6ZxZK+F2ZR0BW7oT39NBHzEm6m H7Ayzi9AZBkCl8ozJpHxo+Icy8+Q1ZgklOmZuUhf96nbB/+lpsMbHgaFn0olq+2YeCDR s6teENPkztPCSjgM3OI1kkTTY6ITSjCAt3jgdLJHiOi1je1lUS1angGjDHVr2IHV6pYO 12UQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1xKQidze; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id mq16-20020a17090b381000b00268414272cbsi1157684pjb.75.2023.09.20.01.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 01:33:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1xKQidze; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BAFB980C2E09; Wed, 20 Sep 2023 00:21:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233671AbjITHVj (ORCPT + 26 others); Wed, 20 Sep 2023 03:21:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233694AbjITHVh (ORCPT ); Wed, 20 Sep 2023 03:21:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 46AEFEA; Wed, 20 Sep 2023 00:21:28 -0700 (PDT) Date: Wed, 20 Sep 2023 07:21:25 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1695194486; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/5KJNffF9+5nflASRQLuduWKw+t4/oBUSb/rEqjysqg=; b=1xKQidzeW6MhNkgGwAwtZ5RX3jdN/0tRQXxm3kdSllbVafx9VONnSefp7z7tOiF3/IBx6D NJAsYddi3LExxNaiblIKaQDEiV+/D/nhOjkkA5Hqo4YTlYrLQc/rk4P2QzBgMpOGmL0DZr 53xwiCO6siqZQfUHOe1vsu5ZybVJYO6CMww1rEeT0QMRnTIe1QcFKBkLMJdFflm6Q7ua4U lqPsuugLWT+4WntDW3XhBk7wFBY1vvq8ogDnQE9opOwnml5yyWrwuGxHMO8rUFna18Alc4 B4nXiGUiimGszdvrqVkZnXAmGsVP8gr5Lha/dVPVKK8+3Oxdcn/hk4ov4Z9B5g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1695194486; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/5KJNffF9+5nflASRQLuduWKw+t4/oBUSb/rEqjysqg=; b=Nvy1+iSqfLSq1YVJ4N2EdBBk6V3JlS6LMtuTxHMYNxUqJMlf28gi4xkb29Q4eU94Y/xfYh AZ0ctaNY3r+SmgBw== From: "tip-bot2 for Liam R. Howlett" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] kernel/sched: Modify initial boot task idle setup Cc: "Liam R. Howlett" , "Peter Zijlstra (Intel)" , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <169519448577.27769.8422721059198672038.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 20 Sep 2023 00:21:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777544757874821941 X-GMAIL-MSGID: 1777544757874821941 The following commit has been merged into the sched/urgent branch of tip: Commit-ID: cff9b2332ab762b7e0586c793c431a8f2ea4db04 Gitweb: https://git.kernel.org/tip/cff9b2332ab762b7e0586c793c431a8f2ea4db04 Author: Liam R. Howlett AuthorDate: Fri, 15 Sep 2023 13:44:44 -04:00 Committer: Peter Zijlstra CommitterDate: Tue, 19 Sep 2023 10:48:04 +02:00 kernel/sched: Modify initial boot task idle setup Initial booting is setting the task flag to idle (PF_IDLE) by the call path sched_init() -> init_idle(). Having the task idle and calling call_rcu() in kernel/rcu/tiny.c means that TIF_NEED_RESCHED will be set. Subsequent calls to any cond_resched() will enable IRQs, potentially earlier than the IRQ setup has completed. Recent changes have caused just this scenario and IRQs have been enabled early. This causes a warning later in start_kernel() as interrupts are enabled before they are fully set up. Fix this issue by setting the PF_IDLE flag later in the boot sequence. Although the boot task was marked as idle since (at least) d80e4fda576d, I am not sure that it is wrong to do so. The forced context-switch on idle task was introduced in the tiny_rcu update, so I'm going to claim this fixes 5f6130fa52ee. Fixes: 5f6130fa52ee ("tiny_rcu: Directly force QS when call_rcu_[bh|sched]() on idle_task") Signed-off-by: Liam R. Howlett Signed-off-by: Peter Zijlstra (Intel) Cc: stable@vger.kernel.org Link: https://lore.kernel.org/linux-mm/CAMuHMdWpvpWoDa=Ox-do92czYRvkok6_x6pYUH+ZouMcJbXy+Q@mail.gmail.com/ --- kernel/sched/core.c | 2 +- kernel/sched/idle.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2299a5c..802551e 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; kthread_set_per_cpu(idle, cpu); #ifdef CONFIG_SMP diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index 342f58a..5007b25 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -373,6 +373,7 @@ EXPORT_SYMBOL_GPL(play_idle_precise); void cpu_startup_entry(enum cpuhp_state state) { + current->flags |= PF_IDLE; arch_cpu_idle_prepare(); cpuhp_online_idle(state); while (1)