From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C108606A31A for ; Mon, 26 Oct 2026 11:50:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jxcox5v1; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=Ty2+RCmY DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:CC:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=rk1WovkF3sv2NFNM8sIBXD2tHrqmbxPVkrmVTLJoFiI=; b=jxcox5v1+cUHsk e7DU4FhEpK4hKi6PhfmyAojy/Zzs/kb44YJgOu6G78FilazCPPnHT/Fddb9S00Ap6sPXmFC6lRW1O Vya544zkhPliaC5n6zGbE8xPsx8Ee/GtIkjfNXN1TB2kMnVdkz3zdgQ1agvdO8VKY8zrcO+Wm4Egr 0x5IcI9go3+c6b8r8aLbf6vwSmae6IbvnpSDlK2fD8Ddt+33AQ2ibkcKSzr1bKv/Vpm4uI0lFQVFe t9tqNeYZ3sI7iCJumbxoHfsCUtwJJ4cO+NQAMqb6kDUCjZ/qau3vb4qNvCW5svx8thrW+ajAuMgCj 7P25sKK2cxOFrZRfyqTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xLJDH-00000002Pqs-1aMM; Mon, 26 Oct 2026 11:50:03 +0000 Received: from canpmsgout12.his.huawei.com ([113.46.200.227]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xLJDE-00000002Ppy-1fBd for linux-arm-kernel@lists.infradead.org; Mon, 26 Oct 2026 11:50:02 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=rk1WovkF3sv2NFNM8sIBXD2tHrqmbxPVkrmVTLJoFiI=; b=Ty2+RCmY/RhVyQkMoz9C1ddh1eeYM1p12Gzkyw/vKNxwCvrqGE/ZPfYOoraE9D+zGfZGDP7+9 igKkwKwvAjrQ4CejsEyMZ4l48+2g9zlhWLPL+9kFnqd1vmTp2/DSvk55zmucXBXoEX5348j9dv7 ErWyc58JnYjn0ienpcX1WW0= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4jCsPH0qycznV09; Mon, 26 Oct 2026 19:49:55 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id 7D99640565; Mon, 26 Oct 2026 19:49:50 +0800 (CST) Received: from [10.67.110.68] (10.67.110.68) by kwepemk200008.china.huawei.com (7.202.194.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Mon, 26 Oct 2026 19:49:49 +0800 Message-ID: Date: Mon, 26 Oct 2026 19:49:49 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 04/10] arm_mpam: resctrl: Split control and monitoring domain setup into helpers To: Reinette Chatre , , , , CC: , , , , , , References: <20621c28067916be2709fc4437473f1ccad7e334.1792443633.git.reinette.chatre@intel.com> From: Jinjie Ruan In-Reply-To: <20621c28067916be2709fc4437473f1ccad7e334.1792443633.git.reinette.chatre@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems100002.china.huawei.com (7.221.188.206) To kwepemk200008.china.huawei.com (7.202.194.74) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261026_045001_085189_C77B25A7 X-CRM114-Status: GOOD ( 26.11 ) X-Spam-Score: -2.1 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 在 2026/10/20 6:07, Reinette Chatre 写道: > mpam_resctrl_alloc_domain() allocates one structure that holds both the > control domain and the monitoring domain of a resource. It sets up > whichever of the two domains the resource supports, with the setup of > both open coded in the function, and undoes the control domain if > setting up the monitoring domain fails. > > Apart from the code that manages domains, every user of the structure > accesses only one of its two domains, so the monitoring domain can be > given a structure of its own. Doing so starts with separating its setup > from that of the control domain. > > Move the setup of each domain into its own helper in preparation for > giving the monitoring domain its own structure as part of supporting > multiple controls per resource. Keep the allocation and the error > handling in mpam_resctrl_alloc_domain() so that a failure to set up the > monitoring domain still undoes the control domain. > > No functional change intended. > > Signed-off-by: Reinette Chatre > --- > drivers/resctrl/mpam_resctrl.c | 116 ++++++++++++++++++++------------- > 1 file changed, 70 insertions(+), 46 deletions(-) > > diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c > index dc442851fd7e..246560247a28 100644 > --- a/drivers/resctrl/mpam_resctrl.c > +++ b/drivers/resctrl/mpam_resctrl.c > @@ -1615,13 +1615,77 @@ static struct mpam_component *find_component(struct mpam_class *class, int cpu) > return NULL; > } > > +static int mpam_resctrl_setup_ctrl_domain(unsigned int cpu, > + struct rdt_resource *r, > + struct mpam_component *comp, > + struct mpam_resctrl_dom *dom) > +{ > + struct rdt_ctrl_domain *ctrl_d = &dom->resctrl_ctrl_dom; > + int err; > + > + dom->ctrl_comp = comp; > + > + mpam_resctrl_domain_hdr_init(cpu, comp, r->rid, &ctrl_d->hdr); > + ctrl_d->hdr.type = RESCTRL_CTRL_DOMAIN; > + err = resctrl_online_ctrl_domain(r, ctrl_d); > + if (err) > + return err; > + > + mpam_resctrl_domain_insert(&r->ctrl_domains, &ctrl_d->hdr); > + > + return 0; > +} > + > +static int mpam_resctrl_setup_mon_domain(unsigned int cpu, > + struct rdt_resource *r, > + struct mpam_resctrl_dom *dom) > +{ > + struct rdt_l3_mon_domain *mon_d = &dom->resctrl_mon_dom; > + struct mpam_component *any_mon_comp = NULL; > + enum resctrl_event_id eventid; > + struct mpam_resctrl_mon *mon; > + int err; > + > + /* > + * Even if the monitor domain is backed by a different > + * component, the L3 component IDs need to be used... only > + * there may be no ctrl_comp for the L3. > + * Search each event's class list for a component with > + * overlapping CPUs and set up the dom->mon_comp array. > + */ > + > + for_each_mpam_resctrl_mon(mon, eventid) { > + struct mpam_component *mon_comp; > + > + if (!mon->class) > + continue; // dummy resource > + > + mon_comp = find_component(mon->class, cpu); > + dom->mon_comp[eventid] = mon_comp; > + if (mon_comp) > + any_mon_comp = mon_comp; > + } > + if (!any_mon_comp) { > + WARN_ON_ONCE(0); > + return -EFAULT; > + } > + > + mpam_resctrl_domain_hdr_init(cpu, any_mon_comp, r->rid, &mon_d->hdr); > + mon_d->hdr.type = RESCTRL_MON_DOMAIN; > + err = resctrl_online_mon_domain(r, &mon_d->hdr); > + if (err) > + return err; > + > + mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr); > + > + return 0; > +} > + > static void mpam_resctrl_alloc_domain(unsigned int cpu, > struct mpam_resctrl_res *res) > { > int err; > struct mpam_resctrl_dom *dom; > - struct rdt_l3_mon_domain *mon_d; > - struct rdt_ctrl_domain *ctrl_d; > struct mpam_class *class = res->class; > struct mpam_component *comp; > struct rdt_resource *r = &res->resctrl_res; > @@ -1638,57 +1702,17 @@ static void mpam_resctrl_alloc_domain(unsigned int cpu, > return; > > if (r->alloc_capable) { > - dom->ctrl_comp = comp; > - > - ctrl_d = &dom->resctrl_ctrl_dom; > - mpam_resctrl_domain_hdr_init(cpu, comp, r->rid, &ctrl_d->hdr); > - ctrl_d->hdr.type = RESCTRL_CTRL_DOMAIN; > - err = resctrl_online_ctrl_domain(r, ctrl_d); > + err = mpam_resctrl_setup_ctrl_domain(cpu, r, comp, dom); > if (err) > goto free_domain; LGTM Reviewed-by: Jinjie Ruan > - > - mpam_resctrl_domain_insert(&r->ctrl_domains, &ctrl_d->hdr); > } else { > pr_debug("Skipped control domain online - no controls\n"); > } > > if (r->mon_capable) { > - struct mpam_component *any_mon_comp = NULL; > - struct mpam_resctrl_mon *mon; > - enum resctrl_event_id eventid; > - > - /* > - * Even if the monitor domain is backed by a different > - * component, the L3 component IDs need to be used... only > - * there may be no ctrl_comp for the L3. > - * Search each event's class list for a component with > - * overlapping CPUs and set up the dom->mon_comp array. > - */ > - > - for_each_mpam_resctrl_mon(mon, eventid) { > - struct mpam_component *mon_comp; > - > - if (!mon->class) > - continue; // dummy resource > - > - mon_comp = find_component(mon->class, cpu); > - dom->mon_comp[eventid] = mon_comp; > - if (mon_comp) > - any_mon_comp = mon_comp; > - } > - if (!any_mon_comp) { > - WARN_ON_ONCE(0); > - goto offline_ctrl_domain; > - } > - > - mon_d = &dom->resctrl_mon_dom; > - mpam_resctrl_domain_hdr_init(cpu, any_mon_comp, r->rid, &mon_d->hdr); > - mon_d->hdr.type = RESCTRL_MON_DOMAIN; > - err = resctrl_online_mon_domain(r, &mon_d->hdr); > + err = mpam_resctrl_setup_mon_domain(cpu, r, dom); > if (err) > goto offline_ctrl_domain; > - > - mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr); > } else { > pr_debug("Skipped monitor domain online - no monitors\n"); > } > @@ -1697,8 +1721,8 @@ static void mpam_resctrl_alloc_domain(unsigned int cpu, > > offline_ctrl_domain: > if (r->alloc_capable) { > - mpam_resctrl_offline_domain_hdr(cpu, &ctrl_d->hdr); > - resctrl_offline_ctrl_domain(r, ctrl_d); > + mpam_resctrl_offline_domain_hdr(cpu, &dom->resctrl_ctrl_dom.hdr); > + resctrl_offline_ctrl_domain(r, &dom->resctrl_ctrl_dom); > } > free_domain: > kfree(dom); -- Best regards, Jinjie