From nobody Mon Feb 9 12:09:05 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9167D1957FC for ; Fri, 17 Jan 2025 15:10:56 +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=1737126658; cv=none; b=DriHCN4UahEDrfnT0jGmT3NWCZ7JQwt4woZwe5E+4mOh7jZPPmvN6o9lroXq7rQRxfdVYurq0dxf7kFGDksLkhCPGaozJ15RhSVL4Pq5R9nqlOAMoO06KC0AQ6dNRh1M6dUznmyICUpbhOmU8Nm0cMAmcJLu78EK6SuUw6yAvWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737126658; c=relaxed/simple; bh=iTsKPAw6g851fA4n9Bf2FkzcGG6hJvEP0DODKYWFmHA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=svhHVXyPa5UEBmyaE0R4ux9+ygBe7o/Fl9dfilEU3CC+bvFzzlvz+XdZhiWIby/yYJtrNjiU7RysQAJQXFp1YyHVRgiiqBp8nJQedNMA+tOiSyvLhn4SsxeQst9i9FjDLa+puzzpv6L5+gDY2wKjEJUcjPo8CkqgYSBl2ZXcve4= 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 6E0C922C7; Fri, 17 Jan 2025 07:11:24 -0800 (PST) Received: from e133380.cambridge.arm.com (e133380.arm.com [10.1.197.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F98B3F73F; Fri, 17 Jan 2025 07:10:55 -0800 (PST) From: Dave Martin To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Zeng Heng , Shaopeng Tan , James Morse Subject: [RFC PATCH v2 04/11] fs/resctrl: Add arch hook to set up the default CLOSID Date: Fri, 17 Jan 2025 15:10:14 +0000 Message-Id: <20250117151033.1517882-5-Dave.Martin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250117151033.1517882-1-Dave.Martin@arm.com> References: <20250117151033.1517882-1-Dave.Martin@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" Currently, the resctrl core code assumes that CLOSID 0 requires no special initialisation before use. This is true on x86, but may not be true on other architectures (including Arm MPAM, in certain configurations). Since the allocation of CLOSIDs can depend on parameters such as resctrl filesystem mount options that are not available at arch driver init time, an arch hook is needed to set up the default CLOSID when the resctrl filesystem is mounted. Add a suitable arch hook resctrl_arch_init_domains(). Wire it up to arch stubs that do nothing, for now. (This is also the right thing for x86.) No functional change. Signed-off-by: Dave Martin --- arch/x86/include/asm/resctrl.h | 12 ++++++++++++ fs/resctrl/rdtgroup.c | 26 ++++++++++++++++++++++++-- include/linux/arm_mpam.h | 10 ++++++++++ include/linux/resctrl.h | 2 ++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 332b0617d728..b5fbb94e756a 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -50,6 +50,18 @@ DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); =20 +/* The default CLOSID needs no special setup on x86: */ +static inline bool resctrl_arch_default_closid_needs_init(void) +{ + return false; +} + +/* ... so this won't be needed either: */ +static inline int resctrl_arch_init_domains(struct rdt_resource *r, u32 cl= osid) +{ + return 0; +} + static inline bool resctrl_arch_alloc_capable(void) { return rdt_alloc_capable; diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 30f1dd05e10b..200f92e8f619 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -65,6 +65,8 @@ static struct seq_buf last_cmd_status; =20 static char last_cmd_status_buf[512]; =20 +static int rdtgroup_init_first_alloc(struct rdtgroup *rdtgrp); + static int rdtgroup_setup_root(struct rdt_fs_context *ctx); =20 static void rdtgroup_destroy_root(void); @@ -2542,6 +2544,9 @@ static int rdt_get_tree(struct fs_context *fc) } =20 closid_init(); + ret =3D rdtgroup_init_first_alloc(&rdtgroup_default); + if (ret) + goto out_schemata_free; =20 if (resctrl_arch_mon_capable()) flags |=3D RFTYPE_MON; @@ -3230,7 +3235,7 @@ static void rdtgroup_init_mba(struct rdt_resource *r,= u32 closid) } =20 /* Initialize the RDT group's allocations. */ -static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) +static int __rdtgroup_init_alloc(struct rdtgroup *rdtgrp, bool first_time_= init) { struct resctrl_schema *s; struct rdt_resource *r; @@ -3251,7 +3256,11 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtg= rp) goto out; } =20 - ret =3D resctrl_arch_update_domains(r, rdtgrp->closid); + if (first_time_init) + ret =3D resctrl_arch_init_domains(r, rdtgrp->closid); + else + ret =3D resctrl_arch_update_domains(r, rdtgrp->closid); + if (ret < 0) { rdt_last_cmd_puts("Failed to initialize allocations\n"); goto out; @@ -3265,6 +3274,19 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtg= rp) return ret; } =20 +static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) +{ + return __rdtgroup_init_alloc(rdtgrp, false); +} + +static int rdtgroup_init_first_alloc(struct rdtgroup *rdtgrp) +{ + if (!resctrl_arch_default_closid_needs_init()) + return 0; + + return __rdtgroup_init_alloc(rdtgrp, true); +} + static int mkdir_rdt_prepare_rmid_alloc(struct rdtgroup *rdtgrp) { int ret; diff --git a/include/linux/arm_mpam.h b/include/linux/arm_mpam.h index c00b5fc1d235..dd5f18474846 100644 --- a/include/linux/arm_mpam.h +++ b/include/linux/arm_mpam.h @@ -45,6 +45,16 @@ static inline unsigned int resctrl_arch_round_mon_val(un= signed int val) return val; } =20 +static inline bool resctrl_arch_default_closid_needs_init(void) +{ + return false; +} + +static inline int resctrl_arch_init_domains(struct rdt_resource *r, u32 cl= osid) +{ + return 0; +} + bool resctrl_arch_alloc_capable(void); bool resctrl_arch_mon_capable(void); bool resctrl_arch_is_llc_occupancy_enabled(void); diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index be9d9f4c7b81..fc00b080f1a1 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -371,6 +371,8 @@ u32 resctrl_arch_system_num_rmid_idx(void); =20 struct rdt_domain_hdr *resctrl_arch_find_domain(struct list_head *domain_l= ist, int id); +bool resctrl_arch_default_closid_needs_init(void); +int resctrl_arch_init_domains(struct rdt_resource *r, u32 closid); int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid); =20 bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt); --=20 2.34.1