Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp272203lqb; Tue, 28 May 2024 15:21:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWEOB9PoRMnDCY/hWS5o/lnlswbSsvIr0V8orbDnqxzyERptPMTp9RExeQsX8wDd7qS+tuLdF+euojgfC8/KY7VQLoQflTttWtzQv4ddQ== X-Google-Smtp-Source: AGHT+IHfz2Rvnwk/QfA5MTz/Vv1gqfivHf8jwAu0Tt/OLC6yDW3RkH9vZJhOIggSyRwymjhxnThu X-Received: by 2002:a17:90b:ec4:b0:2bd:e8ca:d302 with SMTP id 98e67ed59e1d1-2bf5f51ad84mr13871939a91.37.1716934879243; Tue, 28 May 2024 15:21:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716934879; cv=pass; d=google.com; s=arc-20160816; b=WuR3B4ZX97OH/yh4XSc12h75OfXE/77ZdO8YHCdCUrnCsB3eMstm4xHWy/aapvspYq Cr7a9NXL1RqmnbFHv1eDBzDUZuPEXg7/5p3b6dJMfCH6qSG4GCkI/N7kiWqxs1jWvF3D 6TI4P0IY8ef6/LmtwYvkTMs1CGqwlH0kqN/jq4Wxz3a1PLOYwHIhXxdhd5re+x+tpEvS JUcING8qXsj+vcPh7t89dwrgN7xFgwEzv0rJP9fN8bDoHPfgdSjXp3ex/HbAQmxyq6+z di3TGARaZcV+ZjR73CDeLYYFlPWJcYfTbxqEDvyNxvPBXzuAZOfl+cOAXpBi4VdxrXya TEHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=E8jHZoFiHpqcxon/Kh2DIjJIik6Ji7rzldvL4XC/+uc=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=VdfjsUEiQs1/37p6QWKnYo/onsRGcnvIgBRtz6NNfOV7ZnlipHmMemMllKoT5AM28l pcTY2IERZAGPtFcjiqQMHwZ0Cv1/WnV6Ko6oYZw0eCdPNBzavZNn5b3Kwng+1WdoSHRB ohreV7R3Tk/Ar93hYPXQz5Kqbsjp4nyZJ9Z8rwGdhNU4v1RFKyR+9/Kx6Pc9o3bD6YgR eRbdaTPN4PSqO+547gQekhcqf1DSyz9o/RbwNoBLdmgjs7cBYbRhU9ieOKb9p+vgNEjw hxPcBCzWaFrj5fTGIS6z1Ofxn1sg7cSnYLoSCbfQPzuKOLtVKXpi2vcaVizd+NuM0joE gJXQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cGYlVMxZ; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193161-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bdd9ef31e0si10750547a91.71.2024.05.28.15.21.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 15:21:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193161-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=cGYlVMxZ; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-193161-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193161-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A7C7E2893C9 for ; Tue, 28 May 2024 22:21:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39BEC13FD79; Tue, 28 May 2024 22:20:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="cGYlVMxZ" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 5352813E8B8 for ; Tue, 28 May 2024 22:20:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934823; cv=none; b=WjwPjVSPOyeuR+1R12cpY5vW7OQFLvdZrdg5lKWxkVi/d5U8HckVVuY69qzmPPM6Uyya6kv9vFg+vDikDalUJ/oG3wPW0tKYhUhfrPf8yqKLFMyYZsDbrF6efV6nbmreOIkLPylgJcRlXxaSWfxv9ynj0zQ2hkqI5wYEHM7JO0s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934823; c=relaxed/simple; bh=+d/CfgoQlj3LxBdTbrw5ws4sh4DgcSjzzP45sdvMehw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MKoVDAmDW76W+bhDnV3lZiZttJrkIYhW5LKxAlcXMA7+ONBw86N2KShysgLY/6+HJyN4FUH+rpBTsiW0vv/+2ei3fIH4JwUyiXbM6oTt/KPeO1IDtHXybngGbMw539IF814E4DsJJk31GThEqaNHcGwD6H8U6j5U2a4GSXtjdpY= 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=cGYlVMxZ; arc=none smtp.client-ip=198.175.65.10 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1716934822; x=1748470822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+d/CfgoQlj3LxBdTbrw5ws4sh4DgcSjzzP45sdvMehw=; b=cGYlVMxZSWBNDqkWYq/qlYTYBePZ4XmmiFOABbjvf01k7jlNypJIjQrx d8TZZnEr9x/5az5ORbwLKQR4zi/T93PKei9wZENdY2BAsyqKxUFwa75yo UYSVDitrl1+bHUTBvrj+vm+ZXm7w1RL5lAdGzcvtdUtR4TPpwmLLV78rS BlNk0a64xlllivoGozZWSUCitipuEj01hmgm5hMFuMFs0iQYQHA8YJKrG wkpI6i3BhBNTa7+sQglayGdzApRJ7GkrJ/OO8soCI8I8oX31NGAQOMAQk gcfB/ekc6egvtk1P+jtEBau2R7dG77VyoQBPhLxq4PYL7NbFgNiSSc+UN Q==; X-CSE-ConnectionGUID: JH3GH2K+TQiRoqZVb9q88A== X-CSE-MsgGUID: Q2cst6ldS+W0ynGuVmPdkw== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="30812190" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="30812190" Received: from orviesa005.jf.intel.com ([10.64.159.145]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 15:20:17 -0700 X-CSE-ConnectionGUID: bPdrcfAJReCWsRhQlsr54g== X-CSE-MsgGUID: 5jyXBg9KQYuzN2lhzM44Wg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="40090734" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by orviesa005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2024 15:20:16 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini , Dave Martin Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v19 08/20] x86/resctrl: Prepare for new Sub-NUMA Cluster (SNC) monitor files Date: Tue, 28 May 2024 15:19:53 -0700 Message-ID: <20240528222006.58283-9-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240528222006.58283-1-tony.luck@intel.com> References: <20240528222006.58283-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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When SNC is enabled monitoring data is collected at the SNC node granularity, but must be reported at L3-cache granularity for backwards compatibility in addition to reporting at the node level. Add a "ci" field to the rdt_mon_domain structure to save the cache information about the enclosing L3 cache for the domain. This provides: 1) The cache id which is needed to compose the name of the legacy monitoring directory, and to determine which domains should be summed to provide L3-scoped data. 2) The shared_cpu_map which is needed to determine which CPUs can be used to read the RMID counters with the MSR interface. This is the first step to an eventual goal of monitor reporting files like this (for a system with two SNC nodes per L3): $ cd /sys/fs/resctrl/mon_data $ tree mon_L3_00 mon_L3_00 <- 00 here is L3 cache id ├── llc_occupancy \ These files provide legacy support ├── mbm_local_bytes > for non-SNC aware monitor apps ├── mbm_total_bytes / that expect data at L3 cache level ├── mon_sub_L3_00 <- 00 here is SNC node id │   ├── llc_occupancy \ These files are finer grained │   ├── mbm_local_bytes > data from each SNC node │   └── mbm_total_bytes / └── mon_sub_L3_01 ├── llc_occupancy \ ├── mbm_local_bytes > As above, but for node 1. └── mbm_total_bytes / Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 21 +++++++++++++++++++++ arch/x86/kernel/cpu/resctrl/core.c | 7 ++++++- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 1 - arch/x86/kernel/cpu/resctrl/rdtgroup.c | 1 - 5 files changed, 29 insertions(+), 3 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 64b6ad1b22a1..d733e1f6485d 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -96,6 +96,7 @@ struct rdt_ctrl_domain { /** * struct rdt_mon_domain - group of CPUs sharing a resctrl monitor resource * @hdr: common header for different domain types + * @ci: cache info for this domain * @rmid_busy_llc: bitmap of which limbo RMIDs are above threshold * @mbm_total: saved state for MBM total bandwidth * @mbm_local: saved state for MBM local bandwidth @@ -106,6 +107,7 @@ struct rdt_ctrl_domain { */ struct rdt_mon_domain { struct rdt_domain_hdr hdr; + struct cacheinfo *ci; unsigned long *rmid_busy_llc; struct mbm_state *mbm_total; struct mbm_state *mbm_local; diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 135190e0711c..eb70d3136ced 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -2,6 +2,7 @@ #ifndef _ASM_X86_RESCTRL_INTERNAL_H #define _ASM_X86_RESCTRL_INTERNAL_H +#include #include #include #include @@ -509,6 +510,26 @@ static inline bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level l) int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable); +/* + * Get the cacheinfo structure of the cache associated with @cpu at level @level. + * cpuhp lock must be held. + */ +static inline struct cacheinfo *get_cpu_cacheinfo_level(int cpu, int level) +{ + struct cpu_cacheinfo *ci = get_cpu_cacheinfo(cpu); + int i; + + for (i = 0; i < ci->num_leaves; i++) { + if (ci->info_list[i].level == level) { + if (ci->info_list[i].attributes & CACHE_ID) + return &ci->info_list[i]; + break; + } + } + + return NULL; +} + /* * To return the common struct rdt_resource, which is contained in struct * rdt_hw_resource, walk the resctrl member of struct rdt_hw_resource. diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index b86c525d0620..95ef8fe3cb50 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include @@ -608,6 +607,12 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) d = &hw_dom->d_resctrl; d->hdr.id = id; d->hdr.type = RESCTRL_MON_DOMAIN; + d->ci = get_cpu_cacheinfo_level(cpu, RESCTRL_L3_CACHE); + if (!d->ci) { + pr_warn_once("Can't find L3 cache for CPU:%d resource %s\n", cpu, r->name); + mon_domain_free(hw_dom); + return; + } cpumask_set_cpu(cpu, &d->hdr.cpu_mask); if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c index abec0d6d9476..20dd9076f89f 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -11,7 +11,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include #include #include #include diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 1cc4794d5a2e..13f93f2a55b3 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -12,7 +12,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -#include #include #include #include -- 2.45.0