From nobody Thu Nov 28 04:40:11 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3A8D821C198 for ; Fri, 4 Oct 2024 18:06:35 +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=1728065196; cv=none; b=UjaRVol/5KjtKCFaz80vxFsBVCnWtuCb1VVGEX+N27CDEz2hf+9UgQa99beEQBFNf2jYwWuWxlf8dy4HI2go/NQxeiiDTFIeauygDpJLSKSuYxNCI0EQ8cO3zGiCy+8Wyertik0TAOqMkb3yDjBK9W5WhlQQ8wKrvbkxD56AAao= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728065196; c=relaxed/simple; bh=aB2OqAqmAm/n8y2AQqP5b/Im6FpjnzozOEEP/uBnr2A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ltrk9Z9bF/zhWRdkDj09ZvNRALEWNP9j4+GV6CdSKeXnJFSkVaIA9qqXVYzvu7PZ0BzD4DaM8Zcq6WnlXeMxfMMFlHeVXg9NzZJvD/dFMLasg/BvLgpIEVejHWgzohhDddkFjhAzcqM9bZlx83PB+/7lU2LQnWiUBSefjs3g5VE= 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 3D2DA339; Fri, 4 Oct 2024 11:07:04 -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 6656D3F58B; Fri, 4 Oct 2024 11:06:31 -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 v5 28/40] x86/resctrl: Move get_config_index() to a header Date: Fri, 4 Oct 2024 18:03:35 +0000 Message-Id: <20241004180347.19985-29-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" get_config_index() is used by the architecture specific code to map a CLOSID+type pair to an index in the configuration arrays. MPAM needs to do this too to preserve the ABI to user-space, there is no reason to do it differently. Move the helper to a header file. Co-developed-by: Dave Martin Signed-off-by: Dave Martin Signed-off-by: James Morse Tested-by: Carl Worth # arm64 Tested-by: Shaopeng Tan Reviewed-by: Shaopeng Tan --- Changes since v1: * Reindent resctrl_get_config_index() as per coding-style.rst rules. --- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 19 +++---------------- include/linux/resctrl.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 7ea362c099db..c2c1010eb869 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -282,25 +282,12 @@ static int parse_line(char *line, struct resctrl_sche= ma *s, return -EINVAL; } =20 -static u32 get_config_index(u32 closid, enum resctrl_conf_type type) -{ - switch (type) { - default: - case CDP_NONE: - return closid; - case CDP_CODE: - return closid * 2 + 1; - case CDP_DATA: - return closid * 2; - } -} - int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain= *d, u32 closid, enum resctrl_conf_type t, u32 cfg_val) { struct rdt_hw_ctrl_domain *hw_dom =3D resctrl_to_arch_ctrl_dom(d); struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); - u32 idx =3D get_config_index(closid, t); + u32 idx =3D resctrl_get_config_index(closid, t); struct msr_param msr_param; =20 if (!cpumask_test_cpu(smp_processor_id(), &d->hdr.cpu_mask)) @@ -337,7 +324,7 @@ int resctrl_arch_update_domains(struct rdt_resource *r,= u32 closid) if (!cfg->have_new_ctrl) continue; =20 - idx =3D get_config_index(closid, t); + idx =3D resctrl_get_config_index(closid, t); if (cfg->new_ctrl =3D=3D hw_dom->ctrl_val[idx]) continue; hw_dom->ctrl_val[idx] =3D cfg->new_ctrl; @@ -457,7 +444,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, str= uct rdt_ctrl_domain *d, u32 closid, enum resctrl_conf_type type) { struct rdt_hw_ctrl_domain *hw_dom =3D resctrl_to_arch_ctrl_dom(d); - u32 idx =3D get_config_index(closid, type); + u32 idx =3D resctrl_get_config_index(closid, type); =20 return hw_dom->ctrl_val[idx]; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index e7354f581d3b..653d7cf41e64 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -382,6 +382,21 @@ void resctrl_arch_mon_event_config_write(void *info); */ void resctrl_arch_mon_event_config_read(void *info); =20 +/* For use by arch code to remap resctrl's smaller CDP CLOSID range */ +static inline u32 resctrl_get_config_index(u32 closid, + enum resctrl_conf_type type) +{ + switch (type) { + default: + case CDP_NONE: + return closid; + case CDP_CODE: + return closid * 2 + 1; + case CDP_DATA: + return closid * 2; + } +} + /* * Update the ctrl_val and apply this config right now. * Must be called on one of the domain's CPUs. --=20 2.39.2