From patchwork Tue Oct 24 18:16:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 157659 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:ce89:0:b0:403:3b70:6f57 with SMTP id p9csp2123501vqx; Tue, 24 Oct 2023 11:16:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEiVaVq97gtJhuycXLaNDu6P/c2ncu0q58/jBVeBPjIDtW2HTq7FyeMYA12jNdDQ/Y5ilgW X-Received: by 2002:a05:6a20:7d9f:b0:140:6979:295d with SMTP id v31-20020a056a207d9f00b001406979295dmr3719643pzj.2.1698171393601; Tue, 24 Oct 2023 11:16:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698171393; cv=none; d=google.com; s=arc-20160816; b=MrFw6gjIKJs6i1qVvQPiZw2yIO5GnS1DDkvRkim5cDo49x9cO/VTVVLAOEwhUrTdix Z35AQG2tI8PfSyWXXGJlFvTg56Zk3baAF4CmNfB2LF2oHvZydZipkYHd/aR/X8JlyCEt 1b0fFDSu4RgCZEtq2KKZoseyhYdA0iMZUX+3jDWBgrigchcl7iHWz6CaYho74eQpFLl3 dDBFTNAd/kA0u5SS1R0O7wD650itJgqsYHlsV+nNbJ2Zu5WbkHsN/fcMEWNO2xaPZADD n0RysTYOOtjRToyruxfRVPywflRVoBeDIHcXrEybxr1DtS23J3JesSDaCK4iA/ENpbxw u/2Q== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=hF4jKK4yVeensVN6kOSt8kxHxE8w39x9PDsBl7IN/oo=; fh=EIH9XAmicvPIUSP7TBeBhZ/WaoqG49JQ3xV1i3Gl7Co=; b=teNtZlCgsKNMpkfCGDucIYfh32S25nFx6EwBPFVIFiOThpd4bUFPLuB5U9Lg4OVa2g 3nSIPXmf+A3JmJK9oie0XCTo1HdrApS9jNMooDXVQ/wTOCDpbVOXnY2yrpu/LkdB87T2 D+sGbUwdhId4ZVsI5/XA39XnyF4e6600EpNXYIyXi8SgtwtO3zpON3GLc6yMjUybqcRE A63svLOtY5ipgDG1j4YeO+gEdWjrqhTxedgkj5zZhWbq6mRsvvhb8Mfw8+M4TYfLDlzQ BMGpDnwddWLVv7GI3Bt/+/F0gssjCp/voGztUO5L7P41ferAINIG4JS16S9VW+NUrDoe eRhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gewH5H9i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id r11-20020a63204b000000b005aa46216af6si8545930pgm.719.2023.10.24.11.16.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Oct 2023 11:16:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gewH5H9i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 7EFCA8024DD4; Tue, 24 Oct 2023 11:16:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234864AbjJXSQM (ORCPT + 27 others); Tue, 24 Oct 2023 14:16:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232399AbjJXSQK (ORCPT ); Tue, 24 Oct 2023 14:16:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62913111; Tue, 24 Oct 2023 11:16:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698171368; x=1729707368; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=svJxEnxlJxMe9ykA9n2RRTqPvoiO12Rhjx+c7UZ7Qtc=; b=gewH5H9ihy2gCNJ9HyFVF7TAbx+K/QiMkUiPFKPLq4yq7o3p6iC3cfxS 1+Ye9JVnFZb8GKOPE8fQS6cs0vumIbpl4c1RETdXwabX1rMblyiWLyYmH uWFpGP/mqNi9NTJHsE4cpH9lJJqHm2L1YzyLNpzsNMLuUR62ACOgMyNdw vFs8KtKZy6RiOi9SwDAKUk8dqAkzsHnVXkOVI5fj/rs5mTVjTliIJVS0F bgsceP62o8vNu4teXnIsJ6dXcuXAFIawVTFLG7jGMJ5JGEkS254M8i/BG xgk0jVWGXOAnGRcJ+ummVixTeIPlOKs+xixJaZylHz34vXFwfEx4Wnx6P Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="8684419" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="8684419" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 11:16:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10873"; a="1089950438" X-IronPort-AV: E=Sophos;i="6.03,248,1694761200"; d="scan'208";a="1089950438" Received: from agluck-desk3.sc.intel.com ([172.25.222.74]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Oct 2023 11:16:07 -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] x86/resctrl: mba_MBps: Fall back to total b/w if local b/w unavailable Date: Tue, 24 Oct 2023 11:16:00 -0700 Message-ID: <20231024181600.8270-1-tony.luck@intel.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 24 Oct 2023 11:16:31 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780661767199268732 X-GMAIL-MSGID: 1780661767199268732 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 Reviewed-by: Peter Newman --- arch/x86/kernel/cpu/resctrl/monitor.c | 34 ++++++++++++++++---------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index f136ac046851..3b9531cce807 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -418,6 +418,14 @@ static int __mon_event_count(u32 rmid, struct rmid_read *rr) return 0; } +static struct mbm_state *get_mbm_data(struct rdt_domain *dom_mbm, int rmid) +{ + if (is_mbm_local_enabled()) + return &dom_mbm->mbm_local[rmid]; + + return &dom_mbm->mbm_total[rmid]; +} + /* * mbm_bw_count() - Update bw count from values previously read by * __mon_event_count(). @@ -431,7 +439,7 @@ 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]; + struct mbm_state *m = get_mbm_data(rr->d, rmid); u64 cur_bw, bytes, cur_bytes; cur_bytes = rr->val; @@ -526,14 +534,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_data(dom_mbm, rmid); dom_mba = get_domain_from_cpu(smp_processor_id(), r_mba); if (!dom_mba) { @@ -553,7 +561,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_data(dom_mbm, entry->mon.rmid); cur_bw += cmbm_data->prev_bw; delta_bw += cmbm_data->delta_bw; } @@ -595,7 +603,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_data(dom_mbm, entry->mon.rmid); cmbm_data->delta_comp = true; } } @@ -621,15 +629,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()); }