From nobody Tue Apr 7 00:46:15 2026 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 F0AFA3CBE8C for ; Tue, 17 Mar 2026 13:22:07 +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=1773753730; cv=none; b=XtM1viMhghWRk//NfOKVxFfmJNg3jbym6QcTP+uP4P1xONJWKsesAicbTPXXbcOAfwAxA1HsnAdReyPp2Oz/CrOwXgUPmWoIFPsnN/uVYlZCJnLQiRXk4VKlY++ECXo1REbl+HvHFcHzP513P6+JZj6FQQGsK3nSFpEd6fXDKgU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773753730; c=relaxed/simple; bh=LtwnklN1pBjW74fASEgjie0JHthdiIDNPBU7yqemrNo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=spatnU8i1VRMxacNMANheAStSoWo+Csum7ptvMzOcOxozLTA3/cRRLSuJDFAGfQyVFK+omhKO44QEDu7vJDekqaYmM39SBLF8R9UpEZ1luvbhbYvET4qJIM8NJhI5rR9J6gNbBTOFIraWMc4zS5JwSdfk0vkx3fTf/BM41ut/T8= 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=es5wp5jx; 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="es5wp5jx" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=+v2BBENAq9TPpo0HOdE/veZnsoXu31S3Qt7RH3ZdPes=; b=es5wp5jxl+4UpERrW1dVqGAGTKdlZwRDr0hLPx9Mwnj3u6IttP+07egHGBNsttdQxO0sDQefA ZqVoXRhIjJq/u3/4qEs119p6I+1rTl29pGKCSWskr2jXA3SsphuAyuGePnWF/XraDr1ev1BLJA4 FZRb82ACd3TByUtJsslK4mQ= Received: from mail.maildlp.com (unknown [172.19.162.92]) by canpmsgout07.his.huawei.com (SkyGuard) with ESMTPS id 4fZstc6Jy2zLlSF; Tue, 17 Mar 2026 21:16:56 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id CA76940562; Tue, 17 Mar 2026 21:21:55 +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:55 +0800 From: Zeng Heng To: , , , , CC: , , , , , , , , , Subject: [PATCH v3 6/9] fs/resctrl: Add rmid_entry state helpers Date: Tue, 17 Mar 2026 21:21:38 +0800 Message-ID: <20260317132141.1272506-7-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" 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 49f3f6b846b2..4e78fb194c16 100644 --- a/fs/resctrl/monitor.c +++ b/fs/resctrl/monitor.c @@ -284,7 +284,7 @@ int alloc_rmid(u32 closid) if (IS_ERR(entry)) return PTR_ERR(entry); =20 - list_del(&entry->list); + list_del_init(&entry->list); return entry->rmid; } =20 @@ -344,6 +344,20 @@ void free_rmid(u32 closid, u32 rmid) list_add_tail(&entry->list, &rmid_free_lru); } =20 +bool rmid_is_occupied(u32 closid, u32 rmid) +{ + u32 idx =3D 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 =3D resctrl_arch_rmid_idx_encode(closid, rmid); + + rmid_ptrs[idx].closid =3D closid; +} + static struct mbm_state *get_mbm_state(struct rdt_l3_mon_domain *d, u32 cl= osid, u32 rmid, enum resctrl_event_id evtid) { @@ -943,7 +957,7 @@ int setup_rmid_lru_list(void) idx =3D resctrl_arch_rmid_idx_encode(RESCTRL_RESERVED_CLOSID, RESCTRL_RESERVED_RMID); entry =3D __rmid_entry(idx); - list_del(&entry->list); + list_del_init(&entry->list); =20 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_reso= urce *r); extern unsigned int resctrl_rmid_realloc_threshold; extern unsigned int resctrl_rmid_realloc_limit; =20 +/** + * 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); =20 --=20 2.25.1