From patchwork Mon Dec 12 10:09:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 32294 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2155545wrr; Mon, 12 Dec 2022 02:15:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf6mfMeIi7q3g0jpr/K0dJTHrNsOGcJBbkhRUZeKXDFDuU8Mr7DilDPe5qdGYC7am90LStBl X-Received: by 2002:a17:907:76d4:b0:7c0:e5c8:d439 with SMTP id kf20-20020a17090776d400b007c0e5c8d439mr13610090ejc.3.1670840122980; Mon, 12 Dec 2022 02:15:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670840122; cv=none; d=google.com; s=arc-20160816; b=tqgqWCS5npNgeq2IVDyedsjVuMFrTW14d2F26dlDTqczh5mJgZpVi0ewNvl7tPgXjW FUSodMtkVwvbG0+0eMHG5XcR1PcuCVCaHdr/hy39vtt7mfv1rukGvYc9NIOBvsmuDSR1 nbhmGGA+YrcIO7i30ofAEdmmCbCbuCtGHtWtCI26HeLf9eeYb8SnZePT+QIQ1E/aqmWu 424hGSws+99qgv5QOdfIYvX+WAM4dJLFgHE7N3DbR44m0/v26QGKjuotFV2LW++t6qes q5uZ52UwkGnbZlXXqmPA+/FtEV4m8TUWSrOfo0avaa8iJvn83bsxXZFd+KHyXZ/eD2dZ n53Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:content-transfer-encoding :message-id:references:subject:cc:to:dkim-signature:dkim-signature :from; bh=Oev/oZEXAEmZ441vqy0P/QF8AOAgVoGYcZ8P0z9Ldl8=; b=MpXBz5n5aqfDW5EOETIzWm+Jp+9SSqh9lytAk1BQBtMTyHNxjhovQ4MlWhTtwLJ3GJ pN7uz8loLhcFwLf8YJaJoBmEfEm9+if2DMk3F50r4XnKTl/KigqybORP00qqBlWdr/Xo W3pKCmGk3+rv+8ArqdSoZv+H8oGWlY+tLmBBfpsWRzMbhEqfOxYy/+Yu4paAwizwsTDY +PQbJj7thC397Ug0UXQe5OWti90UAAc7ncIpFm6Qz64Xq/ZPYKaxFAryNVkREUQLdfTw 1In+0xxQNPpjXkXQ32sOirHMLA6dDdSHXLmCaPXJxIwUgOAN3J0qmHzfDI3sIumc1Zhl FyAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YKQzzjOI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id pk21-20020a170906d7b500b00783160b16a1si4542516ejb.397.2022.12.12.02.14.59; Mon, 12 Dec 2022 02:15:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YKQzzjOI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231981AbiLLKJK (ORCPT + 99 others); Mon, 12 Dec 2022 05:09:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231524AbiLLKJG (ORCPT ); Mon, 12 Dec 2022 05:09:06 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9715A1A1 for ; Mon, 12 Dec 2022 02:09:04 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1670839743; h=from:from: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: references:references; bh=Oev/oZEXAEmZ441vqy0P/QF8AOAgVoGYcZ8P0z9Ldl8=; b=YKQzzjOI2k3oFS+V7ZnAjqSOvyJ/ycx0vRIX2naFgnRqs3iNhxeHKBwwN/b+K/UVNfEWm1 LHkwnpX0jTZuH4srM4cS1HOI1JbSYncnY2DzGpTbo7jFGu1jPzwuZqSwLIOIjsUDRWjrbc 6QgKi69pVnvI8w84f7A16909q/kUXTnYhYwYvJfaClp3aUwYJgIMNMv0w2C6JivOUKDGIQ THl4allguMiOZxgyEPIQnp2OLXrUvKzr8pleL29QxhlqV8her7c8H9jztQH6oOFXyyZqsN hnagi6Pv6zRsHLPXY0NX10ys5pgrW9azoD0pFLv61De61OXslHKzMrcLMhjqdA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1670839743; h=from:from: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: references:references; bh=Oev/oZEXAEmZ441vqy0P/QF8AOAgVoGYcZ8P0z9Ldl8=; b=oy0gzo3D5944cV6c24nDVttY6yZ+bPZrlE0f5Y4lsGrIiOI3W7kMztnewqLAzYU0cglTdT VTRXlcEt6iKLQoDA== To: Linus Torvalds Cc: linux-kernel@vger.kernel.org, x86@kernel.org Subject: [GIT pull] smp/core for v6.2-rc1 References: <167083907785.564878.11381307641454805335.tglx@xen13.tec.linutronix.de> Message-ID: <167083908161.564878.1790621826078402593.tglx@xen13.tec.linutronix.de> MIME-Version: 1.0 Date: Mon, 12 Dec 2022 11:09:02 +0100 (CET) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752002853017365608?= X-GMAIL-MSGID: =?utf-8?q?1752002853017365608?= Linus, please pull the latest smp/core branch from: git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git smp-core-2022-12-10 up to: 6f855b39e460: cpu/hotplug: Do not bail-out in DYING/STARTING sections A small set of updates for CPU hotplug: - Prevent stale CPU hotplug state in the cpu_down() path which was detected by stress testing the sysfs interface - Ensure that the target CPU hotplug state for the boot CPU is CPUHP_ONLINE instead of the compile time init value CPUHP_OFFLINE. - Switch back to the original behaviour of warning when a CPU hotplug callback in the DYING/STARTING section returns an error code. Otherwise a buggy callback can leave the CPUs in an non recoverable state. Thanks, tglx ------------------> Phil Auld (2): cpu/hotplug: Make target_store() a nop when target == state cpu/hotplug: Set cpuhp target for boot cpu Vincent Donnefort (1): cpu/hotplug: Do not bail-out in DYING/STARTING sections kernel/cpu.c | 61 +++++++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index bbad5e375d3b..6c0a92ca6bb5 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -663,21 +663,51 @@ static bool cpuhp_next_state(bool bringup, return true; } -static int cpuhp_invoke_callback_range(bool bringup, - unsigned int cpu, - struct cpuhp_cpu_state *st, - enum cpuhp_state target) +static int __cpuhp_invoke_callback_range(bool bringup, + unsigned int cpu, + struct cpuhp_cpu_state *st, + enum cpuhp_state target, + bool nofail) { enum cpuhp_state state; - int err = 0; + int ret = 0; while (cpuhp_next_state(bringup, &state, st, target)) { + int err; + err = cpuhp_invoke_callback(cpu, state, bringup, NULL, NULL); - if (err) + if (!err) + continue; + + if (nofail) { + pr_warn("CPU %u %s state %s (%d) failed (%d)\n", + cpu, bringup ? "UP" : "DOWN", + cpuhp_get_step(st->state)->name, + st->state, err); + ret = -1; + } else { + ret = err; break; + } } - return err; + return ret; +} + +static inline int cpuhp_invoke_callback_range(bool bringup, + unsigned int cpu, + struct cpuhp_cpu_state *st, + enum cpuhp_state target) +{ + return __cpuhp_invoke_callback_range(bringup, cpu, st, target, false); +} + +static inline void cpuhp_invoke_callback_range_nofail(bool bringup, + unsigned int cpu, + struct cpuhp_cpu_state *st, + enum cpuhp_state target) +{ + __cpuhp_invoke_callback_range(bringup, cpu, st, target, true); } static inline bool can_rollback_cpu(struct cpuhp_cpu_state *st) @@ -999,7 +1029,6 @@ static int take_cpu_down(void *_param) struct cpuhp_cpu_state *st = this_cpu_ptr(&cpuhp_state); enum cpuhp_state target = max((int)st->target, CPUHP_AP_OFFLINE); int err, cpu = smp_processor_id(); - int ret; /* Ensure this CPU doesn't handle any more interrupts. */ err = __cpu_disable(); @@ -1012,13 +1041,10 @@ static int take_cpu_down(void *_param) */ WARN_ON(st->state != (CPUHP_TEARDOWN_CPU - 1)); - /* Invoke the former CPU_DYING callbacks */ - ret = cpuhp_invoke_callback_range(false, cpu, st, target); - /* - * DYING must not fail! + * Invoke the former CPU_DYING callbacks. DYING must not fail! */ - WARN_ON_ONCE(ret); + cpuhp_invoke_callback_range_nofail(false, cpu, st, target); /* Give up timekeeping duties */ tick_handover_do_timer(); @@ -1296,16 +1322,14 @@ void notify_cpu_starting(unsigned int cpu) { struct cpuhp_cpu_state *st = per_cpu_ptr(&cpuhp_state, cpu); enum cpuhp_state target = min((int)st->target, CPUHP_AP_ONLINE); - int ret; rcu_cpu_starting(cpu); /* Enables RCU usage on this CPU. */ cpumask_set_cpu(cpu, &cpus_booted_once_mask); - ret = cpuhp_invoke_callback_range(true, cpu, st, target); /* * STARTING must not fail! */ - WARN_ON_ONCE(ret); + cpuhp_invoke_callback_range_nofail(true, cpu, st, target); } /* @@ -2326,8 +2350,10 @@ static ssize_t target_store(struct device *dev, struct device_attribute *attr, if (st->state < target) ret = cpu_up(dev->id, target); - else + else if (st->state > target) ret = cpu_down(dev->id, target); + else if (WARN_ON(st->target != target)) + st->target = target; out: unlock_device_hotplug(); return ret ? ret : count; @@ -2688,6 +2714,7 @@ void __init boot_cpu_hotplug_init(void) cpumask_set_cpu(smp_processor_id(), &cpus_booted_once_mask); #endif this_cpu_write(cpuhp_state.state, CPUHP_ONLINE); + this_cpu_write(cpuhp_state.target, CPUHP_ONLINE); } /*