From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from canpmsgout11.his.huawei.com (canpmsgout11.his.huawei.com [113.46.200.226]) (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 A5FE93AEF5F for ; Mon, 13 Apr 2026 08:54:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=113.46.200.226 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776070467; cv=none; b=X7iYkjSwm2TJVGMjFcXsskkoIDAC5ue6hhdLew4fquU0AOda5euiUQReDF8mI9rOPHMybynxAQW6QlNKRFoH7xdu/AK36Ux7tP5xHDDaE+cvK84P/3RWzsUiIApk1TcYIDvt2zLmAB5s73Rbyjf/vAfYZ/0KFT71Yzck8GFEoEo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776070467; c=relaxed/simple; bh=35plxa4VsVAUrApz4/Z6C7UzTGEnIEJrsQ1aVILgi0Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=rXfGCjYRg6bKkt3IZcAxgslvFOJIQdS0z0WkxhD/c9WFJGlFPqz3meWh3cOjn/JDYMihcXjiGmz7UiQ7oubZYwebEhTkcZyyV3El/2n+sTcjoyqYvyeuNSUpzETw+ud2e+tVwgqNb2Lcl0LOYlInnKvMh8xG4Fu6vElbC2Ct9PI= 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=p10X20Nx; arc=none smtp.client-ip=113.46.200.226 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="p10X20Nx" dkim-signature: v=1; a=rsa-sha256; d=h-partners.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=eJ/Fu8UkQxan6cDqeDBa1wfhWDhaxcfUlfU7YUO4zqI=; b=p10X20NxTM6rnCJL3c2Cl4mb2R6bnAxpvth0gd5Syerxzr6CTWHArByK91h0iRkeUymhWWiyh FGiut8GUr4L40eT51d/Al1GHOAMYTEoc3p1QOL/Y7AfBFGU3z7ctA2K/gXySHvEUFV/3qQfXKcj P8pwvj9/Qjy2d7VWzgIdMiI= Received: from mail.maildlp.com (unknown [172.19.163.127]) by canpmsgout11.his.huawei.com (SkyGuard) with ESMTPS id 4fvLdp4Fl9zKm9R; Mon, 13 Apr 2026 16:47:58 +0800 (CST) Received: from kwepemf100008.china.huawei.com (unknown [7.202.181.222]) by mail.maildlp.com (Postfix) with ESMTPS id 8691940572; Mon, 13 Apr 2026 16:54:17 +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:16 +0800 From: Zeng Heng To: , , , , , , , , , , , , , , , CC: , , , Subject: [PATCH v8 next 03/10] arm_mpam: Disable reqPARTID expansion when Narrow-PARTID is unavailable Date: Mon, 13 Apr 2026 16:53:58 +0800 Message-ID: <20260413085405.1166412-4-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) MPAM supports heterogeneous systems where some type of MSCs may implement Narrow-PARTID while others do not. However, when an MSC uses percentage-based throttling (non-bitmap partition control) and lacks Narrow-PARTID support, resctrl cannot correctly apply control group configurations across multiple PARTIDs. To enable free assignment of multiple reqPARTIDs to resource control groups, all MSCs used by resctrl must either: Implement Narrow-PARTID, allowing explicit PARTID remapping, or only have stateless resource controls (non-percentage-based), such that splitting a control group across multiple PARTIDs does not affect behavior. The detection occurs at initialization time on the first call to get_num_reqpartid() from update_rmid_limits(). This call is guaranteed to occur after mpam_resctrl_pick_{mba,caches}() have set up the resource classes, ensuring the necessary properties are available for the Narrow-PARTID capability check. When an MSC with percentage-based control lacks Narrow-PARTID support, get_num_reqpartid() falls back to returning the number of intPARTIDs, effectively disabling the reqPARTID expansion for monitoring groups. Signed-off-by: Zeng Heng --- drivers/resctrl/mpam_resctrl.c | 43 +++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c index 5f4364c8101a..56859f354efa 100644 --- a/drivers/resctrl/mpam_resctrl.c +++ b/drivers/resctrl/mpam_resctrl.c @@ -257,9 +257,50 @@ u32 resctrl_arch_get_num_closid(struct rdt_resource *ignored) return mpam_intpartid_max + 1; } +/* + * Determine the effective number of PARTIDs available for resctrl. + * + * This function performs a one-time check to determine if Narrow-PARTID + * can be used. It must be called after mpam_resctrl_pick_{mba,caches}() + * have initialized the resource classes, as class properties are used + * to detect Narrow-PARTID support. + * + * The first call occurs in update_rmid_limits(), ensuring the + * prerequisite initialization is complete. + */ +static u32 get_num_reqpartid(void) +{ + struct mpam_resctrl_res *res; + struct mpam_props *cprops; + static bool first = true; + int rid; + + if (first) { + for_each_mpam_resctrl_control(res, rid) { + if (!res->class) + continue; + + cprops = &res->class->props; + if (mpam_has_feature(mpam_feat_partid_nrw, cprops)) + continue; + + if (mpam_has_feature(mpam_feat_mbw_max, cprops) || + mpam_has_feature(mpam_feat_mbw_min, cprops) || + mpam_has_feature(mpam_feat_cmax_cmax, cprops) || + mpam_has_feature(mpam_feat_cmax_cmin, cprops)) { + mpam_partid_max = mpam_intpartid_max; + break; + } + } + } + + first = false; + return mpam_partid_max + 1; +} + u32 resctrl_arch_system_num_rmid_idx(void) { - return (mpam_pmg_max + 1) * (mpam_partid_max + 1); + return (mpam_pmg_max + 1) * get_num_reqpartid(); } u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) -- 2.25.1