From patchwork Thu Jul 13 16:32:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 120040 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp1963881vqm; Thu, 13 Jul 2023 10:06:59 -0700 (PDT) X-Google-Smtp-Source: APBJJlGV9n8e7EFMIq54rzIhwTNhHGl2Hbw4U5Tnypdeb1//FzclkWacuFvXqBlE+QnCFCsJmV/f X-Received: by 2002:a05:6512:370b:b0:4f8:7503:203f with SMTP id z11-20020a056512370b00b004f87503203fmr1467735lfr.48.1689268017791; Thu, 13 Jul 2023 10:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689268017; cv=none; d=google.com; s=arc-20160816; b=HDZDINDrr47WWX7//48kdJY7zWfwVQtkh5YwSwgJiHXYgqSl0nINpYa48FIbrjdnlp uyH0pE9s93owYZiHCk2YYEbeWI/PnqusMzbD3pkIZD0Q7S/1XF0sh+f+X8k8XufZL47F KI9CCQ+M4J8NGP3QXV95qbPO7IGbTsGndxhTTOOmh+ed3xmYa1yUAxOVsrVckx3YB5Vg Rd3uYaiGK7Z4LMc8bpJtDGLzRyiEWinJu54QC3xcjrMYGVCuoNkogu6/7pBuACaggEzA 05JrhSOPBmJrl9pXO7AHAvoB0bVilz1tO5cX5NW8R+1pCnJF7U24ReUJPz98sTOxYdCw 04TQ== 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=YM5JFCi9gXNtwCzz9xLLZVCFSlKhTBwJVLZEcbvz0H8=; fh=g0WKEVDdB8sQamShH39vSa8SoB8TDPrv8hO7zbxV08s=; b=DgfZL1goVS5FoWofnAvN7qDOa0/w3C5CB90fwmArlGkdoATzSknr7s7WNJ0tWXMtt6 h3orcFFVvsfdc0OYcAwJHYzdDsXV45wNVN93EnmtFwqxzJhdyoizFUa7zDzfGfiFhabR EukJFXmeKEqAYQIqOA6gW962srwXGA8DceDTJoRKqXQX/VVNlB5mPHV9gn4rsMg5nMC7 ExnEARY+5dLIQL/XrnvGcDZkylBVtPDVo9eSVXHHgKamzbR0qvUZ9/MC1oQL4OyRM+WM hPYotc1TuxU3e4/KiyTXDjG0Uart9GphQr9Mub1gk7IxE6AMBew9ga6TVbtfWVjOqazV ok1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TVF+kkA5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf20-20020a0564021a5400b0051878e08975si7246332edb.441.2023.07.13.10.06.23; Thu, 13 Jul 2023 10:06:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TVF+kkA5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231799AbjGMQcg (ORCPT + 99 others); Thu, 13 Jul 2023 12:32:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230166AbjGMQcd (ORCPT ); Thu, 13 Jul 2023 12:32:33 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F6472719; Thu, 13 Jul 2023 09:32:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689265952; x=1720801952; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UfMNDGqaFTdJ9acHmvMM5A8aK/ToJAVWU+2PC7nhIQo=; b=TVF+kkA5oUzSy4xh2J+maOj5HuzcGk/qeewYdQ5jvWUnXNBrrV55pHg8 G6bFI7DY4LHFyBym8Ao4ymUqHE7F3ZlG0a6U8u2Py2BXySGbuu6NK5EaK IcsXgVLBfufYJbU82aVAMcpsISqhlsJdrmhueelrCzES/TNZZKn+Ewwpw o7aCAMghIoIKJIsQqByfKKix6rRN+meOoFenma4vDayNxdTf5kONgKhuv gAE8DJa0gT4+/oMZ02bOk/CItGkdbk0bjy/DFYLGUjluN/LbNJ3jvUAk3 9YazBwI63CAdjLEDg6/K+pBN8iv2eMRezW1jXMZWV0cb1IaugKDBC0TXG g==; X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="362707607" X-IronPort-AV: E=Sophos;i="6.01,203,1684825200"; d="scan'208";a="362707607" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 09:32:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="722046373" X-IronPort-AV: E=Sophos;i="6.01,203,1684825200"; d="scan'208";a="722046373" Received: from agluck-desk3.sc.intel.com ([172.25.222.74]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 09:32:22 -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 2/8] x86/resctrl: Remove hard code of RDT_RESOURCE_L3 in monitor.c Date: Thu, 13 Jul 2023 09:32:01 -0700 Message-Id: <20230713163207.219710-3-tony.luck@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713163207.219710-1-tony.luck@intel.com> References: <20230713163207.219710-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771325901121066244 X-GMAIL-MSGID: 1771325901121066244 Scope of monitoring may be scoped at L3 cache granularity (legacy) or at the node level (systems with Sub NUMA Cluster enabled). Save the struct rdt_resource pointer that was used to initialize the monitor sections of code and use that value instead of the hard-coded RDT_RESOURCE_L3. No functional change. Signed-off-by: Tony Luck Reviewed-by: Peter Newman --- arch/x86/kernel/cpu/resctrl/monitor.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index ded1fc7cb7cb..9be6ffdd01ae 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -30,6 +30,8 @@ struct rmid_entry { struct list_head list; }; +static struct rdt_resource *mon_resource; + /** * @rmid_free_lru A least recently used list of free RMIDs * These RMIDs are guaranteed to have an occupancy less than the @@ -268,7 +270,7 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, */ void __check_limbo(struct rdt_domain *d, bool force_free) { - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r = mon_resource; struct rmid_entry *entry; u32 crmid = 1, nrmid; bool rmid_dirty; @@ -333,7 +335,7 @@ int alloc_rmid(void) static void add_rmid_to_limbo(struct rmid_entry *entry) { - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r = mon_resource; struct rdt_domain *d; int cpu, err; u64 val = 0; @@ -645,7 +647,7 @@ void cqm_handle_limbo(struct work_struct *work) mutex_lock(&rdtgroup_mutex); - r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + r = mon_resource; d = container_of(work, struct rdt_domain, cqm_limbo.work); __check_limbo(d, false); @@ -681,7 +683,7 @@ void mbm_handle_overflow(struct work_struct *work) if (!static_branch_likely(&rdt_mon_enable_key)) goto out_unlock; - r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + r = mon_resource; d = container_of(work, struct rdt_domain, mbm_over.work); list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { @@ -759,9 +761,9 @@ static struct mon_evt mbm_local_event = { /* * Initialize the event list for the resource. * - * Note that MBM events are also part of RDT_RESOURCE_L3 resource - * because as per the SDM the total and local memory bandwidth - * are enumerated as part of L3 monitoring. + * Monitor events can either be part of RDT_RESOURCE_L3 resource, + * or they may be per NUMA node on systems with sub-NUMA cluster + * enabled and are then in the RDT_RESOURCE_NODE resource. */ static void l3_mon_evt_init(struct rdt_resource *r) { @@ -773,6 +775,8 @@ static void l3_mon_evt_init(struct rdt_resource *r) list_add_tail(&mbm_total_event.list, &r->evt_list); if (is_mbm_local_enabled()) list_add_tail(&mbm_local_event.list, &r->evt_list); + + mon_resource = r; } int __init rdt_get_mon_l3_config(struct rdt_resource *r)