From nobody Tue Apr 7 00:46:16 2026 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 A9AD73CB2E4 for ; Tue, 17 Mar 2026 13:21:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753722; cv=none; b=lC1cV7o5nGARQILleK0BthLeZnqFjEyCM6KTt28KeGWhVtP98fmo6yOMZwRJuiEmnvLwhjb9bOloxXCP9xjK/GN1Se4wIQ3WLuVlxjRGNr3399lHsx+FXVWR68hioMicsx9jtQp68BKqEDFFAICi/26GawB1V+BhJ34unCr/pM0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753722; c=relaxed/simple; bh=+yFc+ApwwYuHmwbMlK/VTOFrbDxxd2l8YSrtwq+NH4U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=FiHgKFn5YhS6eZBUmDT2d4V+6ESW411yL2Uk7mccNqwTBCtBFKZV3JACV6DPdMjcghjF9fP/t54Objplw6zoK+bjQDl+oPOzGnk17OMhGFKyGDlci3MyTQgeXMfQNQlk6e7VEhrLnnAwMtyFYLgfZty4TN6X04TqGmz5qc7rlGc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=h-partners.com; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b=mFnevj9R; arc=none smtp.client-ip=113.46.200.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=h-partners.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=h-partners.com header.i=@h-partners.com header.b="mFnevj9R" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=tDxYO41ssbPQ9d6hnkQIYtmLEz+3UCNl10f9cbj2TcM=; b=mFnevj9RkzxWzzRrMpaTBtCHJG17NxWdw7d7Ny7wl3sMQy3igy5g5lCK1cUGBL1+SCjZ8YpIQ 7CCVCgqrkWPlOoBwGmxLK4Nx1qQZqSvIruh9gsFniFWL0hXyPL2818UEh5vJAjs/ftXXn5sKxow yOReBF0NQmU5Uut+Ye/B3kg= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4fZst042LtznTXd; Tue, 17 Mar 2026 21:16:24 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id BC8E340565; Tue, 17 Mar 2026 21:21:56 +0800 (CST) Received: from huawei.com (10.50.87.109) by kwepemf100008.china.huawei.com (7.202.181.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.36; Tue, 17 Mar 2026 21:21:56 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 8/9] fs/resctrl: Wire up rmid expansion and reclaim functions Date: Tue, 17 Mar 2026 21:21:40 +0800 Message-ID: <20260317132141.1272506-9-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260317132141.1272506-1-zengheng4@huawei.com> References: <20260317132141.1272506-1-zengheng4@huawei.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 X-ClientProxiedBy: kwepems500002.china.huawei.com (7.221.188.17) To kwepemf100008.china.huawei.com (7.202.181.222) Content-Type: text/plain; charset="utf-8" The previous patch implemented resctrl_arch_rmid_expand() and resctrl_arch_rmid_reclaim() for ARM MPAM. This patch integrates these architecture-specific functions into the generic resctrl layer. Refactor resctrl_find_free_rmid() to support dynamic rmid expansion. If no free rmid is available for the current closid, attempt to expand via resctrl_arch_expand_rmid(). On success, retry the rmid allocation. As this capability is architecture-specific, x86 maintains existing behavior by returning -ENOSPC when rmid resources are exhausted. Additionally, invoke resctrl_arch_rmid_reclaim() when rmids are released to enable architecture-specific resource cleanup. Signed-off-by: Zeng Heng --- arch/x86/include/asm/resctrl.h | 7 +++++++ fs/resctrl/monitor.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 575f8408a9e7..7f8c8d84f2a0 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -167,6 +167,13 @@ static inline void resctrl_arch_sched_in(struct task_s= truct *tsk) __resctrl_sched_in(tsk); } =20 +static inline int resctrl_arch_rmid_expand(u32 closid) +{ + return -ENOSPC; +} + +static inline void resctrl_arch_rmid_reclaim(u32 closid, u32 rmid) {} + static inline void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 = *rmid) { *rmid =3D idx; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 4e78fb194c16..c58440eb7cc9 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -122,6 +122,8 @@ static void limbo_release_entry(struct rmid_entry *entr= y) =20 if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) closid_num_dirty_rmid[entry->closid]--; + + resctrl_arch_rmid_reclaim(entry->closid, entry->rmid); } =20 /* @@ -197,7 +199,7 @@ bool has_busy_rmid(struct rdt_l3_mon_domain *d) return find_first_bit(d->rmid_busy_llc, idx_limit) !=3D idx_limit; } =20 -static struct rmid_entry *resctrl_find_free_rmid(u32 closid) +static struct rmid_entry *__resctrl_find_free_rmid(u32 closid) { struct rmid_entry *itr; u32 itr_idx, cmp_idx; @@ -214,7 +216,12 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 c= losid) * very first entry will be returned. */ itr_idx =3D resctrl_arch_rmid_idx_encode(itr->closid, itr->rmid); + if (itr_idx =3D=3D U32_MAX) + continue; + cmp_idx =3D resctrl_arch_rmid_idx_encode(closid, itr->rmid); + if (cmp_idx =3D=3D U32_MAX) + continue; =20 if (itr_idx =3D=3D cmp_idx) return itr; @@ -223,6 +230,25 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 c= losid) return ERR_PTR(-ENOSPC); } =20 +static struct rmid_entry *resctrl_find_free_rmid(u32 closid) +{ + struct rmid_entry *err; + int ret; + + err =3D __resctrl_find_free_rmid(closid); + if (err =3D=3D ERR_PTR(-ENOSPC)) { + ret =3D resctrl_arch_rmid_expand(closid); + if (ret < 0) + /* Out of rmid */ + goto out; + + /* Try it again */ + return __resctrl_find_free_rmid(closid); + } +out: + return err; +} + /** * resctrl_find_cleanest_closid() - Find a CLOSID where all the associated * RMID are clean, or the CLOSID that has @@ -340,8 +366,10 @@ void free_rmid(u32 closid, u32 rmid) =20 if (resctrl_is_mon_event_enabled(QOS_L3_OCCUP_EVENT_ID)) add_rmid_to_limbo(entry); - else + else { list_add_tail(&entry->list, &rmid_free_lru); + resctrl_arch_rmid_reclaim(closid, rmid); + } } =20 bool rmid_is_occupied(u32 closid, u32 rmid) --=20 2.25.1