Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp448058pxb; Fri, 16 Apr 2021 09:22:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdv/YyUcnExVigTOC4+rLZi0U8AmFsVk1U0F6XdEYTBfEWXwBurjzO/uaB9pa9seePGeVJ X-Received: by 2002:aa7:c913:: with SMTP id b19mr11041638edt.170.1618590138452; Fri, 16 Apr 2021 09:22:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618590138; cv=none; d=google.com; s=arc-20160816; b=gT2bLgj0SYRDRfV3kA3N3yTgYv9pFWuaxMaHMlxZXRiBVzAZqydE5TlhwyQAhkushz YCmu31+o4G0cHhsICK1vCTlZLz0xW02BpBVV4TF5Dk86PSbSlWLx2L89dUGIsidT0X51 vFwyjRwxojpVQRAXpoGTWbva7K+o0HvxELAPs8V8B4alehzkoIwAQ1OjWZn93KojGGXR phvHMiNGbfAlFAdTT82ZyJMZvdsjFynYVZfys4RasymWmml55QYBwatKUUz2zvxzzuoV QzRFkdT4lAcLZDhY1uwSeHBknD1J5iGe21rxIsgovNUozSHgeajRZ0/VLC4swziPREOV mEfw== 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:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=6qE2yJxzonP8C3SKSYcvuIhy8zvJ6gGv7M6CIrXOX8M=; b=U3Eyy0sQoX/2XQlNosMPQ82dajD2fBReV0GjfJLaNNS3twk3rR2mYlVmJD0k+yhrLS MuDLRL2Kp+Re7f0LZm5kAzLtQmO1DHuoo/SWC1yCs69i5W8x4PjIrVGbxTrZSeklshhe r8VK+XBPDPaY8bQEQ9CVpE6+2hGSZTkuPBMO8NLHKm4U9WYYL+mIZSBthg324JqrhVkk sjQUcfriKmbarVTk/t2AFOuz0YSvQ1xNv0PPYfB5rjbNlVpI/mVGSRAwrDmCQtUTtDfI Uh0arVe3N+XynDG7YJBkdruWvoLr4kcYcPSU0kg01SzYjmm1yFE48XNvPqbDZfBJv+KV QUOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q75a8yZl; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z21si5216959edb.200.2021.04.16.09.21.55; Fri, 16 Apr 2021 09:22:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q75a8yZl; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S237204AbhDPPyw (ORCPT + 99 others); Fri, 16 Apr 2021 11:54:52 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:58240 "EHLO galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236027AbhDPPyK (ORCPT ); Fri, 16 Apr 2021 11:54:10 -0400 Date: Fri, 16 Apr 2021 15:53:44 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1618588425; 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=6qE2yJxzonP8C3SKSYcvuIhy8zvJ6gGv7M6CIrXOX8M=; b=Q75a8yZl/VC20snywhYzn914oswykE18phOuGiAn0/HyMovtSG24Darmf9rEBBds4XuEs8 01395IK1TMqq4qtcsZ0CbPkVO/ZZpsad+QOjFg0SBw0RZ0Tc9zNyryZ6o5Kt47bSbRBBqM IKoM3rvy7YMBzGOXmtG+n0XG5k+lz83mQ5noiJEl0cC2keeDYQuxR7vXug4nOCbsYw6hYP 231pG5PrlF8d9c09PGcM3MhMMuiQBliiSrbVUX/0OzjdYUNw6yWAVCboTyidYExiO85t3H Q+A4UPhdt2tw9doFruvalBR0JK0P3BBbeAJru5XD8joJRLSCW3KIc4Tq6lPTXQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1618588425; 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=6qE2yJxzonP8C3SKSYcvuIhy8zvJ6gGv7M6CIrXOX8M=; b=GujCNFZu47yyAfLi0n0B7crlSlgxGQMrb3lyJeN3waCs7K7BUpoP9UGXco1DANn9XfMk+L oOEuY8s27kVoQoCg== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] cpumask: Introduce DYING mask Cc: "Peter Zijlstra (Intel)" , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20210310150109.151441252@infradead.org> References: <20210310150109.151441252@infradead.org> MIME-Version: 1.0 Message-ID: <161858842478.29796.12244189943849858201.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the sched/core branch of tip: Commit-ID: e40f74c535b8a0ecf3ef0388b51a34cdadb34fb5 Gitweb: https://git.kernel.org/tip/e40f74c535b8a0ecf3ef0388b51a34cdadb34fb5 Author: Peter Zijlstra AuthorDate: Tue, 19 Jan 2021 18:43:45 +01:00 Committer: Peter Zijlstra CommitterDate: Fri, 16 Apr 2021 17:06:32 +02:00 cpumask: Introduce DYING mask Introduce a cpumask that indicates (for each CPU) what direction the CPU hotplug is currently going. Notably, it tracks rollbacks. Eg. when an up fails and we do a roll-back down, it will accurately reflect the direction. Signed-off-by: Peter Zijlstra (Intel) Reviewed-by: Valentin Schneider Link: https://lkml.kernel.org/r/20210310150109.151441252@infradead.org --- include/linux/cpumask.h | 20 ++++++++++++++++++++ kernel/cpu.c | 6 ++++++ 2 files changed, 26 insertions(+) diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h index a584336..e6b948a 100644 --- a/include/linux/cpumask.h +++ b/include/linux/cpumask.h @@ -91,10 +91,12 @@ extern struct cpumask __cpu_possible_mask; extern struct cpumask __cpu_online_mask; extern struct cpumask __cpu_present_mask; extern struct cpumask __cpu_active_mask; +extern struct cpumask __cpu_dying_mask; #define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask) #define cpu_online_mask ((const struct cpumask *)&__cpu_online_mask) #define cpu_present_mask ((const struct cpumask *)&__cpu_present_mask) #define cpu_active_mask ((const struct cpumask *)&__cpu_active_mask) +#define cpu_dying_mask ((const struct cpumask *)&__cpu_dying_mask) extern atomic_t __num_online_cpus; @@ -826,6 +828,14 @@ set_cpu_active(unsigned int cpu, bool active) cpumask_clear_cpu(cpu, &__cpu_active_mask); } +static inline void +set_cpu_dying(unsigned int cpu, bool dying) +{ + if (dying) + cpumask_set_cpu(cpu, &__cpu_dying_mask); + else + cpumask_clear_cpu(cpu, &__cpu_dying_mask); +} /** * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask * @@ -900,6 +910,11 @@ static inline bool cpu_active(unsigned int cpu) return cpumask_test_cpu(cpu, cpu_active_mask); } +static inline bool cpu_dying(unsigned int cpu) +{ + return cpumask_test_cpu(cpu, cpu_dying_mask); +} + #else #define num_online_cpus() 1U @@ -927,6 +942,11 @@ static inline bool cpu_active(unsigned int cpu) return cpu == 0; } +static inline bool cpu_dying(unsigned int cpu) +{ + return false; +} + #endif /* NR_CPUS > 1 */ #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu)) diff --git a/kernel/cpu.c b/kernel/cpu.c index 23505d6..838dcf2 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -160,6 +160,9 @@ static int cpuhp_invoke_callback(unsigned int cpu, enum cpuhp_state state, int (*cb)(unsigned int cpu); int ret, cnt; + if (cpu_dying(cpu) != !bringup) + set_cpu_dying(cpu, !bringup); + if (st->fail == state) { st->fail = CPUHP_INVALID; return -EAGAIN; @@ -2512,6 +2515,9 @@ EXPORT_SYMBOL(__cpu_present_mask); struct cpumask __cpu_active_mask __read_mostly; EXPORT_SYMBOL(__cpu_active_mask); +struct cpumask __cpu_dying_mask __read_mostly; +EXPORT_SYMBOL(__cpu_dying_mask); + atomic_t __num_online_cpus __read_mostly; EXPORT_SYMBOL(__num_online_cpus);