Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp350550rdb; Thu, 5 Oct 2023 07:47:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuJAIvASm63ZjVY5KamyU91IqS8/EjtutTuXVOcRb9Zvlysi9p59mBKB+W7IqARwcD4DjN X-Received: by 2002:a9d:4e96:0:b0:6c6:18c7:7ca2 with SMTP id v22-20020a9d4e96000000b006c618c77ca2mr5007316otk.12.1696517246081; Thu, 05 Oct 2023 07:47:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696517246; cv=none; d=google.com; s=arc-20160816; b=uMn8NqROJVQstu+srzBQYoCyVMfxeZ9qT4Ks+iNg+OfBD733G3nZWnWm2rIlctp96j gMlw+lsQHB19b6PD0xv1sX9hs6XvO+KVU3E4bJaIx93PHAi4fVBKBYfNOa8eF3M4ymEW XTygZqTjIaC6LSvm2pk7Ii9yfLADizjH5YieJimz+IKRknl8cfPHSI4FX1BLByTT2Kt3 p6MExI4/Uf4bIkwDvfYoRorvAJEy5fSGIDnjOzM2c8pKx5AdmW2Bkl9jLAXBEXIYQ6rs zS76hOcz41A2iGPGgz8gFdx5tu64kFtZZDa66h1N+H906V3c3UZAaftyqGub5PN9qlL/ YgRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=myNhEoa+bRas6E1ZYNgQNx/1M1cgiXXXXUFz20om+fk=; fh=F1gpqSS/HYttK+doOKuW4yrAifo5qykyq1MCI9SIQmQ=; b=N29w6lbbFCxsEJRwUkLXLoriotwOD78+I1fkHTz4R3tuuzgQX4We9P3WbEC1jxlCjz k6QiDI9bK89aWM/pNuXDXRHrdutbdK0pT0Jy2xIwunUwXHXlWzetKccM4pIul35e1g49 iPPoxMxoe8Z2yWbIOMsgXLvLFqm0GY++WOodARGiTLuW94FvFXETnyR0qKcIV6tyF2sc FkgBCMci0ArSxbNsOuwOq8Cga5euJDp93/QQf9cThWhQtw75ZFkz6uVgPF8TKucaCa6x 3zj2idM1BfSoPARsgO7ji7Hus/Ap2UssUq7aEY2vsct49J07tgllwqTVq5W4aGD45NDH iaWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JxUMQQWt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bs188-20020a6328c5000000b0056952b496efsi1523838pgb.366.2023.10.05.07.47.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:47:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=JxUMQQWt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D46528027B5B; Thu, 5 Oct 2023 07:46:43 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238967AbjJEOoB (ORCPT + 99 others); Thu, 5 Oct 2023 10:44:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237266AbjJEOiw (ORCPT ); Thu, 5 Oct 2023 10:38:52 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D9926619 for ; Thu, 5 Oct 2023 07:04:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696514681; x=1728050681; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=qwslEXpVpdjmSlqhv7KA+43haihOLBSreW4A7xlGLmo=; b=JxUMQQWtCYva/s2PcsHG1dRB9NgH5CismZtSLiIdtxcAR/zGte8T7QEF WPUZHB2USd9RQ1qdDdIhD2MTpjITgyEUczO7vIBAjbwKE6g7C9jodLzww A3jUeTmTRnYB0BcjZ3XhY/3Uy3WJ1Yeq0zmRO9cPK2Bufo9O965CvSA62 Ouf1SOJgZLdeeM9wXgJZSaR7LlaCaLXpjeO8WAConTcfsv+xeuBjR5Sdb fWoEFxuAVxcjgzskBuPZlIMcJGUshNFozkKuz/oH+6+FPw68m/MplyDUl vLgRGVRz5C75TCVSm37aXAcVPY0aOz4TCscS89YLqIo+lwMmm/9HIa90M w==; X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="380767064" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="380767064" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 06:14:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10854"; a="728449205" X-IronPort-AV: E=Sophos;i="6.03,203,1694761200"; d="scan'208";a="728449205" Received: from skwasnia-mobl.ger.corp.intel.com (HELO box.shutemov.name) ([10.251.222.71]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Oct 2023 06:14:16 -0700 Received: by box.shutemov.name (Postfix, from userid 1000) id 2144510A12F; Thu, 5 Oct 2023 16:14:14 +0300 (+03) From: "Kirill A. Shutemov" To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Kuppuswamy Sathyanarayanan , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, "Kirill A. Shutemov" Subject: [PATCH 02/13] kernel/cpu: Add support for declaring CPU hotplug not supported Date: Thu, 5 Oct 2023 16:13:51 +0300 Message-ID: <20231005131402.14611-3-kirill.shutemov@linux.intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> References: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:46:44 -0700 (PDT) The function cpu_hotplug_not_supported() can be called to indicate that CPU hotplug should be disabled. It does not prevent the initial bring up of the CPU, but it stops subsequent offlining. This function is intended to replace CC_ATTR_HOTPLUG_DISABLED. Signed-off-by: Kirill A. Shutemov --- include/linux/cpu.h | 2 ++ kernel/cpu.c | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/include/linux/cpu.h b/include/linux/cpu.h index f19f56501809..aab3887cadbc 100644 --- a/include/linux/cpu.h +++ b/include/linux/cpu.h @@ -132,6 +132,7 @@ extern void cpus_read_lock(void); extern void cpus_read_unlock(void); extern int cpus_read_trylock(void); extern void lockdep_assert_cpus_held(void); +extern void cpu_hotplug_not_supported(void); extern void cpu_hotplug_disable(void); extern void cpu_hotplug_enable(void); void clear_tasks_mm_cpumask(int cpu); @@ -147,6 +148,7 @@ static inline void cpus_read_lock(void) { } static inline void cpus_read_unlock(void) { } static inline int cpus_read_trylock(void) { return true; } static inline void lockdep_assert_cpus_held(void) { } +static inline void cpu_hotplug_not_supported(void) { } static inline void cpu_hotplug_disable(void) { } static inline void cpu_hotplug_enable(void) { } static inline int remove_cpu(unsigned int cpu) { return -EPERM; } diff --git a/kernel/cpu.c b/kernel/cpu.c index 6de7c6bb74ee..cf536fe1a88a 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -484,6 +484,9 @@ static int cpu_hotplug_disabled; DEFINE_STATIC_PERCPU_RWSEM(cpu_hotplug_lock); +/* Cleared if platform declares CPU hotplug not supported */ +static bool cpu_hotplug_supported = true; + void cpus_read_lock(void) { percpu_down_read(&cpu_hotplug_lock); @@ -543,6 +546,18 @@ static void lockdep_release_cpus_lock(void) rwsem_release(&cpu_hotplug_lock.dep_map, _THIS_IP_); } +/* + * Declare CPU hotplug not supported. + * + * It doesn't prevent initial bring up of the CPU, but stops offlining. + */ +void cpu_hotplug_not_supported(void) +{ + cpu_maps_update_begin(); + cpu_hotplug_supported = false; + cpu_maps_update_done(); +} + /* * Wait for currently running CPU hotplug operations to complete (if any) and * disable future CPU hotplug (from sysfs). The 'cpu_add_remove_lock' protects @@ -1507,7 +1522,7 @@ static int cpu_down_maps_locked(unsigned int cpu, enum cpuhp_state target) * If the platform does not support hotplug, report it explicitly to * differentiate it from a transient offlining failure. */ - if (cc_platform_has(CC_ATTR_HOTPLUG_DISABLED)) + if (cc_platform_has(CC_ATTR_HOTPLUG_DISABLED) || !cpu_hotplug_supported) return -EOPNOTSUPP; if (cpu_hotplug_disabled) return -EBUSY; -- 2.41.0