From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.227 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795081757; b=Hah3JkIJYGqwjrV8XnAPqXRTMBw6vgzTlBfYjP7p7E5h62net6qwUbtCPexcnxdr+rZD cLKj8XQALu4NTgl15BuXE3dcoUrE14CYHPYsHpaavwV/atJWPl4Ggmb8M+zSHUJRzuDDx KHdnj1g94BR4eMIx5MtMH8NKfUixz3OJmeg7hw8hqfZ2b+Bi4uEie+OfOggh+tB3NWUEq mVMTJ42AEY0m1xOx0aLj+/XjiO717thGbD5oyMgD3DjpqgjtpAnzMo5o6nuTPTzXYi3wr g8K+GTUPpHssBeNF1hDgaLnMrn13gB8cwX9g30lAsJS1zNaZT2lMfbZH0dP21yU69Mw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795081757; h=DMARC-Filter:dkim-signature:Received:Received:Received:From:To:CC: Subject:Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Originating-IP: X-ClientProxiedBy; bh=zSBnRfstLFOLJk+BY0dtRWMawegjn8REAGRmsm4ud7c=; b=abSSsLJ8bQCMPV3qf2gjxBspqs7MTISmu4BT2YJODjX3NI7+7anQTZVyn1tE5a6K0DYN mQDkMMZ/0Ilo2fnY5cgKqEIvdhL+XkcIWTNFuL2KQJi4/biwk+/xs5JFFrUc1uIc2x8d1 +0jsX04zwDKu5v5bzKjWcoATMCZunCLWry2oTzreMAAnWBkNcLMSSummBgcS7VS1r3Z5o j1rs6dbuBwmqjC/OPey7bNsKoSc1Ro+eVocvRjw33fdDGIgi4wlSWCbBexJVgOz82PDQn 67QEhmH9vkzY8mWmyHpp6FfjP0skCsubpIrQhuJMrnJG5cYGQIlaoQPZy2DPEe43fqQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=UBCYnugU; arc=none smtp.remote-ip=113.46.200.227 Received: from canpmsgout12.his.huawei.com (canpmsgout12.his.huawei.com [113.46.200.227]) (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 66190606A320; Thu, 19 Nov 2026 09:49:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 66190606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=UBCYnugU dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=zSBnRfstLFOLJk+BY0dtRWMawegjn8REAGRmsm4ud7c=; b=UBCYnugURFX2k+6sGCKv3+d1buWao2ZJIOw6lCh4G0PlmvVPfGr8eS0EK4Vs3n5zLI8fgincE TyAxs1KYK+Eo4djWGTuh0nlj1qDMg0RrbSwP5VS6oRaNiYCWdWC+GWIdh3FIfc7X/CDuas7Tyi4 qHqf1YDaWGm3WQIZkdNgR08= Received: from mail.maildlp.com (unknown [172.19.163.15]) by canpmsgout12.his.huawei.com (SkyGuard) with ESMTPS id 4jVYYv0LF4znTW1; Thu, 19 Nov 2026 17:48:19 +0800 (CST) Received: from kwepemk200008.china.huawei.com (unknown [7.202.194.74]) by mail.maildlp.com (Postfix) with ESMTPS id 8B2EB40578; Thu, 19 Nov 2026 17:49:11 +0800 (CST) Received: from huawei.com (10.90.53.73) 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; Thu, 19 Nov 2026 17:49:10 +0800 From: Jinjie Ruan To: , , , , , , , , , , , , , , , , , CC: Subject: [PATCH v6 1/6] fs/resctrl: Report a temporary RMID shortage per CLOSID Date: Thu, 19 Nov 2026 17:48:53 +0800 Message-ID: <20261119094858.813874-2-ruanjinjie@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20261119094858.813874-1-ruanjinjie@huawei.com> References: <20261119094858.813874-1-ruanjinjie@huawei.com> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemk200008.china.huawei.com (7.202.194.74) An RMID that is freed is held in limbo until its cache occupancy drops below the threshold, after which it returns to the free list. A request that fails because of limbo is thus temporary and worth retrying, which resctrl reports to userspace as -EBUSY. A request that fails because every RMID is in use is permanent and reported as -ENOSPC. Where an RMID is only meaningful together with a CLOSID, a request can only be satisfied by an RMID belonging to the requested CLOSID, so the distinction has to be drawn per CLOSID. Instead it is drawn system wide. -ENOSPC is reported when the free list holds no RMID for the requested CLOSID, even when that CLOSID has RMIDs in limbo. -EBUSY is reported when the free list is empty and another CLOSID has an RMID in limbo, even when the requested CLOSID has none. Userspace is thus told to give up on a shortage that may clear on its own, and to retry one that cannot clear until it removes a group itself. Architectures where the RMID is independent of the CLOSID always match the first entry on the free list, so neither case arises there and only MPAM systems are affected. Draw the distinction from the number of RMIDs the requested CLOSID has in limbo where the RMID depends on the CLOSID, and from the system wide count otherwise. Drop the separate test for an empty free list, which the search handles on its own. Fixes: c4c0376eefe1 ("x86/resctrl: Allow RMID allocation to be scoped by CLOSID") Signed-off-by: Jinjie Ruan Reviewed-by: Reinette Chatre Reviewed-by: Ben Horgan Cc: James Morse Cc: Reinette Chatre Cc: Babu Moger Cc: # 7.1.x --- fs/resctrl/monitor.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 04e4ea612b7c..b8f4e1ff4083 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -207,9 +207,6 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid) struct rmid_entry *itr; u32 itr_idx, cmp_idx; - if (list_empty(&rmid_free_lru)) - return rmid_limbo_count ? ERR_PTR(-EBUSY) : ERR_PTR(-ENOSPC); - list_for_each_entry(itr, &rmid_free_lru, list) { /* * Get the index of this free RMID, and the index it would need @@ -225,7 +222,17 @@ static struct rmid_entry *resctrl_find_free_rmid(u32 closid) return itr; } - return ERR_PTR(-ENOSPC); + /* + * No free RMID matched. If this CLOSID has RMIDs in limbo, return + * -EBUSY so userspace can retry. Otherwise, the CLOSID is genuinely + * out of RMIDs. When RMIDs are not per-CLOSID, any RMID in limbo + * delays the allocation. + */ + if (IS_ENABLED(CONFIG_RESCTRL_RMID_DEPENDS_ON_CLOSID)) + return closid_num_dirty_rmid[closid] ? ERR_PTR(-EBUSY) : + ERR_PTR(-ENOSPC); + + return rmid_limbo_count ? ERR_PTR(-EBUSY) : ERR_PTR(-ENOSPC); } /** -- 2.34.1