Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp695095rdh; Thu, 26 Oct 2023 13:02:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEjEMm80fxIVIhpjVV3zUJNA+lXRVro0Usg575Uy2F+Pm6a9DS/+tU5tYNkm5ewIr2sMKya X-Received: by 2002:a05:6902:1204:b0:d7b:90c6:683c with SMTP id s4-20020a056902120400b00d7b90c6683cmr566130ybu.26.1698350576140; Thu, 26 Oct 2023 13:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698350576; cv=none; d=google.com; s=arc-20160816; b=t2p36rANSxOoPlmxejXw/3Q+rPLizcV4eZPo57gCur9t4orNqgmjwMfHLzK7od/sKk xnWVOH7rHhArONMPVxXeKKfdiMoOxGAAq92WMSpAAOO+3ayLP/Pp0toDL6puM7B4a/Jw SCxjSE+ASB39oU//BghIoc6zCgojqUIjHmjYXqJVqEYUPVM81jGNBtVyhsK7ysy/S0im Ni2LyGPWyZ7/jst2OW1reNd9pQJUPQJ/8tDHE7+h2nNwxwSDWgaa6JI8kSoYyfsWEtc9 YRNBlTYSdA9ZSo6LhpWERthGAqT1rDEeXOuxvif0ggh9y7fR9DRfRRam95TV1FSCLBTG xR+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xwZePk5WOLqPYQAHPNAgxuUFYdByNJynoBnszeqeDmQ=; fh=EIH9XAmicvPIUSP7TBeBhZ/WaoqG49JQ3xV1i3Gl7Co=; b=VdIwY9NDBjt3cZka1HGpqRXwh98dYlAFWu/QchThz/YsYI+a3j4pIRAOIqo4XGY039 pca3j1LzBwpeZF3pe9bLjtN6G9FAbMt1oeeJldSeEsQWQf9iXk/1bgd513uyP6RbDZE2 UpSJzMt00YisLER6YNRaFn1FTFfuxKpDgWRuQU3qxg9yZ0DrgoYX6UteshfRKTKKTd03 sWEXp+XRPLI2ZnCCGA10ZHNOsHaZyHHO2oocKur0XkFLqAFGEm+5USxEI8DIJ+a7pmk8 eAzEwvfuWSyOWkJO9MCp2IqCFgR9bYbMn2qqLmwrw78qhFJ2UdIAqin2/rJNx4zHxDBx Xykg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="V3KiXJ/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id 130-20020a250188000000b00da0c9bc5873si185072ybb.356.2023.10.26.13.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 13:02:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="V3KiXJ/Y"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 200F4825A194; Thu, 26 Oct 2023 13:02:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344738AbjJZUC3 (ORCPT + 99 others); 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: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 26 Oct 2023 13:02:52 -0700 (PDT) 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/resctrl/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_read *rr) return 0; } +/* + * 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_read *rr) */ static void mbm_bw_count(u32 rmid, struct rmid_read *rr) { - struct mbm_state *m = &rr->d->mbm_local[rmid]; + enum resctrl_event_id mba_mbps_evt_id = pick_mba_mbps_event(); u64 cur_bw, bytes, cur_bytes; + struct mbm_state *m; + m = get_mbm_state(rr->d, rmid, mba_mbps_evt_id); cur_bytes = rr->val; bytes = cur_bytes - m->prev_bw_bytes; m->prev_bw_bytes = cur_bytes; @@ -518,6 +534,7 @@ void mon_event_count(void *info) */ static void update_mba_bw(struct rdtgroup *rgrp, struct rdt_domain *dom_mbm) { + enum resctrl_event_id mba_mbps_evt_id = 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, struct rdt_domain *dom_mbm) struct list_head *head; struct rdtgroup *entry; - if (!is_mbm_local_enabled()) + if (!is_mbm_enabled()) return; r_mba = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; closid = rgrp->closid; rmid = rgrp->mon.rmid; - pmbm_data = &dom_mbm->mbm_local[rmid]; + pmbm_data = get_mbm_state(dom_mbm, rmid, mba_mbps_evt_id); dom_mba = 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 = &rgrp->mon.crdtgrp_list; list_for_each_entry(entry, head, mon.crdtgrp_list) { - cmbm_data = &dom_mbm->mbm_local[entry->mon.rmid]; + cmbm_data = get_mbm_state(dom_mbm, entry->mon.rmid, mba_mbps_evt_id); cur_bw += cmbm_data->prev_bw; delta_bw += 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 = true; list_for_each_entry(entry, head, mon.crdtgrp_list) { - cmbm_data = &dom_mbm->mbm_local[entry->mon.rmid]; + cmbm_data = get_mbm_state(dom_mbm, entry->mon.rmid, mba_mbps_evt_id); cmbm_data->delta_comp = true; } } @@ -621,15 +638,15 @@ static void mbm_update(struct rdt_resource *r, struct rdt_domain *d, int rmid) rr.evtid = QOS_L3_MBM_LOCAL_EVENT_ID; rr.val = 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); } /* diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/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 = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; - return (is_mbm_local_enabled() && + return (is_mbm_enabled() && r->alloc_capable && is_mba_linear()); } -- 2.41.0