From nobody Mon May 25 08:13:39 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A26321771B; Fri, 15 May 2026 14:06:31 +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=1778853994; cv=none; b=VLFm+wl0ZgpHiUHmThGsud5OC3R+PBgAMgK/wxMF4/AkYp9o9owdnWKtQS4Qog7DMR/VxqTFk/i/zuNH6anRIVfbO1hf0GCg5Ja5xuLhftrpSNAshwJ+6ptu7g4u3kTx7c8jL17v3LFQDsBVA1v+woeRmhrE8bclfNUQyYhMdpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778853994; c=relaxed/simple; bh=e6XqPjBOPomAbfisL/+ctCwr9bdhsFJi1zOUo3qkhng=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=azJmwRIaZsZ8+Q0QMUDa8krZdUutyIpP+M2MymYjA5rgCQJofOoFrVs+8/7MaFfWNI1fExGjsI6SuS9BNKTw1XIKLg8s2/b3x/i9jeVj0vFNBfB2Ts2syk+NW/Ta0GNvR8EWhCWHFlQYO6o/0+Pg/1Yh9YTSfnVLiK/Gj208eIU= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=OoagTEX+; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="OoagTEX+" 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 04C80292B; Fri, 15 May 2026 07:06:24 -0700 (PDT) Received: from e134344.cambridge.arm.com (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E17113F836; Fri, 15 May 2026 07:06:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778853989; bh=e6XqPjBOPomAbfisL/+ctCwr9bdhsFJi1zOUo3qkhng=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OoagTEX+AseQAiSScCHwyUzrsZbGngbYyQF2kgXhHCwLUjtsNk1Xdzxso0oF2jdXB jmNSDzN+JzP911AzTaQHsMDgbPe6jpK5fGjrx/RATZhY6hHF+YTL+o6henpd6lmkqj o5uXuo+OnhUpoW0f+3UvxpaqeTFezRvwADUiPjlI= From: Ben Horgan To: ben.horgan@arm.com Cc: james.morse@arm.com, reinette.chatre@intel.com, fenghuay@nvidia.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, corbet@lwn.net, x86@kernel.org, linux-doc@vger.kernel.org, dave.martin@arm.com Subject: [PATCH v3 1/3] x86/resctrl: Add resctrl_arch_preconvert_bw() Date: Fri, 15 May 2026 15:06:10 +0100 Message-ID: <20260515140612.1205251-2-ben.horgan@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260515140612.1205251-1-ben.horgan@arm.com> References: <20260515140612.1205251-1-ben.horgan@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" On MPAM systems the rounding behaviour of the MBA control would be improved if the rounding in the fs/resctrl code is removed but this is not the case for x86. To allow any rounding or conversion of the bandwidth value provided by the user to be specified by the arch code a new arch hook is required. Introduce resctrl_arch_preconvert_bw(), and add its x86 implementation. This is currently unused in resctrl but when plumbed in it will replace the call to roundup() in bw_validate(). Signed-off-by: Dave Martin Signed-off-by: Ben Horgan --- Changes since Dave's v2: Split from larger patch and add commit message Update kernel-doc (Reinette) --- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 6 ++++++ include/linux/resctrl.h | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index b20e705606b8..19ae596f6b30 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -16,9 +16,15 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt =20 #include +#include =20 #include "internal.h" =20 +u32 resctrl_arch_preconvert_bw(u32 val, const struct rdt_resource *r) +{ + return roundup(val, (unsigned long)r->membw.bw_gran); +} + int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain= *d, u32 closid, enum resctrl_conf_type t, u32 cfg_val) { diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57fd7ca5..33a6742da4f9 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -500,6 +500,25 @@ bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_r= esource *r); */ int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable); =20 +/** + * resctrl_arch_preconvert_bw() - Prepare bandwidth control value for arch= use. + * @val: Bandwidth control value written to the schemata file by userspace. + * @r: Resource whose schema was written. + * + * Convert the user provided bandwidth control value to an appropriate for= m for + * consumption by the hardware driver for resource @r. Converted value is = stored + * in rdt_ctrl_domain::staged_config[] for later consumption by + * resctrl_arch_update_domains(). Is not called when MBA software controll= er is + * enabled. + * + * Architectures for which this pre-conversion hook is not useful should s= upply + * an implementation of this function that just returns val unmodified. + * + * Return: + * The converted value. + */ +u32 resctrl_arch_preconvert_bw(u32 val, const struct rdt_resource *r); + /* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs. --=20 2.43.0 From nobody Mon May 25 08:13:39 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA5EC48097A; Fri, 15 May 2026 14:06:34 +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=1778853996; cv=none; b=G1eN4zi4yA057QcaOLlrCU9bSyL9Rlqq5QX4BruCz810TvhL3nDnFOCn/djMMciG90z63uwEWVi7T3Nlz4gbSz4js3U2mSM5mEmSzzDo9YCgYqiDFXrNciiGuQ6kcU1wY4kqHPWRBU0n78mNAg5ePTtT6vmZuQL2Z19bj9npnCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778853996; c=relaxed/simple; bh=fT5zpgH8sZLDiwtCzmI9hNrpGxEbBAiElP2J+OjSfBE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H+vT844VnH6yOcMmKmQLzSRMJ3wFLkvI6y4sWTWANLPd6Q3wxyOv7mtimduBTOgPaqoytjJ9IjfH50M4EqB/lWUce1GmSpMSIcuXfNinI/6rz/QzhKeMa6M8fubKgSfW4nnqwvikq1P0n1q1P4It03fx8XiCQHvJRi+HhQ5ojUE= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=pD2IjQeB; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="pD2IjQeB" 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 9E05B35A5; Fri, 15 May 2026 07:06:27 -0700 (PDT) Received: from e134344.cambridge.arm.com (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8EBAC3F836; Fri, 15 May 2026 07:06:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778853992; bh=fT5zpgH8sZLDiwtCzmI9hNrpGxEbBAiElP2J+OjSfBE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pD2IjQeBH+1GQ1NS2tAG1aYTe2GJEqgOTjSK1cL2ERK5RsOOOk4Ll68ip1x7JFrJ1 H9B+MEkAITgwj1AqjcpcDvRiHU3hC3BkR71JfhskWPmgFhjZjH288M2boxDj9rO8+x UcJlhirlQwuDw2SYY5qHidF0AjIaTvCUaO+ZewX8= From: Ben Horgan To: ben.horgan@arm.com Cc: james.morse@arm.com, reinette.chatre@intel.com, fenghuay@nvidia.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, corbet@lwn.net, x86@kernel.org, linux-doc@vger.kernel.org, dave.martin@arm.com Subject: [PATCH v3 2/3] arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw() Date: Fri, 15 May 2026 15:06:11 +0100 Message-ID: <20260515140612.1205251-3-ben.horgan@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260515140612.1205251-1-ben.horgan@arm.com> References: <20260515140612.1205251-1-ben.horgan@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" resctrl rounds up the percentage value of the MBA based on the bw_gran. As MPAM uses a binary fixed point fraction format for MBA rather than a decimal percentage, this introduces rounding errors. Without this additional rounding, if the user reads the value in an MB schema and then writes it back to the schema, the value in hardware won't change. However, with this additional rounding, this guarantee is broken for systems with mbw_wd < 7. resctrl is introducing resctrl_arch_preconvert_bw() to allow the arch code to specify the conversion resctrl does to the user-provided bandwidth value. Add the MPAM version of resctrl_arch_preconvert_bw(). This does no conversion. Signed-off-by: Ben Horgan --- drivers/resctrl/mpam_resctrl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 226ff6f532fa..5a2104af22cc 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -167,6 +167,11 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_lev= el rid) return mpam_resctrl_controls[rid].cdp_enabled; } =20 +u32 resctrl_arch_preconvert_bw(u32 val, const struct rdt_resource *r) +{ + return val; +} + /** * resctrl_reset_task_closids() - Reset the PARTID/PMG values for all task= s. * --=20 2.43.0 From nobody Mon May 25 08:13:39 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E9FCD48C3F0; Fri, 15 May 2026 14:06:37 +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=1778854000; cv=none; b=cklo0M90OCcxFypVdSJ+4gGols/YtQa/5ayOZmxgjFUew/0Ta41Z8pl3WIrUKfLCJQ1HeiU6GFIABk4QC8/szB9ikAEgpvk2+gMeYQwD3qOexs+lS9AMvB7nRQXSU8mDfXhn/da1D0YIyeG8BifYDgQwlfbC2ZtVqhun3ONzcuI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778854000; c=relaxed/simple; bh=/X5vvNOKH2UKMw4tT6pijLDefuLZqv7SXoC571MH1NI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FOfwnFtuPoZR8ek7k4fbcs/k7A1Cg0q6FYSzi/usxyEVlNLCtJDGPRrnT6KmnKVChlP9g7ZguK1Lz2yWuAhmD1Bk3MCAnpArk5Swn48MUyBJWBdRxPGp10ge8v6799zVkmE7eDMhXK35xo0TxivnuajwMJ/08LZJUQym0b1QrhM= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=fcjXZtSZ; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="fcjXZtSZ" 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 BE5EC35A6; Fri, 15 May 2026 07:06:31 -0700 (PDT) Received: from e134344.cambridge.arm.com (e134344.arm.com [10.1.196.46]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 51B793F836; Fri, 15 May 2026 07:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1778853997; bh=/X5vvNOKH2UKMw4tT6pijLDefuLZqv7SXoC571MH1NI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fcjXZtSZl2ZNrGbX6+vWkP9u57+qjXoxb6pY1g1Os5S26m6y5WFJX35ZMh+e3QsT6 DvQImAJ+dn92pHdHv32vcq/1VtsSovXI1bemv6yNfKjeW9ii1j0yrtr3ktbKCJI3e7 Y1lrLT2iHh+AE7jLrjcl77GgBqKk6LLw+u2jMYPE= From: Ben Horgan To: ben.horgan@arm.com Cc: james.morse@arm.com, reinette.chatre@intel.com, fenghuay@nvidia.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, hpa@zytor.com, corbet@lwn.net, x86@kernel.org, linux-doc@vger.kernel.org, dave.martin@arm.com, Dave Martin , Ben Horgan Subject: [PATCH v3 3/3] fs/resctrl: Factor MBA parse-time conversion to be per-arch Date: Fri, 15 May 2026 15:06:12 +0100 Message-ID: <20260515140612.1205251-4-ben.horgan@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260515140612.1205251-1-ben.horgan@arm.com> References: <20260515140612.1205251-1-ben.horgan@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" From: Dave Martin The control value parser for the MB resource currently coerces the memory bandwidth percentage value from userspace to be an exact multiple of the rdt_resource::resctrl_membw::bw_gran parameter. On MPAM systems, this results in somewhat worse-than-worst-case rounding, since the bandwidth granularity advertised to resctrl by the MPAM driver is in general only an approximation to the actual hardware granularity on these systems, and the hardware bandwidth allocation control value is not natively a percentage -- necessitating a further conversion in the resctrl_arch_update_domains() path, regardless of the conversion done at parse time. For MPAM and x86 use their custom pre-prepared parse-time conversion, resctrl_arch_preconvert_bw(). This will avoid accumulated error from rounding the value twice on MPAM systems. For x86 systems there is no functional change. Clarify the documentation, but avoid overly exact promises. Clamping to bw_min and bw_max still feels generic: leave it in the core code, for now. [ BH: Split out x86 specific changes ] Signed-off-by: Dave Martin Signed-off-by: Ben Horgan Reviewed-by: Ben Horgan --- Documentation/filesystems/resctrl.rst | 17 +++++++++-------- fs/resctrl/ctrlmondata.c | 6 +++--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesyst= ems/resctrl.rst index b003bed339fd..4322d8025453 100644 --- a/Documentation/filesystems/resctrl.rst +++ b/Documentation/filesystems/resctrl.rst @@ -236,12 +236,11 @@ with respect to allocation: user can request. =20 "bandwidth_gran": - The granularity in which the memory bandwidth - percentage is allocated. The allocated - b/w percentage is rounded off to the next - control step available on the hardware. The - available bandwidth control steps are: - min_bandwidth + N * bandwidth_gran. + The approximate granularity in which the memory bandwidth + percentage is allocated. The allocated bandwidth percentage + is rounded up to the next control step available on the + hardware. The available hardware steps are no larger than + this value. =20 "delay_linear": Indicates if the delay scale is linear or @@ -871,8 +870,10 @@ The minimum bandwidth percentage value for each cpu mo= del is predefined and can be looked up through "info/MB/min_bandwidth". The bandwidth granularity that is allocated is also dependent on the cpu model and can be looked up at "info/MB/bandwidth_gran". The available bandwidth -control steps are: min_bw + N * bw_gran. Intermediate values are rounded -to the next control step available on the hardware. +control steps are, approximately, min_bw + N * bw_gran. The steps may +appear irregular due to rounding to an exact percentage: bw_gran is the +maximum interval between the percentage values corresponding to any two +adjacent steps in the hardware. =20 The bandwidth throttling is a core specific mechanism on some of Intel SKUs. Using a high bandwidth and a low bandwidth setting on two threads diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c index 9a7dfc48cb2e..934e12f5d145 100644 --- a/fs/resctrl/ctrlmondata.c +++ b/fs/resctrl/ctrlmondata.c @@ -37,8 +37,8 @@ typedef int (ctrlval_parser_t)(struct rdt_parse_data *dat= a, /* * Check whether MBA bandwidth percentage value is correct. The value is * checked against the minimum and max bandwidth values specified by the - * hardware. The allocated bandwidth percentage is rounded to the next - * control step available on the hardware. + * hardware. The allocated bandwidth percentage is converted as + * appropriate for consumption by the specific hardware driver. */ static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r) { @@ -71,7 +71,7 @@ static bool bw_validate(char *buf, u32 *data, struct rdt_= resource *r) return false; } =20 - *data =3D roundup(bw, (unsigned long)r->membw.bw_gran); + *data =3D resctrl_arch_preconvert_bw(bw, r); return true; } =20 --=20 2.43.0