From nobody Fri Dec 19 07:40:46 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 52DAD1A0AFF for ; Fri, 14 Jun 2024 15:02:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377327; cv=none; b=cVwyNwq5cQge3Fttq3Na3H4dFGcVYjh6qisLMfcLz6W5BkNTMoMc0bUCVpkjrWvq91xjaWEy48UG0xmk1NR0bb42j9FS0APvjWM0f7JX76Ujhg29y2+dVWgai5VAzckHEYO94j6aJqyQMbBLasvkDt9ZsuF80YAw1e59yFHdLKo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718377327; c=relaxed/simple; bh=BiKZ3Yg2ou3GMUcLcOoDbajbNdClONDCeK7On16AeL0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HgTFGIcL8Mt67ELV5YGSWWuM09sx9fVh9CBlrmSjIrRMQtad4wzgiK6uttCca/mPA2EjYsjJv/gMUVoKfgCuWZZUbqdLvytZEw4LV3HTAC6FFrvsVPvV9y8taA9c1z69+tMuUpckrvDyyOMFvePd7l/WQBUfCnjfGqu0lQv8qIo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 4810419F0; Fri, 14 Jun 2024 08:02:30 -0700 (PDT) Received: from merodach.members.linode.com (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 783DE3F5A1; Fri, 14 Jun 2024 08:02:02 -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, David Hildenbrand , Rex Nie , Dave Martin , Dave Martin , Shaopeng Tan Subject: [PATCH v3 17/38] x86/resctrl: Stop using the for_each_*_rdt_resource() walkers Date: Fri, 14 Jun 2024 15:00:12 +0000 Message-Id: <20240614150033.10454-18-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20240614150033.10454-1-james.morse@arm.com> References: <20240614150033.10454-1-james.morse@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The for_each_*_rdt_resource() helpers walk the architecture's array of structures, using the resctrl visible part as an iterator. These became over-complex when the structures were split into a filesystem and architecture-specific struct. This approach avoided the need to touch every call site. Once the filesystem parts of resctrl are moved to /fs/, both the architecture's resource array, and the definition of those structures is no longer accessible. To support resctrl, each architecture would have to provide equally complex macros. Change the resctrl code that uses these to walk through the resource_level enum and check the mon/alloc capable flags instead. Instances in core.c, and resctrl_arch_reset_resources() remain part of x86's architecture specific code. Co-developed-by: Dave Martin Signed-off-by: Dave Martin Signed-off-by: James Morse Tested-by: Peter Newman Tested-by: Shaopeng Tan --- Changes since v1: * [Whitespace only] Fix bogus whitespace introduced in rdtgroup_create_info_dir(). * [Commit message only] Typo fix: s/architectures/architecture's/g --- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 7 +++++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 28 +++++++++++++++++++---- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cp= u/resctrl/pseudo_lock.c index aacf236dfe3b..ad20822bb64e 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -840,6 +840,7 @@ bool rdtgroup_cbm_overlaps_pseudo_locked(struct rdt_dom= ain *d, unsigned long cbm bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_domain *d) { cpumask_var_t cpu_with_psl; + enum resctrl_res_level i; struct rdt_resource *r; struct rdt_domain *d_i; bool ret =3D false; @@ -854,7 +855,11 @@ bool rdtgroup_pseudo_locked_in_hierarchy(struct rdt_do= main *d) * First determine which cpus have pseudo-locked regions * associated with them. */ - for_each_alloc_capable_rdt_resource(r) { + for (i =3D 0; i < RDT_NUM_RESOURCES; i++) { + r =3D resctrl_arch_get_resource(i); + if (!r->alloc_capable) + continue; + list_for_each_entry(d_i, &r->domains, list) { if (d_i->plr) cpumask_or(cpu_with_psl, cpu_with_psl, diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 9c03e973a5f6..d9513d7b5157 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -98,12 +98,17 @@ void rdt_last_cmd_printf(const char *fmt, ...) =20 void rdt_staged_configs_clear(void) { + enum resctrl_res_level i; struct rdt_resource *r; struct rdt_domain *dom; =20 lockdep_assert_held(&rdtgroup_mutex); =20 - for_each_alloc_capable_rdt_resource(r) { + for (i =3D 0; i < RDT_NUM_RESOURCES; i++) { + r =3D resctrl_arch_get_resource(i); + if (!r->alloc_capable) + continue; + list_for_each_entry(dom, &r->domains, list) memset(dom->staged_config, 0, sizeof(dom->staged_config)); } @@ -2192,6 +2197,7 @@ static u32 fflags_from_resource(struct rdt_resource *= r) =20 static int rdtgroup_create_info_dir(struct kernfs_node *parent_kn) { + enum resctrl_res_level i; struct resctrl_schema *s; struct rdt_resource *r; unsigned long fflags; @@ -2216,7 +2222,11 @@ static int rdtgroup_create_info_dir(struct kernfs_no= de *parent_kn) goto out_destroy; } =20 - for_each_mon_capable_rdt_resource(r) { + for (i =3D 0; i < RDT_NUM_RESOURCES; i++) { + r =3D resctrl_arch_get_resource(i); + if (!r->mon_capable) + continue; + fflags =3D fflags_from_resource(r) | RFTYPE_MON_INFO; sprintf(name, "%s_MON", r->name); ret =3D rdtgroup_mkdir_info_resdir(r, name, fflags); @@ -2637,10 +2647,15 @@ static int schemata_list_add(struct rdt_resource *r= , enum resctrl_conf_type type =20 static int schemata_list_create(void) { + enum resctrl_res_level i; struct rdt_resource *r; int ret =3D 0; =20 - for_each_alloc_capable_rdt_resource(r) { + for (i =3D 0; i < RDT_NUM_RESOURCES; i++) { + r =3D resctrl_arch_get_resource(i); + if (!r->alloc_capable) + continue; + if (resctrl_arch_get_cdp_enabled(r->rid)) { ret =3D schemata_list_add(r, CDP_CODE); if (ret) @@ -3181,6 +3196,7 @@ static int mkdir_mondata_all(struct kernfs_node *pare= nt_kn, struct rdtgroup *prgrp, struct kernfs_node **dest_kn) { + enum resctrl_res_level i; struct rdt_resource *r; struct kernfs_node *kn; int ret; @@ -3199,7 +3215,11 @@ static int mkdir_mondata_all(struct kernfs_node *par= ent_kn, * Create the subdirectories for each domain. Note that all events * in a domain like L3 are grouped into a resource whose domain is L3 */ - for_each_mon_capable_rdt_resource(r) { + for (i =3D 0; i < RDT_NUM_RESOURCES; i++) { + r =3D resctrl_arch_get_resource(i); + if (!r->mon_capable) + continue; + ret =3D mkdir_mondata_subdir_alldom(kn, r, prgrp); if (ret) goto out_destroy; --=20 2.39.2