From nobody Tue Dec 16 16:37:08 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D5C3DC25B48 for ; Thu, 26 Oct 2023 20:02:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344696AbjJZUC3 (ORCPT ); Thu, 26 Oct 2023 16:02:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231841AbjJZUC2 (ORCPT ); Thu, 26 Oct 2023 16:02:28 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5EAC41B3; Thu, 26 Oct 2023 13:02:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698350546; x=1729886546; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wjSZygfJTLzc3CEGzIuqI0B49Tz5lLOHyJHjqouS46w=; b=V3KiXJ/YNgh7JwSyWDIUJyLFVNNQXBMQyA1ycuYEKDN5PRJk6vKBEBfB XD5CHA2iSfTUQDNhqw7YldjtPc2hkbFK1NBwBVd04JU0UnCIgPZ5RGLZE bjH+zrnUO/kee3yyO8oeUGKhCF4IfM6ELqRmuE/8AS1GXGKq5plpJ2NoY j5oCzzdP/KBzblS7EgiIHrK5glBoQTmbjUL0PKLqjHFoCZTK5H9soGvND PMPe5PQsy8pkWoZZPpVCP46PwRUCRM03Zb6m4BJpR143Bl+yt8qcuWpz8 Y+HEPOb+dQYyBWH0x3uSvSIwiI5COnRiPrCjfOrHVeqSCZavWBSDCQsVW Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="367850590" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="367850590" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 13:02:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10875"; a="903034800" X-IronPort-AV: E=Sophos;i="6.03,254,1694761200"; d="scan'208";a="903034800" Received: from agluck-desk3.sc.intel.com ([172.25.222.74]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Oct 2023 12:59:58 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , Randy Dunlap , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3] x86/resctrl: mba_MBps: Fall back to total b/w if local b/w unavailable Date: Thu, 26 Oct 2023 13:02:14 -0700 Message-ID: <20231026200214.16017-1-tony.luck@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231025235046.12940-1-tony.luck@intel.com> References: <20231025235046.12940-1-tony.luck@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Intel the various resource director technology (RDT) features are all orthogonal and independently enumerated. Thus it is possible to have a system that provides "total" memory bandwidth measurements without providing "local" bandwidth measurements. If local bandwidth measurement is not available, do not give up on providing the "mba_MBps" feedback option completely, make the code fall back to using total bandwidth. Signed-off-by: Tony Luck --- Change since v2: Babu doesn't like the global variable. So here's a version without it. Note that my preference is still the v2 version. But as I tell newbies to Linux "Your job isn't to get YOUR patch upstream. You job is to get the problem fixed.". So taking my own advice I don't really mind whether v2 or v3 is applied. arch/x86/kernel/cpu/resctrl/monitor.c | 43 ++++++++++++++++++-------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index f136ac046851..29e86310677d 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -418,6 +418,20 @@ static int __mon_event_count(u32 rmid, struct rmid_rea= d *rr) return 0; } =20 +/* + * For legacy compatibility use the local memory bandwidth to drive + * the mba_MBps feedback control loop. But on platforms that do not + * provide the local event fall back to use the total bandwidth event + * instead. + */ +static enum resctrl_event_id pick_mba_mbps_event(void) +{ + if (is_mbm_local_enabled()) + return QOS_L3_MBM_LOCAL_EVENT_ID; + + return QOS_L3_MBM_TOTAL_EVENT_ID; +} + /* * mbm_bw_count() - Update bw count from values previously read by * __mon_event_count(). @@ -431,9 +445,11 @@ static int __mon_event_count(u32 rmid, struct rmid_rea= d *rr) */ static void mbm_bw_count(u32 rmid, struct rmid_read *rr) { - struct mbm_state *m =3D &rr->d->mbm_local[rmid]; + enum resctrl_event_id mba_mbps_evt_id =3D pick_mba_mbps_event(); u64 cur_bw, bytes, cur_bytes; + struct mbm_state *m; =20 + m =3D get_mbm_state(rr->d, rmid, mba_mbps_evt_id); cur_bytes =3D rr->val; bytes =3D cur_bytes - m->prev_bw_bytes; m->prev_bw_bytes =3D cur_bytes; @@ -518,6 +534,7 @@ void mon_event_count(void *info) */ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mb= m) { + enum resctrl_event_id mba_mbps_evt_id =3D pick_mba_mbps_event(); u32 closid, rmid, cur_msr_val, new_msr_val; struct mbm_state *pmbm_data, *cmbm_data; u32 cur_bw, delta_bw, user_bw; @@ -526,14 +543,14 @@ static void update_mba_bw(struct rdtgroup *rgrp, stru= ct rdt_domain *dom_mbm) struct list_head *head; struct rdtgroup *entry; =20 - if (!is_mbm_local_enabled()) + if (!is_mbm_enabled()) return; =20 r_mba =3D &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; =20 closid =3D rgrp->closid; rmid =3D rgrp->mon.rmid; - pmbm_data =3D &dom_mbm->mbm_local[rmid]; + pmbm_data =3D get_mbm_state(dom_mbm, rmid, mba_mbps_evt_id); =20 dom_mba =3D get_domain_from_cpu(smp_processor_id(), r_mba); if (!dom_mba) { @@ -553,7 +570,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct= rdt_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->mon.rmid, mba_mbps_evt_id); cur_bw +=3D cmbm_data->prev_bw; delta_bw +=3D cmbm_data->delta_bw; } @@ -595,7 +612,7 @@ static void update_mba_bw(struct rdtgroup *rgrp, struct= rdt_domain *dom_mbm) */ pmbm_data->delta_comp =3D true; 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->mon.rmid, mba_mbps_evt_id); cmbm_data->delta_comp =3D true; } } @@ -621,15 +638,15 @@ static void mbm_update(struct rdt_resource *r, struct= rdt_domain *d, int rmid) rr.evtid =3D QOS_L3_MBM_LOCAL_EVENT_ID; rr.val =3D 0; __mon_event_count(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(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(rmid, &rr); } =20 /* diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 69a1de92384a..0c4f8a1b8df0 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2294,7 +2294,7 @@ static bool supports_mba_mbps(void) { 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()); } =20 --=20 2.41.0