Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp732243lqa; Sun, 28 Apr 2024 01:24:52 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUSxTmsOL7c9D5H2dO7RKXp4Q5mKsUCTzc30AFHJDSIW6REXd+w3ZHawGl7XMwA2kdFDM+JelLFDMVhXD4UGqgUByCeAMqtaoNHBbvgfg== X-Google-Smtp-Source: AGHT+IFSxJBlz3xp73Q7RDfHcoIFVjHwrGRzAuAdXiFohHKzi42tZkEckWB6KQHEmJgxxVueE3y+ X-Received: by 2002:a17:903:2447:b0:1e4:17e4:3a1f with SMTP id l7-20020a170903244700b001e417e43a1fmr4930442pls.4.1714292692693; Sun, 28 Apr 2024 01:24:52 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714292692; cv=pass; d=google.com; s=arc-20160816; b=uMQKekO8WDWbL5CMPrWkM0dsLds6cnuXw80edM0t/xnCxKQFedhOc6blTgkvGb9db/ OsU8zTShX256RMepsSUtfjCSyA7V6WY88t0SS1670PWPIIrrs2ipFaFJzLUxHC4CZYgp eNVymFnwm28nAU6AezuQLOudUYaGLo5cbt2/E8q7TO14y+x+KGPtm5uCZ5ZNtjQjk8mn 5T2TcV2PYkHF9mf9eQNiizT+p6FYOGZ8k0R2VSlY2g58BaS7TXf1lR4ryMIMcvPcggFT Tm8Fcuw2+gmuCxOab2EhcsMQ0ML4r9M9IL3T+XDdbuTm0qo/IlnPj0VHTXuTrw64OYKq SHkQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=cQJyJVk6gQIgoeWCNjweQHoV2R23rcnn9pDzsHMahbQ=; fh=zX+n3+pTY9b/73h0V479qNzWUaRIKL5LM3W2/kQss80=; b=yarNsv2CJTEj5crlmU/tQORtrwq6pJ/1yi4Ku++aylDRC0j1tN17NrhW+dDWGQjkx7 Z0CG2nxf62zR3HEiqYJNI7pNbrVQFBCL8MQVxtuKHAd39x85Xq/El1MfJT+/b3+QdFt0 vwa/7khAGi5TNe1gJ/jnqK+u2ZJI8ohH1lCzMfOhIB6iiIXP+9G2zmNZgBe+fKRkdf/O uyE9l51Kk3dSWnF1k9XLkNlDU7JwQ1KnLCKwWmmOPqQCZj1mAzLcPbTslG2aUKQQPM0S 39B9wPtajK98qOb9JsQd+E1531ehu224MZa8nmQd0HJtuC/3lbX3m94kcjXTqyBuuUfZ IkoQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tmUfiNAY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-161325-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161325-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d17-20020a170903209100b001e528f373edsi17360465plc.602.2024.04.28.01.24.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 28 Apr 2024 01:24:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-161325-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=tmUfiNAY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-161325-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-161325-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4E904281AB0 for ; Sun, 28 Apr 2024 08:24:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 711AC52F63; Sun, 28 Apr 2024 08:24:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="tmUfiNAY"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="vQdZSX8S" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DF89EF9EF; Sun, 28 Apr 2024 08:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714292681; cv=none; b=oYHJmCnG3CuzBGxggCqW7WVNXpfdx80+aPvew8vYURYgyCMjb9fEK2Z6cwrvRyR9xyBNqlb/anwV37zEjcpHYH94B+TgAZmlS7M75EVk044CLwaK0Pk3iEVFjLM8YG4nz6r24NtZ9cPQ4QJfgJ3ZahLT89NunLUPNJMdZEvBGfQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714292681; c=relaxed/simple; bh=Vil+BDqRYDS6LChmPe6Q6on+lguWBTWidGmONc/mXiE=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=X/6l+zWmrRq+997epiQYx0yJ55im4mSHK9F+nIBkbZE6M8AWrIdGvjdI4IxqVhp2N8jyDKzKXcEvwjlIQKo8sdg3S4yZiXh8lRsER1m3WIfTffCzkTnnXmYVVJepgiwPnK03VPmcaInTL+MoZwG+ZFSN43xyD1CPOmm39Ej9zTg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=tmUfiNAY; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=vQdZSX8S; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Sun, 28 Apr 2024 08:24:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1714292672; 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: in-reply-to:in-reply-to:references:references; bh=cQJyJVk6gQIgoeWCNjweQHoV2R23rcnn9pDzsHMahbQ=; b=tmUfiNAY2Hv7ktiFWwCON7M5jMWMVHTm4QTsIYSjDM281Yc9iMjd7CyglKpyCZ1gcxZ9EP +xqLhG6HqHd4xwYYHMdQOStykuRvxxzfQIeb1FYc+lPE3FiXGruW+V8WxhFYVp/64D+RZV rFnPOXAILRwKUBrDKdn7kBfHslr0pqkkBUCA2K3qhzOeAUHmpRpE2mETYUm4xCT686RQ5c QAw81KT7Qtq2Thlu3XYNDfCUXcrJ22Hh7TL1muGtqYDd5iqrtxWSwXPnGmnO+QWNkXeTb0 HxyjMjytOD2oO+QiHLJG++zehcd8GuhohbK0mC5kmFhVZf52nmpnb9QPNPgV9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714292672; 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: in-reply-to:in-reply-to:references:references; bh=cQJyJVk6gQIgoeWCNjweQHoV2R23rcnn9pDzsHMahbQ=; b=vQdZSX8SVgiChBBDX3YfN6ICojemZl+ZwVVIuF9fVbmoY6mLopPUhBKstSF6V3NOjbZ3KN 3zrWks/uk3zZIrBQ== From: "tip-bot2 for Oleg Nesterov" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/urgent] sched/isolation: Prevent boot crash when the boot CPU is nohz_full Cc: Chris von Recklinghausen , Oleg Nesterov , Thomas Gleixner , Ingo Molnar , Phil Auld , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240411143905.GA19288@redhat.com> References: <20240411143905.GA19288@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171429267181.10875.2633061764782446732.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the sched/urgent branch of tip: Commit-ID: 5097cbcb38e6e0d2627c9dde1985e91d2c9f880e Gitweb: https://git.kernel.org/tip/5097cbcb38e6e0d2627c9dde1985e91d2c9f880e Author: Oleg Nesterov AuthorDate: Thu, 11 Apr 2024 16:39:05 +02:00 Committer: Ingo Molnar CommitterDate: Sun, 28 Apr 2024 10:07:12 +02:00 sched/isolation: Prevent boot crash when the boot CPU is nohz_full Documentation/timers/no_hz.rst states that the "nohz_full=" mask must not include the boot CPU, which is no longer true after: 08ae95f4fd3b ("nohz_full: Allow the boot CPU to be nohz_full"). However after: aae17ebb53cd ("workqueue: Avoid using isolated cpus' timers on queue_delayed_work") the kernel will crash at boot time in this case; housekeeping_any_cpu() returns an invalid CPU number until smp_init() brings the first housekeeping CPU up. Change housekeeping_any_cpu() to check the result of cpumask_any_and() and return smp_processor_id() in this case. This is just the simple and backportable workaround which fixes the symptom, but smp_processor_id() at boot time should be safe at least for type == HK_TYPE_TIMER, this more or less matches the tick_do_timer_boot_cpu logic. There is no worry about cpu_down(); tick_nohz_cpu_down() will not allow to offline tick_do_timer_cpu (the 1st online housekeeping CPU). Fixes: aae17ebb53cd ("workqueue: Avoid using isolated cpus' timers on queue_delayed_work") Reported-by: Chris von Recklinghausen Signed-off-by: Oleg Nesterov Signed-off-by: Thomas Gleixner Signed-off-by: Ingo Molnar Reviewed-by: Phil Auld Acked-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20240411143905.GA19288@redhat.com Closes: https://lore.kernel.org/all/20240402105847.GA24832@redhat.com/ --- Documentation/timers/no_hz.rst | 7 ++----- kernel/sched/isolation.c | 11 ++++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Documentation/timers/no_hz.rst b/Documentation/timers/no_hz.rst index f8786be..7fe8ef9 100644 --- a/Documentation/timers/no_hz.rst +++ b/Documentation/timers/no_hz.rst @@ -129,11 +129,8 @@ adaptive-tick CPUs: At least one non-adaptive-tick CPU must remain online to handle timekeeping tasks in order to ensure that system calls like gettimeofday() returns accurate values on adaptive-tick CPUs. (This is not an issue for CONFIG_NO_HZ_IDLE=y because there are no running -user processes to observe slight drifts in clock rate.) Therefore, the -boot CPU is prohibited from entering adaptive-ticks mode. Specifying a -"nohz_full=" mask that includes the boot CPU will result in a boot-time -error message, and the boot CPU will be removed from the mask. Note that -this means that your system must have at least two CPUs in order for +user processes to observe slight drifts in clock rate.) Note that this +means that your system must have at least two CPUs in order for CONFIG_NO_HZ_FULL=y to do anything for you. Finally, adaptive-ticks CPUs must have their RCU callbacks offloaded. diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 373d42c..2a262d3 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -46,7 +46,16 @@ int housekeeping_any_cpu(enum hk_type type) if (cpu < nr_cpu_ids) return cpu; - return cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); + cpu = cpumask_any_and(housekeeping.cpumasks[type], cpu_online_mask); + if (likely(cpu < nr_cpu_ids)) + return cpu; + /* + * Unless we have another problem this can only happen + * at boot time before start_secondary() brings the 1st + * housekeeping CPU up. + */ + WARN_ON_ONCE(system_state == SYSTEM_RUNNING || + type != HK_TYPE_TIMER); } } return smp_processor_id();