Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp143597rdg; Tue, 10 Oct 2023 06:38:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ/KiHqYCmGSHcYjBUv405FLw9oNsz0rUgLPsC3K8NuPxnEGRUQdC4NZ6wVgWCbtJ5AP6X X-Received: by 2002:a17:90a:b945:b0:27c:f21b:6342 with SMTP id f5-20020a17090ab94500b0027cf21b6342mr924472pjw.22.1696945082940; Tue, 10 Oct 2023 06:38:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696945082; cv=none; d=google.com; s=arc-20160816; b=MOlsiNKl5UPolAz8j3ExqA/41qI8DZTNAWa1jQ+TNR3NrjQcc+kTMhjlfhcfC0R2lZ SfgRJPeTAlyLrvqBMpd4hqKFFGGJrYRMkauf0zIJ14t5CtBb18uhxJdqvLicnXmGWvnP q20i/t2v+HRkdAwL1D4IdMts+lPjhHffh9iCN1OIpLdPchaASqFCiQN2gKBhRPxOVJue JJmTyw3ddwoDmqyWotmez0VpiiaoYMLHjlO5YCsWgftkP1eZqhXgBP8UfCu/vJaw9zrN PNejugmz6H6jLv8XpmF7jUJmrYC6j3myx4rzEiYmMGs9me9hAWQNbQ2jvWGF9Hxnqb9X ut7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=5GsNNvqHhkY506JU9JCDJftKND7SandqZsbIftstRxA=; fh=cMyFVT0sh6ZwVP2rvst5CQqRq6dUn/5tjJx0MsDQfWQ=; b=oWbhD8ffaZtZYPAQLQFAIISQdLuaS9lNmUYoE1oKabe8XlyJdHT/NIdBK6nQncFVcv 2Bcg+8EpmeyMNXuUI2vIM5RSd0wfxRXWGMU5SEKEWqUcVAgcbhvfOxcUdpC7WWucheTc 3zEhlqGAgu48jTXWycnNzcM3oFblmaBNpHfqMDaJLwQXGfO18ZVa4UNjFQsb+2k5Gx5O yPEjoHz6Ds1ihXE1sYy5SQ4DEcNnkWmPt/l/zrnmCAJrNVfsQtkReZGf05c8D13DSe59 MX5TJZ5yMPf7DYQ9WEwsxYDmDiIIilrQtS9fy/+xQFulC+0Za6zJf/9NMQoTb2l1+XSa N8AA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NcaBTHCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id oo3-20020a17090b1c8300b00276df8c5b83si12824341pjb.143.2023.10.10.06.38.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 06:38:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=NcaBTHCa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (Postfix) with ESMTP id E990F805CB2B; Tue, 10 Oct 2023 06:37:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232269AbjJJNho (ORCPT + 99 others); Tue, 10 Oct 2023 09:37:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232243AbjJJNhn (ORCPT ); Tue, 10 Oct 2023 09:37:43 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18D2C9E for ; Tue, 10 Oct 2023 06:37: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=1696945061; x=1728481061; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=XxupxmtyB6MfsqYIPevKjc8Mkmjyag2c1qs/SolrDdo=; b=NcaBTHCaJnFpf/KRspbxJx6yxaw7m+ElYXQS2qJDzdUimfaD8YUX88lA IQcYKtqqXMCM59DPKQAfCESEZufOaysmI+Cl0iMlYheIKhweR9tiGOChq J4P1kKwOqsDbjC9dCWAkQwR3qnMBF/XUZbczoR0n+L/zGKXfH9pOOr308 VVIJ/Rznmgo3fA0eNQm+8bzc0VwGN7h7oZ5Qjg8vofla/qxpCBbA+Kk+P v5t7IDI8whCId1bbKFKjEbxcRdj4IUzJiNpf/YXTB900YoSpFq/aX3RJM 6IcBlSy5Fe5NZKQTAfIKA+ze8B6mLS/HiZfTA7DFSnctlGt3GaIxaxOEj w==; X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="384250793" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="384250793" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 06:36:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10859"; a="747072144" X-IronPort-AV: E=Sophos;i="6.03,212,1694761200"; d="scan'208";a="747072144" Received: from patinira-mobl.amr.corp.intel.com (HELO [10.212.128.216]) ([10.212.128.216]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Oct 2023 06:35:59 -0700 Message-ID: Date: Tue, 10 Oct 2023 06:35:59 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 02/13] kernel/cpu: Add support for declaring CPU hotplug not supported Content-Language: en-US To: "Kirill A. Shutemov" , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org Cc: "Rafael J. Wysocki" , Peter Zijlstra , Adrian Hunter , Elena Reshetova , Jun Nakajima , Rick Edgecombe , Tom Lendacky , kexec@lists.infradead.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org References: <20231005131402.14611-1-kirill.shutemov@linux.intel.com> <20231005131402.14611-3-kirill.shutemov@linux.intel.com> From: Kuppuswamy Sathyanarayanan In-Reply-To: <20231005131402.14611-3-kirill.shutemov@linux.intel.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=2.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 10 Oct 2023 06:38:00 -0700 (PDT) X-Spam-Level: ** On 10/5/2023 6:13 AM, Kirill A. Shutemov wrote: > 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. > Looks good to me. Reviewed-by: Kuppuswamy Sathyanarayanan > 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(); > +} Since this function is not used in this patch, do you need to add __maybe_unused to avoid warnings? > + > /* > * 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; -- Sathyanarayanan Kuppuswamy Linux Kernel Developer