Received: by 2002:ab2:715a:0:b0:1fd:c064:50c with SMTP id l26csp36167lqm; Mon, 10 Jun 2024 11:52:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU4xWgbbP8BXEbgFG8BCNfUHZQRlMUce9FKO71qsssadLlkCIaH9ShWNj1qThlxwHc3sKBq7+vYCuwQbmO+5ErNhLeJmOBxgFR536N1pA== X-Google-Smtp-Source: AGHT+IFw+Y8/EqW9cbHWtt+XLOxisrj1f36+99vnaoZQCPJEnHoko3lEcUc68Jwet3OrsdzELWrV X-Received: by 2002:a05:6358:910e:b0:19f:5317:49a1 with SMTP id e5c5f4694b2df-19f53174cddmr405894655d.28.1718045557553; Mon, 10 Jun 2024 11:52:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718045557; cv=pass; d=google.com; s=arc-20160816; b=oxxRdaaLM4CijcSICUgijp35FSXiesgB7FnxhJ+KsNj3dgE6p41ZW3tdhMbjupMkye ptTYJp9WEyBUF9c7OKALEkrBCPDziGlcFzqcgk5L2nF0BNLW4Mnr4ePMDMUT3afPojLD Cc0hlwoov+/Vmv4C3XsOIZpsVI3EJj5PRRDUskHAYK3iukwawQDSQw/l2GkY8x4vYnQu TvLv0pGaTvefnIgks0CNfW6Pcb5Q+Zb3XW01/+9ljtHyoXGcJhRlneaadM5HiAhB4hyz pKje7k7XmYSHG1c+pD/85T+MaidJhPArDykfFSm1ELAhE0W2b/Fwae7/fN2lrqqcd+2s XHpw== 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=2hbXvWNtohVsRSm63+pyrRpNUV5Cnh4ttrxhlAkLvwE=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=lc2+Yu0q1Cl3Fh17oJLo4xeZVDnydFSZtyCSm9ROeyC69vexhy7QaD6C6NpYCAcAfW Qs2y5QUParYIJDI7iMkg3+LSM5/nhewND9P47reptYU10QKX6N0kmN3YAtyMDNVm5re4 qR+rA8ESHStLcg9pHyFjInHRM11hLdoX3r+e8lwgW8ry+iXUIUiASV2wIoi9gEA0vKJp 6rY4eo52QEd/km+Fo/olYr2cQ10vk2IolqLQLL+MFpTpZ+YvpWz9Z7LqLv+L4GiZFeXb IlX4M2kkDF94jiMSVgq5NjpZzIHQml2klbonQkzALwj9enxp9AP01qwZNqNQYNP9TtYX q4tw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gx8EXh8O; 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-208759-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208759-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6de2760647esi4863524a12.515.2024.06.10.11.52.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 11:52:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-208759-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=gx8EXh8O; 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-208759-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-208759-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7B5B0B249DA for ; Mon, 10 Jun 2024 18:39:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2B518155726; Mon, 10 Jun 2024 18:35:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="gx8EXh8O" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.16]) (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 E41B4153BC1 for ; Mon, 10 Jun 2024 18:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.16 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718044554; cv=none; b=VThzn/SU1NhKPitFf4WHyXPe12+Fnmou2L6cvAqASLthg0nNk+w6+MeKZn9uh7oAXfBgEs43RXz79kBcbQ1cR0z9cxIiCUaDIBWnutDYok/dTKEnkUs6d5xnGMIA+NOl6zUWLGuwZuOGTxc8mI744LacRWEQgts9Rs2ud18aFIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718044554; c=relaxed/simple; bh=4kgVh6lNLSXJ4fIrrvYFPzPnsVi3AEm2XGNURKg5z3k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VHKOuZQuoOOP1mfQ1PiEIrPZIn+xoFlgTsRolOgc49V2ZXUXy/u5lEmiKkL7OT1gWKl0o7f/HKSyZ1C7y8Ljxg4wnyLDf3S3CXdSZ9PUbGK9y+rCxeHaL1g0SqFJRUFmR5mX8PB5mJtGETCUpo6B0d8xRAnI7yOChl99ctScIKs= 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=gx8EXh8O; arc=none smtp.client-ip=192.198.163.16 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=1718044552; x=1749580552; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4kgVh6lNLSXJ4fIrrvYFPzPnsVi3AEm2XGNURKg5z3k=; b=gx8EXh8OqATztnXUPP69CqohwM4qPr5BYCZm44S2AyKfNoZAQkZp3XaT Ipm74olrurjiBisr86AEtJvmm1KHRirexj2gpvKp7ZaXCnADMVGSCGwbb glDOGV9guEYM0nuk5GV4/7nFyJBZb/KLvRZbUBZoOm1Z+pZXjZ/8wo+dE JRgPwZXpfgmUC1Sg4aQc+BM3zgv6iax/NNJSpeawL4F8K8PMf9af2kkl+ AB6NJWaHejlYlgJ5Ki1PpvANy94tVcYCljxmg3mwWseSwvg0TN51IMdoa S5/Gye4VTej9vgtx1ZwfIzwiyUuhTsqVXheJm2DAMkTSkE7Pnby69OpWi w==; X-CSE-ConnectionGUID: 4+24gEsgRledsKFq1S7mdg== X-CSE-MsgGUID: rHKWZqgOThWG69/A+ZCs4w== X-IronPort-AV: E=McAfee;i="6600,9927,11099"; a="12004880" X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="12004880" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa110.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 11:35:39 -0700 X-CSE-ConnectionGUID: owF1COTiR8umn1SByGQ+xQ== X-CSE-MsgGUID: FDPv9XF8QT2ez7U2uJaGig== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,227,1712646000"; d="scan'208";a="43576601" Received: from agluck-desk3.sc.intel.com ([172.25.222.70]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Jun 2024 11:35:39 -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 v20 16/18] x86/resctrl: Enable RMID shared RMID mode on Sub-NUMA Cluster (SNC) systems Date: Mon, 10 Jun 2024 11:35:26 -0700 Message-ID: <20240610183528.349198-17-tony.luck@intel.com> X-Mailer: git-send-email 2.45.0 In-Reply-To: <20240610183528.349198-1-tony.luck@intel.com> References: <20240610183528.349198-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-Transfer-Encoding: 8bit Hardware has two RMID configuration options for SNC systems. The default mode divides RMID counters between SNC nodes. E.g. with 200 RMIDs and two SNC nodes per L3 cache RMIDs 0..99 are used on node 0, and 100..199 on node 1. This isn't very compatible with Linux resctrl usage. On this example system a process using RMID 5 would only update monitor counters while running on SNC node 0. The other mode is "RMID Sharing Mode". This is enabled by clearing bit 0 of the RMID_SNC_CONFIG (0xCA0) model specific register. In this mode the number of logical RMIDs is the number of physical RMIDs (from CPUID leaf 0xF) divided by the number of SNC nodes per L3 cache instance. A process can use the same RMID across different SNC nodes. See the "Intel Resource Director Technology Architecture Specification" for additional details. When SNC is enabled, update the MSR when a monitor domain is marked online. Tehcnically this is overkill. It only needs to be done once per L3 cache instance rather than per SNC domain. But there is no harm in doing it more than once, and this is not in a critical path. Signed-off-by: Tony Luck --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 2 ++ arch/x86/kernel/cpu/resctrl/monitor.c | 26 ++++++++++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index e022e6eb766c..3cb8dd6311c3 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1164,6 +1164,7 @@ #define MSR_IA32_QM_CTR 0xc8e #define MSR_IA32_PQR_ASSOC 0xc8f #define MSR_IA32_L3_CBM_BASE 0xc90 +#define MSR_RMID_SNC_CONFIG 0xca0 #define MSR_IA32_L2_CBM_BASE 0xd10 #define MSR_IA32_MBA_THRTL_BASE 0xd50 diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 75bb1afc4842..324cf05858f5 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -529,6 +529,8 @@ 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); +void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d); + /* * 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 95ef8fe3cb50..1930fce9dfe9 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -615,6 +615,8 @@ static void domain_add_cpu_mon(int cpu, struct rdt_resource *r) } cpumask_set_cpu(cpu, &d->hdr.cpu_mask); + arch_mon_domain_online(r, d); + if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { mon_domain_free(hw_dom); return; diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index c4d9a8df8d2d..efbb84c00d79 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1082,6 +1082,32 @@ static void l3_mon_evt_init(struct rdt_resource *r) list_add_tail(&mbm_local_event.list, &r->evt_list); } +/* + * The power-on reset value of MSR_RMID_SNC_CONFIG is 0x1 + * which indicates that RMIDs are configured in legacy mode. + * This mode is incompatible with Linux resctrl semantics + * as RMIDs are partitioned between SNC nodes, which requires + * a user to know which RMID is allocated to a task. + * Clearing bit 0 reconfigures the RMID counters for use + * in Sub-NUMA Cluster mode. This mode is better for Linux. + * The RMID space is divided between all SNC nodes with the + * RMIDs renumbered to start from zero in each node when + * counting operations from tasks. Code to read the counters + * must adjust RMID counter numbers based on SNC node. See + * logical_rmid_to_physical_rmid() for code that does this. + */ +void arch_mon_domain_online(struct rdt_resource *r, struct rdt_mon_domain *d) +{ + u64 val; + + if (snc_nodes_per_l3_cache == 1) + return; + + rdmsrl(MSR_RMID_SNC_CONFIG, val); + val &= ~BIT_ULL(0); + wrmsrl(MSR_RMID_SNC_CONFIG, val); +} + int __init rdt_get_mon_l3_config(struct rdt_resource *r) { unsigned int mbm_offset = boot_cpu_data.x86_cache_mbm_width_offset; -- 2.45.0