From nobody Thu Nov 28 04:42:07 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F00B1DACA5 for ; Fri, 4 Oct 2024 18:05:17 +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=1728065118; cv=none; b=mV4MxrtDkhzC/h+dWR/Xz8aeLt5s1q4fuLHSjiviUUeTXOYHHy5e0Ko/bNGVR7PGkL49datHETHkjumToCU/P2dP5mwg7BXdPwvKSfZu3Yz+FADn9K3ZWj9Mc29gQx3RouYJZreMI/0TUEm6YW0l/m4FmKweidMTM1bDXFgOlvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728065118; c=relaxed/simple; bh=COrX6HM4KaD4H1Ck/vPeIvkCymbeyZ319kuiuXrE3as=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HMhWPFFi0LF+rLslNceEvlr7LoMv9BYCbK4c3oMn69p30KqokrDaHbzlBxwwuxAIBcFbXnnjyijWrqJq1QAGFg2MIqpYCBQAO/yo7H09kUa9Ttegt0SX+NpiSCbAZB83JQoAqkpjgYo4bqENiGPTqacgEP0mBaxe77eFqQRqoW4= 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 4815B339; Fri, 4 Oct 2024 11:05:46 -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 3B9DC3F58B; Fri, 4 Oct 2024 11:05:12 -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 , Shaopeng Tan Subject: [PATCH v5 07/40] x86/resctrl: Add max_bw to struct resctrl_membw Date: Fri, 4 Oct 2024 18:03:14 +0000 Message-Id: <20241004180347.19985-8-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20241004180347.19985-1-james.morse@arm.com> References: <20241004180347.19985-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" __rdt_get_mem_config_amd() and __get_mem_config_intel() both use the default_ctrl property as a maximum value. This is because the MBA schema works differently between these platforms. Doing this complicates determining whether the default_ctrl property belongs to the arch code, or can be derived from the schema format. Add a max_bw property for x86 platforms to specify their maximum MBA bandwidth. This isn't needed for other schema formats. This will allow the default_ctrl to be generated from the schema properties when it is needed. Signed-off-by: James Morse Tested-by: Carl Worth # arm64 Tested-by: Shaopeng Tan Reviewed-by: Shaopeng Tan --- Changes since v2: * This patch is new. --- arch/x86/kernel/cpu/resctrl/core.c | 3 +++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 9 +++++---- include/linux/resctrl.h | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 4c16e58c4a1b..e79807a8f060 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -212,6 +212,7 @@ static bool __get_mem_config_intel(struct rdt_resource = *r) hw_res->num_closid =3D edx.split.cos_max + 1; max_delay =3D eax.split.max_delay + 1; r->default_ctrl =3D MAX_MBA_BW; + r->membw.max_bw =3D MAX_MBA_BW; r->membw.arch_needs_linear =3D true; if (ecx & MBA_IS_LINEAR) { r->membw.delay_linear =3D true; @@ -248,6 +249,8 @@ static bool __rdt_get_mem_config_amd(struct rdt_resourc= e *r) cpuid_count(0x80000020, subleaf, &eax, &ebx, &ecx, &edx); hw_res->num_closid =3D edx + 1; r->default_ctrl =3D 1 << eax; + r->schema_fmt =3D RESCTRL_SCHEMA_RANGE; + r->membw.max_bw =3D 1 << eax; =20 /* AMD does not use delay */ r->membw.delay_linear =3D false; diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 8d1bdfe89692..56c41bfd07e4 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -57,10 +57,10 @@ static bool bw_validate(char *buf, unsigned long *data,= struct rdt_resource *r) return false; } =20 - if ((bw < r->membw.min_bw || bw > r->default_ctrl) && + if ((bw < r->membw.min_bw || bw > r->membw.max_bw) && !is_mba_sc(r)) { rdt_last_cmd_printf("MB value %ld out of range [%d,%d]\n", bw, - r->membw.min_bw, r->default_ctrl); + r->membw.min_bw, r->membw.max_bw); return false; } =20 @@ -108,8 +108,9 @@ static int parse_bw(struct rdt_parse_data *data, struct= resctrl_schema *s, */ static bool cbm_validate(char *buf, u32 *data, struct rdt_resource *r) { - unsigned long first_bit, zero_bit, val; + u32 supported_bits =3D BIT_MASK(r->cache.cbm_len + 1) - 1; unsigned int cbm_len =3D r->cache.cbm_len; + unsigned long first_bit, zero_bit, val; int ret; =20 ret =3D kstrtoul(buf, 16, &val); @@ -118,7 +119,7 @@ static bool cbm_validate(char *buf, u32 *data, struct r= dt_resource *r) return false; } =20 - if ((r->cache.min_cbm_bits > 0 && val =3D=3D 0) || val > r->default_ctrl)= { + if ((r->cache.min_cbm_bits > 0 && val =3D=3D 0) || val > supported_bits) { rdt_last_cmd_puts("Mask out of range\n"); return false; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0f61673c9165..b66cd977b658 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -165,6 +165,7 @@ enum membw_throttle_mode { /** * struct resctrl_membw - Memory bandwidth allocation related data * @min_bw: Minimum memory bandwidth percentage user can request + * @max_bw: Maximum memory bandwidth value, used as the reset value * @bw_gran: Granularity at which the memory bandwidth is allocated * @delay_linear: True if memory B/W delay is in linear scale * @arch_needs_linear: True if we can't configure non-linear resources @@ -175,6 +176,7 @@ enum membw_throttle_mode { */ struct resctrl_membw { u32 min_bw; + u32 max_bw; u32 bw_gran; u32 delay_linear; bool arch_needs_linear; --=20 2.39.2