From nobody Sat Sep 27 20:26:42 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 26F1535E4E8 for ; Fri, 12 Sep 2025 22:11:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757715083; cv=none; b=WQnmIvaIfPL0nizQeDbyaEXS+Uc7OwUPo9IP1Wz9dLZugf3lM2Eose+3/1IewD0GPtcvZAngdwuoHrj38HZuMTrZMDooMRJ7PDg8+M9btEUbJpaich6RcFR2cfxAdDgS/wja9yvm/CfCWSKbhRhUcc7EWWVb3xutN8gu18xwUYo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757715083; c=relaxed/simple; bh=XaI4sEEAvBKMr2iHFuVDsNB8k/wku6ZYSVPsPpeEy14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V4xf/ZGVh7s4EG8DWMUnbk9xTd9Mu88e5wJfOnvifmIEKg/EY7A0OlS5jckwWgAlmyYWNZ4iUQRgUaOXfPPiWDeoKWUs5xKMLs40szyJepSL3WHsYlPBnXN12y8G7IdeJ0llyMoYVr4ytA43FKM9HUr6LFH6rU7RanpWKaYCb3s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Bs/p9ZVo; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Bs/p9ZVo" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1757715081; x=1789251081; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XaI4sEEAvBKMr2iHFuVDsNB8k/wku6ZYSVPsPpeEy14=; b=Bs/p9ZVoSWxB/vVjuf7t4v9wCFVp2/OtBHUknvXt4czGgZ2DypV2iN+Q Tioq9gHDqlcRoS+e8x/rDuGBZIFrAuRUn04O7UKmwm8rwsYfmEQZTwuVy tmYduFF9PSfzHsGTnr51+u66wdXyNe0TYKHBjhbsjPINgUYMUyJOVYBfu M5k/2OpHjlVbBfVAsizENamlRNV6HvK7n2oWJO3rtKehIbpITNEjhBv4C sl0DOSCdlpXRX34iphFi4D6y6B2Pj9/gBY1AYdoqTJ93J752k6Rc0eZBo mMNsk+yaWnxJmV3pVekJ+NTdijIF70pPiagQ90W1jim3dzgASZqnCfanG w==; X-CSE-ConnectionGUID: oXfXDJFqQRaSkEXE4CMs7Q== X-CSE-MsgGUID: UtX3gcpjR8WIMnv7YA2W5A== X-IronPort-AV: E=McAfee;i="6800,10657,11551"; a="60002819" X-IronPort-AV: E=Sophos;i="6.18,260,1751266800"; d="scan'208";a="60002819" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2025 15:11:12 -0700 X-CSE-ConnectionGUID: K3SeRciBRrSh6xa5q1TUrg== X-CSE-MsgGUID: 9E3R3cVZTgCU6rjrkns46w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,260,1751266800"; d="scan'208";a="179265221" Received: from smoehrl-linux.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.49]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Sep 2025 15:11:12 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin , Chen Yu Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v10 23/28] fs,x86/resctrl: Compute number of RMIDs as minimum across resources Date: Fri, 12 Sep 2025 15:10:44 -0700 Message-ID: <20250912221053.11349-24-tony.luck@intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250912221053.11349-1-tony.luck@intel.com> References: <20250912221053.11349-1-tony.luck@intel.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 Content-Type: text/plain; charset="utf-8" resctrl assumes that only the L3 resource supports monitor events, so it simply takes the rdt_resource::num_rmid from RDT_RESOURCE_L3 as the system's number of RMIDs. The addition of telemetry events in a different resource breaks that assumption. Compute the number of available RMIDs as the minimum value across all mon_capable resources (analogous to how the number of CLOSIDs is computed across alloc_capable resources). Note that mount time enumeration of the telemetry resource means that this number can be reduced. If this happens, then some memory will be wasted as the allocations for rdt_l3_mon_domain::mbm_states[] and rdt_l3_mon_domain::rmid_busy_llc created during resctrl initialization will be larger than needed. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/core.c | 15 +++++++++++++-- fs/resctrl/rdtgroup.c | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 8487449558c6..876258545b0e 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -110,12 +110,23 @@ struct rdt_hw_resource rdt_resources_all[RDT_NUM_RESO= URCES] =3D { }, }; =20 +/** + * resctrl_arch_system_num_rmid_idx - Compute number of supported RMIDs + * (minimum across all mon_capable resource) + * + * Return: Number of supported RMIDs at time of call. Note that mount time + * enumeration of resources may reduce the number. + */ u32 resctrl_arch_system_num_rmid_idx(void) { - struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + u32 num_rmids =3D U32_MAX; + struct rdt_resource *r; + + for_each_mon_capable_rdt_resource(r) + num_rmids =3D min(num_rmids, r->mon.num_rmid); =20 /* RMID are independent numbers for x86. num_rmid_idx =3D=3D num_rmid */ - return r->mon.num_rmid; + return num_rmids =3D=3D U32_MAX ? 0 : num_rmids; } =20 struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c index 5052ddb6a7a6..19f0feb51420 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4270,6 +4270,12 @@ void resctrl_offline_mon_domain(struct rdt_resource = *r, struct rdt_domain_hdr *h * During boot this may be called before global allocations have been made= by * resctrl_l3_mon_resource_init(). * + * Called during CPU online that may run as soon as CPU online callbacks + * are set up during resctrl initialization. The number of supported RMIDs + * may be reduced if additional mon_capable resources are enumerated + * at mount time. This means the rdt_l3_mon_domain::mbm_states[] and + * rdt_l3_mon_domain::rmid_busy_llc allocations may be larger than needed. + * * Returns 0 for success, or -ENOMEM. */ static int domain_setup_l3_mon_state(struct rdt_resource *r, struct rdt_l3= _mon_domain *d) --=20 2.51.0