From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout01.his.huawei.com (canpmsgout01.his.huawei.com [113.46.200.216]) (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 CAD9B3AE189 for ; Mon, 13 Apr 2026 08:54:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.216 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776070463; cv=none; b=Ns8SaCZyumxxkB1jIiLyZ0MJ2qyoemd8ULU0o/POzZ+rojmcDOVAMPulV/M/vkFnbVJANCW7RUH9AsBHScUbYv3KLMG6TfpEAfq26vTIoqCIGk+8VLCDrQ/2bVHPfNzX9B4rNTOCFdiAVHx9Qj9gZnBGru0k2olzDpX3/pPPRAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776070463; c=relaxed/simple; bh=Lr3/CJgIhAYaEWgminvqddnOd7//tAnKPTDDgjSRbcs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=awkI8u4ZN26Yt4ShaX/e+zebAPcyTrgMEA9w0zge5ccU4C0yVt6/hr6SmNXKc/inux8pMIODN/fKfXFFjgKijkp80Z3zjHQ2LUUSga4P4A2/PJlg/0dZzr+Hw2/F4pDt3B6DN7LutRmLEszaqL/JIo2g8AAj6PXGGydiWaj83GM= 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=dSY7AHX1; arc=none smtp.client-ip=113.46.200.216 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="dSY7AHX1" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=KvhMMZp/GsQefc49ctoJ7WGEbW2EPdmBkUqroYz7npc=; b=dSY7AHX1foqKvJYvTnxqbZunGF5MwOhCAT7WEjawOb/HZPmZGdaLo76VfQP58fBR1EfujYFuC hsT40wtHMevHvgog4v5vkzO9wjYiTB+gnLokc3+U1shyIIhqgN/1xe4wfnfGBYfmh/Fm/QTIYFs 5B+JvPGbl6ypDFGcTZCUYLQ= Received: from mail.maildlp.com (unknown [172.19.163.104]) by canpmsgout01.his.huawei.com (SkyGuard) with ESMTPS id 4fvLfF4p37z1T4JS; Mon, 13 Apr 2026 16:48:21 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 71B664056D; Mon, 13 Apr 2026 16:54:19 +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:18 +0800 From: Zeng Heng To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH v8 next 07/10] fs/resctrl: Add rmid_entry state helpers Date: Mon, 13 Apr 2026 16:54:02 +0800 Message-ID: <20260413085405.1166412-8-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) Introduce helper functions for rmid_entry management, in preparation for upcoming patches supporting dynamic monitoring group allocation: * rmid_is_occupied(): Query whether a RMID entry is currently allocated by checking if its list node has been removed from the free list. * rmid_entry_reassign_closid(): Update the closid associated with a RMID entry. Fix list node initialization in alloc_rmid() and dom_data_init() by using list_del_init() instead of list_del(). This ensures list_empty() checks in rmid_is_occupied() work correctly without encountering LIST_POISON values. Signed-off-by: Zeng Heng --- fs/resctrl/monitor.c | 18 ++++++++++++++++-- include/linux/resctrl.h | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/fs/resctrl/monitor.c b/fs/resctrl/monitor.c index 9fd901c78dc6..7473c43600cf 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -286,7 +286,7 @@ int alloc_rmid(u32 closid) if (IS_ERR(entry)) return PTR_ERR(entry); - list_del(&entry->list); + list_del_init(&entry->list); return entry->rmid; } @@ -346,6 +346,20 @@ void free_rmid(u32 closid, u32 rmid) list_add_tail(&entry->list, &rmid_free_lru); } +bool rmid_is_occupied(u32 closid, u32 rmid) +{ + u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid); + + return list_empty(&rmid_ptrs[idx].list); +} + +void rmid_entry_reassign_closid(u32 closid, u32 rmid) +{ + u32 idx = resctrl_arch_rmid_idx_encode(closid, rmid); + + rmid_ptrs[idx].closid = closid; +} + static struct mbm_state *get_mbm_state(struct rdt_l3_mon_domain *d, u32 closid, u32 rmid, enum resctrl_event_id evtid) { @@ -945,7 +959,7 @@ int setup_rmid_lru_list(void) idx = resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, RESCTRL_RESERVED_RMID); entry = __rmid_entry(idx); - list_del(&entry->list); + list_del_init(&entry->list); return 0; } diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 006e57fd7ca5..b636e7250c20 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -702,6 +702,27 @@ bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r); extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; +/** + * rmid_is_occupied() - Check whether the specified rmid has been + * allocated. + * @closid: Specify the closid that matches the rmid. + * @rmid: Specify the rmid entry to check status. + * + * This function checks if the rmid_entry is currently allocated by testing + * whether its list node is empty (removed from the free list). + * + * Return: + * True if the specified rmid is still in use. + */ +bool rmid_is_occupied(u32 closid, u32 rmid); + +/** + * rmid_entry_reassign_closid() - Update the closid field of a rmid_entry. + * @closid: Specify the reassigned closid. + * @rmid: Specify the rmid entry to update closid. + */ +void rmid_entry_reassign_closid(u32 closid, u32 rmid); + int resctrl_init(void); void resctrl_exit(void); -- 2.25.1