From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout07.his.huawei.com (canpmsgout07.his.huawei.com [113.46.200.222]) (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 AA4F63AE1A0 for ; Mon, 13 Apr 2026 08:54:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.222 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776070465; cv=none; b=efGrxGb6VB57P+w8dhIImmQrJUOw+dFWsHAPsAedbwwpKD+WSog40YV2PdWOgpACE+SyBjq0YzqgAng5AD7H3kVGqJfdvJQ3mknFvkjBV/Ws0XnixHpT2Qa5gp8e9GZB2mkCo/0eYq+/SM/86W781eJo5dct5+Y1XQvilISCTJc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776070465; c=relaxed/simple; bh=iPAZyGqQDgqC6JbO2TmiAxkycoPuWJ2V8s9HW2XN6AM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ZSyccxgkuHCINkcWqtaiRHy9q1rSRRhxBpbRVLVgHk1FwY70wmMxuy12yQMZZMN+tecr73ZM3gt9xkE1lbmjQQghGbTidK52ZkgH+aZSCTkCAvsL5LrHmPgB7EL9dDme2DV5mtIaxmDQCwzB9nmpA9ztCRl6/ieY9w4TL1ZpaSQ= 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=cSgw0M84; arc=none smtp.client-ip=113.46.200.222 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="cSgw0M84" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=yw+HF7RpwhnK0fVJzlDYt8d8/CD4wE+/irYw9MBaZMo=; b=cSgw0M84Ss+O8CGToZbwz/5wVzN23c1/ickwDFelK5Kwe9FW7vVp0D4adfGQoxXE3W7p6smt9 H4qMnKieZgcsLU5ys3BSfGFLKP1K1aJdlPDpWivqW5lbFuan/U+GMvWdMOvnLOsCZ1iv5mACUds ZTyzfaY+FevczLqHOX3kKxw= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4fvLdw0J6xzLlSv; Mon, 13 Apr 2026 16:48:04 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 5B1EF40565; Mon, 13 Apr 2026 16:54:20 +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; Mon, 13 Apr 2026 16:54:19 +0800 From: Zeng Heng To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH v8 next 09/10] fs/resctrl: Wire up rmid expansion and reclaim functions Date: Mon, 13 Apr 2026 16:54:04 +0800 Message-ID: <20260413085405.1166412-10-zengheng4@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20260413085405.1166412-1-zengheng4@huawei.com> References: <20260413085405.1166412-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: 8bit Content-Type: text/plain X-ClientProxiedBy: kwepems100001.china.huawei.com (7.221.188.238) To kwepemf100008.china.huawei.com (7.202.181.222) 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 its 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_struct *tsk) __resctrl_sched_in(tsk); } +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 = idx; diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 7473c43600cf..3ac86995278e 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -122,6 +122,8 @@ static void limbo_release_entry(struct rmid_entry *entry) if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) closid_num_dirty_rmid[entry->closid]--; + + resctrl_arch_rmid_reclaim(entry->closid, entry->rmid); } /* @@ -197,7 +199,7 @@ bool has_busy_rmid(struct rdt_l3_mon_domain *d) return find_first_bit(d->rmid_busy_llc, idx_limit) != idx_limit; } -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 closid) * very first entry will be returned. */ itr_idx = resctrl_arch_rmid_idx_encode(itr->closid, itr->rmid); + if (itr_idx == U32_MAX) + continue; + cmp_idx = resctrl_arch_rmid_idx_encode(closid, itr->rmid); + if (cmp_idx == U32_MAX) + continue; if (itr_idx == cmp_idx) return itr; @@ -223,6 +230,25 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid) return ERR_PTR(-ENOSPC); } +static struct rmid_entry *resctrl_find_free_rmid(u32 closid) +{ + struct rmid_entry *err; + int ret; + + err = __resctrl_find_free_rmid(closid); + if (err == ERR_PTR(-ENOSPC)) { + ret = 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 @@ -342,8 +368,10 @@ void free_rmid(u32 closid, u32 rmid) 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); + } } bool rmid_is_occupied(u32 closid, u32 rmid) -- 2.25.1