From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 82D3CAD51; Thu, 14 Nov 2024 00:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543443; cv=none; b=gTG+2sgTx2NXP+mBizkQfCy9nld1Pjrmn5/ZkcctRgEP86JnRpVyt3ViPc2Z6ASKDdAYcG8LNjvC+aYryArdrrLISgl1cXy+0V+0XiUsGvSKlM/SjdYwCTo6kK8/X5fmAPGtwYFwiUNeowVs6CQEwc4ie2KmN0tkHOMA6hbXmNA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543443; c=relaxed/simple; bh=rd9xJQTtveQdINhF0jEO8qp9R1tkk6e0Z+s3jIicQzE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lk4iJx6cuJ3R/7qKKZfxfcCzQgTx27uR4GdCWQLcPGdQCia7rQmi+WZRmEmv4P6GeKiE/9GwA6y3W4SKO6IAWieDNUNJUYXt294aXl8P1Pa4E0fR0IeMn1XNtRkf3AmYQMvmdsldL2ZF7uG2WrKpC2kSDwl1E4cSng13vSlwjC8= 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=I0zzM/BU; arc=none smtp.client-ip=192.198.163.19 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="I0zzM/BU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543441; x=1763079441; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rd9xJQTtveQdINhF0jEO8qp9R1tkk6e0Z+s3jIicQzE=; b=I0zzM/BUhG350uNeNQdC2Kw3Re4Ndg0oHj8IHVBLcDHRJNrsBJ4B9uKl MTvUtdmqHY7PgPli78D5xZU+tbzHqF2yCfX/kcOxdtetfRkiMp1l3ZZnW SQj9ssCV9t12LFFsIyEkf6W3Nh2ixz++T/Bh9esU1ERt6SzFRBwct6g+w pvT3pXKOOpiQ9fqVoIb/XKU+BGvUqz+CSkGs8KrteP87UXBDN3xadaXww l/h43SRXeKh4hlA9AmNONnVIyIis+oJdD63w5FuVgv1VwjT+gaxTHJKAD QX5PZAnq9YH0KvQPp+YgdfAN5kAVdXFR9bzuRzpXq8wk7lptJ842EQ54S Q==; X-CSE-ConnectionGUID: JjN/1OfjQAShSbjNaM2oPA== X-CSE-MsgGUID: nUi2Aw2GQzi+9M33hkQztA== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869460" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869460" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 X-CSE-ConnectionGUID: vtPkFVseT16u3ZssEIHo4A== X-CSE-MsgGUID: uZR3L1LiSmmtwM5HJtz/1A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081151" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 1/9] x86/resctrl: Introduce resctrl_file_fflags_init() to initialize fflags Date: Wed, 13 Nov 2024 16:17:03 -0800 Message-ID: <20241114001712.80315-2-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" From: Babu Moger thread_throttle_mode_init() and mbm_config_rftype_init() both initialize fflags for resctrl files. Adding new files will involve adding another function to initialize the fflags. This can be simplified by adding a new function resctrl_file_fflags_init() and passing the file name and flags to be initialized. Consolidate fflags initialization into resctrl_file_fflags_init() and remove thread_throttle_mode_init() and mbm_config_rftype_init(). Signed-off-by: Babu Moger Reviewed-by: Reinette Chatre Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 3 +-- arch/x86/kernel/cpu/resctrl/core.c | 4 +++- arch/x86/kernel/cpu/resctrl/monitor.c | 6 ++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 ++------------- 4 files changed, 10 insertions(+), 18 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 955999aecfca..faaff9d64102 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -647,8 +647,7 @@ void cqm_handle_limbo(struct work_struct *work); bool has_busy_rmid(struct rdt_mon_domain *d); void __check_limbo(struct rdt_mon_domain *d, bool force_free); void rdt_domain_reconfigure_cdp(struct rdt_resource *r); -void __init thread_throttle_mode_init(void); -void __init mbm_config_rftype_init(const char *config); +void resctrl_file_fflags_init(const char *config, unsigned long fflags); void rdt_staged_configs_clear(void); bool closid_allocated(unsigned int closid); int resctrl_find_cleanest_closid(void); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index b681c2e07dbf..f3ee5859b69d 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -234,7 +234,9 @@ static __init bool __get_mem_config_intel(struct rdt_re= source *r) r->membw.throttle_mode =3D THREAD_THROTTLE_PER_THREAD; else r->membw.throttle_mode =3D THREAD_THROTTLE_MAX; - thread_throttle_mode_init(); + + resctrl_file_fflags_init("thread_throttle_mode", + RFTYPE_CTRL_INFO | RFTYPE_RES_MB); =20 r->alloc_capable =3D true; =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 851b561850e0..7ef1a293cc13 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1223,11 +1223,13 @@ int __init rdt_get_mon_l3_config(struct rdt_resourc= e *r) =20 if (rdt_cpu_has(X86_FEATURE_CQM_MBM_TOTAL)) { mbm_total_event.configurable =3D true; - mbm_config_rftype_init("mbm_total_bytes_config"); + resctrl_file_fflags_init("mbm_total_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) { mbm_local_event.configurable =3D true; - mbm_config_rftype_init("mbm_local_bytes_config"); + resctrl_file_fflags_init("mbm_local_bytes_config", + RFTYPE_MON_INFO | RFTYPE_RES_CACHE); } } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d7163b764c62..2b198ef95e1e 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2020,24 +2020,13 @@ static struct rftype *rdtgroup_get_rftype_by_name(c= onst char *name) return NULL; } =20 -void __init thread_throttle_mode_init(void) -{ - struct rftype *rft; - - rft =3D rdtgroup_get_rftype_by_name("thread_throttle_mode"); - if (!rft) - return; - - rft->fflags =3D RFTYPE_CTRL_INFO | RFTYPE_RES_MB; -} - -void __init mbm_config_rftype_init(const char *config) +void resctrl_file_fflags_init(const char *config, unsigned long fflags) { struct rftype *rft; =20 rft =3D rdtgroup_get_rftype_by_name(config); if (rft) - rft->fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE; + rft->fflags =3D fflags; } =20 /** --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 0632CA94A; Thu, 14 Nov 2024 00:17:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543441; cv=none; b=iL7ngXXmQ0F3ghv9IbV9MU9PtPLYjkRZjaW0/9Au8ibVHJs+a1twib8FENo7ZH1kVGMaJQ/vjjPHp2w0Lp8K51564macWffaSjETvgYffsX8iVD7N87GdgDT+trKpXj9FPD6s+YujGntgLOsMLSamaRPLYCRPsn9ZMTBEmwNZl4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543441; c=relaxed/simple; bh=QOP2S3/eSZU055KgxYEaUwnTF8QcW5KmqwswnyWxDoc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ULr7NhjpnibK+NKj7DR77AYqyEBckI8Fl/fGWcGehTmmuueR1uhRc6iUTc/mUZe7ONJ2e6HACrE+YRdgNKjvMbm97ntw8oXiprE3ijzh/9fzenQc08iwzP5l2j9Ve7C4ryggwc3iQp6M6clzECp5fUU3W033sXNVLrAtQH5Sf2o= 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=R4VsRydL; arc=none smtp.client-ip=192.198.163.19 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="R4VsRydL" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543440; x=1763079440; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=QOP2S3/eSZU055KgxYEaUwnTF8QcW5KmqwswnyWxDoc=; b=R4VsRydLfTN/AlTVE1CWM1ZrbVa/E+REmaEAN0y3XfgGzBJk7qOnUdlQ fZldjNJ9ixQ9u38jAi+QyPTlrpMdNsmwGbo0eB/mHMqfZFoFk7WfpGxJ3 NJtZu3W2I1P3/XEM3TtAtkO2ONKhlocCYRZp81mHmHcNiw5ib0ozPLSS9 CVklL0I4cHQ2weT+Ncs1zNUw8rG82mSf0YkpSkBSmNBQ3P94AeWK6hisP bDHB/pSRN8VJ/2nCCLK+qpoavqkcCzIPJA+fFW83//GBcYD4u5z5W2LKn 1luP8jpkQ8agaC9yJWRK7+dGhbdqbw+fDup+lzLw1fBYN0v3gmUa26KBg A==; X-CSE-ConnectionGUID: Qh36Uxa8QBm/wOhioxNAiw== X-CSE-MsgGUID: upnDnX1mTn2k9oLtVR5Gjw== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869479" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869479" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 X-CSE-ConnectionGUID: +3PNhHgqQlKzSxPlggOKCg== X-CSE-MsgGUID: sgkj0/zaTFWCPSuOgs1LHg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081154" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 2/9] x86/resctrl: Prepare for per-ctrl_mon group mba_MBps control Date: Wed, 13 Nov 2024 16:17:04 -0800 Message-ID: <20241114001712.80315-3-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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 uses local memory bandwidth event as input to the feedback loop when the mba_MBps mount option is used. This means that this mount option cannot be used on systems that only support monitoring of total bandwidth. Prepare to allow users to choose the input event independently for each ctrl_mon group. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 3 +++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 ++++++ 4 files changed, 13 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index d94abba1c716..fd05b937e2f4 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -49,6 +49,8 @@ enum resctrl_event_id { QOS_L3_MBM_LOCAL_EVENT_ID =3D 0x03, }; =20 +extern enum resctrl_event_id mba_mbps_default_event; + /** * struct resctrl_staged_config - parsed configuration to be applied * @new_ctrl: new ctrl value to be loaded diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index faaff9d64102..485800055a7d 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -283,6 +283,7 @@ struct pseudo_lock_region { * monitor only or ctrl_mon group * @mon: mongroup related data * @mode: mode of resource group + * @mba_mbps_event: input monitoring event id when mba_sc is enabled * @plr: pseudo-locked region */ struct rdtgroup { @@ -295,6 +296,7 @@ struct rdtgroup { enum rdt_group_type type; struct mongroup mon; enum rdtgrp_mode mode; + enum resctrl_event_id mba_mbps_event; struct pseudo_lock_region *plr; }; =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index f3ee5859b69d..94bf559966d6 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -963,6 +963,9 @@ static __init bool get_rdt_mon_resources(void) if (!rdt_mon_features) return false; =20 + if (is_mbm_local_enabled()) + mba_mbps_default_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; + return !rdt_get_mon_l3_config(r); } =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 2b198ef95e1e..a8022bddf9f7 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -65,6 +65,8 @@ static void rdtgroup_destroy_root(void); =20 struct dentry *debugfs_resctrl; =20 +enum resctrl_event_id mba_mbps_default_event; + static bool resctrl_debug; =20 void rdt_last_cmd_clear(void) @@ -3611,6 +3613,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, rdt_last_cmd_puts("kernfs subdir error\n"); goto out_del_list; } + if (is_mba_sc(NULL)) + rdtgrp->mba_mbps_event =3D mba_mbps_default_event; } =20 goto out_unlock; @@ -3970,6 +3974,8 @@ static void __init rdtgroup_setup_default(void) rdtgroup_default.closid =3D RESCTRL_RESERVED_CLOSID; rdtgroup_default.mon.rmid =3D RESCTRL_RESERVED_RMID; rdtgroup_default.type =3D RDTCTRL_GROUP; + if (supports_mba_mbps()) + rdtgroup_default.mba_mbps_event =3D mba_mbps_default_event; INIT_LIST_HEAD(&rdtgroup_default.mon.crdtgrp_list); =20 list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups); --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 F232EC13B; Thu, 14 Nov 2024 00:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543443; cv=none; b=fEjsFst9h6tEVLKkBi1RoKBlqn2zuAzPggTFd1VApwgQV3u6Ku/blq5oC5VEW0VNDcktjLR9+pETBlhq0bzyI7OoDt4f9xkGCVy//9LP0wIJrgyPOy2LM3L+9Kn5ULIa88J62JCT6nZyqtMx5oCICMEQCtiX88MWuLqT2TWT4sY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543443; c=relaxed/simple; bh=XHNsAvQC21OhE47FufCcFsVPXtd14pius/9r2yHonYY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pT+CkT9kyYMEFZm9K5KdGZ5lRCo88DvSSwvJtkqBf8iJr/jR1AiPlwoEq3LJZXqMi0Lb35awmvsA8vbFlN2NUuV/9jS38HoammILre0Hq+LAvASmlWCcTlC0wmBsxZKM3bLg5ymVA6COuBOGQWvJX8i41IUXulEsLQt/uiXhjTE= 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=LWM49H3G; arc=none smtp.client-ip=192.198.163.19 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="LWM49H3G" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543442; x=1763079442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XHNsAvQC21OhE47FufCcFsVPXtd14pius/9r2yHonYY=; b=LWM49H3Gid7+S5H4Sxh9ZCH5YhEl5BmSUd6LM/8REvisdfL4c529lDEC PSUiPmcpBdbvqa467Iqhc1hoMILO4Kbv/lkyg81NK+MlyGoFPXLofqSbL 95rA7VyBMjtFW84o7obRbltr8MYHGVHyVx10OqfJSkx93rFDZuMuPzfI9 Eq7Rzam5SvTVyVsIN6dp6sNdf4BKKTTuxnAndy84kFF/4G8KNjbjd1iTG UpjlT8rjRe5rN/HOdxLvoj87iIadozcsRLdGVW3OTI0wJdQOOFkRgZErt c4G3D/Tge4gr5+rH0w+I+OKneJROcnfr3anHDtNnfabU1p37s8rjxf2ed Q==; X-CSE-ConnectionGUID: EDA6NKeOTA6EYfB1UenpVw== X-CSE-MsgGUID: K5pJHvO4TTWFszdRov4zSQ== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869480" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869480" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 X-CSE-ConnectionGUID: ArU6JcoXS+KWVAQUgPQFoQ== X-CSE-MsgGUID: MKnWP4CvSumMUWMl4T8sRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081157" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 3/9] x86/resctrl: Modify update_mba_bw() to use per ctrl_mon group event Date: Wed, 13 Nov 2024 16:17:05 -0800 Message-ID: <20241114001712.80315-4-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" Instead of hard-coding the memory bandwidth local event as the input to the mba_sc feedback look, use the event that the user configured for each ctrl_mon group. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/monitor.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 7ef1a293cc13..2176e355e864 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -752,20 +752,31 @@ static void update_mba_bw(struct rdtgroup *rgrp, stru= ct rdt_mon_domain *dom_mbm) u32 closid, rmid, cur_msr_val, new_msr_val; struct mbm_state *pmbm_data, *cmbm_data; struct rdt_ctrl_domain *dom_mba; + enum resctrl_event_id evt_id; struct rdt_resource *r_mba; - u32 cur_bw, user_bw, idx; struct list_head *head; struct rdtgroup *entry; + u32 cur_bw, user_bw; =20 - if (!is_mbm_local_enabled()) + if (!is_mbm_enabled()) return; =20 r_mba =3D &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; + evt_id =3D rgrp->mba_mbps_event; + + if (WARN_ON_ONCE(!is_mbm_event(evt_id))) + return; + if (WARN_ON_ONCE(evt_id =3D=3D QOS_L3_MBM_LOCAL_EVENT_ID && !is_mbm_local= _enabled())) + return; + if (WARN_ON_ONCE(evt_id =3D=3D QOS_L3_MBM_TOTAL_EVENT_ID && !is_mbm_total= _enabled())) + return; + =20 closid =3D rgrp->closid; rmid =3D rgrp->mon.rmid; - idx =3D resctrl_arch_rmid_idx_encode(closid, rmid); - pmbm_data =3D &dom_mbm->mbm_local[idx]; + pmbm_data =3D get_mbm_state(dom_mbm, closid, rmid, evt_id); + if (WARN_ON_ONCE(!pmbm_data)) + return; =20 dom_mba =3D get_ctrl_domain_from_cpu(smp_processor_id(), r_mba); if (!dom_mba) { @@ -784,7 +795,9 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct= rdt_mon_domain *dom_mbm) */ head =3D &rgrp->mon.crdtgrp_list; list_for_each_entry(entry, head, mon.crdtgrp_list) { - cmbm_data =3D &dom_mbm->mbm_local[entry->mon.rmid]; + cmbm_data =3D get_mbm_state(dom_mbm, entry->closid, entry->mon.rmid, evt= _id); + if (WARN_ON_ONCE(!cmbm_data)) + return; cur_bw +=3D cmbm_data->prev_bw; } =20 --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 DA7F0BA42; Thu, 14 Nov 2024 00:17:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543443; cv=none; b=j7BxR4O+h0xlNUjNl9aLemNo8dWtWFzj3Xqp4A7/EemOUaLLQURTzJ/HAVYIOIlJGX193IWgOU3K6nkH44tD7FQHxV/GK0Gc4Z/TNsSVfi2WjHeVtjhcYnSfxxcM4Rq5laLJkZ+zMjmURnil24j8OTcEKrhOn/cuQ7YuQ2w+AWs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543443; c=relaxed/simple; bh=zzo2aTPnZlb8eHWTc7jsHa6kx3qkBJuqN1+to4NFkNU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gMktcN8wkcEO1AYiQ277HXXwvRoDFFNEW6i22V2B9qkWQmSJ5es23mLCcwFNvvlWK1dNLGc7Lt48KVFOsGOwZKBhklakKB46OlbWfS2ky01eQUgqn2wWmm/lQlPzKC3Bxxrk+i0Z2Gt5bbT51LAoAYEdEpwbe/EeHp6hZnMmR8Q= 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=Qjt2N7sp; arc=none smtp.client-ip=192.198.163.19 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="Qjt2N7sp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543442; x=1763079442; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zzo2aTPnZlb8eHWTc7jsHa6kx3qkBJuqN1+to4NFkNU=; b=Qjt2N7spAfk5lkwIgxd3+a/1ojmOylF7glIXThUKCfD5Ihf+/if+7lZQ 9nhfHwdhO0UM9UQpaQbZmEQQVxc4FkabD4R0M2uS1paF/LDTgrJJGuxOh 3e/C71MQMYQPYQhpyyTeuEHkGJ/24NUaT6awMWF3TTaq2pvmNDW54Wko6 W7m3gSRKniK2be1nO25nqr7m8IH/eadAApR9rjAbrwlWKOs7KoPPGAWz9 XfxjbYHFWkw5lqGV9mpHvskMPmF0ii5Uknnq/JysziJM4Aa7CLujssVkF NL7dISDfLkMzhEFGZKrhCF2i6TT3Ljggtx+Vnlu8+a84g2RVpLPYicGsw A==; X-CSE-ConnectionGUID: TPwFJz/TTnWY4/uD4+UmZA== X-CSE-MsgGUID: 0DmNsEXoSNqEtkszsL3d8Q== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869490" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869490" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 X-CSE-ConnectionGUID: i6zxnNvCTYCJsNXdkSVPzg== X-CSE-MsgGUID: b1khOCY2SyCZqOsO8LdC6w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081160" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 4/9] x86/resctrl: Compute memory bandwidth for all supported events Date: Wed, 13 Nov 2024 16:17:06 -0800 Message-ID: <20241114001712.80315-5-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" Computing the bandwidth for an event is cheap, and only done once per second. Doing so simplifies switching between events and allows choosing different events per ctrl_mon group. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck Tested-by: Peter Newman --- arch/x86/kernel/cpu/resctrl/monitor.c | 72 ++++++++++++--------------- 1 file changed, 33 insertions(+), 39 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 2176e355e864..da4ae21350c8 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -663,9 +663,12 @@ static int __mon_event_count(u32 closid, u32 rmid, str= uct rmid_read *rr) */ static void mbm_bw_count(u32 closid, u32 rmid, struct rmid_read *rr) { - u32 idx =3D resctrl_arch_rmid_idx_encode(closid, rmid); - struct mbm_state *m =3D &rr->d->mbm_local[idx]; u64 cur_bw, bytes, cur_bytes; + struct mbm_state *m; + + m =3D get_mbm_state(rr->d, closid, rmid, rr->evtid); + if (WARN_ON_ONCE(!m)) + return; =20 cur_bytes =3D rr->val; bytes =3D cur_bytes - m->prev_bw_bytes; @@ -826,54 +829,45 @@ static void update_mba_bw(struct rdtgroup *rgrp, stru= ct rdt_mon_domain *dom_mbm) resctrl_arch_update_one(r_mba, dom_mba, closid, CDP_NONE, new_msr_val); } =20 -static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d, - u32 closid, u32 rmid) +static void mbm_update_one_event(struct rdt_resource *r, struct rdt_mon_do= main *d, + u32 closid, u32 rmid, enum resctrl_event_id evtid) { struct rmid_read rr =3D {0}; =20 rr.r =3D r; rr.d =3D d; + rr.evtid =3D evtid; + rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, rr.evtid); + if (IS_ERR(rr.arch_mon_ctx)) { + pr_warn_ratelimited("Failed to allocate monitor context: %ld", + PTR_ERR(rr.arch_mon_ctx)); + return; + } + + __mon_event_count(closid, rmid, &rr); =20 /* - * This is protected from concurrent reads from user - * as both the user and we hold the global mutex. + * If the software controller is enabled, compute the + * bandwidth for this event id. */ - if (is_mbm_total_enabled()) { - rr.evtid =3D QOS_L3_MBM_TOTAL_EVENT_ID; - rr.val =3D 0; - rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, rr.evtid); - if (IS_ERR(rr.arch_mon_ctx)) { - pr_warn_ratelimited("Failed to allocate monitor context: %ld", - PTR_ERR(rr.arch_mon_ctx)); - return; - } - - __mon_event_count(closid, rmid, &rr); + if (is_mba_sc(NULL)) + mbm_bw_count(closid, rmid, &rr); =20 - resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); - } - if (is_mbm_local_enabled()) { - rr.evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID; - rr.val =3D 0; - rr.arch_mon_ctx =3D resctrl_arch_mon_ctx_alloc(rr.r, rr.evtid); - if (IS_ERR(rr.arch_mon_ctx)) { - pr_warn_ratelimited("Failed to allocate monitor context: %ld", - PTR_ERR(rr.arch_mon_ctx)); - return; - } - - __mon_event_count(closid, rmid, &rr); + resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); +} =20 - /* - * Call the MBA software controller only for the - * control groups and when user has enabled - * the software controller explicitly. - */ - if (is_mba_sc(NULL)) - mbm_bw_count(closid, rmid, &rr); +static void mbm_update(struct rdt_resource *r, struct rdt_mon_domain *d, + u32 closid, u32 rmid) +{ + /* + * This is protected from concurrent reads from user + * as both the user and we hold the global mutex. + */ + if (is_mbm_total_enabled()) + mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_TOTAL_EVENT_ID); =20 - resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); - } + if (is_mbm_local_enabled()) + mbm_update_one_event(r, d, closid, rmid, QOS_L3_MBM_LOCAL_EVENT_ID); } =20 /* --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 44FC911CA9; Thu, 14 Nov 2024 00:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543444; cv=none; b=OSNA8H3TUhN1ny0UVnBRpbUr5gw/EjHnI8iz4A2FHTRNS8Wwsczfe3PdgL789x4j6T3vxg6Kdoa52p0rqK1tGmpuNBOpdDB9JiqYevi7Dp7VUYgTw65zRsJjSWOFHL4n2RUjOZ/8TfFUEMDj/LJUjlEO1WIfVrjujy/GdEni/rI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543444; c=relaxed/simple; bh=ZkSSM2q5MnFvLgg48mZuk8LBjeJj2H/nYXDhejRCDUU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gY06mw9SGMlPK4eadEamxMd7KyhQPPDAjPb3zSZeBq34I0lYc5QSnSnfKr4ejBEcV9lGXKEPXOnSNwJoa/PDZmK2Bu/JamFCXuZ3kATGadW7dw/14bToLU4p4UTXCIyEhxkAl0N95nOIm6c0gCmEBgE49IrchHwux5ej4gGuefE= 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=Gwl+VmjV; arc=none smtp.client-ip=192.198.163.19 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="Gwl+VmjV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543443; x=1763079443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ZkSSM2q5MnFvLgg48mZuk8LBjeJj2H/nYXDhejRCDUU=; b=Gwl+VmjVvKMXyD9Kk0O+r5c0rLmzoYEbY2tNiXyudTjqyWs83pJOR/Jo MssNk2Xr8g1BynAI79fy/2HDOO8JOuDJN79VZsaa7hYU+5AlxuWlwO/+p +SBv4Y/hpd/Y0tuF1HdqGkJhnbjj4r7FfH243wOrfdjL7w7uBalShJQuW jFkRM6J0+DEFkhjaiRO+ujGrlYTlW99ptGg4ZIpvoQaaH0WHHNZYXuivm gs29eI9KIaM0phGJlEGovdvPvBMUjumNCBJV/oXF9qOWKFTEa8McbeGXP +rZYQK51p+vBlDnKRbVn4+37TPlRRn7WHHQ7YuWiKEXYrfMlGU31lTD/v w==; X-CSE-ConnectionGUID: LfqOu5SpSXquO7y2FFZ/Gw== X-CSE-MsgGUID: mSi8mPdoSnKHMtLl+WAWHg== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869503" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869503" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 X-CSE-ConnectionGUID: NCDS9fs3TSWPUjm/p/Xn3w== X-CSE-MsgGUID: LppNAjtBRamNw5SHSe9vWQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081163" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 5/9] x86/resctrl: Relax checks for mba_MBps mount option Date: Wed, 13 Nov 2024 16:17:07 -0800 Message-ID: <20241114001712.80315-6-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" This option may be used with any memory bandwidth monitoring event. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index a8022bddf9f7..3a89516e6f56 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2334,7 +2334,7 @@ static bool supports_mba_mbps(void) struct rdt_resource *rmbm =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resct= rl; struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; =20 - return (is_mbm_local_enabled() && + return (is_mbm_enabled() && r->alloc_capable && is_mba_linear() && r->ctrl_scope =3D=3D rmbm->mon_scope); } @@ -2759,7 +2759,7 @@ static int rdt_parse_param(struct fs_context *fc, str= uct fs_parameter *param) ctx->enable_cdpl2 =3D true; return 0; case Opt_mba_mbps: - msg =3D "mba_MBps requires local MBM and linear scale MBA at L3 scope"; + msg =3D "mba_MBps requires MBM and linear scale MBA at L3 scope"; if (!supports_mba_mbps()) return invalfc(fc, msg); ctx->enable_mba_mbps =3D true; --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 A78F8179BD; Thu, 14 Nov 2024 00:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543445; cv=none; b=WCHg1aWhm3zZ07bGxgw++LsNxOdifZkruW8/nx3zX25nVHP/186lQctdoutcTSkVQWB/Y0zuThmAFFsESqVe5Zoz+6toHBV568zWRusZkzIylTZVTurIn69R8MxR94ZQBKHAf239a1Jm803e8mweW09RPYpvUkQHcMB7eEc46aI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543445; c=relaxed/simple; bh=5Q4+X0iEeH+YMNS6vFyI/IkaOhw7AVsWZa5jlibXe4Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UAaBvd23X4C2e11ZXKJmF9klXFuB3yWirAtdAVt4YwMXHfkvqVhn3kDkn/EEShnK5IMbk9+6wgMZIGHzZeMnIDfbpP/7xxPNCTY5kxewrxHWFkALnCs1aXn1rQ4Bi7IeMmhJxA+ptgCs6A3BE6WkCGlkQOOCc1UAW9TtBtjZa+Q= 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=L7SXvKZY; arc=none smtp.client-ip=192.198.163.19 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="L7SXvKZY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543443; x=1763079443; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5Q4+X0iEeH+YMNS6vFyI/IkaOhw7AVsWZa5jlibXe4Y=; b=L7SXvKZYwcfLVZIhGPk0EG8yNp2F6AR1whbc2WQPJEOEf/dC8V09uxuX cOlDCODsq1dENcc0Mgts4IzT7Q7it7Lnz3Ps8lWAiIQFzhgHMinZUC057 e4WR8lJf8I/SVFz2QL4r7PaEGc4CTgafd1IfZvJZ8GtmqAsoM0ii5yT1m r3AMm2QeNU1+EQlBs5ZJgMLcWW2Nz56Mn5vLF3E3j2IIyyWQN7/Lso6cr 3PmTAnLIqoVZaNY5bz31jZ+bra2now4SS9uTN0h2Xrjef3vEate9NczGj wUc3fAMny10z9bmlSSrY/EQjHVx8/lMX1fWPVlkKpPhRkMX0b7h0SM4cF g==; X-CSE-ConnectionGUID: kcuhbRa7Sq6ZuxnXvpvZ3A== X-CSE-MsgGUID: Nb6VqmVHQ/6iNKF8tyA0EQ== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869519" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869519" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 X-CSE-ConnectionGUID: OBJ9MdICQK2y9UU0cxo7vA== X-CSE-MsgGUID: g0naypt6TpWIMR76BCOIYg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081166" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:19 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 6/9] x86/resctrl: Add "mba_MBps_event" file to ctrl_mon directories Date: Wed, 13 Nov 2024 16:17:08 -0800 Message-ID: <20241114001712.80315-7-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" The "mba_MBps" mount option provides an alternate method to control memory bandwidth. Instead of specifying allowable bandwidth as a percentage of maximum possible, the user provides a MiB/s limit value. Historically the limit was enforced by a feedback loop from the measure local bandwidth to adjust the memory bandwidth allocation controls. In preparation to allow the user to pick the memory bandwidth monitoring event used as input to the feedback loop, provide a file in each ctrl_mon group directory that shows the event currently in use. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 30 +++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 10 ++++++++ 3 files changed, 42 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 485800055a7d..ce10a883ecf8 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -609,6 +609,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file= *of, char *buf, size_t nbytes, loff_t off); int rdtgroup_schemata_show(struct kernfs_open_file *of, struct seq_file *s, void *v); +int rdtgroup_mba_mbps_event_show(struct kernfs_open_file *of, + struct seq_file *s, void *v); bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_ctrl_domai= n *d, unsigned long cbm, int closid, bool exclusive); unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, struct rdt_ctrl_= domain *d, diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 200d89a64027..5fa37b4ecc7a 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -518,6 +518,36 @@ static int smp_mon_event_count(void *arg) return 0; } =20 +int rdtgroup_mba_mbps_event_show(struct kernfs_open_file *of, + struct seq_file *s, void *v) +{ + struct rdtgroup *rdtgrp; + int ret =3D 0; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + + if (rdtgrp) { + switch (rdtgrp->mba_mbps_event) { + case QOS_L3_MBM_LOCAL_EVENT_ID: + seq_puts(s, "mbm_local_bytes\n"); + break; + case QOS_L3_MBM_TOTAL_EVENT_ID: + seq_puts(s, "mbm_total_bytes\n"); + break; + default: + pr_warn_once("Bad event %d\n", rdtgrp->mba_mbps_event); + ret =3D -EINVAL; + break; + } + } else { + ret =3D -ENOENT; + } + + rdtgroup_kn_unlock(of->kn); + + return ret; +} + void mon_event_read(struct rmid_read *rr, struct rdt_resource *r, struct rdt_mon_domain *d, struct rdtgroup *rdtgrp, cpumask_t *cpumask, int evtid, int first) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 3a89516e6f56..416e1acfad9f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1943,6 +1943,12 @@ static struct rftype res_common_files[] =3D { .seq_show =3D rdtgroup_schemata_show, .fflags =3D RFTYPE_CTRL_BASE, }, + { + .name =3D "mba_MBps_event", + .mode =3D 0444, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mba_mbps_event_show, + }, { .name =3D "mode", .mode =3D 0644, @@ -2348,6 +2354,7 @@ static int set_mba_sc(bool mba_sc) struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; u32 num_closid =3D resctrl_arch_get_num_closid(r); struct rdt_ctrl_domain *d; + unsigned long fflags; int i; =20 if (!supports_mba_mbps() || mba_sc =3D=3D is_mba_sc(r)) @@ -2360,6 +2367,9 @@ static int set_mba_sc(bool mba_sc) d->mbps_val[i] =3D MBA_MAX_MBPS; } =20 + fflags =3D mba_sc ? RFTYPE_CTRL_BASE | RFTYPE_MON_BASE : 0; + resctrl_file_fflags_init("mba_MBps_event", fflags); + return 0; } =20 --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 C0A7A1862A; Thu, 14 Nov 2024 00:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543445; cv=none; b=pXT2MMfpwZna8vmOI0hYHn6KfwFb8fLMhVBVNXEK6YnV32RyX16h7Q3yqmZHhlrPaOq0HTZ4lL7dC18apbwFIdKSD1hKVVuqHKmMMelwmTwwLBchi9shFC5V1G3eu2/jqYDcPoVDsSdN02K/ekqTwOv+S8bcDgarp6QuXQ17wlM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543445; c=relaxed/simple; bh=GIBBPueD41f/gJbHQyFVQ4yIOZGadcuF/ZE+ZTaWWqc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZMF7oEqH7bBsprTBrj4K5khgKdixUBHLmfHUxtkvOQH68oBcCMT5RFYT6fqhD+isU7oO/UyN2s8r69a2molMNknUxpOV9IuN47d6ubHESFkHaGVZayVKAMbyL2V1LHprhWPWY9N53j74ugUJ8i2YZGA6uYyW5GgKx0iWvF4Lo5w= 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=ipxUWFwV; arc=none smtp.client-ip=192.198.163.19 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="ipxUWFwV" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543444; x=1763079444; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GIBBPueD41f/gJbHQyFVQ4yIOZGadcuF/ZE+ZTaWWqc=; b=ipxUWFwVpWD0cdQ/nVrwHbDrdUGlpbbvb1ZkMpgTYJqM7eewpYp0zqwU 18/rRmkfaefsbmC01P6KeyjMfU/aWvzfKkYCTayhxT5BaPal0HLTIROzp D7mhcB0vwG7n3Pq125b6XlnOFXBCj0YHyRtRtjH/FMbNWEz9EyZ6ifm1o 32YyeAW9ceH+KLAlNpIDiuEksvytQSD4hlON2Rv1Lah1IUWeoib+7MBUI ffxopdxLBQ1AIQvTszZr3WgMa+P2uH0Rci920DKWu4iZITt8xuo0hfG+Q DEcVTGh441AO1+bUG7YRgNBDrIG/EZpvtEDr3sPBezCi4GyDf5cCzVAvL Q==; X-CSE-ConnectionGUID: Wm+x/8MoQKK66ZgpZb0TzA== X-CSE-MsgGUID: BeiUS6hZQOG2mGZ9Q8skzA== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869529" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869529" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:18 -0800 X-CSE-ConnectionGUID: dAGrj+e/QTeHbfwF+6rOeQ== X-CSE-MsgGUID: AXTdSrBDQNiZGzAmRXtJ9g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081169" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:19 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 7/9] x86/resctrl: Add write option to "mba_MBps_event" file Date: Wed, 13 Nov 2024 16:17:09 -0800 Message-ID: <20241114001712.80315-8-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" The "mba_MBps" mount option provides an alternate method to control memory bandwidth. Instead of specifying allowable bandwidth as a percentage of maximum possible, the user provides a MiB/s limit value. Historically the limit was enforced by a feedback loop from the measure local bandwidth to adjust the memory bandwidth allocation controls. There is a file in each ctrl_mon group directory that shows the event currently in use (always says "mbm_local_bytes"). Allow writing that file to choose a different event. A user can choose any of the memory bandwidth monitoring events listed in /sys/fs/resctrl/info/L3_mon/mon_features independently for each ctrl_mon group by writing to the "mba_MBps_event" file. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 40 +++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 3 +- 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index ce10a883ecf8..6345ab3e0890 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -609,6 +609,8 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file= *of, char *buf, size_t nbytes, loff_t off); int rdtgroup_schemata_show(struct kernfs_open_file *of, struct seq_file *s, void *v); +ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off); int rdtgroup_mba_mbps_event_show(struct kernfs_open_file *of, struct seq_file *s, void *v); bool rdtgroup_cbm_overlaps(struct resctrl_schema *s, struct rdt_ctrl_domai= n *d, diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 5fa37b4ecc7a..ee983b68c046 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -518,6 +518,46 @@ static int smp_mon_event_count(void *arg) return 0; } =20 +ssize_t rdtgroup_mba_mbps_event_write(struct kernfs_open_file *of, + char *buf, size_t nbytes, loff_t off) +{ + struct rdtgroup *rdtgrp; + int ret =3D 0; + + /* Valid input requires a trailing newline */ + if (nbytes =3D=3D 0 || buf[nbytes - 1] !=3D '\n') + return -EINVAL; + buf[nbytes - 1] =3D '\0'; + + rdtgrp =3D rdtgroup_kn_lock_live(of->kn); + if (!rdtgrp) { + rdtgroup_kn_unlock(of->kn); + return -ENOENT; + } + rdt_last_cmd_clear(); + + if (!strcmp(buf, "mbm_local_bytes")) { + if (is_mbm_local_enabled()) + rdtgrp->mba_mbps_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; + else + ret =3D -EINVAL; + } else if (!strcmp(buf, "mbm_total_bytes")) { + if (is_mbm_total_enabled()) + rdtgrp->mba_mbps_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; + else + ret =3D -EINVAL; + } else { + ret =3D -EINVAL; + } + + if (ret) + rdt_last_cmd_printf("Unsupported event id '%s'\n", buf); + + rdtgroup_kn_unlock(of->kn); + + return ret ?: nbytes; +} + int rdtgroup_mba_mbps_event_show(struct kernfs_open_file *of, struct seq_file *s, void *v) { diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 416e1acfad9f..3f2e035208e6 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1945,8 +1945,9 @@ static struct rftype res_common_files[] =3D { }, { .name =3D "mba_MBps_event", - .mode =3D 0444, + .mode =3D 0644, .kf_ops =3D &rdtgroup_kf_single_ops, + .write =3D rdtgroup_mba_mbps_event_write, .seq_show =3D rdtgroup_mba_mbps_event_show, }, { --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 05C3B25776; Thu, 14 Nov 2024 00:17:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543446; cv=none; b=e1EvZ71/IQJLAERWgsmu2a7GAbj9oVzfJwySMWeNbvx+vXbMTPoS7QQZ6RuBiyMhmEX9s15uHcsS7lYa8ZKcO+XV2e6pOCJZpceyjwQCOXyNYrdrLt9VxDD/KAA+8XLPAfaBX3pTM0JCTHYU84lyvzFqL5pnVCDyMqSKzJlhit4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543446; c=relaxed/simple; bh=sams9RAjayhA8eov6q7XFBsoSi+1xtqlPnrjKc9CSyg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OFRzhmF7WEWGJgOREdIqoqOXndcPlU5aBfADspUKhi/riKwK1TqzyZCiiGom0CO30Dn8UrXrNjX9n94Ra5KIoubHfVkqaOUTJCptmA+ZRtG5K+XrEqMJa/m6GaFX4KvocoQJOaGzAvZH5vFwIb3iRImu5YTCXIgAVySGoZyF9bc= 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=duDvIYBR; arc=none smtp.client-ip=192.198.163.19 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="duDvIYBR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543445; x=1763079445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sams9RAjayhA8eov6q7XFBsoSi+1xtqlPnrjKc9CSyg=; b=duDvIYBRJQ3m0i4yBx7fdTjnccrjG9RZuzTvfI00McAgMot2xwIrRs10 VQrNO/UhKTnggsE8IBSSlfL8RKUTj4l+MfcYszYEbqAQh6HmgxfZ98sxS fLkuvhUQoxK0Y3B2OkgAWgrJyW1ZGSWV5fvdqMMJ0z37ppJgKZL6Mkpf5 Jmv20KBBXTNNRgbQxgW3frvbbmqFy9INd4uao4m0sXXv4FPAsdU3LnY1O HpSZHuAg63k+onTQNMcKAMtOOg3apS+2xXf1hNnsLj6mgsdHoq0qW+QZ9 9DgR729ruu5l27ATLzuvUe0IBDvF/+zrycPtWWVRiUUBwhRVFbdMyD4Tb A==; X-CSE-ConnectionGUID: 1+cg2Tg1S8i4UbF2vBmUbg== X-CSE-MsgGUID: ZPv4uoNMQVinLfenlE2DTA== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869539" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869539" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:19 -0800 X-CSE-ConnectionGUID: TVVv+jAbSdS/vw4vyysAfQ== X-CSE-MsgGUID: Uep8lmumTDqekhDZXaaqYQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081172" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:19 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 8/9] x86/resctrl: Make mba_sc use total bandwidth if local is not supported Date: Wed, 13 Nov 2024 16:17:10 -0800 Message-ID: <20241114001712.80315-9-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" The default input measurement to the mba_sc feedback loop for memory bandwidth control when the user mounts with the "mba_MBps" option has historically been the local bandwidth event. But some systems may not support a local bandwidth event. When local bandwidth event is not supported, check for support of total bandwidth and use that instead. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 94bf559966d6..3d1735ed8d1f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -965,6 +965,8 @@ static __init bool get_rdt_mon_resources(void) =20 if (is_mbm_local_enabled()) mba_mbps_default_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; + else if (is_mbm_total_enabled()) + mba_mbps_default_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; =20 return !rdt_get_mon_l3_config(r); } --=20 2.47.0 From nobody Sat Nov 23 05:41:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) (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 A7F022AE8E; Thu, 14 Nov 2024 00:17:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.19 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543447; cv=none; b=KjQjc2u/ejBHL8juLFnDnQMyHPmTwdDllcgzttKeYYKYG4e3t2QEh7Z1TI67aIxHhJeUvcRZtLavGF+2PgEOiuqxJ7lbcITsJVMwhs0NnqlRiA9KzzkXjXLKWrmitfQba44FrHkX4bPln6AThQu4tvQQgpw8mNDWBYC2qk/RFxw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731543447; c=relaxed/simple; bh=l+muwJjd4b/MMagbFBq0iDX4dVxLpcndlyRlD39vk0s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=O1hlu+c6BzZv4RcAxyz5JEHn+oAjb26asMQYND1J86/1V6pDMb782ZGccenSpxqTMQFJqDTinw0cx+GB8LHtQ9VsxCmQk/H94mmjCfTh268QotQVCw6yqNgZENHgxFUtDEM68SncIKTRCU+4P1eNi8kXx7qo6fUBSz7RCM/+1Rk= 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=WytEwoQF; arc=none smtp.client-ip=192.198.163.19 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="WytEwoQF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1731543445; x=1763079445; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l+muwJjd4b/MMagbFBq0iDX4dVxLpcndlyRlD39vk0s=; b=WytEwoQFveP1zXhCA7GJq3c/ZR+RO0XWve0rmm7mVmZCyDyFrAG/SlS6 kWBlF7R33qPvIu48eVNaDsOkoIuVroc8031V5slwQyP2Nrc/orLB7b+wl zvgdo7R4bA/mPEeXst2LI+NVEb5fKRk+yc+iGn4kSCj5+NpAiWnP9svfh oiWZArwsz/TL8zO8Px2YshEvuyNUz4r8ltlY8n1S9emZhtFfRevFQu0R8 YoZ26PIYP1N/Sf03+jLk4BuaC73Hxt/Ws27MEBcTjxclr+Uz+/Lk/SXRY BqH9B1zKbIYu91jntcheE4ncwEm0o+EKKLZjfrl4yDJT0THYVfnyOOijq Q==; X-CSE-ConnectionGUID: pt5/vAEKS0+IPAK3tpdE6g== X-CSE-MsgGUID: oKrCxsuLRSuVzIoqEQ8vDQ== X-IronPort-AV: E=McAfee;i="6700,10204,11255"; a="30869540" X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="30869540" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:19 -0800 X-CSE-ConnectionGUID: khuRkRx+Qm6mbRfwLv0nGg== X-CSE-MsgGUID: QVZiBJ/cRIWtxagvcsXg7A== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.12,152,1728975600"; d="scan'208";a="92081175" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Nov 2024 16:17:19 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: James Morse , Jamie Iles , Babu Moger , Randy Dunlap , "Shaopeng Tan (Fujitsu)" , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v9 9/9] x86/resctrl: Document the new "mba_MBps_event" file Date: Wed, 13 Nov 2024 16:17:11 -0800 Message-ID: <20241114001712.80315-10-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241114001712.80315-1-tony.luck@intel.com> References: <20241114001712.80315-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" Add a section to document a new read/write file that shows/sets the memory bandwidth event used to control bandwidth used by each ctrl_mon group. Signed-off-by: Tony Luck --- Documentation/arch/x86/resctrl.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/re= sctrl.rst index a824affd741d..6768fc1fad16 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -384,6 +384,16 @@ When monitoring is enabled all MON groups will also co= ntain: Available only with debug option. The identifier used by hardware for the monitor group. On x86 this is the RMID. =20 +When the "mba_MBps" mount option is used all CTRL_MON groups will also con= tain: + +"mba_MBps_event": + Reading this file shows which memory bandwidth event is used + as input to the software feedback loop that keeps memory bandwidth + below the value specified in the schemata file. Writing the + name of one of the supported memory bandwidth events found in + /sys/fs/resctrl/info/L3_MON/mon_features changes the input + event. + Resource allocation rules ------------------------- =20 --=20 2.47.0