From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B67520459A for ; Thu, 18 Dec 2025 11:58:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766059105; cv=none; b=ji/d04N9H2h5kHmNwHndj3GnLg5BHPBsqRgls0BFG20+n2hU1ebL7YmU6euu8I9TmX7cOYj4z+p99iku24TWa1iQ4cKR8hjt4PM9n05oJUxSxmWcAH/aUw+ecqasslgjz8ApaKctu0ZTVpfGUzCI9RqMABDNp/Fiktezqp/V1as= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766059105; c=relaxed/simple; bh=peNaRfr7FcwBL0px+dSixpXkhtHfg1SFLa5e2WzR8j0=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=D9aJuFQxeyhGD1K4k43qVzPP/g/meNP9a+HFaCxOB5nXt9xRhuDAAKUpwzBxJkyK0wQqvImFZN6lFpJj1FQuvfMwzvm1gzjUmyMMX/3Qifn4HP9WrG5pZkoVwzWbsuGaIyM/b9rJaWj7GKO+9W8IS76JxA0RAi5ylxyUXHCK14U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.224.150]) by frasgout.his.huawei.com (SkyGuard) with ESMTPS id 4dX8LR315rzHnH81; Thu, 18 Dec 2025 19:57:51 +0800 (CST) Received: from dubpeml100005.china.huawei.com (unknown [7.214.146.113]) by mail.maildlp.com (Postfix) with ESMTPS id 800B540565; Thu, 18 Dec 2025 19:58:18 +0800 (CST) Received: from localhost (10.203.177.15) by dubpeml100005.china.huawei.com (7.214.146.113) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Thu, 18 Dec 2025 11:58:17 +0000 Date: Thu, 18 Dec 2025 11:58:15 +0000 From: Jonathan Cameron To: James Morse CC: , , D Scott Phillips OS , , , , , , Jamie Iles , "Xin Hao" , , , , David Hildenbrand , Dave Martin , Koba Ko , Shanker Donthineni , , , Gavin Shan , Ben Horgan , , , Punit Agrawal Subject: Re: [RFC PATCH 13/38] arm_mpam: resctrl: Add CDP emulation Message-ID: <20251218115815.00003f2c@huawei.com> In-Reply-To: <20251205215901.17772-14-james.morse@arm.com> References: <20251205215901.17772-1-james.morse@arm.com> <20251205215901.17772-14-james.morse@arm.com> X-Mailer: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500009.china.huawei.com (7.191.174.84) To dubpeml100005.china.huawei.com (7.214.146.113) On Fri, 5 Dec 2025 21:58:36 +0000 James Morse wrote: > Intel RDT's CDP feature allows the cache to use a different control value > depending on whether the accesses was for instruction fetch or a data > access. MPAM's equivalent feature is the other way up: the CPU assigns a > different partid label to traffic depending on whether it was instruction > fetch or a data access, which causes the cache to use a different control > value based solely on the partid. > > MPAM can emulate CDP, with the side effect that the alternative partid is > seen by all MSC, it can't be enabled per-MSC. > > Add the resctrl hooks to turn this on or off. Add the helpers that > match a closid against a task, which need to be aware that the value > written to hardware is not the same as the one resctrl is using. > > Update the 'arm64_mpam_global_default' variable the arch code uses > during context switch to know when the per-cpu value should be used > instead. > > Awkwardly, the MB controls don't implement CDP. To emulate this, the > MPAM equivalent needs programming twice by the resctrl glue, as > resctrl expects the bandwidth controls to be applied independently for > both data and isntruction-fetch. > > CC: Dave Martin > CC: Ben Horgan > CC: Amit Singh Tomar > Signed-off-by: James Morse More trivial stuff. It is clearly that kind of a day. > diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c > index c2650abb99ec..d5f75ed67e46 100644 > --- a/drivers/resctrl/mpam_resctrl.c > +++ b/drivers/resctrl/mpam_resctrl.c > +int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable) > +{ > + u32 partid_i, partid_d; > + > + cdp_enabled = enable; > + partid_i = partid_d = RESCTRL_RESERVED_CLOSID; I'd do these at the declarations. The kernel style guide does also say not to do multiple assignments on one line. Obviously this one is fairly obviously fine but none the less... > + > + if (enable) { > + u32 partid = RESCTRL_RESERVED_CLOSID; > + > + partid_d = resctrl_get_config_index(partid, CDP_CODE); > + partid_i = resctrl_get_config_index(partid, CDP_DATA); > + } > + > + mpam_set_task_partid_pmg(current, partid_d, partid_i, 0, 0); > + WRITE_ONCE(arm64_mpam_global_default, mpam_get_regval(current)); > + > + resctrl_reset_task_closids(); > + > + return 0; > +} > @@ -272,6 +369,7 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d, > int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d, > u32 closid, enum resctrl_conf_type t, u32 cfg_val) > { > + int err; > u32 partid; > struct mpam_config cfg; > struct mpam_props *cprops; > @@ -311,7 +409,22 @@ int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d, > return -EINVAL; > } > > - return mpam_apply_config(dom->ctrl_comp, partid, &cfg); > + /* > + * When CDP is enabled, but the resource doesn't support it, we need to > + * apply the same configuration to the other partid. > + */ > + if (mpam_resctrl_hide_cdp(r->rid)) { > + partid = resctrl_get_config_index(closid, CDP_CODE); > + err = mpam_apply_config(dom->ctrl_comp, partid, &cfg); > + if (err) > + return err; > + > + partid = resctrl_get_config_index(closid, CDP_DATA); > + return mpam_apply_config(dom->ctrl_comp, partid, &cfg); Given you returned, maybe drop the else which will reduce the diff as well as a bonus. Definitely drop this blank line. > + > + } else { > + return mpam_apply_config(dom->ctrl_comp, partid, &cfg); > + } > }