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 B24EC606A31B for ; Fri, 23 Oct 2026 08:08:29 +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=PFR9+XG3; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=mt9s1K+o 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=za39DnYI6PwBauvj/wHkuaRj9l0qjUTC+TJamDxPLs0=; b=PFR9+XG3FGRGe8 HdnWpJ8EhFt+3ovqqJ+w0IXIfQPhoC6oe8rvYtOyzaL+ZukEfW0iBvP6uGvhfBp5ZhEp1WUULYeZ7 2ZukN03P+N5Fj7oUY8x0L5ptF2qX2KBMIgW/2ojkS/Z7r9NKVA+QnOO6YXRJJ4+uYDw9EAaN6MM6+ XERGrFRIalyx6wHkDDuNA9y4PQ6i7Tx1nvmSbR0JSXm9xR5WThLLUHq8I4pIHnPxY63siQrvQnm5u MiJ3H7LYFI1SQ4aq8NuV74vcvD51fdWCMtV168z0yjvt2z0xYLDNIjR51uJD9aVcWfvsHUpjtWlp+ +vFo+cE/JKGjF1IfMsKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xKAJG-0000000FsWk-3JPx; Fri, 23 Oct 2026 08:07:30 +0000 Received: from canpmsgout08.his.huawei.com ([113.46.200.223]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xKAJB-0000000FsUI-43UR for linux-arm-kernel@lists.infradead.org; Fri, 23 Oct 2026 08:07:29 +0000 dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=za39DnYI6PwBauvj/wHkuaRj9l0qjUTC+TJamDxPLs0=; b=mt9s1K+o4qRSEp5QrutgC9tudTuWbsiKE3Ocpd8TTz5F+zq4shs+gF6+fIxWx5rM7aPdfjIfd X9D64y0ore6osqlYEBIEUlZXD3fW01A7oS9r/s0dVXiCobya6vUHuZN6zdHybaoy8NMFAsTqaR5 l8JYV/tkEsurwUBORztnonI= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout08.his.huawei.com (SkyGuard) with ESMTPS id 4j9wbl581DzmV8k; Fri, 23 Oct 2026 16:07:15 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id DEE1B40586; Fri, 23 Oct 2026 16:07:18 +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; Fri, 23 Oct 2026 16:07:18 +0800 Message-ID: Date: Fri, 23 Oct 2026 16:07:17 +0800 X-Archived-By: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 01/10] arm_mpam: resctrl: Use find_component() when allocating a domain To: Reinette Chatre , , , , CC: , , , , , , References: <94ddff51b91f4a51965baf0384c2368e292c1a8c.1792443633.git.reinette.chatre@intel.com> From: Jinjie Ruan In-Reply-To: <94ddff51b91f4a51965baf0384c2368e292c1a8c.1792443633.git.reinette.chatre@intel.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-ClientProxiedBy: kwepems500001.china.huawei.com (7.221.188.70) 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-20261023_010726_622789_C3C5BFA8 X-CRM114-Status: GOOD ( 20.71 ) 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() starts by checking that the resource's > class has a component whose CPU affinity includes the CPU, and fails the > domain allocation otherwise. When the resource supports allocation, that > component also backs the control domain. The check uses an open-coded > walk of the class's component list, while the same function uses > find_component() to find the component backing each monitoring event. > > The open-coded walk duplicates find_component(). It also holds the SRCU > read lock until mpam_resctrl_alloc_domain() returns, which suggests that > the component needs this protection while the domain is set up. > > The component does not need it. Components are freed only when an MSC > fails to probe, in which case MPAM is never enabled and no resctrl > domain is created, or by mpam_disable(), which first removes the CPU > hotplug callbacks and thereby tears down all resctrl domains. A component > therefore outlives every domain that refers to it. The SRCU read lock is > only needed while walking the component list, and find_component() holds > it for that walk. In addition, mpam_resctrl_alloc_domain() only runs > from MPAM's CPU hotplug startup callback, which already holds the SRCU > read lock throughout. > > Replace the open-coded walk with find_component(). > > Signed-off-by: Reinette Chatre > --- > drivers/resctrl/mpam_resctrl.c | 13 ++----------- > 1 file changed, 2 insertions(+), 11 deletions(-) > > diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c > index 9cec5843e8fa..3d5f90f9f1f3 100644 > --- a/drivers/resctrl/mpam_resctrl.c > +++ b/drivers/resctrl/mpam_resctrl.c > @@ -1623,21 +1623,12 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) > struct rdt_l3_mon_domain *mon_d; > struct rdt_ctrl_domain *ctrl_d; > struct mpam_class *class = res->class; > - struct mpam_component *comp_iter, *ctrl_comp; > + struct mpam_component *ctrl_comp; > struct rdt_resource *r = &res->resctrl_res; > > lockdep_assert_held(&domain_list_lock); > > - ctrl_comp = NULL; > - guard(srcu)(&mpam_srcu); > - list_for_each_entry_srcu(comp_iter, &class->components, class_list, > - srcu_read_lock_held(&mpam_srcu)) { > - if (cpumask_test_cpu(cpu, &comp_iter->affinity)) { > - ctrl_comp = comp_iter; > - break; > - } > - } LGTM Reviewed-by: Jinjie Ruan > - > + ctrl_comp = find_component(class, cpu); > /* class has no component for this CPU */ > if (WARN_ON_ONCE(!ctrl_comp)) > return ERR_PTR(-EINVAL); -- Best regards, Jinjie