Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2749473rda; Wed, 25 Oct 2023 11:07:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFk0W5lDOBTF9zpHWIes33TvZazyTujvC9ZViRUz+7DHri9BymSDJ2sr8zuacDnbNnDVm9j X-Received: by 2002:a25:d8cc:0:b0:d9a:45d7:4eae with SMTP id p195-20020a25d8cc000000b00d9a45d74eaemr19410671ybg.62.1698257256963; Wed, 25 Oct 2023 11:07:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698257256; cv=none; d=google.com; s=arc-20160816; b=VJubQS4x3yedmgK1zHvDfY5Ip+r6co0Gg/SIwHiQbeL9kMF9eCxumKpsmkgY2D09M6 kF8TfwLtV02SGRPrBzpd256rim2ojtNEgCLsCGBQVMjV5r+GsxeTtlDsakiFrr0/oXRt VBFzinL2sBlyyD9w0zYhcbRgeFhzfkojno2enV+UhSR2Vnoi/o8Wfy6rGV9PfJwUai3u DLDHHKbVcpLo2rvhhShB6ls6/+xt8EvTD2Ac+oBZbqu6skipbvb5aAY9fE1LoQW+B9YS FB9SLzBbq2wYUuX6dgoNvQlMuM2LCa5ci8jnwJfNSjV9TL3mcCsfCxXd6kwl3ib9BuHh S6rg== 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=r3t4mFzOhm+OGeF7YkLThI02Sisw+4rABD8l780j1RA=; fh=66J7Y+TGxNFNx8VjvpfZFFUqd7hqgnmmrifbhuLe8jE=; b=P68fRIkDxqJqYJnO7Qz6e7ZpDg/BssXyXKB9q+70ob2+20th+O88zht72YpelW8qLw Pm1f4tXVX9MWCAgW0SxyNBLb7kAt5EndYQp+1uJCtJ16JMkMX5AYirDUaSo6cMHeIsH5 UuQUJRhVgoGNifkdjkLSNmV5SDNc+zxKJRCH4tAvUR6Ms1x9DM1bXuSLTsGW5dWaMSIa ObuRUcK+pDOgiLms+CP1KGj8bgnr/56tytACmygCgH9AjyCSUqDm5NKSHEdPkD5UGiUa 2w0gXw5YnzWYclu0jp0JnqnT0vSemmxpPjIrhRehevkIUMhySLpY3ccXdGgU/8he3glM haqw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id l9-20020a25ad49000000b00d817e2ae7c8si11893186ybe.214.2023.10.25.11.07.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 11:07:36 -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; 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=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 howler.vger.email (Postfix) with ESMTP id 0622080898DC; Wed, 25 Oct 2023 11:07:26 -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 S1343561AbjJYSHU (ORCPT + 99 others); Wed, 25 Oct 2023 14:07:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343608AbjJYSHB (ORCPT ); Wed, 25 Oct 2023 14:07:01 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EE7D91BCE for ; Wed, 25 Oct 2023 11:06:15 -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 1DE851515; Wed, 25 Oct 2023 11:06:57 -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 1C4713F738; Wed, 25 Oct 2023 11:05:58 -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, baolin.wang@linux.alibaba.com, Jamie Iles , Xin Hao , peternewman@google.com, dfustini@baylibre.com, amitsinght@marvell.com Subject: [PATCH v7 20/24] x86/resctrl: Add CPU online callback for resctrl work Date: Wed, 25 Oct 2023 18:03:41 +0000 Message-Id: <20231025180345.28061-21-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20231025180345.28061-1-james.morse@arm.com> References: <20231025180345.28061-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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]); Wed, 25 Oct 2023 11:07:26 -0700 (PDT) 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. Tested-by: Shaopeng Tan Tested-by: Peter Newman Reviewed-by: Shaopeng Tan Reviewed-by: Reinette Chatre 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. No changes since v6 --- 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 fc70a2650729..1a74e9c47416 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -608,16 +608,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; @@ -969,7 +969,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 bd4d1c8a9b4f..ab9db7ce706f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4012,6 +4012,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 bf460c912bf5..4c4bad3c34e4 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