Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4057649rdb; Thu, 14 Sep 2023 10:23:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF3S5H7mPoenVvc8uLSPW9ocLiAx1JAHxbtGWQ0MyZJFPrexOpViLzjbE2nEoOmnGT0Bx7m X-Received: by 2002:a05:6a00:1590:b0:68b:c2c7:a8ce with SMTP id u16-20020a056a00159000b0068bc2c7a8cemr6442751pfk.17.1694712239011; Thu, 14 Sep 2023 10:23:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694712238; cv=none; d=google.com; s=arc-20160816; b=Gq0edLPemStTNbRybD6UaMqqMvnV4QiGF5FrZDvNHqm3/eh/7alDgwQSSkIe23APQi rTMIkzzeiY1pnHcTe/RWcu9zNn2FmvFqEmNZmqoUnV16d6VxKOzeZMGX8o4wnpm9ldob blgzqIOl1CjMYsMelctqtG9NuL5GNpCl+Kebv801Yt6Xv+eXZNTIheJ8SAwLGySfDV+Y uGX2gaZbalDbhZeSwTXJuboWxnWzhS4xu+45yBJHu/C47CbI+zwh1nGHF2n9obsrJ/w9 8K8BO4ca65sw0qklgfadsYMIzXLqWlt+9PVttvqnDBuBRUdz53msx9hJ1GFVcgH36KzN iAvg== 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; bh=LmXbN+hBxtxTQQzarYNyKmcFPCllMlAwsH6lCdu+4o0=; fh=6Nl2MjDBXofbhMXyzAhf7L7loTtEBflFxRNey74qSFc=; b=S2vKk7RKtEPqN14fGEgL0KsPhWeeg26KdWp8XQNM1dFEoW2E1d/EjTuZt6A8qADS2d IKPDIloCpnTlVR4B5sjxigYss5ggKHySMde51iOA8ZhetB2E7rszJhb+ywFC0OarmUFo Z55W3CMbg1V9gwKWEVrypQM79MGrbT61BWgE81sP8uCmG3mZV9a6BMYg3GohdlpBmdPD cnxWCOtQZOk0jOX4M7f5+oJvRLmAEnWsafgt2o4tXjlgbXP0wt0dBp0IuhadpK4kMeBF xwv/v+Jk9q3VSVmciT9tEQkRDPBoHKoT1/X9ujWg060nf5GHx/gG2JpbGtpk3sxAnbQ6 JmBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id ck7-20020a056a00328700b0068bc4b6bfccsi1924832pfb.22.2023.09.14.10.23.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 10:23:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id D0E82801C180; Thu, 14 Sep 2023 10:23:55 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240284AbjINRX4 (ORCPT + 99 others); Thu, 14 Sep 2023 13:23:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239550AbjINRXd (ORCPT ); Thu, 14 Sep 2023 13:23:33 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 68F672D79 for ; Thu, 14 Sep 2023 10:22:57 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5BF1511FB; Thu, 14 Sep 2023 10:23:34 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 592203F5A1; Thu, 14 Sep 2023 10:22:54 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , carl@os.amperecomputing.com, lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com Subject: [PATCH v6 20/24] x86/resctrl: Add CPU online callback for resctrl work Date: Thu, 14 Sep 2023 17:21:34 +0000 Message-Id: <20230914172138.11977-21-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20230914172138.11977-1-james.morse@arm.com> References: <20230914172138.11977-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 10:23:56 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email The resctrl architecture specific code may need to create a domain when a CPU comes online, it also needs to reset the CPUs PQR_ASSOC register. The resctrl filesystem code needs to update the rdtgroup_default CPU mask when CPUs are brought online. Currently this is all done in one function, resctrl_online_cpu(). This will need to be split into architecture and filesystem parts before resctrl can be moved to /fs/. Pull the rdtgroup_default update work out as a filesystem specific cpu_online helper. resctrl_online_cpu() is the obvious name for this, which means the version in core.c needs renaming. resctrl_online_cpu() is called by the arch code once it has done the work to add the new CPU to any domains. In future patches, resctrl_online_cpu() will take the rdtgroup_mutex itself. Reviewed-by: Shaopeng Tan Tested-by: Shaopeng Tan Tested-By: Peter Newman Signed-off-by: James Morse --- Changes since v3: * Renamed err to ret Changes since v4: * Changes in capitalisation. Changes since v5: * More changes in capitalisation. * Made resctrl_online_cpu() return void. --- arch/x86/kernel/cpu/resctrl/core.c | 8 ++++---- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++++++ include/linux/resctrl.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index eaadf6f20900..5b4c719ac129 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -604,16 +604,16 @@ static void clear_closid_rmid(int cpu) RESCTRL_RESERVED_CLOSID); } -static int resctrl_online_cpu(unsigned int cpu) +static int resctrl_arch_online_cpu(unsigned int cpu) { struct rdt_resource *r; mutex_lock(&rdtgroup_mutex); for_each_capable_rdt_resource(r) domain_add_cpu(cpu, r); - /* The cpu is set in default rdtgroup after online. */ - cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); clear_closid_rmid(cpu); + + resctrl_online_cpu(cpu); mutex_unlock(&rdtgroup_mutex); return 0; @@ -966,7 +966,7 @@ static int __init resctrl_late_init(void) state = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "x86/resctrl/cat:online:", - resctrl_online_cpu, resctrl_offline_cpu); + resctrl_arch_online_cpu, resctrl_offline_cpu); if (state < 0) return state; diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index dfaef047dead..0c609cdfe7e5 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3868,6 +3868,14 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) return 0; } +void resctrl_online_cpu(unsigned int cpu) +{ + lockdep_assert_held(&rdtgroup_mutex); + + /* The CPU is set in default rdtgroup after online. */ + cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); +} + /* * rdtgroup_init - rdtgroup initialization * diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 5e4b4df9610b..9d5f75a4e192 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -223,6 +223,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, u32 closid, enum resctrl_conf_type type); int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d); void resctrl_offline_domain(struct rdt_resource *r, struct rdt_domain *d); +void resctrl_online_cpu(unsigned int cpu); /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid -- 2.39.2