From nobody Tue Dec 16 14:50:57 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 71E3E303CAF for ; Fri, 5 Dec 2025 22:01:39 +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=1764972100; cv=none; b=UoQliRNRlF01sQvE53nOXwXSJy8v9fPULRIcn/7dgRhjZSiNppMLerz262RNV6erg2PS94gR4oqj5WnO9si9VSNXWtGEXzDCBFSSSUyU9jLNdR64ulxPHJKrRBcX8E/qDHh0rJQbr6Kuwhn+pQ7nEBxoBJ35XO5LOEa8m6edtFw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764972100; c=relaxed/simple; bh=m13qBAYowbTXnQf3A0uGLy41029QptbGlF7fAdxd80U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WonjpOxcqdL/RJzbBytoy6ddqCGCUnt7djLvJGXTEQ9LYWYEANnJC6xKnUwIJBJO9Cfo2uY2rB12JBl3X8WtqWv++40PwQQk72RxToxKAOm6pwyVDNvtBlwRIgBhRdAYi5lQorSYTH4GR5JwmOscntgE9880rddVlvPNU/Yg0iE= 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 099D11BA8; Fri, 5 Dec 2025 14:01:31 -0800 (PST) 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 9BCC13F740; Fri, 5 Dec 2025 14:01:34 -0800 (PST) From: James Morse To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , 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 , Dave Martin , Koba Ko , Shanker Donthineni , fenghuay@nvidia.com, baisheng.gao@unisoc.com, Jonathan Cameron , Gavin Shan , Ben Horgan , rohit.mathew@arm.com, reinette.chatre@intel.com, Punit Agrawal Subject: [RFC PATCH 32/38] arm_mpam: resctrl: Sort the order of the domain lists Date: Fri, 5 Dec 2025 21:58:55 +0000 Message-Id: <20251205215901.17772-33-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20251205215901.17772-1-james.morse@arm.com> References: <20251205215901.17772-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" resctrl documents that the domains appear in numeric order in the schemata file. This means a little more work is needed when bringing a domain online. Add the support for this, using resctrl_find_domain() to find the point to insert in the list. Signed-off-by: James Morse --- drivers/resctrl/mpam_resctrl.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index ccdf8db742c9..84ef3c1b4f53 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -1547,6 +1547,21 @@ static struct mpam_component *find_component(struct = mpam_class *victim, int cpu) return NULL; } =20 +static void mpam_resctrl_domain_insert(struct list_head *list, + struct rdt_domain_hdr *new) +{ + struct rdt_domain_hdr *err; + struct list_head *pos =3D NULL; + + lockdep_assert_held(&domain_list_lock); + + err =3D resctrl_find_domain(list, new->id, &pos); + if (WARN_ON_ONCE(err)) + return; + + list_add_tail_rcu(&new->list, pos); +} + static struct mpam_resctrl_dom * mpam_resctrl_alloc_domain(unsigned int cpu, struct mpam_resctrl_res *res) { @@ -1584,8 +1599,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mp= am_resctrl_res *res) ctrl_d =3D &dom->resctrl_ctrl_dom; mpam_resctrl_domain_hdr_init(cpu, ctrl_comp, &ctrl_d->hdr); ctrl_d->hdr.type =3D RESCTRL_CTRL_DOMAIN; - /* TODO: this list should be sorted */ - list_add_tail_rcu(&ctrl_d->hdr.list, &r->ctrl_domains); + mpam_resctrl_domain_insert(&r->ctrl_domains, &ctrl_d->hdr); err =3D resctrl_online_ctrl_domain(r, ctrl_d); if (err) { dom =3D ERR_PTR(err); @@ -1623,8 +1637,7 @@ mpam_resctrl_alloc_domain(unsigned int cpu, struct mp= am_resctrl_res *res) mon_d =3D &dom->resctrl_mon_dom; mpam_resctrl_domain_hdr_init(cpu, any_mon_comp, &mon_d->hdr); mon_d->hdr.type =3D RESCTRL_MON_DOMAIN; - /* TODO: this list should be sorted */ - list_add_tail_rcu(&mon_d->hdr.list, &r->mon_domains); + mpam_resctrl_domain_insert(&r->mon_domains, &mon_d->hdr); err =3D resctrl_online_mon_domain(r, mon_d); if (err) { dom =3D ERR_PTR(err); --=20 2.39.5