From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 E9AB2152E18 for ; Wed, 27 Mar 2024 20:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569845; cv=none; b=Q+BuVaRQ3dIaReJok16im0yVW9KTuQb7hATHHYnyq4hjOf+uCHKV3Lp3VpycSsA9PlkmY55GvyP4gS9dfCY5kiCqKlxOwgpfVjiad4wsQwXwCHz0IjMxswOkflpbQa0EDRCTlILOAbdIGETtEkqxDBUmLKLkkr24nkSKaGL4W38= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569845; c=relaxed/simple; bh=Gv2UBosedYSRzWxM6zFo4RUUu8lj/BWphBsgSEs9rtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KaJX4rpTFZjy0rBOGidyFFBW94j6ZcZGXQNDmU+UkQpZh4/Evy4XXhkMXC/eixq70rww5VbE4Wp0hDyhMGicFrqJEjZM12HhthKT5ukB00CS7rYDYDD+K2wv+3/eNk7hGIz3u3/wYW8OyAAjeH1K3Xb6wbqcJlIUYTF8uKuo9LY= 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=X09Uia1r; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="X09Uia1r" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569843; x=1743105843; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gv2UBosedYSRzWxM6zFo4RUUu8lj/BWphBsgSEs9rtY=; b=X09Uia1ry+J6o4dFdz/PHvImtavQVlGPee5mn1D90S+mt+h9GUCy1Vdu I1IeRRiNKZSuoIybCjwPtQjpjbX4I4dsqtmACR/QPIpslyvIhcA9AXmpP rajHgjDPLXGkKVSoc81YlWaL8LlhKgwAE4clnq7i86eUPf2U3cGZzItmM qF44FnlB5joq1ilBfrJGllV0bkcQyHImhQfWvCFN+MJZn6H/KvVOV9Xtr Zq9beeruOtA1n+wJhRvGQ8QJ3YVJFJig9e2DjF+tMiAZdRFFCwPMQRJZ/ O0sVKtWVGWcJmgPpDXcpyRyzhO+n2iY7Jkjiy98bmk2dXBw1zV85EiC6N g==; X-CSE-ConnectionGUID: wQ40ycPjRvmfchO06zCCAA== X-CSE-MsgGUID: 4aFLNt2pRxqUTRG17CJ29A== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18132961" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18132961" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246100" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:01 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 01/10] x86/resctrl: Prepare for new domain scope Date: Wed, 27 Mar 2024 13:03:43 -0700 Message-ID: <20240327200352.236835-2-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" Resctrl resources operate on subsets of CPUs in the system with the defining attribute of each subset being an instance of a particular level of cache. E.g. all CPUs sharing an L3 cache would be part of the same domain. In preparation for features that are scoped at the NUMA node level change the code from explicit references to "cache_level" to a more generic scope. Clean up the error handling when looking up domains. Report invalid id's before calling rdt_find_domain() in preparation for better messages when scope can be other than cache scope. This means that rdt_find_domain() will never return an error. So remove checks for error from the callsites. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 9 ++++- arch/x86/kernel/cpu/resctrl/core.c | 46 ++++++++++++++++------- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 2 +- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 6 ++- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 ++- 5 files changed, 49 insertions(+), 19 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index a365f67131ec..ed693bfe474d 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -150,13 +150,18 @@ struct resctrl_membw { struct rdt_parse_data; struct resctrl_schema; =20 +enum resctrl_scope { + RESCTRL_L2_CACHE =3D 2, + RESCTRL_L3_CACHE =3D 3, +}; + /** * struct rdt_resource - attributes of a resctrl resource * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine * @num_rmid: Number of RMIDs available - * @cache_level: Which cache level defines scope of this resource + * @scope: Scope of this resource * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. * @domains: RCU list of all domains for this resource @@ -174,7 +179,7 @@ struct rdt_resource { bool alloc_capable; bool mon_capable; int num_rmid; - int cache_level; + enum resctrl_scope scope; struct resctrl_cache cache; struct resctrl_membw membw; struct list_head domains; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 7751eea19fd2..4c5e985e1388 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -68,7 +68,7 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .r_resctrl =3D { .rid =3D RDT_RESOURCE_L3, .name =3D "L3", - .cache_level =3D 3, + .scope =3D RESCTRL_L3_CACHE, .domains =3D domain_init(RDT_RESOURCE_L3), .parse_ctrlval =3D parse_cbm, .format_str =3D "%d=3D%0*x", @@ -82,7 +82,7 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .r_resctrl =3D { .rid =3D RDT_RESOURCE_L2, .name =3D "L2", - .cache_level =3D 2, + .scope =3D RESCTRL_L2_CACHE, .domains =3D domain_init(RDT_RESOURCE_L2), .parse_ctrlval =3D parse_cbm, .format_str =3D "%d=3D%0*x", @@ -96,7 +96,7 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .r_resctrl =3D { .rid =3D RDT_RESOURCE_MBA, .name =3D "MB", - .cache_level =3D 3, + .scope =3D RESCTRL_L3_CACHE, .domains =3D domain_init(RDT_RESOURCE_MBA), .parse_ctrlval =3D parse_bw, .format_str =3D "%d=3D%*u", @@ -108,7 +108,7 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .r_resctrl =3D { .rid =3D RDT_RESOURCE_SMBA, .name =3D "SMBA", - .cache_level =3D 3, + .scope =3D RESCTRL_L3_CACHE, .domains =3D domain_init(RDT_RESOURCE_SMBA), .parse_ctrlval =3D parse_bw, .format_str =3D "%d=3D%*u", @@ -392,9 +392,6 @@ struct rdt_domain *rdt_find_domain(struct rdt_resource = *r, int id, struct rdt_domain *d; struct list_head *l; =20 - if (id < 0) - return ERR_PTR(-ENODEV); - list_for_each(l, &r->domains) { d =3D list_entry(l, struct rdt_domain, list); /* When id is found, return its domain. */ @@ -484,6 +481,19 @@ static int arch_domain_mbm_alloc(u32 num_rmid, struct = rdt_hw_domain *hw_dom) return 0; } =20 +static int get_domain_id_from_scope(int cpu, enum resctrl_scope scope) +{ + switch (scope) { + case RESCTRL_L2_CACHE: + case RESCTRL_L3_CACHE: + return get_cpu_cacheinfo_id(cpu, scope); + default: + break; + } + + return -EINVAL; +} + /* * domain_add_cpu - Add a cpu to a resource's domain list. * @@ -499,7 +509,7 @@ static int arch_domain_mbm_alloc(u32 num_rmid, struct r= dt_hw_domain *hw_dom) */ static void domain_add_cpu(int cpu, struct rdt_resource *r) { - int id =3D get_cpu_cacheinfo_id(cpu, r->cache_level); + int id =3D get_domain_id_from_scope(cpu, r->scope); struct list_head *add_pos =3D NULL; struct rdt_hw_domain *hw_dom; struct rdt_domain *d; @@ -507,12 +517,14 @@ static void domain_add_cpu(int cpu, struct rdt_resour= ce *r) =20 lockdep_assert_held(&domain_list_lock); =20 - d =3D rdt_find_domain(r, id, &add_pos); - if (IS_ERR(d)) { - pr_warn("Couldn't find cache id for CPU %d\n", cpu); + if (id < 0) { + pr_warn_once("Can't find domain id for CPU:%d scope:%d for resource %s\n= ", + cpu, r->scope, r->name); return; } =20 + d =3D rdt_find_domain(r, id, &add_pos); + if (d) { cpumask_set_cpu(cpu, &d->cpu_mask); if (r->cache.arch_has_per_cpu_cfg) @@ -552,15 +564,21 @@ static void domain_add_cpu(int cpu, struct rdt_resour= ce *r) =20 static void domain_remove_cpu(int cpu, struct rdt_resource *r) { - int id =3D get_cpu_cacheinfo_id(cpu, r->cache_level); + int id =3D get_domain_id_from_scope(cpu, r->scope); struct rdt_hw_domain *hw_dom; struct rdt_domain *d; =20 lockdep_assert_held(&domain_list_lock); =20 + if (id < 0) { + pr_warn_once("Can't find domain id for CPU:%d scope:%d for resource %s\n= ", + cpu, r->scope, r->name); + return; + } + d =3D rdt_find_domain(r, id, NULL); - if (IS_ERR_OR_NULL(d)) { - pr_warn("Couldn't find cache id for CPU %d\n", cpu); + if (!d) { + pr_warn("Couldn't find domain with id=3D%d for CPU %d\n", id, cpu); return; } hw_dom =3D resctrl_to_arch_dom(d); diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index b7291f60399c..2bf021d42500 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -577,7 +577,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) =20 r =3D &rdt_resources_all[resid].r_resctrl; d =3D rdt_find_domain(r, domid, NULL); - if (IS_ERR_OR_NULL(d)) { + if (!d) { ret =3D -ENOENT; goto out; } diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cp= u/resctrl/pseudo_lock.c index 884b88e25141..0013b1b39c17 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -292,10 +292,14 @@ static void pseudo_lock_region_clear(struct pseudo_lo= ck_region *plr) */ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) { + enum resctrl_scope scope =3D plr->s->res->scope; struct cpu_cacheinfo *ci; int ret; int i; =20 + if (WARN_ON_ONCE(scope !=3D RESCTRL_L2_CACHE && scope !=3D RESCTRL_L3_CAC= HE)) + return -ENODEV; + /* Pick the first cpu we find that is associated with the cache. */ plr->cpu =3D cpumask_first(&plr->d->cpu_mask); =20 @@ -311,7 +315,7 @@ static int pseudo_lock_region_init(struct pseudo_lock_r= egion *plr) plr->size =3D rdtgroup_cbm_to_size(plr->s->res, plr->d, plr->cbm); =20 for (i =3D 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level =3D=3D plr->s->res->cache_level) { + if (ci->info_list[i].level =3D=3D scope) { plr->line_size =3D ci->info_list[i].coherency_line_size; return 0; } diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 02f213f1c51c..b8588ce88eef 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1454,10 +1454,13 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resour= ce *r, unsigned int size =3D 0; int num_b, i; =20 + if (WARN_ON_ONCE(r->scope !=3D RESCTRL_L2_CACHE && r->scope !=3D RESCTRL_= L3_CACHE)) + return size; + num_b =3D bitmap_weight(&cbm, r->cache.cbm_len); ci =3D get_cpu_cacheinfo(cpumask_any(&d->cpu_mask)); for (i =3D 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level =3D=3D r->cache_level) { + if (ci->info_list[i].level =3D=3D r->scope) { size =3D ci->info_list[i].size / r->cache.cbm_len * num_b; break; } --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 2D06C1534E1 for ; Wed, 27 Mar 2024 20:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569846; cv=none; b=LKGYLVD99KmzCplAi87k4CBQj92OZ2a6no+I2JDjmMTWJPAK0XYRMMmY2N6Sv8kZDXxJX6uy4TlaF3nXOq93oQqWlXy1nGrAwcO7bEeRALqhGvOWC0573wTwxRy+KADLs4mpC+2aDBUuOgHc48FyqgHyTkxA2GYorWSJ9HB267A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569846; c=relaxed/simple; bh=p9PxKFKNPcVQ3UIxnb1saO+ycTTfGlj0Z2RcgpesIvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k+6OBWzy3sln7tDUxPjDR1eMBn8V4Gf4MQYEnIN95+PR2ntnIiIAiwvDdEgJEyfuWi8ICwbK68NLrQX+g+LLGI/iNEEaOciwBdhL3yo/oWCRul9Y0hITPzIT9MpS3KIycDhFLNem8gIf0yIJd0VomVRJB1z5N+Yr9h/12ZAoR2w= 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=Pl4oGSM4; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Pl4oGSM4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569844; x=1743105844; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p9PxKFKNPcVQ3UIxnb1saO+ycTTfGlj0Z2RcgpesIvA=; b=Pl4oGSM43duxjbwX16c+/sV0jt09CpNPuNT0nRJFt5ukZgS+MPaH9lk8 tAMTEhEO2DLHHFrmrk9Ha90viuFnRNFwGepVh0gB0ufzCvT4MTNlLAiy4 3+HLtWQb9L6wxbOMAiXGuOQHfXF79CQuY8N9XadN+O1CC870Gs6khjBxi psVpY9PRIqqCoeIZkcEIu6j86pZKTz+6bd4GsHVxTnhOZHTvObo5XWXmD 1+Baar5XpHbBHS4Gr23xwtnDOojhw/feiiIkUNN7KoyXXd38+DzQTXSsW mHliXuNIh4CSU/QqChF2WbuyQlM8M4+T0jHuByGQVYEMfor8iRVVrMpcp Q==; X-CSE-ConnectionGUID: 3hi88GGxRCW0bxroej9EiA== X-CSE-MsgGUID: of73pvr5QD+J1EvqByXqyA== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18132969" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18132969" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246107" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 02/10] x86/resctrl: Add new rdt_resource for sub-node monitoring Date: Wed, 27 Mar 2024 13:03:44 -0700 Message-ID: <20240327200352.236835-3-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" When a system enables Sub-NUMA Cluster (SNC) mode each CPU socket is divided into 2 or more NUMA nodes. CPU cores and memory are divided between these nodes. L3 cache monitoring functions are independently implemented on each SNC node. Add a new rdt_resource as a foundation for the structures to track monitor resources in each of the L3 sub-nodes. Add new scope option RESCTRL_NODE to build domains scoped at the NUMA node level. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++++++++ 3 files changed, 14 insertions(+) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index ed693bfe474d..f39a07b27a98 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -153,6 +153,7 @@ struct resctrl_schema; enum resctrl_scope { RESCTRL_L2_CACHE =3D 2, RESCTRL_L3_CACHE =3D 3, + RESCTRL_NODE, }; =20 /** diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 8f40fb35db78..24fad5ecc158 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -472,6 +472,7 @@ enum resctrl_res_level { RDT_RESOURCE_L2, RDT_RESOURCE_MBA, RDT_RESOURCE_SMBA, + RDT_RESOURCE_SUBL3, =20 /* Must be the last */ RDT_NUM_RESOURCES, diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 4c5e985e1388..395bcb3199f8 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -115,6 +115,16 @@ struct rdt_hw_resource rdt_resources_all[] =3D { .fflags =3D RFTYPE_RES_MB, }, }, + [RDT_RESOURCE_SUBL3] =3D + { + .r_resctrl =3D { + .rid =3D RDT_RESOURCE_SUBL3, + .name =3D "SUBL3", + .scope =3D RESCTRL_NODE, + .domains =3D domain_init(RDT_RESOURCE_SUBL3), + .fflags =3D RFTYPE_RES_CACHE, + }, + }, }; =20 /* @@ -487,6 +497,8 @@ static int get_domain_id_from_scope(int cpu, enum resct= rl_scope scope) case RESCTRL_L2_CACHE: case RESCTRL_L3_CACHE: return get_cpu_cacheinfo_id(cpu, scope); + case RESCTRL_NODE: + return cpu_to_node(cpu); default: break; } --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 2DFB1152DFB for ; Wed, 27 Mar 2024 20:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569846; cv=none; b=i1if3A9yDLvPfqPrYoLehHN2h9p9xJ9ADSe+XMkuebY27FJDyRszUgABA/SYFUMEJCqbrs21ilrHwveXqFpVCd8LWbiHqGp+Qfs11k1LkN3NTltx5EEAWIsjn2VccePn77Faaxo7oOBRR/bXH2aG7sYLHns2zaxIOcJCD8lRAXE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569846; c=relaxed/simple; bh=LAoiP0dp4wUs75VF3HzMl8OnzM3feG6POB1Op/0uGlw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GaBxXeUIzM+nv3bTJSnFf8maTRtxfkTAQz+riyAZWd5cy2cnphGX5vxgDxD0zPBK3A39vn57zdHHgReC67EfMxcVPYvqf7qNH+UGAucXSDB0tO6TeWC3mSAl7B7Blx7iFUdQPSEwX0DDOXEhwLvffOs+W3BzllXjsjcXzHmRGG0= 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=apFZSNjl; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="apFZSNjl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569845; x=1743105845; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=LAoiP0dp4wUs75VF3HzMl8OnzM3feG6POB1Op/0uGlw=; b=apFZSNjlQ8klZOFAzbavwsnSrld3DZ85yVdFmMVJ7zEi7llbuZRIVL5s NMJVju4SBt3YFnAhcXMKM1zZwhApr5nyEujezsyiry/ss/5tKDATKTIqd 99TZw4KVvlBrBty7+dRaZ2fGkbPqwHHJMo10Xz0zA6fTZyd7k+y3WHVBo ykOPaslEWrXLLmSPyqIzTk78ZZaonPA4nVv5qeY1UHB9hD6gaVJXCjOm6 ne+M4UdxljKtFfEni27JR+TWdt5We3xoTA44aSURUgQqEVxUy6588/8dA gBCktZsigNUGHdaxYCC3lOOyCzXRL9VwMem/XLG6EK1rAW2RsQePCsYY3 g==; X-CSE-ConnectionGUID: wNvgAx8+RPm8BM5PqM3DHQ== X-CSE-MsgGUID: X9u2Vu/gQwaq/tL16t9ePg== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18132976" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18132976" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246111" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 03/10] x86/resctrl: Add new "enabled" state for monitor resources Date: Wed, 27 Mar 2024 13:03:45 -0700 Message-ID: <20240327200352.236835-4-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" When Sub-NUMA cluster is enabled resctrl needs to build domain lists for both the regular L3 resource (scoped at L3 cache level) and the SUBL3 resource (scoped at NUMA node level). But only one of these resources will be used for all monitoring functions. Add a new "enabled" flag to indicate which resource should allocate space for MBM counters, run MBM overflow and LLC occupancy timeouts etc. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 ++ arch/x86/kernel/cpu/resctrl/internal.h | 4 ++++ arch/x86/kernel/cpu/resctrl/core.c | 4 ++-- arch/x86/kernel/cpu/resctrl/monitor.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 ++++---- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index f39a07b27a98..dea79f6a8122 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -161,6 +161,7 @@ enum resctrl_scope { * @rid: The index of the resource * @alloc_capable: Is allocation available on this machine * @mon_capable: Is monitor feature available on this machine + * @mon_enabled: Monitor feature enabled for this resource * @num_rmid: Number of RMIDs available * @scope: Scope of this resource * @cache: Cache allocation related data @@ -179,6 +180,7 @@ struct rdt_resource { int rid; bool alloc_capable; bool mon_capable; + bool mon_enabled; int num_rmid; enum resctrl_scope scope; struct resctrl_cache cache; diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 24fad5ecc158..5fcff861e185 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -514,6 +514,10 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_leve= l l, bool enable); for_each_rdt_resource(r) \ if (r->mon_capable) =20 +#define for_each_mon_enabled_rdt_resource(r) \ + for_each_rdt_resource(r) \ + if (r->mon_enabled) + /* CPUID.(EAX=3D10H, ECX=3DResID=3D1).EAX */ union cpuid_0x10_1_eax { struct { diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 395bcb3199f8..bfa179f20802 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -559,7 +559,7 @@ static void domain_add_cpu(int cpu, struct rdt_resource= *r) return; } =20 - if (r->mon_capable && arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { + if (r->mon_enabled && arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { domain_free(hw_dom); return; } @@ -1002,7 +1002,7 @@ static void __exit resctrl_exit(void) =20 rdtgroup_exit(); =20 - if (r->mon_capable) + if (r->mon_enabled) rdt_put_mon_l3_config(); } =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index c34a35ec0f03..84a2056190c8 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -1060,6 +1060,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) l3_mon_evt_init(r); =20 r->mon_capable =3D true; + r->mon_enabled =3D true; =20 return 0; } diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index b8588ce88eef..ffcafe567b25 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3150,7 +3150,7 @@ static int mkdir_mondata_all(struct kernfs_node *pare= nt_kn, * Create the subdirectories for each domain. Note that all events * in a domain like L3 are grouped into a resource whose domain is L3 */ - for_each_mon_capable_rdt_resource(r) { + for_each_mon_enabled_rdt_resource(r) { ret =3D mkdir_mondata_subdir_alldom(kn, r, prgrp); if (ret) goto out_destroy; @@ -3937,7 +3937,7 @@ void resctrl_offline_domain(struct rdt_resource *r, s= truct rdt_domain *d) if (supports_mba_mbps() && r->rid =3D=3D RDT_RESOURCE_MBA) mba_sc_domain_destroy(r, d); =20 - if (!r->mon_capable) + if (!r->mon_enabled) goto out_unlock; =20 /* @@ -4011,7 +4011,7 @@ int resctrl_online_domain(struct rdt_resource *r, str= uct rdt_domain *d) goto out_unlock; } =20 - if (!r->mon_capable) + if (!r->mon_enabled) goto out_unlock; =20 err =3D domain_setup_mon_state(r, d); @@ -4074,7 +4074,7 @@ void resctrl_offline_cpu(unsigned int cpu) } } =20 - if (!l3->mon_capable) + if (!l3->mon_enabled) goto out_unlock; =20 d =3D get_domain_from_cpu(cpu, l3); --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 CFCA31534E4 for ; Wed, 27 Mar 2024 20:04:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569847; cv=none; b=Vl6ZFvQS0OCqetTypP3gRg4LrqNuNnVsnVx+VxhiMd2aNyZXF5U2950d055xPasmuV51r+loe3FTI6IbgNsvS0+mm3HdOHWGK4/bxwp5QWDRZaR8JglzLkFTuo+xpFvn0BpYsVhkDKwUrPK0KbxI1poVXbpiejFeBT5qJS3s2/U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569847; c=relaxed/simple; bh=UAgoVYMozpNrZsRTA+xS7ef2Vl0uFY5WsmZWWJAct4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ers8Z8pi7wyGYHmtlZYP2OtlHeGnigvFvrnoPcIeP9Lb8aZ1HA6Qz0FYkhZ2dDSn/pgsJ9INbTIPfbUF3zLfD0k8fAW7OscxPPsFiV3ETYr64v2qaUQ0QL7ymSWuodDHjy+MpJ1ZWpJPYR7EakNqx8qSsbQBQAk3ol0ItNa11LI= 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=IpqP3vir; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="IpqP3vir" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569846; x=1743105846; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=UAgoVYMozpNrZsRTA+xS7ef2Vl0uFY5WsmZWWJAct4o=; b=IpqP3vir1n0myUR8bkMDAgCydRc0l5m3scLLrj9qm8TAQdYK6t/29Jos gt3+HhRWYS5bpqDCHnTONdOFIRPrUFkWEceK4WPGQjwltefXF5YzPRISQ p8tYJEig2UCiFQFUWW70p8YzpfknArZml/aFLfqtm0X0K35dD1j1UYwvR ILWqpGgXYxEhk6xqzrIrl/XWdFez9PuM8iKu8S9UlDjvjGpDsJQ/cTfry 6C6dwvPx3irNdciotPM5GtnQe8Nf/1O3CpfFrWpEtaUjP7puj6ctwc4yr Us8dGlnj/LAxXFOe2Jj+r6cUZUAe+aLMwTn0iNq+GBj6JBXJHca5YTu6T A==; X-CSE-ConnectionGUID: mI7vn1vrRWWdPiSRdQLv4Q== X-CSE-MsgGUID: 57Sz/OgqR2Kx11eGzZCU+A== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18132983" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18132983" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246118" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 04/10] x86/resctrl: Add pointer to enabled monitor resource Date: Wed, 27 Mar 2024 13:03:46 -0700 Message-ID: <20240327200352.236835-5-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" Sub-NUMA cluster enabled systems do all monitoring using the SUBL3 resource. Others use the regular L3 resource. Replace the hard-coded rdt_resources_all[RDT_RESOURCE_L3].r_resctrl references with a new pointer "rdt_l3_mon_resource". Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/core.c | 2 +- arch/x86/kernel/cpu/resctrl/monitor.c | 19 ++++++++++++------- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 7 +++---- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 5fcff861e185..21d81f51838f 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -464,6 +464,7 @@ int parse_bw(struct rdt_parse_data *data, struct resctr= l_schema *s, extern struct mutex rdtgroup_mutex; =20 extern struct rdt_hw_resource rdt_resources_all[]; +extern struct rdt_resource *rdt_l3_mon_resource; extern struct rdtgroup rdtgroup_default; extern struct dentry *debugfs_resctrl; =20 diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index bfa179f20802..2fa04375da8c 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -996,7 +996,7 @@ late_initcall(resctrl_late_init); =20 static void __exit resctrl_exit(void) { - struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r =3D rdt_l3_mon_resource; =20 cpuhp_remove_state(rdt_online); =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 84a2056190c8..95455cb187eb 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -78,6 +78,9 @@ static struct rmid_entry *rmid_ptrs; */ bool rdt_mon_capable; =20 +/* Resource (L3 or SUBL3) that is base for monitoring */ +struct rdt_resource *rdt_l3_mon_resource; + /* * Global to indicate which monitoring events are enabled. */ @@ -321,7 +324,7 @@ static void limbo_release_entry(struct rmid_entry *entr= y) */ void __check_limbo(struct rdt_domain *d, bool force_free) { - struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r =3D rdt_l3_mon_resource; u32 idx_limit =3D resctrl_arch_system_num_rmid_idx(); struct rmid_entry *entry; u32 idx, cur_idx =3D 1; @@ -467,7 +470,7 @@ int alloc_rmid(u32 closid) =20 static void add_rmid_to_limbo(struct rmid_entry *entry) { - struct rdt_resource *r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r =3D rdt_l3_mon_resource; struct rdt_domain *d; u32 idx; =20 @@ -839,7 +842,7 @@ void mbm_handle_overflow(struct work_struct *work) if (!resctrl_mounted || !resctrl_arch_mon_capable()) goto out_unlock; =20 - r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + r =3D rdt_l3_mon_resource; d =3D container_of(work, struct rdt_domain, mbm_over.work); =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { @@ -1036,7 +1039,9 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) */ resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 - ret =3D dom_data_init(r); + rdt_l3_mon_resource =3D r; + + ret =3D dom_data_init(rdt_l3_mon_resource); if (ret) return ret; =20 @@ -1057,10 +1062,10 @@ int __init rdt_get_mon_l3_config(struct rdt_resourc= e *r) } } =20 - l3_mon_evt_init(r); + l3_mon_evt_init(rdt_l3_mon_resource); =20 - r->mon_capable =3D true; - r->mon_enabled =3D true; + rdt_l3_mon_resource->mon_capable =3D true; + rdt_l3_mon_resource->mon_enabled =3D true; =20 return 0; } diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index ffcafe567b25..a2ebd7e051bb 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2703,7 +2703,7 @@ static int rdt_get_tree(struct fs_context *fc) resctrl_mounted =3D true; =20 if (is_mbm_enabled()) { - r =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + r =3D rdt_l3_mon_resource; list_for_each_entry(dom, &r->domains, list) mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL, RESCTRL_PICK_ANY_CPU); @@ -4062,7 +4062,6 @@ static void clear_childcpus(struct rdtgroup *r, unsig= ned int cpu) =20 void resctrl_offline_cpu(unsigned int cpu) { - struct rdt_resource *l3 =3D &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; struct rdtgroup *rdtgrp; struct rdt_domain *d; =20 @@ -4074,10 +4073,10 @@ void resctrl_offline_cpu(unsigned int cpu) } } =20 - if (!l3->mon_enabled) + if (!rdt_l3_mon_resource->mon_enabled) goto out_unlock; =20 - d =3D get_domain_from_cpu(cpu, l3); + d =3D get_domain_from_cpu(cpu, rdt_l3_mon_resource); if (d) { if (is_mbm_enabled() && cpu =3D=3D d->mbm_work_cpu) { cancel_delayed_work(&d->mbm_over); --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 1B8251534F1 for ; Wed, 27 Mar 2024 20:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569847; cv=none; b=kdlUwpVukUjF1zQobnBjgiJaulJbEp6bpM2O6k+FM7DDO66VEQK1ww1Z9dV1WJMpuW6sPZupdrB1urpCX4crx8f0h9e0DgeXJAld9Zz7qwciEg6/XZYo5S6MJtNWCggP0QhUb/V2jNNyb9S+9CMPO2r6agys2W46nWBT9AqzR5k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569847; c=relaxed/simple; bh=DQfB7ziQiSVsGqVtUGTeoCLbXrf9m9tIM71X5OZ5E0M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D0HfrkyIagEMTi7CjW3rr47/WDRakLs2N8om5eocbOWlKUvWzNu9dbI/I2cNE296MV+sgZ6uWjauFRqJH7amPPK6/Z+2KdYe7UAffwJZGB3UF7DPxXjdyjtjj96DCkig429oYCa4tI/UD65GnECTbU0LvXb4YjRC6MJXtjpC4NQ= 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=nRTmx5BT; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="nRTmx5BT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569846; x=1743105846; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DQfB7ziQiSVsGqVtUGTeoCLbXrf9m9tIM71X5OZ5E0M=; b=nRTmx5BTrUAquSAxDnQ+oIDYDUDGCHEWzCU0swnjlqGwrnsOAuiFxJaQ ce4pRdcPqHtAopdQ1t9DATw71dbb2FBABXg8Mhgd5JO8KxxaX11/NqUSq qTlejnbf6i1JjrFCzSDHRIvWfhKm3fKX6QsZyhGY9izFt97UK0jL/jXKC BHkgrkNBDdnWpmFuhheUJyOdx0OExTTDtcJ8eYGb+0X1JIA+djfT21EnL e9/7iT8NnpIjrcUxaBlzY+ZN/QgCSFw6wFmBV27WrUYVV3OYr6ZmRkvwP eKDYjQVEgLg50kX5yAky617INoM8WfSryA5jI8l5ynl9CZ6wU9SCLagdq A==; X-CSE-ConnectionGUID: g3syR+rmQr69dzODuOCJzw== X-CSE-MsgGUID: OFBPDUEtSWi0bMwRg8kLrw== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18132991" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18132991" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246122" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:02 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 05/10] x86/resctrl: Add parent/child information to rdt_resource and rdt_domain Date: Wed, 27 Mar 2024 13:03:47 -0700 Message-ID: <20240327200352.236835-6-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" The L3 resource is a "parent" to the SUBL3 resource in that each of the domains in L3 is subdivided into two or more SUBL3 domains. Add parent/child pointers to the rdt_resource structure and a parent domain id number to the rdt_domain structure. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 6 ++++++ arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++++++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 4 +++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index dea79f6a8122..b7ade7627e08 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -70,6 +70,7 @@ struct resctrl_staged_config { * @cqm_limbo: worker to periodically read CQM h/w counters * @mbm_work_cpu: worker CPU for MBM h/w counters * @cqm_work_cpu: worker CPU for CQM h/w counters + * @parent: parent domain number in parent resource * @plr: pseudo-locked region (if any) associated with domain * @staged_config: parsed configuration to be applied * @mbps_val: When mba_sc is enabled, this holds the array of user @@ -87,6 +88,7 @@ struct rdt_domain { struct delayed_work cqm_limbo; int mbm_work_cpu; int cqm_work_cpu; + int parent; struct pseudo_lock_region *plr; struct resctrl_staged_config staged_config[CDP_NUM_TYPES]; u32 *mbps_val; @@ -173,6 +175,8 @@ enum resctrl_scope { * @format_str: Per resource format string to show domain value * @parse_ctrlval: Per resource function pointer to parse control values * @evt_list: List of monitoring events + * @parent: Parent of this resource + * @child: Child of this resource * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource */ @@ -194,6 +198,8 @@ struct rdt_resource { struct resctrl_schema *s, struct rdt_domain *d); struct list_head evt_list; + struct rdt_resource *parent; + struct rdt_resource *child; unsigned long fflags; bool cdp_capable; }; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resct= rl/core.c index 2fa04375da8c..1f5d7ee0096e 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -552,6 +552,18 @@ static void domain_add_cpu(int cpu, struct rdt_resourc= e *r) d->id =3D id; cpumask_set_cpu(cpu, &d->cpu_mask); =20 + if (r->parent) { + struct rdt_domain *pd; + + list_for_each_entry(pd, &r->parent->domains, list) + if (cpumask_test_cpu(cpu, &pd->cpu_mask)) + goto found; + WARN_ON_ONCE(1); + return; +found: + d->parent =3D pd->id; + } + rdt_domain_reconfigure_cdp(r); =20 if (r->alloc_capable && domain_setup_ctrlval(r, d)) { diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index a2ebd7e051bb..f2af58a791a4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1107,9 +1107,11 @@ static int rdt_mon_features_show(struct kernfs_open_= file *of, struct seq_file *seq, void *v) { struct rdt_resource *r =3D of->kn->parent->priv; + struct list_head *evt_list; struct mon_evt *mevt; =20 - list_for_each_entry(mevt, &r->evt_list, list) { + evt_list =3D r->child ? &r->child->evt_list : &r->evt_list; + list_for_each_entry(mevt, evt_list, list) { seq_printf(seq, "%s\n", mevt->name); if (mevt->configurable) seq_printf(seq, "%s_config\n", mevt->name); --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 EFD06153501 for ; Wed, 27 Mar 2024 20:04:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569848; cv=none; b=tb71K0bG7qMhzUpEUjapguxATb6a80//TbSIRso9+fjY2HcbAJ+e1rYbIFBrK0mF1gvwqfYd+XWfxoRp3hDv7VQJobnreJT05kN/YmB9r2oZza4sOUb2HvAguBpkIkO5sYODBE/2Jf8sWRbdbW+976LJPj2Xh7gvd0DZNk0G4XY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569848; c=relaxed/simple; bh=PviGf2ukuqvClh6Tzg6t+9sRC+0cgDfB2kvycRzoQFo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sz5MEHq2E50j/VmlReUsdbQsgFw5DFacLEk2UlRiCdRPVsOdyd2Cddc6g54U5FOgh+XvcKGsAe6vpyNAQi4jbs0VwhCrclYIPKttJqXJ71fDfAtZkM9L2scI+LaUwUZYI1v7HuyMjc3qDMZ7oA+O/CWDAbKF2Wetrbgh+heNYoo= 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=WaTh3hwz; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="WaTh3hwz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569847; x=1743105847; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=PviGf2ukuqvClh6Tzg6t+9sRC+0cgDfB2kvycRzoQFo=; b=WaTh3hwzWaE0WVUrIuUPcwwhbOOdEXYhi1eqWCNQTFTZBm3vGWEBaaro sLfvhkiwhQR/PO81MqmMvtkTAxgvV+eEhNMHSj4gkBDd6Yv+1bgrOiLC/ UBUWyp1fo3Gjwy+harQfhHYvJ97IBSc709NwZUGr3tTHfrKXBKYVbE5Rm RmH0bEguYS4fnMV+th68i44T1cWN9e4jZvcGdEKyB4rhnl37/28wYwzQt PcbbfVrsrW96dv+MIxAd2oqCVJ/xD3zOe6ooyt9ZoklbGGE718VmJaFDf Ea1G1IVpyihCuVa2hd0fJgCgDXJdvfaQDOMW1PJUlcw8PhRyYPRrBGIz/ w==; X-CSE-ConnectionGUID: AKLxWARnTd2Bqhzzg331Nw== X-CSE-MsgGUID: O1pdmX1uS9SW3oiU7qXAyA== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18132999" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18132999" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246128" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:03 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 06/10] x86/resctrl: Update mkdir_mondata_subdir() for Sub-NUMA domains Date: Wed, 27 Mar 2024 13:03:48 -0700 Message-ID: <20240327200352.236835-7-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" When Sub-NUMA domain mode is enabled all the monitoring happens at the SUBL3 resource level. Changes are required to populate the "mon_data" directories in the resctrl file system. When making the first SUBL3 directory code must first create the parent mon_L3_XX directory and fill it with files for each of the monitoring functions. Subsequent SUBL3 creation requests will simply use the directory that was created by the first request. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 12 +++++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 74 ++++++++++++++++++-------- 2 files changed, 65 insertions(+), 21 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 21d81f51838f..7f05502454c5 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -456,6 +456,18 @@ static inline struct rdt_hw_resource *resctrl_to_arch_= res(struct rdt_resource *r return container_of(r, struct rdt_hw_resource, r_resctrl); } =20 +static inline struct rdt_domain *get_parent_domain(struct rdt_resource *r, + struct rdt_domain *d) +{ + struct rdt_domain *pd; + + list_for_each_entry(pd, &r->parent->domains, list) + if (pd->id =3D=3D d->parent) + return pd; + + return NULL; +} + int parse_cbm(struct rdt_parse_data *data, struct resctrl_schema *s, struct rdt_domain *d); int parse_bw(struct rdt_parse_data *data, struct resctrl_schema *s, diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index f2af58a791a4..22effd8dc207 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3026,31 +3026,16 @@ static void rmdir_mondata_subdir_allrdtgrp(struct r= dt_resource *r, } } =20 -static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, - struct rdt_domain *d, - struct rdt_resource *r, struct rdtgroup *prgrp) +static int mon_add_all_files(struct kernfs_node *kn, struct rdt_domain *d, + struct rdt_resource *r, struct rdtgroup *prgrp) { union mon_data_bits priv; - struct kernfs_node *kn; struct mon_evt *mevt; struct rmid_read rr; - char name[32]; int ret; =20 - sprintf(name, "mon_%s_%02d", r->name, d->id); - /* create the directory */ - kn =3D kernfs_create_dir(parent_kn, name, parent_kn->mode, prgrp); - if (IS_ERR(kn)) - return PTR_ERR(kn); - - ret =3D rdtgroup_kn_set_ugid(kn); - if (ret) - goto out_destroy; - - if (WARN_ON(list_empty(&r->evt_list))) { - ret =3D -EPERM; - goto out_destroy; - } + if (WARN_ON(list_empty(&r->evt_list))) + return -EPERM; =20 priv.u.rid =3D r->rid; priv.u.domid =3D d->id; @@ -3058,11 +3043,58 @@ static int mkdir_mondata_subdir(struct kernfs_node = *parent_kn, priv.u.evtid =3D mevt->evtid; ret =3D mon_addfile(kn, mevt->name, priv.priv); if (ret) - goto out_destroy; + return ret; =20 if (is_mbm_event(mevt->evtid)) mon_event_read(&rr, r, d, prgrp, mevt->evtid, true); } + + return 0; +} + +static int mkdir_mondata_subdir(struct kernfs_node *parent_kn, + struct rdt_domain *d, + struct rdt_resource *r, struct rdtgroup *prgrp) +{ + struct kernfs_node *kn =3D parent_kn, *ckn; + struct rdt_domain *pd; + char name[32]; + int ret; + + if (r->parent) { + pd =3D get_parent_domain(r, d); + if (!pd) + return 0; + sprintf(name, "mon_%s_%02d", r->parent->name, pd->id); + kn =3D kernfs_find_and_get_ns(parent_kn, name, NULL); + if (kn) { + parent_kn =3D kn; + goto subdir; + } + kn =3D kernfs_create_dir(parent_kn, name, parent_kn->mode, prgrp); + if (IS_ERR(kn)) + return PTR_ERR(kn); + ret =3D rdtgroup_kn_set_ugid(kn); + if (ret) + goto out_destroy; + ret =3D mon_add_all_files(kn, d, r, prgrp); + if (ret) + goto out_destroy; + } +subdir: + sprintf(name, "mon_%s_%02d", r->name, d->id); + /* create the directory */ + ckn =3D kernfs_create_dir(kn, name, parent_kn->mode, prgrp); + if (IS_ERR(ckn)) + goto out_destroy; + + ret =3D rdtgroup_kn_set_ugid(ckn); + if (ret) + goto out_destroy; + + ret =3D mon_add_all_files(ckn, d, r, prgrp); + if (ret) + goto out_destroy; kernfs_activate(kn); return 0; =20 @@ -3078,8 +3110,8 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, static void mkdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, struct rdt_domain *d) { - struct kernfs_node *parent_kn; struct rdtgroup *prgrp, *crgrp; + struct kernfs_node *parent_kn; struct list_head *head; =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 DD90C153566 for ; Wed, 27 Mar 2024 20:04:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569849; cv=none; b=oynUIWVOVwWci6dEoG9nEMVABTWacIVoXicj2+BEG1nLLKehQV6P7JKTglBWeCNvtG35hfM1EckLttFiAh3MHp9aCCju8JYuRu36a9ZEeregsglPFCA9PP03/srZhS2uHzh/vE+xjrLXfqR6z3ZXgpi5m7ILGKMCjOFfGyIGqQ0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569849; c=relaxed/simple; bh=GqHADRWSK9k2kWQziCyKzMojosS7K/TvpaCs77T6KdU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f0tCXcb+gviKlHnYHAZv3RFQELpnO7ETDqY7QJ0JyCwDvoxpdy1kDPcXlGEdAqDV+Kjbnovoczx5bLIadMUFG42O42whlEYI3LBiBCY9TQkAid5j7d3E3aVk2GahpF6pf2lE6Ymi2ztrGnbnLgHm1ab1pj+0KlHMeYvuD/mQVMo= 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=jyHLOP04; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jyHLOP04" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569848; x=1743105848; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GqHADRWSK9k2kWQziCyKzMojosS7K/TvpaCs77T6KdU=; b=jyHLOP0445bVCpk3qaO1t2+DCiWKhDYKuCZOQoNuRWGEi1Pe7sjU+RTe tE/y703V9EkQdub/KNU3oLR1GvAY80qMbozZlnEykpfF/zXAehjrcChdC UNf57taGKei6lsxfC+t0uadyjTvOzjwvhCtx2u18GPUt2a7kTCc6/H0q3 U/NndsYUem4pROT/XmcfBEcAUJzt6W41HpdKlL5VJVCJ0S6ysBfKgWZew FI512y9xQTI1hkcMqJfoQnSIzgAZuSrNAy80Pch83U6XK+emxFuTggMb2 AK0z+LkQdYUjrs4FqrYAbd+pVllZ+WHlrY1jYi8aHHzWtd7wvlpYF9LyY Q==; X-CSE-ConnectionGUID: 54Ry8GBST/K/+62+FZQCmw== X-CSE-MsgGUID: 729fafhyQqKxT3jfucC0XA== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18133006" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18133006" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246133" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:03 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 07/10] x86/resctrl: Update rmdir_mondata_subdir_allrdtgrp() for Sub-NUMA domains Date: Wed, 27 Mar 2024 13:03:49 -0700 Message-ID: <20240327200352.236835-8-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" Old code could simply remove the mon_L3_XX directory with all contents when a domain was taken offline. With Sub-NUMA cluster enabled this becomes a multi-stage process. While the parent L3 domain is still online the offline process for a SUBL3 domain removes just one directory from mon_L3_XX. When the last such domain goes offline the whole mon_L3_XX must be removed. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 46 ++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 22effd8dc207..399dc3175292 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3012,17 +3012,49 @@ static int mon_addfile(struct kernfs_node *parent_k= n, const char *name, * and monitor groups with given domain id. */ static void rmdir_mondata_subdir_allrdtgrp(struct rdt_resource *r, - unsigned int dom_id) + struct rdt_domain *d) { struct rdtgroup *prgrp, *crgrp; - char name[32]; + char pname[32], name[32]; + bool remove_all =3D false; + struct kernfs_node *kn; + struct rdt_domain *pd; + + sprintf(name, "mon_%s_%02d", r->name, d->id); + + if (!r->parent) { + list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { + kernfs_remove_by_name(prgrp->mon.mon_data_kn, name); + + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) + kernfs_remove_by_name(crgrp->mon.mon_data_kn, name); + } + return; + } + + sprintf(pname, "mon_%s_%02d", r->parent->name, d->parent); + pd =3D get_parent_domain(r, d); + if (!pd) + remove_all =3D true; =20 list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { - sprintf(name, "mon_%s_%02d", r->name, dom_id); - kernfs_remove_by_name(prgrp->mon.mon_data_kn, name); + if (remove_all) { + kernfs_remove_by_name(prgrp->mon.mon_data_kn, pname); + } else { + kn =3D kernfs_find_and_get_ns(prgrp->mon.mon_data_kn, pname, NULL); + if (kn) + kernfs_remove_by_name(kn, name); + } =20 - list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) - kernfs_remove_by_name(crgrp->mon.mon_data_kn, name); + list_for_each_entry(crgrp, &prgrp->mon.crdtgrp_list, mon.crdtgrp_list) { + if (remove_all) { + kernfs_remove_by_name(crgrp->mon.mon_data_kn, pname); + } else { + kn =3D kernfs_find_and_get_ns(crgrp->mon.mon_data_kn, pname, NULL); + if (kn) + kernfs_remove_by_name(kn, name); + } + } } } =20 @@ -3979,7 +4011,7 @@ void resctrl_offline_domain(struct rdt_resource *r, s= truct rdt_domain *d) * per domain monitor data directories. */ if (resctrl_mounted && resctrl_arch_mon_capable()) - rmdir_mondata_subdir_allrdtgrp(r, d->id); + rmdir_mondata_subdir_allrdtgrp(r, d); =20 if (is_mbm_enabled()) cancel_delayed_work(&d->mbm_over); --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 0E859153570 for ; Wed, 27 Mar 2024 20:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569850; cv=none; b=DEWjP8tBtK0ntJO9mgq0XAi04tYFW7AUvaSeaBi1xOrs1VnDN5ljnXAGYtsUMKY5npwFz/Ce5Z9efwMZwx/4RBlmQHi1hMpVkuYGhNxur494yMSt1LkiPeLboXCtNF/8dunsdkE9NcDUjEdRaaPviHikdyiB85hi3wcXr6Fa3hU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569850; c=relaxed/simple; bh=CLmeyEJVusEGYfnF/7WHgMN0KkjloHLy09ihZfkY5qU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YMqNNBBse3nPIjzn0+Yjn0o1r5Ev+Xaz31WQOnU/ZyVOuwcB7Oew5agDB0cpoh1HKOjhj59hfavoIUeYUKUi4VCsa4RoWIMiILtTZj4okZLEdK6eSGxJxvK04VguzTtKUnw9SryB9XmvFnPsEaVVIcXF3t6zDQC2NsRwO/wPAIw= 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=lSId1XxF; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lSId1XxF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569848; x=1743105848; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=CLmeyEJVusEGYfnF/7WHgMN0KkjloHLy09ihZfkY5qU=; b=lSId1XxFLUzXRPXg3mYANYrMUHABwkEoYVKQnyPgwFvvd4Sy27/UgS31 7Y5wTfGYoepMp1z0N0TC3fj4Ieh2mbXWqCwtMIQ9scsF/LgM3NF3W/TIJ sXiAph0JyizP261MR9z4DoBmGH1ZFZ5I97bVdi4JDY+wivLyz5kXebEt2 4dA8bbd81BCe1mQa9rqKYz4tMmkbuN+CmDnQcPyg+6mJRoU6fwLcQ5BYF dZSk3pXZgnvUz8y4ZsJ09xvvReCTFXfQvLCCYjd20iUzORRM3DH/5LAan kHhI3kCyg3h33OZMb6VphPvobj7S8vGeCXgfaUVwZoHKk7008OMtS1j/O w==; X-CSE-ConnectionGUID: OHwZAv4bSeinI/w/OO0hOA== X-CSE-MsgGUID: /ozbtIYiTfuC7Xc3qDH4hw== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18133014" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18133014" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246139" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:03 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 08/10] x86/resctrl: Mark L3 monitor files with summation flag. Date: Wed, 27 Mar 2024 13:03:50 -0700 Message-ID: <20240327200352.236835-9-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" When Sub-NUMA cluster mode is enabled, the parent monitor files in the mon_L3_XX directories need to sum all child siblings from the SUBL3 domains. Add a flag to the parent files and pass that down to the routines that will read values from hardware RMID counters. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 5 ++++- arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 8 +++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/r= esctrl/internal.h index 7f05502454c5..4263fbdf7ee7 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -130,6 +130,7 @@ struct mon_evt { * @priv: Used to store monitoring event data in @u * as kernfs private data * @rid: Resource id associated with the event file + * @sumdomains: Report total of all SNC domains sharing an L3 cache * @evtid: Event id associated with the event file * @domid: The domain to which the event file belongs * @u: Name of the bit fields struct @@ -137,7 +138,8 @@ struct mon_evt { union mon_data_bits { void *priv; struct { - unsigned int rid : 10; + unsigned int rid : 9; + unsigned int sumdomains : 1; enum resctrl_event_id evtid : 8; unsigned int domid : 14; } u; @@ -149,6 +151,7 @@ struct rmid_read { struct rdt_domain *d; enum resctrl_event_id evtid; bool first; + bool sumdomains; int err; u64 val; void *arch_mon_ctx; diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cp= u/resctrl/ctrlmondata.c index 2bf021d42500..fedcf50df6e5 100644 --- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c +++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c @@ -574,6 +574,7 @@ int rdtgroup_mondata_show(struct seq_file *m, void *arg) resid =3D md.u.rid; domid =3D md.u.domid; evtid =3D md.u.evtid; + rr.sumdomains =3D md.u.sumdomains; =20 r =3D &rdt_resources_all[resid].r_resctrl; d =3D rdt_find_domain(r, domid, NULL); diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 399dc3175292..3e7f2e36b71e 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -3059,7 +3059,8 @@ static void rmdir_mondata_subdir_allrdtgrp(struct rdt= _resource *r, } =20 static int mon_add_all_files(struct kernfs_node *kn, struct rdt_domain *d, - struct rdt_resource *r, struct rdtgroup *prgrp) + struct rdt_resource *r, struct rdtgroup *prgrp, + bool sumdomains) { union mon_data_bits priv; struct mon_evt *mevt; @@ -3071,6 +3072,7 @@ static int mon_add_all_files(struct kernfs_node *kn, = struct rdt_domain *d, =20 priv.u.rid =3D r->rid; priv.u.domid =3D d->id; + priv.u.sumdomains =3D sumdomains; list_for_each_entry(mevt, &r->evt_list, list) { priv.u.evtid =3D mevt->evtid; ret =3D mon_addfile(kn, mevt->name, priv.priv); @@ -3109,7 +3111,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, ret =3D rdtgroup_kn_set_ugid(kn); if (ret) goto out_destroy; - ret =3D mon_add_all_files(kn, d, r, prgrp); + ret =3D mon_add_all_files(kn, d, r, prgrp, true); if (ret) goto out_destroy; } @@ -3124,7 +3126,7 @@ static int mkdir_mondata_subdir(struct kernfs_node *p= arent_kn, if (ret) goto out_destroy; =20 - ret =3D mon_add_all_files(ckn, d, r, prgrp); + ret =3D mon_add_all_files(ckn, d, r, prgrp, false); if (ret) goto out_destroy; kernfs_activate(kn); --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 D5A3E152E00 for ; Wed, 27 Mar 2024 20:04:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569850; cv=none; b=lEd65MJppv6U7YxD2m25sTR19tXut7/zpqOKBTaUA7UxuRrKAKB+7q1U4U6uFZvsLLaN1XdPx1WRPMtBSBaST1uWPHigZEB687PQiLSZrFzJA9q/wKBce9hNd9NjItkBv4iFh0X60u/3SUofBCaug8bMlPRUze0Xq1XFVWmNz4U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569850; c=relaxed/simple; bh=KmXt+nlPE9uG6oRD+ve4qLMKyEv+rwEBB4DSzyRfYbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pAW7NpSklhFXW5AiG0pzTa1R8brZCmQseRgwfaS8Vg2YHDQ0SScXerE/Dp542Twd/j46SL3PplQfThYlj1+J21BOpR33ROh0lDxgS4J4KPBcgYIFaSjyfd/d6Dcz5+X6Ngr4L4rYcI/KxV1VAtPNlTsdzTTLj4+XiuXdAqe2etQ= 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=VFaZCx1K; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="VFaZCx1K" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569849; x=1743105849; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=KmXt+nlPE9uG6oRD+ve4qLMKyEv+rwEBB4DSzyRfYbU=; b=VFaZCx1K1jp5L5YelD6PmCKA+eZYz0VG325j762XcgfaM/OkB3GaTr6c ws5hN5bEsfoeZOCx6jF20/EF1Xp3Sql68tBrjCanBTPpRobX9r59rLyA6 kecJbQcVzHGDIew/HM0M2FLzZ8kGNwM7/o6bXgrnlGmHWkvnYmtyTnkOh YnSCDmjjQshbdki7Frp4rFECIMjgPe/ssSeLQQcoUyQVfoN71lA4kVQmu vFrT0FCDe+IYfGVJLVs9iyExOkKwfD44HUzPYjdrhxfp1mbLNmkbZsn4l dRu4NGkTRsT7eb5qwA6PIIrRC3Qc8LMoUf5dWdX62M9XGEw36sR/xxZQz g==; X-CSE-ConnectionGUID: vz7BRHnNQSyQmTbifSef9g== X-CSE-MsgGUID: V1s88WVJQ/ag1YSBueO1Xw== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18133023" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18133023" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246145" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:04 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 09/10] x86/resctrl: Update __mon_event_count() for Sub-NUMA domains Date: Wed, 27 Mar 2024 13:03:51 -0700 Message-ID: <20240327200352.236835-10-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" Chack the flag to see if the request is for a file that must calculate the sum of RMID counters from all sibling domains. Note that when reading RMID counters to sum across SUBL3 domains it is OK to read from any CPU in the parent L3 domain. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 2 + arch/x86/kernel/cpu/resctrl/monitor.c | 56 ++++++++++++++++++++++++--- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index b7ade7627e08..4cf256053f53 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -177,6 +177,7 @@ enum resctrl_scope { * @evt_list: List of monitoring events * @parent: Parent of this resource * @child: Child of this resource + * @num_siblings: Number of sibling domains that share a parent * @fflags: flags to choose base and info files * @cdp_capable: Is the CDP feature available on this resource */ @@ -200,6 +201,7 @@ struct rdt_resource { struct list_head evt_list; struct rdt_resource *parent; struct rdt_resource *child; + int num_siblings; unsigned long fflags; bool cdp_capable; }; diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 95455cb187eb..1ba40d5f5d77 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -279,12 +279,24 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, st= ruct rdt_domain *d, struct rdt_hw_domain *hw_dom =3D resctrl_to_arch_dom(d); struct arch_mbm_state *am; u64 msr_val, chunks; - int ret; + int cpu, ret; =20 resctrl_arch_rmid_read_context_check(); =20 - if (!cpumask_test_cpu(smp_processor_id(), &d->cpu_mask)) - return -EINVAL; + /* This sanity check is now heavyweight. Keep it? */ + cpu =3D smp_processor_id(); + if (r->parent) { + struct rdt_domain *pd; + + pd =3D rdt_find_domain(r->parent, d->parent, NULL); + if (WARN_ON_ONCE(!pd)) + return -EINVAL; + if (!cpumask_test_cpu(cpu, &pd->cpu_mask)) + return -EINVAL; + } else { + if (!cpumask_test_cpu(cpu, &d->cpu_mask)) + return -EINVAL; + } =20 ret =3D __rmid_read(rmid, eventid, &msr_val); if (ret) @@ -538,7 +550,7 @@ static struct mbm_state *get_mbm_state(struct rdt_domai= n *d, u32 closid, } } =20 -static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr) +static int ___mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr, = u64 *rrval) { struct mbm_state *m; u64 tval =3D 0; @@ -556,11 +568,44 @@ static int __mon_event_count(u32 closid, u32 rmid, st= ruct rmid_read *rr) if (rr->err) return rr->err; =20 - rr->val +=3D tval; + *rrval +=3D tval; =20 return 0; } =20 +static u32 get_node_rmid(struct rdt_resource *r, struct rdt_domain *d, u32= rmid) +{ + int cpu =3D cpumask_any(&d->cpu_mask); + + return rmid + (cpu_to_node(cpu) % r->num_siblings) * r->num_rmid; +} + +static int __mon_event_count(u32 closid, u32 rmid, struct rmid_read *rr) +{ + struct rdt_domain *d; + struct rmid_read tmp; + u32 node_rmid; + int ret =3D 0; + + if (!rr->sumdomains) { + node_rmid =3D get_node_rmid(rr->r, rr->d, rmid); + return ___mon_event_count(closid, node_rmid, rr, &rr->val); + } + + tmp =3D *rr; + list_for_each_entry(d, &rr->r->domains, list) { + if (d->parent =3D=3D rr->d->parent) { + tmp.d =3D d; + node_rmid =3D get_node_rmid(rr->r, d, rmid); + ret =3D ___mon_event_count(closid, node_rmid, &tmp, &rr->val); + if (ret) + break; + } + } + + return ret; +} + /* * mbm_bw_count() - Update bw count from values previously read by * __mon_event_count(). @@ -1039,6 +1084,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) */ resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 + r->num_siblings =3D 1; rdt_l3_mon_resource =3D r; =20 ret =3D dom_data_init(rdt_l3_mon_resource); --=20 2.44.0 From nobody Sun Feb 8 12:37:25 2026 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 ED1F0153823 for ; Wed, 27 Mar 2024 20:04:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569851; cv=none; b=rHXX84RqWXvK9LaxSG7fIag7j6CFXj0XbLHpm9ZOVsOIIbgs9DlurG1wZ22gpn09LtzfzBlRJYCO9AduvWLcZfZQnRGR9hNC3DjABT+ex4Cn3qsDj4ZF5qHDURrZ2b7jG6fmRlPmFho7AhGAYnaO8Qmkvr3zwIeBlVAMPdEPsSs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711569851; c=relaxed/simple; bh=jnjYRbh/fPxftA3RtGXzv9UpX5enrkyZvcYUhq10uNg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kOymHdHF6kcnbbAT6wY7GoxM4BL69lEZtdsPmnbwKnrY0lJqnTmswT0nLP39hM/r6N85D+wel6yA1oWh3aArDB8+YK5I7Ibzys/WQrzK1gTa1SauIPGEb5RdKEijX7Jv3R3X5HYIDnuo+xyTtywGDRqw8eYROWHqeg5E6siKj0g= 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=KtktXxvn; arc=none smtp.client-ip=198.175.65.12 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="KtktXxvn" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1711569850; x=1743105850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jnjYRbh/fPxftA3RtGXzv9UpX5enrkyZvcYUhq10uNg=; b=KtktXxvnxwcv6XGt8VLiYSSI9Rvh4ShVWSnyzu+iuefD2n4NP70LPEOJ ZWkslgBwq96mBXu+DpYfgZb0/f/+jrshWYPv3nNJu3UrJl0ZLKGVoNGcn 3K9H9H6sLJbm7aaHf2t6MpCirnSqu74PDHMCFrrTUwhNxWZ4RBLu7+KkZ JZ3pzpsb5BLyUPfetaFBsnhz4VlhIrhKoo1CM4+/ufl/Stl4N8sugtKJm 3cTFtHZ33I5KUjhvdHjwe+IAdOX3MlsXucpCRl6QJOPz7G/aiLBytWjOF IBch43duRtiVepAUQCvJNGgqFYdhHBZmqIGXOUfbhj7IR1SxTF9Z0DJU5 Q==; X-CSE-ConnectionGUID: W8wRhlIrS0O910ukY8U+vQ== X-CSE-MsgGUID: sxEC4Ze1Q6qH83+uwQe2mQ== X-IronPort-AV: E=McAfee;i="6600,9927,11026"; a="18133030" X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="18133030" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,159,1708416000"; d="scan'208";a="16246150" Received: from agluck-desk3.sc.intel.com ([172.25.222.105]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Mar 2024 13:04:04 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Maciej Wieczor-Retman , Peter Newman , James Morse , Babu Moger , Drew Fustini Cc: x86@kernel.org, linux-kernel@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 10/10] x86/resctrl: Determine Sub-NUMA configuration Date: Wed, 27 Mar 2024 13:03:52 -0700 Message-ID: <20240327200352.236835-11-tony.luck@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240327200352.236835-1-tony.luck@intel.com> References: <20240327200352.236835-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: quoted-printable Content-Type: text/plain; charset="utf-8" There isn't an explicit enumeration of Sub-NUMA cluster mode. Use the ratio of the number of CPUs that share an L3 cache instance with CPU 0 against the number of CPUs that share a node with CPU0. When Sub-NUMA cluster mode is enabled, adjust the number of RMIDs, the sclaing factor, and setup the parent/child pointers in the L3 and SUBL3 rdt_resource structures, etc. As each Sub-NUMA domain is brought online, update the MSR_RMID_SNC_CONFIG to remap RMID counters. Signed-off-by: Tony Luck --- arch/x86/include/asm/msr-index.h | 1 + arch/x86/kernel/cpu/resctrl/monitor.c | 68 ++++++++++++++++++++++++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 26 ++++++++++ 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-in= dex.h index 05956bd8bacf..b54c26016c93 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -1158,6 +1158,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 =20 diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/re= sctrl/monitor.c index 1ba40d5f5d77..757d475158a3 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -17,6 +17,7 @@ =20 #include #include +#include #include #include =20 @@ -1051,16 +1052,59 @@ static void l3_mon_evt_init(struct rdt_resource *r) list_add_tail(&mbm_local_event.list, &r->evt_list); } =20 +/* CPU models that support MSR_RMID_SNC_CONFIG */ +static const struct x86_cpu_id snc_cpu_ids[] __initconst =3D { + X86_MATCH_INTEL_FAM6_MODEL(ICELAKE_X, 0), + X86_MATCH_INTEL_FAM6_MODEL(SAPPHIRERAPIDS_X, 0), + X86_MATCH_INTEL_FAM6_MODEL(EMERALDRAPIDS_X, 0), + X86_MATCH_INTEL_FAM6_MODEL(GRANITERAPIDS_X, 0), + X86_MATCH_INTEL_FAM6_MODEL(ATOM_CRESTMONT_X, 0), + {} +}; + +static __init int snc_get_config(void) +{ + struct cpu_cacheinfo *ci =3D get_cpu_cacheinfo(0); + cpumask_t *l3_cpumask =3D NULL; + const cpumask_t *node0_cpumask; + int i; + + if (!x86_match_cpu(snc_cpu_ids)) + return 1; + + for (i =3D 0; i < ci->num_leaves; i++) { + if (ci->info_list[i].level =3D=3D 3) { + if (ci->info_list[i].attributes & CACHE_ID) { + l3_cpumask =3D &ci->info_list[i].shared_cpu_map; + break; + } + } + } + if (!l3_cpumask) { + pr_info("can't get CPU0 L3 mask\n"); + return 1; + } + + node0_cpumask =3D cpumask_of_node(cpu_to_node(0)); + + return bitmap_weight(cpumask_bits(l3_cpumask), nr_cpu_ids) / + bitmap_weight(cpumask_bits(node0_cpumask), nr_cpu_ids); +} + int __init rdt_get_mon_l3_config(struct rdt_resource *r) { unsigned int mbm_offset =3D boot_cpu_data.x86_cache_mbm_width_offset; struct rdt_hw_resource *hw_res =3D resctrl_to_arch_res(r); unsigned int threshold; + int snc_ways; int ret; =20 + snc_ways =3D snc_get_config(); + if (snc_ways > 1) + pr_info("Sub-NUMA cluster detected with %d nodes per L3 cache\n", snc_wa= ys); resctrl_rmid_realloc_limit =3D boot_cpu_data.x86_cache_size * 1024; - hw_res->mon_scale =3D boot_cpu_data.x86_cache_occ_scale; - r->num_rmid =3D boot_cpu_data.x86_cache_max_rmid + 1; + hw_res->mon_scale =3D boot_cpu_data.x86_cache_occ_scale / snc_ways; + r->num_rmid =3D (boot_cpu_data.x86_cache_max_rmid + 1) / snc_ways; hw_res->mbm_width =3D MBM_CNTR_WIDTH_BASE; =20 if (mbm_offset > 0 && mbm_offset <=3D MBM_CNTR_WIDTH_OFFSET_MAX) @@ -1084,8 +1128,23 @@ int __init rdt_get_mon_l3_config(struct rdt_resource= *r) */ resctrl_rmid_realloc_threshold =3D resctrl_arch_round_mon_val(threshold); =20 - r->num_siblings =3D 1; - rdt_l3_mon_resource =3D r; + if (snc_ways > 1) { + struct rdt_hw_resource *shw_res; + + rdt_l3_mon_resource =3D &rdt_resources_all[RDT_RESOURCE_SUBL3].r_resctrl; + rdt_l3_mon_resource->num_rmid =3D r->num_rmid; + rdt_l3_mon_resource->num_siblings =3D snc_ways; + + shw_res =3D resctrl_to_arch_res(rdt_l3_mon_resource); + shw_res->mon_scale =3D hw_res->mon_scale; + shw_res->mbm_width =3D hw_res->mbm_width; + + r->child =3D rdt_l3_mon_resource; + rdt_l3_mon_resource->parent =3D r; + } else { + r->num_siblings =3D 1; + rdt_l3_mon_resource =3D r; + } =20 ret =3D dom_data_init(rdt_l3_mon_resource); if (ret) @@ -1110,6 +1169,7 @@ int __init rdt_get_mon_l3_config(struct rdt_resource = *r) =20 l3_mon_evt_init(rdt_l3_mon_resource); =20 + r->mon_capable =3D true; rdt_l3_mon_resource->mon_capable =3D true; rdt_l3_mon_resource->mon_enabled =3D true; =20 diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 3e7f2e36b71e..b1f79fafa333 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -4067,6 +4067,29 @@ static int domain_setup_mon_state(struct rdt_resourc= e *r, struct rdt_domain *d) return 0; } =20 +/* + * 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 + * couning operations from tasks. Code to read the counters + * must adjust RMID counter numbers based on SNC node. See + * __rmid_read() for code that does this. + */ +static void snc_remap_rmids(void) +{ + u64 val; + + rdmsrl(MSR_RMID_SNC_CONFIG, val); + val &=3D ~BIT_ULL(0); + wrmsrl(MSR_RMID_SNC_CONFIG, val); +} + int resctrl_online_domain(struct rdt_resource *r, struct rdt_domain *d) { int err =3D 0; @@ -4082,6 +4105,9 @@ int resctrl_online_domain(struct rdt_resource *r, str= uct rdt_domain *d) if (!r->mon_enabled) goto out_unlock; =20 + if (r->num_siblings > 1) + snc_remap_rmids(); + err =3D domain_setup_mon_state(r, d); if (err) goto out_unlock; --=20 2.44.0