Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp273219lqb; Tue, 28 May 2024 15:23:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVmRXQzRmwL7wlwTUP4VuVdFFVXqIOLMU9/9qJayyCi3CCDJ051FJQhV/9eT6SXqLq0Lu4Rarn1VDXmvA4xMMnF4IrpYQdC6x3Fr0VpMg== X-Google-Smtp-Source: AGHT+IGedeI89/hfjc+mFXX1OCDXUHJXBvpKXz9lfd9HYZliYFZVyPxpVzysJbUlDfhg62al18/d X-Received: by 2002:a2e:9b0a:0:b0:2e5:67a8:10e1 with SMTP id 38308e7fff4ca-2e95b093950mr79184141fa.17.1716935008301; Tue, 28 May 2024 15:23:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716935008; cv=pass; d=google.com; s=arc-20160816; b=X8grUmPrmw7Oh79tMk3LYDxeIkwclSEoqdeIKXVsib29UB18fh+263LnrW/H8gIfe5 zmjt0D4q4sw9z4ZVwHLhjsFjeTZ6rhgZHIkayGBVmprPWh5oJtnXcUKt9KoZZBwyq6Mi dlkDxxPRRvYSWV1ympAjwgolwTWItKPSs+6DDB43iEJKvMkOpP0sSaan44JKBHCEFcjR LrHwD/rq4w8T2s01PtjDw0dMOhexfDYdfg+k+aDa535eUHIl53A1Xgc40m9w+2siCoa0 7CchQuxEQTnvUCdmt7d7Gw+S+CniHSybf45vQ10OR94+bbuIemchXwUxWzC2f047YVwg PX6A== 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=s/c2hkviFEMXHHvdYZ76YlC/cBxtMHFSVZO3wB6+9mU=; fh=qTx768JYq6oxdX3jfjUzjJGF83d0IKGtQzHdow3lchk=; b=oPpTB48M/py5MgWLhPTgwXx7BI5y6xLN9PXmEOsaW3cZsBWP8i01DojN0JhBDj53mZ QXDiJ8bxwC3CpnlQvKhoIcJTvczZvVCcJycUbQo0CiQWquUbZoeiaDAYsdV8bIatddmv MJJePliTU8aem4OlIpqwK5wIgzOJn7x9bH+G1CMAlIOL1eVf0WKnE7bAnA3/axV5Yuh/ 5TfxX738U6ArG5dCyf/a1CTZ8vfOuhXJP6ktgc4JQxhzYidUpF0FlSc6cZFfraaPjWQG V5oJYe/62EZ1+eLUMfTifp6zaBcBr/mEioUP2zLrLfg2P4YWWPK4PNX3uSCSJww+CQTP 0U1g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="U7en//bj"; 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-193172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193172-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-57852330fedsi5692394a12.111.2024.05.28.15.23.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 15:23:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-193172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="U7en//bj"; 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-193172-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-193172-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 am.mirrors.kernel.org (Postfix) with ESMTPS id D31F21F24B66 for ; Tue, 28 May 2024 22:23:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8EF813E3E4; Tue, 28 May 2024 22:20:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="U7en//bj" 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 0264914388F for ; Tue, 28 May 2024 22:20:28 +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=1716934830; cv=none; b=eeIQzYzbBeGVLQ2gOW2dD4D7TJTRlCahiofmPGq+oD2f7L4640aWpYBKyQy4QYxZsuKHXzjc7OmyIzZPzTPEPADa1L4wFrCzlUtiI8yqm0ivFaE3hKgUqMfuzuQNY65ihW1tmK+tMyXdxThc+Tr58LO6fs8tA2j0aUs+3O8t108= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716934830; c=relaxed/simple; bh=5GfAF4d64QU3XOAsHg5jauTIBzHoAkFgwTZurK76Vu8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d3jdzBD+B53ad2uFZLxtVd0p5YbpSHbCOTDUY3L6s9uB2mA7UAfKlKlk2cxEueblVyao72TTh9ycN38bsHwTUNv61qUXAHurSsgXvtftVP2f99+cFk7cdQRfEhsx33nzw0okUjIN6/q06YPAcPLA0jhlBghZY/j4uuFNpoZvc7I= 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=U7en//bj; 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=1716934829; x=1748470829; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=5GfAF4d64QU3XOAsHg5jauTIBzHoAkFgwTZurK76Vu8=; b=U7en//bjhoRqeqhePPfQMCNXrRzIXDqmY6uBKov26YsjiBfDAyeOHNgZ ncubh0bEXzjM15CJGApRnh1pamB9qOJmInhpbQ3b2QCXnwNZq2ralOCnf rP8J5ihjiTQmbwuoQG0yBYDJfPdbh53tvvKqkpydvOKEBnV3AAXt8wmFI xc3x7Nr8yeedWeIrBcK4YKWF1zy8UWV6jqT6d015WafL6Rym7EtgKb3yN cVlKMlgIhzbyczrK3c4KJcmm1DB4AM0keRX4PtLNKEU18V36euJx8151M b3lJTtjPiXL9obmObjmbqD0sgsoKh2v4XKPEc5D2FTkeJEAGfD1JVOHtg g==; X-CSE-ConnectionGUID: LiC+DGyiQh+cgvrw0YFYkg== X-CSE-MsgGUID: oChf0C6TRouw761fOuhL8g== X-IronPort-AV: E=McAfee;i="6600,9927,11085"; a="30812261" X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="30812261" 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:20 -0700 X-CSE-ConnectionGUID: Gdv81BkWQd+PmSNCI+Vv2g== X-CSE-MsgGUID: LKu/UuMkQSaPr3K9+a86Wg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,196,1712646000"; d="scan'208";a="40090780" 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:19 -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 18/20] x86/resctrl: Enable RMID shared RMID mode on Sub-NUMA Cluster (SNC) systems Date: Tue, 28 May 2024 15:20:03 -0700 Message-ID: <20240528222006.58283-19-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-Transfer-Encoding: 8bit There is an MSR which configures how RMIDs are distributed across SNC nodes. When SNC is enabled bit 0 of this MSR must be cleared. Add an architecture specific hook into domain_add_cpu_mon() to call a function to set the MSR. 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 7957fc38b71c..08520321f5d0 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -532,6 +532,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); + /* * Get the cacheinfo structure of the cache associated with @cpu at level @level. * cpuhp lock must be held. 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 e7a8e96821e5..c7559735e33a 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1069,6 +1069,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