From patchwork Fri Oct 21 13:12:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 6708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp691674wrr; Fri, 21 Oct 2022 06:15:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5oByA3Dio7wDlRNZOd3cMiaMTmnkAHZpN+CwA/IJ29nxtGbdC1VvsQcN90HMCNz3EgPJMB X-Received: by 2002:a17:90a:540e:b0:210:1e26:9422 with SMTP id z14-20020a17090a540e00b002101e269422mr13901845pjh.100.1666358123380; Fri, 21 Oct 2022 06:15:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666358123; cv=none; d=google.com; s=arc-20160816; b=LkNDI9a+U/Yt25GgZNH7RoOIW9hMSRVRRJbW2yI1jVYZWBYq/LjHJ8Dt6XX03oTBPt 4Tq/9wOsoUM3d+o+0aLpzvPnncyIewPv0AiIfUwVVhT/d0jAQ417cZQkEniJ11hu2yaK YJ4qrqUv6Pkd8uW5mZKAEW2BLjmZk99Fr80TaiENbNsiExWkcSwF+5VOYPR3xbewn7IC dm+Crtp57ZawkrI+Hnf+nfD55hLWT9ZV4XLi/o2nsmNOHbdGpAbr7nU5wjaRAEy0w5Q0 yb6li45SZmWSoA6UQagMWBLba9o8CZLh+QkdGeAOjI2LnRP7497PHZCN6yxsnQBBMuTG a0xA== 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=JB2mF0OIehw/wfG+fLWD7H5RHg15+9Hyve7cogGjmZM=; b=uxnKjnmxpRb+T/8bajsii7I2LBLRWI0QZcn4lUdZ1KCI3FHW4kunA9UbINyK/8AE+T KlsaxjR1CtJRJzG7NbiuaigMI1rJHN8iEVut0EYGu1LzWSi6cvnktJVimM+CGmdZGbY6 7N1R6ZbyWct2bfDQQ4PtDRuAiS8aUnuJsEftWe+6xNtTXiL+AXgMNccmL77dyCvy1Qeu Lqr9u0l33RjqL84jsi8k0pbuWlzBJKl33zzICJ5W8xjkeUnQLz3TE9vqLF1da3KEp0G0 8dcHMGokL1MCl3zgssSaOEoJNQmSM2N5wxX7YHPGp8OfqHc2GnMlefU9yTsGzaWhQLwL NvGw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o6-20020a056a001bc600b005644806915csi24645559pfw.42.2022.10.21.06.15.09; Fri, 21 Oct 2022 06:15:23 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbiJUNOr (ORCPT + 99 others); Fri, 21 Oct 2022 09:14:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230361AbiJUNN1 (ORCPT ); Fri, 21 Oct 2022 09:13:27 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 86F9226D92A for ; Fri, 21 Oct 2022 06:13:10 -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 5B7F31042; Fri, 21 Oct 2022 06:13:16 -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 B14323F792; Fri, 21 Oct 2022 06:13:07 -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, Jamie Iles , Xin Hao , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com, peternewman@google.com Subject: [PATCH 15/18] x86/resctrl: Add cpu online callback for resctrl work Date: Fri, 21 Oct 2022 13:12:01 +0000 Message-Id: <20221021131204.5581-16-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20221021131204.5581-1-james.morse@arm.com> References: <20221021131204.5581-1-james.morse@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE 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?1747303135393943494?= X-GMAIL-MSGID: =?utf-8?q?1747303135393943494?= 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. Signed-off-by: James Morse --- arch/x86/kernel/cpu/resctrl/core.c | 11 ++++++----- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++++++++ include/linux/resctrl.h | 1 + 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index de62b0b87ced..511ced743a79 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -584,19 +584,20 @@ static void clear_closid_rmid(int cpu) wrmsr(IA32_PQR_ASSOC, 0, 0); } -static int resctrl_online_cpu(unsigned int cpu) +static int resctrl_arch_online_cpu(unsigned int cpu) { struct rdt_resource *r; + int err; 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); + + err = resctrl_online_cpu(cpu); mutex_unlock(&rdtgroup_mutex); - return 0; + return err; } static void clear_childcpus(struct rdtgroup *r, unsigned int cpu) @@ -923,7 +924,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 81ed458be70b..ef444a5690e9 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3425,6 +3425,16 @@ int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) return 0; } +int 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); + + return 0; +} + /* * rdtgroup_init - rdtgroup initialization * diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 1f345d24e236..b140ee6de00e 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -219,6 +219,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); +int resctrl_online_cpu(unsigned int cpu); /** * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid