From nobody Sat Apr 4 06:26:40 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (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 B1329358372 for ; Fri, 20 Mar 2026 22:03:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044243; cv=none; b=Nm7MfqSLdO1ZzRFs/L7Ls/zA2SQpgSPHMmxGpPLkOc4DYROUjBs78Eq7DNsqW7RtPIPooYKGKLY8j6COVF531kTPKFUMSgY+7TEGMmJItvMeXfzPpA4i3J4jh6Q7AHHEWFh9ZUXfW6iZeSM/Iwo490uB7XFvPFEHubkIr7zqWwY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774044243; c=relaxed/simple; bh=6S4Kbf26Ho80olkPFiZ8UngQhelhtisWM0bMfgO68B4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Cdnx3cGbs7WziPByBJZNQNL8LPNUYkCbK0se27Kv8uqFqNRXFQLKIrvtFKgKe+z4TjFsECCzskF2AC3UgXzl4pmSZwkLhIszL3YRpiExOmrAssQ8477xMdoVUoRcweKPLFnikpL2WyniyGTQHNxdPtgnhjIBxeSdZDp5Kc5WITg= 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=TB8FYYbL; arc=none smtp.client-ip=198.175.65.9 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="TB8FYYbL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774044239; x=1805580239; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=6S4Kbf26Ho80olkPFiZ8UngQhelhtisWM0bMfgO68B4=; b=TB8FYYbL8tcCM/bAOl5M6YLx4wfplvgSUCSmkKXR4/XgBSxhzEvKM6pM af6sdueB0vz1ZVGuyka6o6c+MPXRveFuncrSOo3U83GKdxXZ5oYIVPVGq TSHA6VuEi+vDvkCtEwq8mqjP/MgcP1PGu6LOb8yKgTyZZBajO+9FOUf+C Oxk7tLe/DVKrupq2I3+QUtWkvFcPMmAeZp9hIXaMpVhgZ134TmTXPigTk z/crfEa3YGHRVZXWV8lo5n2BekrgClzbc92Mzk3nBHjmJ0FyxxbBYG8IB Au2OIXimgrdjTotkxYjpiKNgQSugZ/mBqLn4bpG0VQoNl+mfrPAePBDRs g==; X-CSE-ConnectionGUID: 7Sn2dDuqQSO/itR8uW3Gyg== X-CSE-MsgGUID: RMSA5UfIQvG/4XmGz+v92A== X-IronPort-AV: E=McAfee;i="6800,10657,11735"; a="97758395" X-IronPort-AV: E=Sophos;i="6.23,132,1770624000"; d="scan'208";a="97758395" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 X-CSE-ConnectionGUID: o6e4Ft09Sp6BLbxL0J9nUQ== X-CSE-MsgGUID: gV+OJ3KRS6KM/I9o0gt0bQ== X-ExtLoop1: 1 Received: from rchatre-desk1.jf.intel.com ([10.165.154.99]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Mar 2026 15:03:55 -0700 From: Reinette Chatre To: tony.luck@intel.com, james.morse@arm.com, Dave.Martin@arm.com, babu.moger@amd.com, bp@alien8.de, tglx@linutronix.de, dave.hansen@linux.intel.com Cc: x86@kernel.org, hpa@zytor.com, ben.horgan@arm.com, fustini@kernel.org, fenghuay@nvidia.com, peternewman@google.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev, reinette.chatre@intel.com Subject: [PATCH v2 07/14] fs/resctrl: Use accurate type for rdt_resource::rid Date: Fri, 20 Mar 2026 15:03:17 -0700 Message-ID: <1ae8867b43acb509f6359139297ee3a340bd0441.1774043709.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.50.1 In-Reply-To: References: 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" Every resctrl resource has a unique ID described by enum resctrl_res_level. enum resctrl_res_level is used in all resource ID initializations and all resource ID comparisons. All functions consuming the resource ID expects an enum resctrl_res_level. Of the four structures that contain a resource ID (struct mon_data, struct mon_evt, struct rdt_domain_hdr, and struct rdt_resource) only struct rdt_resource does not use enum resctrl_res_level. Switch the type of rdt_resource::rid to be enum resctrl_res_level to make it obvious what values are valid, match the type everywhere this member is used, and obtain benefits from tools that can flag any enum misuse. Move define of RDT_NUM_RESOURCES outside the enum to enable tools to catch when a switch() on the resource ID does not handle all the resources and thus help flag which switch statements need an update when a new resource is added. Signed-off-by: Reinette Chatre Reviewed-by: Ben Horgan --- Changes since v1: - Use RDT_RESOURCE_LAST =3D RDT_RESOURCE_PERF_PKG as last entry in enum.(Be= n) --- include/linux/resctrl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0b28049378c8..99a4774735c7 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -54,11 +54,11 @@ enum resctrl_res_level { RDT_RESOURCE_MBA, RDT_RESOURCE_SMBA, RDT_RESOURCE_PERF_PKG, - - /* Must be the last */ - RDT_NUM_RESOURCES, + RDT_RESOURCE_LAST =3D RDT_RESOURCE_PERF_PKG }; =20 +#define RDT_NUM_RESOURCES (RDT_RESOURCE_LAST + 1) + /** * enum resctrl_conf_type - The type of configuration. * @CDP_NONE: No prioritisation, both code and data are controlled or moni= tored. @@ -320,7 +320,7 @@ struct resctrl_mon { * @cdp_capable: Is the CDP feature available on this resource */ struct rdt_resource { - int rid; + enum resctrl_res_level rid; bool alloc_capable; bool mon_capable; enum resctrl_scope ctrl_scope; --=20 2.50.1