From nobody Sun Dec 14 23:39:51 2025 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.13]) (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 238093009E5 for ; Wed, 10 Dec 2025 23:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.13 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765408538; cv=none; b=a9uw5irhyUl32AQlCLDlReY3Bdi+3UZCWbKD1zDmFmpHGZh4CNINjQhXRAuunRELD+OEoDaHe4sHUfJ6J/5adByD7upq3z6ckBWVMw/sj4c+faslNhqjKkiaJ23IUt/Eq0FPYAYRm4XiZ+v7B3MZefW0GfvBH13nQggtvHG+lBg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765408538; c=relaxed/simple; bh=6P6/qdwIinWh3GhPxgZSngc0CYjUPfiSTLftQro4OAU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=thabdIqNFrEobcFacR+K/DIRFEcHnXUrJGl+RqkXJqEjqQQXWGqfG+TZgw9KuyhDDLqw9EuydrQzcIieMukm8tCrQYDvMpmJ150pO0b42JOxt/HUbM6e3rXbDiFh34VLCXDK0gNp6r3MYus5qeeBr+wDXrqF0nnjfzuSQaSGu5Y= 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=Zc3KO4sA; arc=none smtp.client-ip=192.198.163.13 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="Zc3KO4sA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1765408522; x=1796944522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6P6/qdwIinWh3GhPxgZSngc0CYjUPfiSTLftQro4OAU=; b=Zc3KO4sAeH0YsRpuCsiA7wLKxUQIGjKMdJmj/NFyEcv9iMWF3JwAm1bq KgCShDlGzq77zwlaxdpEWxvO/XGHN2P8k6Q6Te4+CpvHc1uJPcU0egGnl ayCKEyaMFlB0NGllLOCm7+xLeCjFYhOYVKEmBA1ob1CQo7ogtuSdT73Ke x2h5lhpGvrzwuS2U9yk8J86Dkoca3fhnJWOzCdd5RbbeLlTgHTXQpSayi AECv9kcsYqcBXfrNcLhePK3K9ptW3ThDMZHgSNToNHCYZFSDAdRgI7l7l dAgwH+Jvn+k3TwXaXkX0gTUG2Uz05bFTyy92iGYotfOt6I2MehekG8+xN Q==; X-CSE-ConnectionGUID: nLBd8GeqQryFYnoIyu/CBg== X-CSE-MsgGUID: yxBI1kqzR+mPUMdK1vODcA== X-IronPort-AV: E=McAfee;i="6800,10657,11638"; a="69973697" X-IronPort-AV: E=Sophos;i="6.20,265,1758610800"; d="scan'208";a="69973697" Received: from orviesa002.jf.intel.com ([10.64.159.142]) by fmvoesa107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2025 15:14:42 -0800 X-CSE-ConnectionGUID: h5tA16MaTOq2r3wMD/2Ifw== X-CSE-MsgGUID: EgkP/Gw2Rm2kCJPKzSOFLg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.20,265,1758610800"; d="scan'208";a="227297146" Received: from daliomra-mobl3.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.221.254]) by orviesa002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Dec 2025 15:14:42 -0800 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 v16 27/32] x86,fs/resctrl: Compute number of RMIDs as minimum across resources Date: Wed, 10 Dec 2025 15:14:06 -0800 Message-ID: <20251210231413.59102-28-tony.luck@intel.com> X-Mailer: git-send-email 2.51.1 In-Reply-To: <20251210231413.59102-1-tony.luck@intel.com> References: <20251210231413.59102-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 Reviewed-by: Reinette Chatre --- 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 960974ffa866..bca65851d592 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 60ce2390723e..e95d3d0dc515 100644 --- a/fs/resctrl/rdtgroup.c +++ b/fs/resctrl/rdtgroup.c @@ -4352,6 +4352,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. + * * Return: 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.1