From nobody Mon Nov 25 05:51:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 9F88C20720E; Tue, 29 Oct 2024 17:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222924; cv=none; b=QessTwrB2HJpurzMtgTyt8QTQcmlyhVZlB0BVowOSASzNSq1nmpabSm2WxbHwNZKDst2Rb5fonFsPycPguZe0xQiqGtYkB5O3NYFowe1OjoyomlR2n0qPtCn5VKyjv5vOr3aK8i8a5zGZILZqqnV1yz7EyEZoLjNXWeVwgL4Ud8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222924; c=relaxed/simple; bh=SHRi/W/hccHUHwXfh2MbFeVEffxuPn8jRJHIpiMoqm8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DdoGn3MmV27AFJiMXrOhMm7iQhVN0zg/JelgzNbJd1mu1IQSFsunPTaSMr8vXbGCC2G5W3GCpu6n/l2RkvEfrRDYYeACV+B6HgOQDeutPmYbJWEhfd655xVHhXya+WlNRh4wrVot2aPLjBAAK64lN3dMDq39uB9wmbjomrcsDhQ= 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=BJnplrOM; arc=none smtp.client-ip=192.198.163.16 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="BJnplrOM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730222922; x=1761758922; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=SHRi/W/hccHUHwXfh2MbFeVEffxuPn8jRJHIpiMoqm8=; b=BJnplrOM1SbhFTeECN0ryKQSWJv0ENqD4b/vKwUI3lMt27O59jfTml35 g0Fr6DcP3JkeUqPYzHXLevmAHxFVyjJl20Lv0L5LkNFIIGYAH24gh+kEU 6FewOSZINCbRd7QFwJ/jZkpP4pbDnNnF0W7Lrb3nett27spUwftKfzJUm hPxfSiN7fcZQ9iPl4kBPDI2Uwu9BvCv6OhjCMYyDvsn3ANlWB5tJpIVz3 E5vFNLXIk/TDZDkKRDl4+zSRo/Tyw+fz3ifYZESNBuIX3Q7ZUmFD+3px+ Fpogpvm8ItJdGTSdbCmn2jTg0j+8TJgOjF8h6Z/dbngreVFzI8YFU64Ta Q==; X-CSE-ConnectionGUID: qI+kAPBoQk+vp8mAHVvJiQ== X-CSE-MsgGUID: aJXGkaAZS4Ko33lQhsS4HQ== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="17515644" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="17515644" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 X-CSE-ConnectionGUID: BOFCIB5QRBKbdxtkvryHQQ== X-CSE-MsgGUID: xYAeSO2AQSKDliCw3GcSrA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="81585597" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , 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 v8 1/7] x86/resctrl: Prepare for per-ctrl_mon group mba_MBps control Date: Tue, 29 Oct 2024 10:28:26 -0700 Message-ID: <20241029172832.93963-2-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029172832.93963-1-tony.luck@intel.com> References: <20241029172832.93963-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 | 5 +++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 6 ++++++ 4 files changed, 15 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 955999aecfca..a6f051fb2e69 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 event id when mba_sc mode is active * @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 b681c2e07dbf..5b55a7ac7013 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -958,6 +958,11 @@ static __init bool get_rdt_mon_resources(void) if (rdt_cpu_has(X86_FEATURE_CQM_MBM_LOCAL)) rdt_mon_features |=3D (1 << QOS_L3_MBM_LOCAL_EVENT_ID); =20 + if (rdt_mon_features & (1 << QOS_L3_MBM_LOCAL_EVENT_ID)) + mba_mbps_default_event =3D QOS_L3_MBM_LOCAL_EVENT_ID; + else if (rdt_mon_features & (1 << QOS_L3_MBM_TOTAL_EVENT_ID)) + mba_mbps_default_event =3D QOS_L3_MBM_TOTAL_EVENT_ID; + if (!rdt_mon_features) return false; =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index d7163b764c62..dbfb9d11f3f8 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) @@ -2665,6 +2667,8 @@ static int rdt_get_tree(struct fs_context *fc) if (ret) goto out_schemata_free; =20 + rdtgroup_default.mba_mbps_event =3D mba_mbps_default_event; + kernfs_activate(rdtgroup_default.kn); =20 ret =3D rdtgroup_create_info_dir(rdtgroup_default.kn); @@ -3624,6 +3628,8 @@ static int rdtgroup_mkdir_ctrl_mon(struct kernfs_node= *parent_kn, } } =20 + rdtgrp->mba_mbps_event =3D mba_mbps_default_event; + goto out_unlock; =20 out_del_list: --=20 2.47.0 From nobody Mon Nov 25 05:51:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 3C69220495C; Tue, 29 Oct 2024 17:28:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222923; cv=none; b=em3KHfOpM+8pjHKdAMkmIcEwzNkSwqWiovGtP0xTXKmmniGsGUl15ixDSV6yY0Bs1+o5tRELi79N7IWEbneP0T1f9Aypt9usSC1iY6Kfw/bl0jHB/CBJuQ31WZmW46ckv/UgV6mdsMEXoPXkji03cuy7t5Z2YwLJIuVrUp81cwE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222923; c=relaxed/simple; bh=NGkaoI9qAkY3/PRKqgR7Ojby6kj9rG3/xXGUsvQqhio=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kvDzgWrvuDjkJ3EZtLonLcyzJNgxj27EnsZxzXSZwbJyiAYPnzxQVzKW5JiNHToROykLKgY1YdWpni2kqVVqO+ID6onORKtal/cFf0zqWerqMfr5sJG4vn9GoxhfB+aC+t8XC+ksHrkL/XKt0GHOoA/S1QGlUhjJO05nCgOjRrU= 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=m1romaM9; arc=none smtp.client-ip=192.198.163.16 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="m1romaM9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730222921; x=1761758921; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=NGkaoI9qAkY3/PRKqgR7Ojby6kj9rG3/xXGUsvQqhio=; b=m1romaM9VR1JvOyN1ZP83rnI2nMxaiV4qIsvVUasgDjJ4QCIoaMbrUGy nm0ugDZIlsa5RfNH9A9cLRGqGUuXOpNjkbzOa88v2SjMZMUk+DfXjd+H0 rO4bpdt8aNo6CD5sSBlf4qk1mPKZsuIuWQd24wokIE6FeyP53pPheZFkv cZfAHhJQI4ct+hWihdqfHZ6GpsiU2UvnQqbc7hB3Q3f3g2E4mGh2QntZs f5fj++Dyo2iRZ3kKUXAtZuCrExJ5fGwrva3OGU5QZ0lV/Xluha9TwiCq4 K9HHTM7/rhWCEKyjf0Cv7PWwpdG0cJWBU3l04cpXGS8XPsYaQbcOeR0at Q==; X-CSE-ConnectionGUID: K+Tc8AmlQqC51XBabV8cJA== X-CSE-MsgGUID: HJ+kQkv4R06zU1OTi6GFxQ== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="17515665" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="17515665" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 X-CSE-ConnectionGUID: GJb4gQBgTwG6xoFu2WNHNw== X-CSE-MsgGUID: fgEfaAj1QIOkcjsRKRWMbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="81585600" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , 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 v8 2/7] x86/resctrl: Compute memory bandwidth for all supported events Date: Tue, 29 Oct 2024 10:28:27 -0700 Message-ID: <20241029172832.93963-3-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029172832.93963-1-tony.luck@intel.com> References: <20241029172832.93963-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 --- arch/x86/kernel/cpu/resctrl/monitor.c | 38 ++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 851b561850e0..3ef339e405c2 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; @@ -752,20 +755,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 +798,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 @@ -837,6 +853,14 @@ static void mbm_update(struct rdt_resource *r, struct = rdt_mon_domain *d, =20 __mon_event_count(closid, rmid, &rr); =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); + resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); } if (is_mbm_local_enabled()) { --=20 2.47.0 From nobody Mon Nov 25 05:51:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 1126B207214; Tue, 29 Oct 2024 17:28:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222926; cv=none; b=u2FgZ2HNMbzV6JsLTAs/vg5qSwMzpOSMo1rzQrfI4lbJb1PI7XRRo3u3wrHgjqWOb2b2G0/M2SiZ7Fy777eHgirRuEssU87siB4ktI5EXMLIBS/7PYQgE9zhSZyyKKNueOFUg3Sl2Rmb2hRmGts9bPtLSOuUlDgnnUstWowkYAs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222926; c=relaxed/simple; bh=v+xCJOJVDhdzdFGOhm7Qwh+e7FfyEjIfLSDzmGGOMgQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X0JFhGviJUQYbgUaNe5M0EISGzq4iONYpxtNavEtvSvktg47QuTsheHWDPtqQNFwKGET47wPtWKa8RN23avz1FG24EVNi5Tx4R2q1aXJuAuJiTWidNwLf3/xT1M2xdmgoIX/anq+UnqiiuULIvHJUAG210WZkoHfSXTn4AfTgZ4= 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=g9nOi+Ys; arc=none smtp.client-ip=192.198.163.16 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="g9nOi+Ys" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730222923; x=1761758923; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=v+xCJOJVDhdzdFGOhm7Qwh+e7FfyEjIfLSDzmGGOMgQ=; b=g9nOi+Ys0hy6tcrQjztTGZ04pV/UfeomCG0qMhPPTZgW0FQYvahaMF/7 7h7JOOuxgY30GIKfM3WlHXKfGfYj4nhi3QckZlxCt7+eYU/mtyIsS9rjy domSjO7sQZ/3BIPrJefehEsjNB3C3dnhykCX84lhYIKmHYMkyf4ohtRji h6CgHgMQRlqdI35jWETRu+YGthkMsWCSkDt6E5EtIbDsG03byddZ/JjWo U0qiksjb6ZbIr7Ffb16f6wgpGtQuBiuh+ku3G77NwaKvF1SZqB07HzXQe 1LZpBuk/ug7MEZDg7A3bnErwJmw9obyeXMtY1/gXEDLRXHTplP/WY1rAy A==; X-CSE-ConnectionGUID: lW9ANReuQpu1+NlDAGIZiw== X-CSE-MsgGUID: sxDMpCrPQz+nSR9M1ciY+A== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="17515666" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="17515666" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 X-CSE-ConnectionGUID: YbGM6yPjRA+TbtWKUmg+QQ== X-CSE-MsgGUID: apXHOrM1RPSSX9LhriNZUA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="81585603" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , 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 v8 3/7] x86/resctrl: Refactor mbm_update() Date: Tue, 29 Oct 2024 10:28:28 -0700 Message-ID: <20241029172832.93963-4-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029172832.93963-1-tony.luck@intel.com> References: <20241029172832.93963-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 memory bandwidth for all enabled events resulted in identical code blocks for total and local bandwidth in mbm_update(). Refactor with a helper function to eliminate code duplication. No functional change. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/monitor.c | 69 ++++++++++----------------- 1 file changed, 24 insertions(+), 45 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 3ef339e405c2..1b6cb3bbc008 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -829,62 +829,41 @@ 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); + + if (is_mba_sc(NULL)) + mbm_bw_count(closid, rmid, &rr); + + resctrl_arch_mon_ctx_free(rr.r, rr.evtid, rr.arch_mon_ctx); +} =20 +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()) { - 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); - - /* - * 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); - - 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); - - /* - * 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); + 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 Mon Nov 25 05:51:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 A2F5420721D; Tue, 29 Oct 2024 17:28:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222925; cv=none; b=PWLt6Uqn4TFuCPzbruGotwRxL1TRgU1o3HmHlJMucxtR7xmFFwSWBBTfQ4j93G/DVoAawUX3CoRUMez6rqrZKDTO6BA3mm3B5FqY6lXZ1rngT3pG0vZWNJGd5bQDYkGN/EjSvbPKOEkuAP905+nOkIQXB1oJQd2M8bjE48yw4tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222925; c=relaxed/simple; bh=miXmdTqCp2YZmLRjd/Hq5yASIhebLezdHmtBpTOcFW8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oY6++KSbErhoqluMY2k/RuQDsqdBrlo04s2LmtvZGKypTAUioxlALKtB/roiO4Mg9CPMkS0j3TUoy1xq8HMWmVu+aHIqAEOkYGH9nJGv/22qQ/KsF/xTj+o7h7La+QzzF6/JM/nWcF9Ly3NNegOee7gph+UcDqIJnkH2/ZQk7C0= 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=Bcg3q6ql; arc=none smtp.client-ip=192.198.163.16 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="Bcg3q6ql" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730222923; x=1761758923; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=miXmdTqCp2YZmLRjd/Hq5yASIhebLezdHmtBpTOcFW8=; b=Bcg3q6qlqZ3OvrEH1LcUEE0wEhSOioRarBaX4xP2G9Jpj9pHUZY+Kuen c8soBv9eBrVsixHfPd/xF/CbI/j72th2LWx/Asbv0jaumZBBo7CqPrAhF Try2SYL9KlMF0UliC2ZiJs4Gtt9KRnsLvokO4y57dziy1olYVyA0z/X1Z +5It+09iQqmLVBSyUIk+WntJPtVVcU39G12SzpknLSuQqdq4g08PTqCpl +FH5lP8jqjx8DmIgq5JUbQV8XysJ1CeeFgfARmHyuHZf45Yvj9i5NYb3t mNGqBUWswSSRKzCCHcve47I2J/0Ah6S5HYs2Rkt9hVsYXeggx8VAKdGEK Q==; X-CSE-ConnectionGUID: o5CBbWLaTZ2KLYMdUkvlpw== X-CSE-MsgGUID: cFHPHtPzQVSHI0zqGp6chQ== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="17515677" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="17515677" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 X-CSE-ConnectionGUID: hKlsxY9cSCierr3EPk7ONw== X-CSE-MsgGUID: d3m9/S7TS7WFH6LcqPhbpg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="81585606" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , 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 v8 4/7] x86/resctrl: Relax checks for mba_MBps mount option Date: Tue, 29 Oct 2024 10:28:29 -0700 Message-ID: <20241029172832.93963-5-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029172832.93963-1-tony.luck@intel.com> References: <20241029172832.93963-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 dbfb9d11f3f8..5034a3dd0430 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2345,7 +2345,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); } @@ -2772,7 +2772,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 Mon Nov 25 05:51:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 08C392076B9; Tue, 29 Oct 2024 17:28:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222927; cv=none; b=Zo8lhzGAo2qmsdpwyuKvwRKp/c+Z+mHD5MnqekChQ5wKe/8jgM5V8f4p0DkgSsW+kusSHyO/z6JdPOzOR4VTS+AmKTPnCd4msPWGx6DVQHHL9fmZQn6VESOYp2aLahYTI7nVB55gEHShLfc1J/FncyRvW/IMZ88C4Sw+5OySJVo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222927; c=relaxed/simple; bh=x885zf274l9nnySJCLiGWLrrEaCGAoB82a5tbTdAiiQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YDAX7fSdiH1EOSHkBuFVEwhQiH/Kd+0GaC8e1gwwOhT1kK7fPnC5CMWgA7obyTkD2FslP5R+qc+EeYw4DXSMK5ukHs9h/p1N7Sr/3phgn6xzfnYBkIhMzUAAhXYeaa4WZm/oO1EYIRG8bMQB0ep0o7yDA7QO9ArgRXu/fVXA7tY= 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=UDqFWFQN; arc=none smtp.client-ip=192.198.163.16 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="UDqFWFQN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730222925; x=1761758925; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=x885zf274l9nnySJCLiGWLrrEaCGAoB82a5tbTdAiiQ=; b=UDqFWFQN5uS8yxDClFiutvUpFRC08q9/vlvoOZ2R9AL1/rZGWiq89U4X lqMSfJxdoKhuojIVXtOhatcybJfkQP8vKYgLgMmr2MlGDe1HK+m9tD4Cw dUzezeHzYeLKy2rqZWIniMZYcNNdgRop0rFewEMMX/04Xm/J6U17mwMOY jIDZ4U7vHFk9hwAVZdXYuWewmBVCciEkPZuKlR1gRZ9BGIUM95Qi8oMEb UEK4ofdmhkZzJzXSmOhLC0wTKmdhgv6k3eSZ+5TAYxXtxZooy+mE4Q43m Pu3p9mnXUInthaGD8klkMpZdw9kkd/1IZUUUZ8Kz9JgS1wY4nbBB4I1nK A==; X-CSE-ConnectionGUID: by96Ob69Sg+COIM3Jt61XQ== X-CSE-MsgGUID: +eYwLSAuRQmMtbkgPXCIng== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="17515688" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="17515688" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:40 -0700 X-CSE-ConnectionGUID: Zc6/88meSeayWJ/uY6FXiA== X-CSE-MsgGUID: dUhMnTlJQU6xnxVKlEJtBQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="81585610" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:39 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , 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 v8 5/7] x86/resctrl: Add "mba_MBps_event" file to ctrl_mon directories Date: Tue, 29 Oct 2024 10:28:30 -0700 Message-ID: <20241029172832.93963-6-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029172832.93963-1-tony.luck@intel.com> References: <20241029172832.93963-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" When the mba_MBps mount option is used, provide a file in each ctrl_mon directory to show which memory monitoring event is being used. Suggested-by: Reinette Chatre Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 25 +++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 17 +++++++++++++++ 3 files changed, 44 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index a6f051fb2e69..5f3438ca9e2b 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..b9ba419e5c88 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -518,6 +518,31 @@ 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; + + 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; + case QOS_L3_OCCUP_EVENT_ID: + break; + } + } + + rdtgroup_kn_unlock(of->kn); + + return 0; +} + 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 5034a3dd0430..3ba81963e981 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 0644, + .kf_ops =3D &rdtgroup_kf_single_ops, + .seq_show =3D rdtgroup_mba_mbps_event_show, + }, { .name =3D "mode", .mode =3D 0644, @@ -2042,6 +2048,15 @@ void __init mbm_config_rftype_init(const char *confi= g) rft->fflags =3D RFTYPE_MON_INFO | RFTYPE_RES_CACHE; } =20 +static void mba_mbps_event_init(bool enable) +{ + struct rftype *rft; + + rft =3D rdtgroup_get_rftype_by_name("mba_MBps_event"); + if (rft) + rft->fflags =3D enable ? RFTYPE_CTRL_BASE : 0; +} + /** * rdtgroup_kn_mode_restrict - Restrict user access to named resctrl file * @r: The resource group with which the file is associated. @@ -2371,6 +2386,8 @@ static int set_mba_sc(bool mba_sc) d->mbps_val[i] =3D MBA_MAX_MBPS; } =20 + mba_mbps_event_init(mba_sc); + return 0; } =20 --=20 2.47.0 From nobody Mon Nov 25 05:51:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 E00EE2076D2; Tue, 29 Oct 2024 17:28:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222928; cv=none; b=LBGeD29tpsE7bLGpX20WAMPAzJl1CztPPq2oxmfBwSib/YsvBtmTJQ+jitV1Q0J90tmI5pDTYGwuRZJt8eMEFgObbjOuhttj2zMEvPbZjKMAW7af/8og3CZZdPn2NdmTPSSBSc2CvA0809wWGCtI1Z0a7WzhixeT8mLnDuh3QG8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222928; c=relaxed/simple; bh=y0upCVuwoxT9d72GZhH8/7dZn6beeSrJGjp/BYFWoQs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WKlVDOalsonKQghFwW0ewrxRjJF7MmneIdoQL3Rka0EBHD3ToMwN1ER/cmoZMT157/jqHeK2PkC0ZJNNqvWVETd+keh8ZzXVKvMe93dJ9SC0zn0x8h9Q3ichgTkNDC8flp9MHMV1a473QiOPcrO6+SSzGm5YGL0saR9NKOCMMWo= 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=ORkjkVDD; arc=none smtp.client-ip=192.198.163.16 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="ORkjkVDD" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730222926; x=1761758926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=y0upCVuwoxT9d72GZhH8/7dZn6beeSrJGjp/BYFWoQs=; b=ORkjkVDDQXRmAJdg39QfVZPyXD0iQddWzVxP6wc3e7q7SLNFvceKKU9D Ym8RM2EgZjObDa7q6EyLfRW6pECzNkojoc7hRZ/koXpbzmH5ad6JW7CJd xvQESYyfLoZVtcRQlryZgxe18sYCVx7wFpdESBUpFZcUJ2IUbjWzPjrkG EJ3dWuMq36mBecsG0trrof10ryEbJ8yQirLleIe/zX23nx/KLnwI6OmD0 +h3rz9+f0SpVT+FFcHoD7o8DT5V+0kcjbseww43SjNiiUwP6ywftPMuP7 tiC4QTGqs7JFd0NuJlxoqLiRNhbbWJRfzim8J/52cKAy1dAlj4uaSQUah g==; X-CSE-ConnectionGUID: 421PWuKYTkWzT/HEdRD9Qw== X-CSE-MsgGUID: 0DQlIOecTmiAxd+I6+eqVA== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="17515699" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="17515699" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:40 -0700 X-CSE-ConnectionGUID: RdYFygGKQamJaMq+6/fmQQ== X-CSE-MsgGUID: YXzBzLS/RcGsdbhsZgnuMQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="81585613" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:40 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , 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 v8 6/7] x86/resctrl: Add write option to "mba_MBps_event" file Date: Tue, 29 Oct 2024 10:28:31 -0700 Message-ID: <20241029172832.93963-7-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029172832.93963-1-tony.luck@intel.com> References: <20241029172832.93963-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" 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 | 46 +++++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 1 + 3 files changed, 49 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5f3438ca9e2b..35483c6615b6 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 b9ba419e5c88..fc5585dc688f 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -518,6 +518,52 @@ 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 -ENXIO; + } 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 -ENXIO; + } else { + ret =3D -EINVAL; + } + + switch (ret) { + case -ENXIO: + rdt_last_cmd_printf("Unsupported event id '%s'\n", buf); + break; + case -EINVAL: + rdt_last_cmd_printf("Unknown event id '%s'\n", buf); + break; + } + + 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 3ba81963e981..6fa501ef187f 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1947,6 +1947,7 @@ static struct rftype res_common_files[] =3D { .name =3D "mba_MBps_event", .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 Mon Nov 25 05:51:40 2024 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 25A7E207A01; Tue, 29 Oct 2024 17:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222928; cv=none; b=g0N71gz5Wg4AbLlNdHSdHzOuXBKyrEEFExCZ0IS5Qt/uRcwwkOm3KQ5b+Tg1s/sqSLltXYXTbj7b955gYqjAQuewmQr6QA2wYYxwr7Fq6qntF2utVpyM+ToxwV/yCeCNfmzDRwUur+HzetRdW7NYjU3V2xUuSCpwWHj9icbNWqU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730222928; c=relaxed/simple; bh=9ogyyqXIQi/uuhL7kuz5NJmlYRlDjf87yhyhV6XKxhk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KCIiZ3DCZhv8gu1iIjpM8IVA10vzCX8fJywxjIr7um9lXVS8D3aODbEmZpxdiYj1tOsfILCjumGAAPA9r2NnqcpEkr0OZM27RNLGsD3BQidi4mTnhNr362K0wVtuiH31xYK05G3nBlF4GN4qrXrPjW5ywSyy5KzliGU/7qC4crg= 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=ZVzEA3m+; arc=none smtp.client-ip=192.198.163.16 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="ZVzEA3m+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1730222926; x=1761758926; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=9ogyyqXIQi/uuhL7kuz5NJmlYRlDjf87yhyhV6XKxhk=; b=ZVzEA3m+ElWqYEIZ3pZVllg7CLhLRqkW8EuLBmbe72pCIes9I00vdc1o zNyIS4hDmwIGyJbQ68cyJUlsu6KnvVaLsR6oPpIAkafSaBY2rmfw/JVau KICEGvbaOqarKgcO1bkfTmRhSLfmy4T39zViI5dWq95a+wdz5lTsfx6Cn 4c+jLeQDxQ3s+jB/Ponw89hkvDX7svw8JB0Yxb5tBkC9dYeP5cDyeQvHH QczZNCEWpTOt0Jth7yljMhPted1lOTVMKAbgfa6DcD2pB3AlAA4kYX55M wB9yzkEWP8hlxTY3aikThXDNvHwwMM/cV6zddT17mRXz6EAH4v2itOwAd g==; X-CSE-ConnectionGUID: c6cMI1pLSpaUl+LcrGOANg== X-CSE-MsgGUID: vmI3UB9oSCiSQIQ9fHymJw== X-IronPort-AV: E=McAfee;i="6700,10204,11240"; a="17515710" X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="17515710" Received: from fmviesa006.fm.intel.com ([10.60.135.146]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:40 -0700 X-CSE-ConnectionGUID: Gmx31W2JQuWsJkP81PRDSA== X-CSE-MsgGUID: ALxxAqEmRnGM8ug5OpYAKg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,241,1725346800"; d="scan'208";a="81585616" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 29 Oct 2024 10:28:40 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , 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 v8 7/7] x86/resctrl: Document the new "mba_MBps_event" file Date: Tue, 29 Oct 2024 10:28:32 -0700 Message-ID: <20241029172832.93963-8-tony.luck@intel.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241029172832.93963-1-tony.luck@intel.com> References: <20241029172832.93963-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" New read/write file to show/set 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..d86081e76bbf 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 a software feedback loop to keep 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/monfeatures will change the input + event. + Resource allocation rules ------------------------- =20 --=20 2.47.0