From nobody Sat Sep 27 21:23:38 2025 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.21]) (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 23CCA323F59 for ; Thu, 25 Sep 2025 20:04:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758830663; cv=none; b=eXwaj6jtK7qo0w4iEG/dhCLhcT6lImlwbRBlUmRRybaoGXM0DFbKwLmX+bSw9bBuB2qlSrR8quya1bmiySMqtjnROhdS12c1UpUAWJ5EG3JUr7s10O1qVD8Wl9vAd12Ta7J5mKkfnefniU3KuRFKmaqHoMkN/u/ZWYU54n59MXo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758830663; c=relaxed/simple; bh=8vlCScUjoTKB0J46AqpBHyDZVyE3uZHSlb4z+5DJdSE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OapZ5k7YRCP4g23aScGc2xkilwajMPdo6X2tU/BQOJgee0i7s+M/yKSPB5hwbbv9gddb6MGe3Sf5jFZbw6xVXODHbO8InLdyW7yIJAJT4iuCMaMcx9fX3jFJIrqhxABCJv41Qw9btzdRMIWyl26GpNmDIyaglnF4B3EhjP/VYt0= 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=VfxUxEf9; arc=none smtp.client-ip=198.175.65.21 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="VfxUxEf9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1758830662; x=1790366662; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8vlCScUjoTKB0J46AqpBHyDZVyE3uZHSlb4z+5DJdSE=; b=VfxUxEf92e6yCqgHEOCbJgxilS2Dbbt4R4ZmDv8Q5RkgPzUe+KCo1zuv Oy8+PJKfiGjjWuEfb/EoHlrdpE65Rbu42rDmZdzh7ODCrJVc71YNO+Yju vl8qdH/QQopSElkgO/BLVcJMjrYhljOc4LxlD5HQ1Z1aZD7rfwIOZ5fru /Tr+KUCbMG/14YL6J8Ti15CyxW+kuNZeeZCEYy00rr5fEzsMAmgGcAkg2 pCWcXK5qZld0YkGupcZtdYZLi5oIOEbNR3bv2VSZF864338mZkrQKnO4X jlD2koVGqiP8dCNfIWl0QI/ZYDikr5qly7cCHBP6Nj5N1SSt5cihIDRD3 w==; X-CSE-ConnectionGUID: onQR3HukTGK7wD11uzFgAQ== X-CSE-MsgGUID: HCqt+fvgR9qONjoOhLUUcg== X-IronPort-AV: E=McAfee;i="6800,10657,11531"; a="61074323" X-IronPort-AV: E=Sophos;i="6.17,312,1747724400"; d="scan'208";a="61074323" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa113.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2025 13:04:13 -0700 X-CSE-ConnectionGUID: 61fSyg6KTQ20rLibVYrkZw== X-CSE-MsgGUID: fbzSZmoxSw+Bkzsq+TWNJw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.18,293,1751266800"; d="scan'208";a="177003678" Received: from inaky-mobl1.amr.corp.intel.com (HELO agluck-desk3.intel.com) ([10.124.220.206]) by orviesa009-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2025 13:04: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 v11 22/31] x86/resctrl: Add energy/perf choices to rdt boot option Date: Thu, 25 Sep 2025 13:03:16 -0700 Message-ID: <20250925200328.64155-23-tony.luck@intel.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250925200328.64155-1-tony.luck@intel.com> References: <20250925200328.64155-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" Legacy resctrl features are enumerated by X86_FEATURE_* flags. These may be overridden by quirks to disable features in the case of errata. Users can use kernel command line options to either disable a feature, or to force enable a feature that was disabled by a quirk. Provide similar functionality for hardware features that do not have an X86_FEATURE_* flag. Unlike other features that are tied to X86_FEATURE_* flags, these must be queried by name. Add rdt_is_feature_enabled() to check whether quirks or kernel command line have disabled a feature. Users may force a feature to be disabled. E.g. "rdt=3D!perf" will ensure that none of the perf telemetry events are enabled. Resctrl architecture code may disable a feature that does not provide full functionality. Users may override that decision. E.g. "rdt=3Denergy" will enable any available energy telemetry events even if they do not provide full functionality. Signed-off-by: Tony Luck --- .../admin-guide/kernel-parameters.txt | 2 +- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 29 +++++++++++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/kernel-parameters.txt b/Documentatio= n/admin-guide/kernel-parameters.txt index 889e68e83682..74bc150b53f7 100644 --- a/Documentation/admin-guide/kernel-parameters.txt +++ b/Documentation/admin-guide/kernel-parameters.txt @@ -6155,7 +6155,7 @@ rdt=3D [HW,X86,RDT] Turn on/off individual RDT features. List is: cmt, mbmtotal, mbmlocal, l3cat, l3cdp, l2cat, l2cdp, - mba, smba, bmec, abmc. + mba, smba, bmec, abmc, energy, perf. E.g. to turn on cmt and turn off mba use: rdt=3Dcmt,!mba =20 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index b920f54f8736..e3710b9f993e 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -225,6 +225,8 @@ void __init intel_rdt_mbm_apply_quirk(void); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void resctrl_arch_mbm_cntr_assign_set_one(struct rdt_resource *r); =20 +bool rdt_is_feature_enabled(char *name); + #ifdef CONFIG_X86_CPU_RESCTRL_INTEL_AET bool intel_aet_get_events(void); void __exit intel_aet_exit(void); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 5dff83e763a5..f749a871e8c5 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -766,6 +766,8 @@ enum { RDT_FLAG_SMBA, RDT_FLAG_BMEC, RDT_FLAG_ABMC, + RDT_FLAG_ENERGY, + RDT_FLAG_PERF, }; =20 #define RDT_OPT(idx, n, f) \ @@ -792,6 +794,8 @@ static struct rdt_options rdt_options[] __ro_after_ini= t =3D { RDT_OPT(RDT_FLAG_SMBA, "smba", X86_FEATURE_SMBA), RDT_OPT(RDT_FLAG_BMEC, "bmec", X86_FEATURE_BMEC), RDT_OPT(RDT_FLAG_ABMC, "abmc", X86_FEATURE_ABMC), + RDT_OPT(RDT_FLAG_ENERGY, "energy", 0), + RDT_OPT(RDT_FLAG_PERF, "perf", 0), }; #define NUM_RDT_OPTIONS ARRAY_SIZE(rdt_options) =20 @@ -841,6 +845,31 @@ bool rdt_cpu_has(int flag) return ret; } =20 +/* + * Hardware features that do not have X86_FEATURE_* bits. There is no + * "hardware does not support this at all" case. Assume that the caller + * has already determined that hardware support is present and just needs + * to check if the feature has been disabled by a quirk that has not been + * overridden by a command line option. + */ +bool rdt_is_feature_enabled(char *name) +{ + struct rdt_options *o; + bool ret =3D true; + + for (o =3D rdt_options; o < &rdt_options[NUM_RDT_OPTIONS]; o++) { + if (!strcmp(name, o->name)) { + if (o->force_off) + ret =3D false; + if (o->force_on) + ret =3D true; + break; + } + } + + return ret; +} + bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt) { if (!rdt_cpu_has(X86_FEATURE_BMEC)) --=20 2.51.0