From patchwork Thu Jan 26 18:41:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 48847 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp428470wrn; Thu, 26 Jan 2023 10:43:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvuCElT5uPtMe98LvimptmOtxNADUdAknsoSQeeKp00E4KLzIzN/6VPiIgOU9sq+Zz5Myeo X-Received: by 2002:a05:6a21:151b:b0:b8:a355:5914 with SMTP id nq27-20020a056a21151b00b000b8a3555914mr41135379pzb.37.1674758614018; Thu, 26 Jan 2023 10:43:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674758614; cv=none; d=google.com; s=arc-20160816; b=cndJDJZjIUwaTc3854tIAnUzU9S4dptjdbYZQkMsT/xWGAKCzAiTAJssuwnGLHt64P YrrQUwVhxLHYroWftnfjYlB0+yxMFUuG6EnKOa31cwAluq85cum4GDP+5//jN++1Vzjc 7QpMa9VH9kJ+m++HzsO9tZatQ9NueGvAV3yD8lY9/vpj2p03jMdIxkYXSqXMpp8jgTl5 ktOnUY9yGZD5M3IgzkpzhFDRm0Lu38KoernD7XnZlLkJ7GfuAsGPdExPTTk8eVZM3E2e zwfMzc4fbCony2aCGsQ85X1iFQ+ptn3GbNvaP6zNXAtO84n+Y6RRFkDmmvivc4asfaMR ylDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=X2qya1PHczCGVTV5TdyIja9duPTgHmAC7vg3NrvFAao=; b=S0iMYdbI6D0i1lqSgL5hap+ZuUJI6My77xg9C8tYGplnugKvL7CLgJyYnplG3xJu7e PP9yVo6dq2k1Ly535w1nBHX6pr5AuzOeNtUaHG9ezP3H3qwNMF/itUX5utE0khbPQO/E keLAXsC94w2D+ivRdzCV0DZTRMFnQRxo5tu/MvwM4OKrtJkRndSLh5nVhv7jUTkPc/6g xNg15bPgzaHGnm76omymr33otMgiH5x4TQKAtTFs6+vJp+gVDqLEsIe1aTlAqzRAS/4E EL+sScq61yCIhqSCz5oc4fqfpCl7bWkpgFS/7s8ai8QISz06JM3THz3VMVWHS9oYuAa7 F+cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M4+DrZXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bs65-20020a632844000000b00478e15039c0si1702799pgb.779.2023.01.26.10.43.22; Thu, 26 Jan 2023 10:43:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=M4+DrZXg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229510AbjAZSmd (ORCPT + 99 others); Thu, 26 Jan 2023 13:42:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229536AbjAZSmb (ORCPT ); Thu, 26 Jan 2023 13:42:31 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 732343EFC6; Thu, 26 Jan 2023 10:42:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674758550; x=1706294550; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Pd74plTjDM934Mu3gAMHaaPSse3mzDXyW5UsS0F/p6Y=; b=M4+DrZXgFsISNEoVz+4DKQxvK+yFOj3zhIvbQlnh9XFRglKmQXe6dDJN M6Bdz0Yibu4rwzoSkclp8zi/9W0zEU/WRi783thglTZQ3UF1VjwojgqgO 1uNm9vDA7IVPy3EpVfKrQ+miFU/6OeOpUdH1zNMbsMlIxLzYzE1pB+Co6 Ha8+OC/OqlsevFMwHscJKkZOrauGidQA2yD19Le9nggr8/5aBsZMi506c EuNzHDWnmmLJh3qAPqvrWR7hyfm94SOHE9tZy0COvwsE0M/TUeFxs7U/e Sc5iOKKq6YS9noaDIHFoElJzW3tzH606RmjmbEm2GVFHjh/uZ2vxIZ3kw Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="354203321" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="354203321" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:05 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="991745439" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="991745439" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:05 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 1/7] x86/resctrl: Refactor in preparation for node-scoped resources Date: Thu, 26 Jan 2023 10:41:51 -0800 Message-Id: <20230126184157.27626-2-tony.luck@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126184157.27626-1-tony.luck@intel.com> References: <20230126184157.27626-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756111688349260059?= X-GMAIL-MSGID: =?utf-8?q?1756111688349260059?= Sub-NUMA cluster systems provide monitoring resources at the NUMA node scope instead of the L3 cache scope. Rename the cache_level field in struct rdt_resource to the more generic "scope" and add symbolic names and a helper function. No functional change. Signed-off-by: Tony Luck --- include/linux/resctrl.h | 4 ++-- arch/x86/kernel/cpu/resctrl/internal.h | 5 +++++ arch/x86/kernel/cpu/resctrl/core.c | 15 ++++++++++----- arch/x86/kernel/cpu/resctrl/pseudo_lock.c | 2 +- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 2 +- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 0cee154abc9f..64ecfcafa0a2 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -150,7 +150,7 @@ struct resctrl_schema; * @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 level or NUMA node) * @cache: Cache allocation related data * @membw: If the component has bandwidth controls, their properties. * @domains: All domains for this resource @@ -168,7 +168,7 @@ struct rdt_resource { bool alloc_capable; bool mon_capable; int num_rmid; - int cache_level; + int scope; struct resctrl_cache cache; struct resctrl_membw membw; struct list_head domains; diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 5ebd28e6aa0c..15cea517efaa 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -414,6 +414,11 @@ enum resctrl_res_level { RDT_NUM_RESOURCES, }; +enum resctrl_scope { + SCOPE_L2_CACHE = 2, + SCOPE_L3_CACHE = 3 +}; + static inline struct rdt_resource *resctrl_inc(struct rdt_resource *res) { struct rdt_hw_resource *hw_res = resctrl_to_arch_res(res); diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index c98e52ff5f20..6914232acf84 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -65,7 +65,7 @@ struct rdt_hw_resource rdt_resources_all[] = { .r_resctrl = { .rid = RDT_RESOURCE_L3, .name = "L3", - .cache_level = 3, + .scope = SCOPE_L3_CACHE, .domains = domain_init(RDT_RESOURCE_L3), .parse_ctrlval = parse_cbm, .format_str = "%d=%0*x", @@ -79,7 +79,7 @@ struct rdt_hw_resource rdt_resources_all[] = { .r_resctrl = { .rid = RDT_RESOURCE_L2, .name = "L2", - .cache_level = 2, + .scope = SCOPE_L2_CACHE, .domains = domain_init(RDT_RESOURCE_L2), .parse_ctrlval = parse_cbm, .format_str = "%d=%0*x", @@ -93,7 +93,7 @@ struct rdt_hw_resource rdt_resources_all[] = { .r_resctrl = { .rid = RDT_RESOURCE_MBA, .name = "MB", - .cache_level = 3, + .scope = SCOPE_L3_CACHE, .domains = domain_init(RDT_RESOURCE_MBA), .parse_ctrlval = parse_bw, .format_str = "%d=%*u", @@ -462,6 +462,11 @@ static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_domain *hw_dom) return 0; } +static int get_domain_id(int cpu, enum resctrl_scope scope) +{ + return get_cpu_cacheinfo_id(cpu, scope); +} + /* * domain_add_cpu - Add a cpu to a resource's domain list. * @@ -477,7 +482,7 @@ static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_domain *hw_dom) */ static void domain_add_cpu(int cpu, struct rdt_resource *r) { - int id = get_cpu_cacheinfo_id(cpu, r->cache_level); + int id = get_domain_id(cpu, r->scope); struct list_head *add_pos = NULL; struct rdt_hw_domain *hw_dom; struct rdt_domain *d; @@ -527,7 +532,7 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r) static void domain_remove_cpu(int cpu, struct rdt_resource *r) { - int id = get_cpu_cacheinfo_id(cpu, r->cache_level); + int id = get_domain_id(cpu, r->scope); struct rdt_hw_domain *hw_dom; struct rdt_domain *d; diff --git a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c index 524f8ff3e69c..d2ba4f7f6a79 100644 --- a/arch/x86/kernel/cpu/resctrl/pseudo_lock.c +++ b/arch/x86/kernel/cpu/resctrl/pseudo_lock.c @@ -297,7 +297,7 @@ static int pseudo_lock_region_init(struct pseudo_lock_region *plr) plr->size = rdtgroup_cbm_to_size(plr->s->res, plr->d, plr->cbm); for (i = 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level == plr->s->res->cache_level) { + if (ci->info_list[i].level == plr->s->res->scope) { plr->line_size = ci->info_list[i].coherency_line_size; return 0; } diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 5993da21d822..a6ba3080e5db 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1333,7 +1333,7 @@ unsigned int rdtgroup_cbm_to_size(struct rdt_resource *r, num_b = bitmap_weight(&cbm, r->cache.cbm_len); ci = get_cpu_cacheinfo(cpumask_any(&d->cpu_mask)); for (i = 0; i < ci->num_leaves; i++) { - if (ci->info_list[i].level == r->cache_level) { + if (ci->info_list[i].level == r->scope) { size = ci->info_list[i].size / r->cache.cbm_len * num_b; break; } From patchwork Thu Jan 26 18:41:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 48848 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp428511wrn; Thu, 26 Jan 2023 10:43:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXtqAfsfu1T9Lcfl8bxABd+1C3QPIVVs1em3OgrUBA8lwD0Vei4h3nQ07eZdR10Laa8xdUZR X-Received: by 2002:a05:6a20:7da2:b0:b8:5a85:632c with SMTP id v34-20020a056a207da200b000b85a85632cmr48754341pzj.60.1674758620117; Thu, 26 Jan 2023 10:43:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674758620; cv=none; d=google.com; s=arc-20160816; b=dXpRg1tmzQVQU5pH6MUBinwS0CgMrTbOyMdwEjkCBYTBpEdobEgEU3Zf/Gl+5/JIlc oyxUPScmYtmOvvaJmMov2uDUvmcT3m1S2RftMZdcpbyj9ONOsAfKWzFT1rZq+pk1tYQu 6tWnbijJ7dGMar2JD8kaoy3saPybppCUg4tTu0HjFPhIyIQ2x0UOswb0G2a8IJWFoU55 datlqzRNSvwOjdCouXjD6Na4Nz9V5yKL/NM6MvFExfJluFjeoAqQ9qiAFjLC+5ptvGz4 63YwbxkgkFWYDsErKBNY55U0obo1dYORspuiQ1T/y0izjAdrhr2HzG3dKcLw4rSxd6an 4T+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1CKjfnx5XKZqtvItaUFKaDBK1TCU32Ry4R+Y/xiq4b0=; b=p+12KyXOlxlHyajcgNmyNoLj2fht3RYopS3hy+HdAFtXYJQvE6QcD0oYZ4vksejLkz cHY7vdRjtgUUjVMh9gnmqD0Fog1HnVLCt9fyVx8IJshIcNC2vqtGDNM6KAOZKYu1Ao+8 gQtkanZJwV9Nc/QrhrKuyDHNmligiqX1JaxeOCxfuFbaVHSj/3Gw1IsOfMpoVQ3fWUs0 JW80AhKf2UUUUCHBAgtYk5Y2RJkGlikoxyX08df9RjAbS0NlpLaHzpp5o817k5+3qUHr ZZsVZw7YwlfD6FQW/eqvcWgyXv0xm6X3IZFWhw/pvhZFXntNaQhZxzTq9Uw5vgnzv/cX SK4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mfHqfGaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c10-20020a63a40a000000b004d21c99e5b7si1786061pgf.316.2023.01.26.10.43.27; Thu, 26 Jan 2023 10:43:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=mfHqfGaD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229558AbjAZSmg (ORCPT + 99 others); Thu, 26 Jan 2023 13:42:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbjAZSmc (ORCPT ); Thu, 26 Jan 2023 13:42:32 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B077366A7; Thu, 26 Jan 2023 10:42:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674758551; x=1706294551; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=bsHRrFSHNHwYzutnGoCpp7L6CsbI7cB3D9T+kZSrwWU=; b=mfHqfGaDmMC6NCYo4PSX4ZkLr/x0RR7UEKkKm100M2cPF3Ntw28aYE9Y JBBpEAK9eVXQ25qjcYZnXhtv6jxytQNn7zUxaQKAuanYulHk8hwaqNfb4 Brrbn+gt7uYQLXe/zzxDcnF77ovxsCi7vstuv9VMQknMr5k3wr09Wc/m4 iD10aQ95XrgcANut7vD1Q+RY3MPxFi+i3lgcm6GMzQxXuR+ChS/1I/py8 EnhLx6LTSa1ifWhKdsjN/5Ylmq0fsiUYBQkWUAkXw5phHLTYyenhRdOsd zf0Y2sZLmPLXnV6xB9KCtI/XVFVJbcyszsgdBvaO1qV3+B20jqKRqLVFP w==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="354203330" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="354203330" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="991745442" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="991745442" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:05 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 2/7] x86/resctrl: Remove hard code of RDT_RESOURCE_L3 in monitor.c Date: Thu, 26 Jan 2023 10:41:52 -0800 Message-Id: <20230126184157.27626-3-tony.luck@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126184157.27626-1-tony.luck@intel.com> References: <20230126184157.27626-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756111694538610415?= X-GMAIL-MSGID: =?utf-8?q?1756111694538610415?= Scope of monitoring may be scoped at L3 cache granularity (legacy) or at the node level (systems with Sub NUMA Cluster enabled). Save the struct rdt_resource pointer that was used to initialize the monitor sections of code and use that value instead of the hard-coded RDT_RESOURCE_L3. No functional change. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/monitor.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index 77538abeb72a..d05bbd4f6b2d 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -30,6 +30,8 @@ struct rmid_entry { struct list_head list; }; +static struct rdt_resource *mon_resource; + /** * @rmid_free_lru A least recently used list of free RMIDs * These RMIDs are guaranteed to have an occupancy less than the @@ -251,7 +253,7 @@ int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, */ void __check_limbo(struct rdt_domain *d, bool force_free) { - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r = mon_resource; struct rmid_entry *entry; u32 crmid = 1, nrmid; bool rmid_dirty; @@ -316,7 +318,7 @@ int alloc_rmid(void) static void add_rmid_to_limbo(struct rmid_entry *entry) { - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r = mon_resource; struct rdt_domain *d; int cpu, err; u64 val = 0; @@ -633,7 +635,7 @@ void cqm_handle_limbo(struct work_struct *work) mutex_lock(&rdtgroup_mutex); - r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + r = mon_resource; d = container_of(work, struct rdt_domain, cqm_limbo.work); __check_limbo(d, false); @@ -669,7 +671,7 @@ void mbm_handle_overflow(struct work_struct *work) if (!static_branch_likely(&rdt_mon_enable_key)) goto out_unlock; - r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + r = mon_resource; d = container_of(work, struct rdt_domain, mbm_over.work); list_for_each_entry(prgrp, &rdt_all_groups, rdtgroup_list) { @@ -747,9 +749,11 @@ static struct mon_evt mbm_local_event = { /* * Initialize the event list for the resource. * - * Note that MBM events are also part of RDT_RESOURCE_L3 resource + * Note that MBM events can either be part of RDT_RESOURCE_L3 resource * because as per the SDM the total and local memory bandwidth - * are enumerated as part of L3 monitoring. + * are enumerated as part of L3 monitoring, or they may be per NUMA + * node on systems with sub-NUMA cluster enabled and are then in the + * RDT_RESOURCE_NODE resource. */ static void l3_mon_evt_init(struct rdt_resource *r) { @@ -761,6 +765,8 @@ static void l3_mon_evt_init(struct rdt_resource *r) list_add_tail(&mbm_total_event.list, &r->evt_list); if (is_mbm_local_enabled()) list_add_tail(&mbm_local_event.list, &r->evt_list); + + mon_resource = r; } int rdt_get_mon_l3_config(struct rdt_resource *r) From patchwork Thu Jan 26 18:41:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 48850 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp429220wrn; Thu, 26 Jan 2023 10:45:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXuXe0+WPUPEhkFOq1GZuxywXygN1+GrV/Dt2Mj8jg5x2dDerqRGhUY8O9acxru+pfceO2Gb X-Received: by 2002:a17:90b:348e:b0:229:5cab:67a8 with SMTP id kd14-20020a17090b348e00b002295cab67a8mr38015351pjb.24.1674758724161; Thu, 26 Jan 2023 10:45:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674758724; cv=none; d=google.com; s=arc-20160816; b=C3lGF3x9JBJjBQbOJq561fB3vAXx58WIT7vELz3cclayWz/kz2qdHlmwzl2srf3/hU gPvtNFVOexW7ACHqfcSq776QnU83nFLLfbE//FjnZeEIKmrzxq4nWyhEcDCoHwYWwIu4 yJUHjq/ljeXCuMPACoL12iEIFVcN3wHP/qXLsHZkuxS3nL38CxdrtenfZcAdDvmriNRw LRHUh5f/lwOti8ZQRQkEbAL9IMB3pS3I75I6cUs4YAZ9seWn0J0jlvLPHlu3JAs3acce ANlxI9EWvCfYBtIr9RQVrZy6uV/LjaRkau8ZoLNMdmFX6vww8Ws1OlAHt63+igro142a YZpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PueeEeiVr/dRafxQRG+wR4MGAAsF8JZb6m2vuMC0LCo=; b=Gdw307kit9AJBKOyDYWiQDYVWLXn23URPU/HctIHi7DB73nASepeywoOIs0VrjR/kQ YIWcPTuc7cv7SO2eGtgz/KSaqSJ2mV3IMCws7qeIrsuE6ipTGcwWKEcP6r759izH/DL7 httkETE8X4OAbAwKgGO78hzPpAvWTjP9MkPQ1pKIk8jM3zMIfMOdfAOcfEaD77QZZRNV 53MqAKIZ1wTm6jyV9rlV8N9VNc2Emwr4RMuHQCU56YeL/UwJEojFZcklOXRRV9ll7mSd COLIbML6FUYqUrnnywYlymVFVmxAtxPD+0Mur/q9z49u9Y10JpNZpWrC7dffb3p1Xgis /Gnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TDv94L+z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o14-20020a17090aac0e00b0022645e2a88csi2297238pjq.56.2023.01.26.10.45.10; Thu, 26 Jan 2023 10:45:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=TDv94L+z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232212AbjAZSmo (ORCPT + 99 others); Thu, 26 Jan 2023 13:42:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230019AbjAZSmd (ORCPT ); Thu, 26 Jan 2023 13:42:33 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68E4E402D8; Thu, 26 Jan 2023 10:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674758552; x=1706294552; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sfw55e9pOISjtn87W0zcDQDfivg/FZE8hQOsm+yl2hY=; b=TDv94L+z2Z7d5rlAohU44bWNGIfKDhy0ZHcIxF2eo35NDF1AButwlqSb rxOACzKAQbcVJuxNrnGZopohLB2SGb9l8vaKy6O4Je5FhBWeC893Q+KwG 9SNKbDKSvGWOL/hJTR6efFf//Dgdr2NjPzN3lbXyS2/25MDQB+M8QiGiV R1rlS7s/8OaNQlbX4Kj2zi+BTl1Tl/25WPwAmEAVaQQPC3BDBaj9JExed U4HDVEIPmLdN21L76PvS9xAk6MkwLJA79YS1fXGuOqtTtGvymP9w16PD4 uKlQ44we40M4ptYKseRgXQ0I7iHVP2/P8xBf8htkFhmw/ROdJhc505rd3 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="354203341" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="354203341" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="991745445" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="991745445" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:05 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 3/7] x86/resctrl: Add a new node-scoped resource to rdt_resources_all[] Date: Thu, 26 Jan 2023 10:41:53 -0800 Message-Id: <20230126184157.27626-4-tony.luck@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126184157.27626-1-tony.luck@intel.com> References: <20230126184157.27626-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756111804282714673?= X-GMAIL-MSGID: =?utf-8?q?1756111804282714673?= Add a placeholder in the array of struct rdt_hw_resource to be used for event monitoring of systems with Sub-NUMA Cluster enabled. Update get_domain_id() to handle SCOPE_NODE. Signed-off-by: Tony Luck Tested-By: Peter Newman Reviewed-By: Peter Newman --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 15cea517efaa..39a62babd60b 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -409,12 +409,14 @@ enum resctrl_res_level { RDT_RESOURCE_L3, RDT_RESOURCE_L2, RDT_RESOURCE_MBA, + RDT_RESOURCE_NODE, /* Must be the last */ RDT_NUM_RESOURCES, }; enum resctrl_scope { + SCOPE_NODE, SCOPE_L2_CACHE = 2, SCOPE_L3_CACHE = 3 }; diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 6914232acf84..19be6fe42ef3 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -100,6 +100,16 @@ struct rdt_hw_resource rdt_resources_all[] = { .fflags = RFTYPE_RES_MB, }, }, + [RDT_RESOURCE_NODE] = + { + .r_resctrl = { + .rid = RDT_RESOURCE_NODE, + .name = "L3", + .scope = SCOPE_NODE, + .domains = domain_init(RDT_RESOURCE_NODE), + .fflags = RFTYPE_RES_MB, + }, + }, }; /* @@ -464,6 +474,8 @@ static int arch_domain_mbm_alloc(u32 num_rmid, struct rdt_hw_domain *hw_dom) static int get_domain_id(int cpu, enum resctrl_scope scope) { + if (scope == SCOPE_NODE) + return cpu_to_node(cpu); return get_cpu_cacheinfo_id(cpu, scope); } From patchwork Thu Jan 26 18:41:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 48849 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp428869wrn; Thu, 26 Jan 2023 10:44:38 -0800 (PST) X-Google-Smtp-Source: AMrXdXuOJfl2mAy6pw3P87gRfJIsPKuUAvL59t34bCPvR+hhSNKQ5krYMSAP3hOYb1FEK1sPEIkF X-Received: by 2002:a17:902:c401:b0:194:dc73:5cf8 with SMTP id k1-20020a170902c40100b00194dc735cf8mr37452363plk.39.1674758678470; Thu, 26 Jan 2023 10:44:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674758678; cv=none; d=google.com; s=arc-20160816; b=nNHrbCyAP+k+p4MQulNEaC9bhCMkXMMvV+rLrZrKulm5LX3aa4k5qSa6ZmRajDibMe Vc7qdizNmqUdfEYOddxtaZSuufZffK9qvD1rdK5Zt6mPfLQx8EyR1iT3isxXAL0IAYJM hhUo6y/+briWBDYeCHH2i8225+GM0/+Qn63rKG5+EWJEXqEY5QdgdcMB74JZQXEtvO0Z 2fFKSTvvc4aPZvRkik/0w4Bm6RKIqygFTwtqbL42/JcbLA7b8qQB9SjVG7qYlHmFPO/2 4fHzHZ2yMTDWV0UPdO4jOZQkzy/JBe01rtebgVEz+jdfl1UVPxer/jejnGQJMNVlgGx8 fgcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=QMfZ4MYj1r46uSj0b63dgM/BxslN4YTLUsi4B9dMlrk=; b=yy6zdZZUCC835HaUgYcBzMc04XHC65e/wBqkqIAPozUaZnzZ0WcorvN5RI1GGWHVEs 7VcCbhLO0M85uR/spDfqdGW21pywo+04yZOgh4oUvs17uEhjuC1XgJkAo3ibp09ag8Va g1m+3VzDHzbR0Y1XarSR4Gr+qJgazQ0igaoFFGKGdb3k2cEIBc1/oqIfaacWHGatEHyU 8r2V4setVNy0Mg/kG5w0b+A7MkZkUhSbJj345F5D3XbmjBBxi1gKbjWfI4UyqPzWsEiH 9XwIsHhDkL57wDkUjlNpgy79JKOTgZ6iGq4THM5zLDvrEhdeiyvc6EG2MrMYosqzASg0 t65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DdliaEVW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n1-20020a170902e54100b00189aab9cdbcsi2429915plf.605.2023.01.26.10.44.26; Thu, 26 Jan 2023 10:44:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DdliaEVW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232226AbjAZSmr (ORCPT + 99 others); Thu, 26 Jan 2023 13:42:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbjAZSmd (ORCPT ); Thu, 26 Jan 2023 13:42:33 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CA7845F74; Thu, 26 Jan 2023 10:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674758552; x=1706294552; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=b/uxKduTxOxhRTdknRQRA39FqoLPxucgbMsljFn2K+0=; b=DdliaEVWjUrRs1Wc5IuIrZ5iHW/zadQS2UJ9SWe7e+NMUtdMIh5okzhV pgM70QlRwCTGbf39lsXn29r+gEK/kcpLUM1K/xa/5S9L6MTjdo208J2F4 5y0etbDfK2gZK1E0N2dyFEaOuGX6atJJD3vy+YmqwY7o1bi/mvj8KJ5Eo UjQNrgLukkPEL0VkDZZlcxS4NK4XRs2TI82O7drt63P40UCwJ4CS4nJT3 zf3fk9Xz9vZVWpIl8hl3Ywo/iBbvZPiw2OxwrI5K2Fq3Zr6CMmz02gFG8 kJcfwGWwiNBdWqIfnxP8Pg0phrZMaeTJVBf4CmqtWmWk0BN0K1I0cXeHO A==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="354203351" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="354203351" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="991745449" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="991745449" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 4/7] x86/resctrl: Add code to setup monitoring at L3 or NODE scope. Date: Thu, 26 Jan 2023 10:41:54 -0800 Message-Id: <20230126184157.27626-5-tony.luck@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126184157.27626-1-tony.luck@intel.com> References: <20230126184157.27626-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756111756010465596?= X-GMAIL-MSGID: =?utf-8?q?1756111756010465596?= When Sub-NUMA cluster is enabled (snc_ways > 1) use the RDT_RESOURCE_NODE instead of RDT_RESOURCE_L3 for all monitoring operations. The mon_scale and num_rmid values from CPUID(0xf,0x1),(EBX,ECX) must be scaled down by the number of Sub-NUMA Clusters. A subsequent change will detect sub-NUMA cluster mode and set "snc_ways". For now set to one (meaning each L3 cache spans one node). Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/core.c | 13 ++++++++++++- arch/x86/kernel/cpu/resctrl/monitor.c | 4 ++-- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 5 ++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 39a62babd60b..ad26d008dafa 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -405,6 +405,8 @@ DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); extern struct dentry *debugfs_resctrl; +extern int snc_ways; + enum resctrl_res_level { RDT_RESOURCE_L3, RDT_RESOURCE_L2, diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 19be6fe42ef3..53b2ab37af2f 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -48,6 +48,11 @@ int max_name_width, max_data_width; */ bool rdt_alloc_capable; +/* + * How many Sub-Numa Cluster nodes share a single L3 cache + */ +int snc_ways = 1; + static void mba_wrmsr_intel(struct rdt_domain *d, struct msr_param *m, struct rdt_resource *r); @@ -786,7 +791,13 @@ static __init bool get_rdt_alloc_resources(void) static __init bool get_rdt_mon_resources(void) { - struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + struct rdt_resource *r; + + /* When SNC enabled, monitor functions at node instead of L3 cache scope */ + if (snc_ways > 1) + r = &rdt_resources_all[RDT_RESOURCE_NODE].r_resctrl; + else + r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; if (rdt_cpu_has(X86_FEATURE_CQM_OCCUP_LLC)) rdt_mon_features |= (1 << QOS_L3_OCCUP_EVENT_ID); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index d05bbd4f6b2d..3fc63aa68130 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -777,8 +777,8 @@ int rdt_get_mon_l3_config(struct rdt_resource *r) int ret; resctrl_rmid_realloc_limit = boot_cpu_data.x86_cache_size * 1024; - hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale; - r->num_rmid = boot_cpu_data.x86_cache_max_rmid + 1; + hw_res->mon_scale = boot_cpu_data.x86_cache_occ_scale / snc_ways; + r->num_rmid = (boot_cpu_data.x86_cache_max_rmid + 1) / snc_ways; hw_res->mbm_width = MBM_CNTR_WIDTH_BASE; if (mbm_offset > 0 && mbm_offset <= MBM_CNTR_WIDTH_OFFSET_MAX) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index a6ba3080e5db..a0dc64a70d01 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2238,7 +2238,10 @@ static int rdt_get_tree(struct fs_context *fc) static_branch_enable_cpuslocked(&rdt_enable_key); if (is_mbm_enabled()) { - r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; + if (snc_ways > 1) + r = &rdt_resources_all[RDT_RESOURCE_NODE].r_resctrl; + else + r = &rdt_resources_all[RDT_RESOURCE_L3].r_resctrl; list_for_each_entry(dom, &r->domains, list) mbm_setup_overflow_handler(dom, MBM_OVERFLOW_INTERVAL); } From patchwork Thu Jan 26 18:41:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 48851 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp429319wrn; Thu, 26 Jan 2023 10:45:41 -0800 (PST) X-Google-Smtp-Source: AK7set9xF6Z3dqeWdLZmKtEAanXBhQb8R+HC0BbJ1gzVzWFEN56ZN385FuMURRQCpTfgcwnh6f9G X-Received: by 2002:a62:828b:0:b0:590:70e0:c6a9 with SMTP id w133-20020a62828b000000b0059070e0c6a9mr5377754pfd.32.1674758741035; Thu, 26 Jan 2023 10:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674758741; cv=none; d=google.com; s=arc-20160816; b=z/33GEMMkkYf8CfMK7V09y7D9P0LZKpmCMClWMM5bb/fSPUB3xGSLTWB2P8+dt71na 7E29QI7knDA2L5US+w65vqiRr+AdrlR41Qm5gw/zGd6n7ZBt2qtJeqivt/IdhwKp5bcF eKMs9aVptouO8C7QLj1WoiPPRj+HcNYcAnGxNkvL3We62wh8+muuw9ujMFxPZdxx1ng7 df5zN8qFMWy6bR3sPz+9q5hv9ufHAz0hs9tIBql1o8Cqt37d9mDEdWDEfa4p37SvGjgQ cUaxsbDwiuiJ89e+5FL6nwq2F5g93hEqj4V/S2PpLUG96P2WzBLr84YQ1LhhGXhfB0kb ZmUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Q6NhNsTvlM//tugqpphfQShKc4dorBvHNARXEmxq1Ho=; b=dm0O40ZUeuHnQSD7jJWMSg/mpX4nwmyDqQAgF+9A7WI2NdaGoXN9hiU/5fMLFkT+wV 3gGA+WOouFXw4oCFgdiI5DPfh7SuvV+au9yA1YnOt3PvmGBEYYhpU0TxmlY88CzbP8pC qGdWMVaE/K2/U8h8CdzGUSyUUURLfxJFgOLAJUUIzFe33B5vyKs4qhuq8MYtCx++q9Hq eFWlX4C7p3wkmpAEKXOCekHi3fcctUXZESuOHRLY9gxEsGgIses42K6U5/StJPMaCUoJ NC5dFDg5Yf7+qvvjfKyou3CNlXVQFNvimYDfa0Z88YBk4SUJa/33kYdIljtKgOtNVWk2 hlkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YZr0bbBf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e14-20020aa7824e000000b0056ea2b1b0fesi1790083pfn.119.2023.01.26.10.45.29; Thu, 26 Jan 2023 10:45:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=YZr0bbBf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232237AbjAZSmt (ORCPT + 99 others); Thu, 26 Jan 2023 13:42:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231513AbjAZSmd (ORCPT ); Thu, 26 Jan 2023 13:42:33 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F314474C7; Thu, 26 Jan 2023 10:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674758553; x=1706294553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=lazqj33+wcKOHpjgmXNXHNJZww2MNyt2EHBaLJXRYCw=; b=YZr0bbBfahBUfu/3SAMOQ6hI6BwMxQ8CQFasPDZ5HwLV8kesrv8s24Hl 0WtUe9oo8GJn8+c+IALbhD/LlfL/SU3gSzPTB5qofKctBLWJTrqFrUo5O ShanDrlviRiTEOeOGS5wHs2QY8SGYhwixZvyGox93/YAIQOSZJCJHH3wM 6od47+f5NrPNwX9WRpbqQrmPETE+U01LzrqGmGjNSnxIknaDJ4HNj07kX Majv+Ly4+zHupenxDshgdJYVAUU1db7mBqhns5iPiMUy8Hn4ii9X7/4H9 kygaLFTiKrRg32zbGrA3E4+K1P7LDjFoY0bwfxQ9t/LqnVDxSkRWnGg3k g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="354203361" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="354203361" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="991745452" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="991745452" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 5/7] x86/resctrl: Add a new "snc_ways" file to the monitoring info directory. Date: Thu, 26 Jan 2023 10:41:55 -0800 Message-Id: <20230126184157.27626-6-tony.luck@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126184157.27626-1-tony.luck@intel.com> References: <20230126184157.27626-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756111821664181037?= X-GMAIL-MSGID: =?utf-8?q?1756111821664181037?= Make it easy for the user to tell if Sub-NUMA Cluster is enabled by providing an info/ file. Signed-off-by: Tony Luck --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index a0dc64a70d01..392e7a08d083 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -997,6 +997,14 @@ static int rdt_num_rmids_show(struct kernfs_open_file *of, return 0; } +static int rdt_snc_ways_show(struct kernfs_open_file *of, + struct seq_file *seq, void *v) +{ + seq_printf(seq, "%d\n", snc_ways); + + return 0; +} + static int rdt_mon_features_show(struct kernfs_open_file *of, struct seq_file *seq, void *v) { @@ -1451,6 +1459,13 @@ static struct rftype res_common_files[] = { .seq_show = rdt_num_rmids_show, .fflags = RF_MON_INFO, }, + { + .name = "snc_ways", + .mode = 0444, + .kf_ops = &rdtgroup_kf_single_ops, + .seq_show = rdt_snc_ways_show, + .fflags = RF_MON_INFO, + }, { .name = "cbm_mask", .mode = 0444, From patchwork Thu Jan 26 18:41:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 48853 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp435186wrn; Thu, 26 Jan 2023 11:01:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXsC0Tx2uyf3JTaczGEtq+2gnZU4eMMow7aznJWdSOrPMGRok9rilRXVjur2yEkbuk2fDmzO X-Received: by 2002:a17:907:c911:b0:870:5bf4:a3b1 with SMTP id ui17-20020a170907c91100b008705bf4a3b1mr34172698ejc.33.1674759689252; Thu, 26 Jan 2023 11:01:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674759689; cv=none; d=google.com; s=arc-20160816; b=zBpDUUra6ThSy26T6FaOLDJM5L4toZy+OAZ34I1aH85TlyK9Kmw2qETyROMHFFkEu3 aWyVentguFbTLTYGZd0A7iBP1Vc+6eyEK2U/Bly9NjFoL//4rSd7+6qjc51oWr6gMRoY lzIIvGhVMPSbFbWuUTo/Dn8kS2PTL268QbsrI9DNLfO3ViXr7Ye9muk3FGKf+RwhQyWm 5YBg19m1tjmEMqJ58cLu3FYhFogDDNnyWMAs7ckTlpp5j3jR2gkzhqYVSWIhvlP+uzs0 Oqtx20JNcXEnf8RpXV6fkzcAagQstDLvwPGqbyCoapeNTh9fmtL436ta6L47ltRAYOww QalQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=EORnN+S6yQXpFuPLsQ/HLmhemsXlKm0e9b6XrA5l/yc=; b=hLoTvqLmEUoikzy9kiQWueYWCYGuGQxv5cXCTaBDuS8S2dwrIuw/xauYB150U0pn6B WNeaHrn7Z5pZQmdPGWhlMN7cuHspgyWPKP04UyLt7GYKjZwTH8VuM5vO7vx/87JXPE1O jrIdijgfggPlvH7N5BKcVgw8Duv3S6KKkVuJHOgcBvqTJGCXfP1cL0qZpiPkz465GSFM 9Ge3/DD9JJk+H0t9swaChkJyUtadrdTn5+feDdnfLHGNrwlB0nC7ma5V8ZTUxyDAFUvx nrtPp699TarggXIUfjRQ+wcQA4+t8Vq2lk4Is5Src+xlvmAyWCz6TRytiOc+GORCR33b 3pLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FizYTQwt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ui42-20020a170907c92a00b0086e0afb91c8si1979312ejc.514.2023.01.26.11.01.06; Thu, 26 Jan 2023 11:01:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=FizYTQwt; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232250AbjAZSmw (ORCPT + 99 others); Thu, 26 Jan 2023 13:42:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229530AbjAZSme (ORCPT ); Thu, 26 Jan 2023 13:42:34 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E65C49022; Thu, 26 Jan 2023 10:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674758553; x=1706294553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ivyLAdBKqYQLl3lR+fj5FZ2eFkx8GG4TgMFpd25I12Y=; b=FizYTQwtsAhHSYsGHMFYSBag+jzIr/fw0g/NX7I/LJAgmrAmf2O4MfsJ ksreZLGCDaz9ekhG1ZfcvwbyKfHYhrhhi3le55HoB4xZGBIQvlbaQYwGH r5zAHfUbR8x5EbHCczY4ThYoRa7XxJJXSTlOQiroYGqAQeI0Z9qC7b9tv jZH/vUB9Z+Im4MPMKVR2KHkzdiHgO3Owgss40Ix/ovH0+IFIG/t+Yw+Pl KFTbfz33PGNYXTEgu4sjQgcTsWbQqEUaxLA49Y478CUytOR/FnqopjjDi 8nRmdSrnp7QTPsTA3HOM95VGd4j27ZVyYI+tDzz5tq1rIG4iz5r4Wdn9t w==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="354203371" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="354203371" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="991745455" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="991745455" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 6/7] x86/resctrl: Update documentation with Sub-NUMA cluster changes Date: Thu, 26 Jan 2023 10:41:56 -0800 Message-Id: <20230126184157.27626-7-tony.luck@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126184157.27626-1-tony.luck@intel.com> References: <20230126184157.27626-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756112816396620279?= X-GMAIL-MSGID: =?utf-8?q?1756112816396620279?= With Sub-NUMA Cluster mode enabled the scope of monitoring resources is per-NODE instead of per-L3 cache. Suffices of directories with "L3" in their name refer to Sun-NUMA nodes instead of L3 cache ids. Signed-off-by: Tony Luck --- Documentation/x86/resctrl.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Documentation/x86/resctrl.rst b/Documentation/x86/resctrl.rst index 71a531061e4e..9043a2d2f2d3 100644 --- a/Documentation/x86/resctrl.rst +++ b/Documentation/x86/resctrl.rst @@ -167,6 +167,11 @@ with the following files: bytes) at which a previously used LLC_occupancy counter can be considered for re-use. +"snc_ways": + A value of "1" marks that SNC mode is disabled. + Values of "2" or "4" indicate how many NUMA + nodes share an L3 cache. + Finally, in the top level of the "info" directory there is a file named "last_cmd_status". This is reset with every "command" issued via the file system (making new directories or writing to any of the @@ -254,9 +259,13 @@ When control is enabled all CTRL_MON groups will also contain: When monitoring is enabled all MON groups will also contain: "mon_data": - This contains a set of files organized by L3 domain and by - RDT event. E.g. on a system with two L3 domains there will - be subdirectories "mon_L3_00" and "mon_L3_01". Each of these + This contains a set of files organized by L3 domain or by NUMA + node (depending on whether SNC mode is disabled or enabled + respectively) and by RDT event. E.g. on a system with SNC + mode disabled with two L3 domains there will be subdirectories + "mon_L3_00" and "mon_L3_01" the numerical suffix refers to the + L3 cache id. With SNC enabled the directory names are the same, + but the numerical suffix refers to the node id. Each of these directories have one file per event (e.g. "llc_occupancy", "mbm_total_bytes", and "mbm_local_bytes"). In a MON group these files provide a read out of the current value of the event for From patchwork Thu Jan 26 18:41:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Luck, Tony" X-Patchwork-Id: 48852 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp432022wrn; Thu, 26 Jan 2023 10:53:08 -0800 (PST) X-Google-Smtp-Source: AK7set98NG+NhcnNzGAw1bE4v/5iBYufzZkozUFf6M22et1f6cj6TSADnjl9OLfrb5Srk+d6vdAc X-Received: by 2002:a17:903:191:b0:196:2364:e908 with SMTP id z17-20020a170903019100b001962364e908mr9375867plg.37.1674759187692; Thu, 26 Jan 2023 10:53:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674759187; cv=none; d=google.com; s=arc-20160816; b=CGggIf45lk3IyJdxWSddwYme12kH/JjenrQhdHAutWZPGnhNUiSgt76vJHglPmxInb IfSGd7aQp8jNSm9+/zhFh2MimpYocItJ/8ITvMz7NSPaEL8JmiLei7f48zarvDR+ETwP U4Xyp9kKaGxKJ4iwjRqy24ZIHlFkWTAWBnpMhwQOeyvEWeeZG/aDDRMZukl1rcfCE2Jv 54Q/JfgfZSZ6MV4tZueQn+EdqxMXT2LgHEGvZTT0dcpHBCDT8KD2oLQ7HCP8jB7Hc0Yk MH57E09VwzCzC81JOqY8sgq2JVloV9LcFqzz50v729fGzYGb6hgE+xYzieAZw6mysJNm urSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=+nxFqMHSrV0tCsNcNRIwpZmkJnaycxEMuACJPkLVquI=; b=CDCSSLfD3RpLZDWWF6GiPJU+vdsUXM+CFG/xMd2kjVjZ9wbaNWqmAw1WS2zmQFOJfG bCIoPiKitmY1YLFRzT9vOh7a0bzV7aO4o4bprviHdcp9fHZ76kViHzKgDpfRyIAU4YEy 2ckqqivsCGH6K3lk3cUY11bVxTsNxMyK2eB/d3Q2K1ugHFQIxfDLbnyUkHmC6krz1iw4 qfyE19BosugvrfxhRS38NYAWNPFUp7JqPegTwAxaUVzR5Eshs4cqE/W1oXoJt8gkn3HS dzGjpr1q3ofYD9ZhrmApZhxSP+meWqLdoiHhbMNRZlt9J+6fsn64E7dimSEdKlp500Qp ROzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eCCLJiCg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i6-20020a170902c94600b0019442e6b916si2432196pla.182.2023.01.26.10.52.54; Thu, 26 Jan 2023 10:53:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eCCLJiCg; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232259AbjAZSmz (ORCPT + 99 others); Thu, 26 Jan 2023 13:42:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231607AbjAZSme (ORCPT ); Thu, 26 Jan 2023 13:42:34 -0500 Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9146D66FA7; Thu, 26 Jan 2023 10:42:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674758553; x=1706294553; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=OeIpfTz2aSbcARPCLzsdspXDjxwH3ccCC0KuAuykCuc=; b=eCCLJiCgqm786FogTNHEUkFFYkB++e2SDf3305B2ADLJ9sjVQ3LP4KOT WZRDPcIsSTfHo56h5CDghJMsgNrlSHzBlT0xNwaECeXpDdlD9lUNygmQn /G/zBpP+xHmhGVBGGXTtlf0hfVdFt9MAAInJmwETmGQMcCHRMgduF9tFr XefsX+QEhrCtqYXK6IJtYM9UpbWRid3ZBBPEPBEV8lpLQv6h3t9dVmsdZ 7ia/0r9MvuxZDeVBCpRtipZvcGzPsx9p7vLLeoU8Ap+MBwV9bk1CDgasr 3RitSoVFXPbzdVlv91uSzTYAosly/8TrCsvvPAiYicUxVIgEaWwHi1c9D g==; X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="354203381" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="354203381" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10602"; a="991745458" X-IronPort-AV: E=Sophos;i="5.97,249,1669104000"; d="scan'208";a="991745458" Received: from agluck-desk3.sc.intel.com ([172.25.222.78]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2023 10:42:06 -0800 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH 7/7] x86/resctrl: Determine if Sub-NUMA Cluster is enabled and initialize. Date: Thu, 26 Jan 2023 10:41:57 -0800 Message-Id: <20230126184157.27626-8-tony.luck@intel.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230126184157.27626-1-tony.luck@intel.com> References: <20230126184157.27626-1-tony.luck@intel.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1756112289747171439?= X-GMAIL-MSGID: =?utf-8?q?1756112289747171439?= There isn't a simple hardware enumeration to indicate to software that a system is running with Sub-NUMA Cluster enabled. Compare the number of NUMA nodes with the number of L3 caches to calculate the number of Sub-NUMA nodes per L3 cache. When Sub-NUMA cluster mode is enabled in BIOS setup the RMID counters are distributed equally between the SNC nodes within each socket. E.g. if there are 400 RMID counters, and the system is configured with two SNC nodes per socket, then RMID counter 0..199 are used on SNC node 0 on the socket, and RMID counter 200..399 on SNC node 1. Handle this by initializing a per-cpu RMID offset value. Use this to calculate the value to write to the RMID field of the IA32_PQR_ASSOC MSR during context switch, and also to the IA32_QM_EVTSEL MSR when reading RMID event values. N.B. this works well for well-behaved NUMA applications that access memory predominantly from the local memory node. For applications that access memory across multiple nodes it may be necessary for the user to read counters for all SNC nodes on a socket and add the values to get the actual LLC occupancy or memory bandwidth. Perhaps this isn't all that different from applications that span across multiple sockets in a legacy system. Signed-off-by: Tony Luck --- arch/x86/include/asm/resctrl.h | 4 ++- arch/x86/kernel/cpu/resctrl/core.c | 43 +++++++++++++++++++++++++-- arch/x86/kernel/cpu/resctrl/monitor.c | 2 +- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/resctrl.h b/arch/x86/include/asm/resctrl.h index 52788f79786f..59b8afd8c53c 100644 --- a/arch/x86/include/asm/resctrl.h +++ b/arch/x86/include/asm/resctrl.h @@ -35,6 +35,8 @@ DECLARE_STATIC_KEY_FALSE(rdt_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_alloc_enable_key); DECLARE_STATIC_KEY_FALSE(rdt_mon_enable_key); +DECLARE_PER_CPU(int, rmid_offset); + /* * __resctrl_sched_in() - Writes the task's CLOSid/RMID to IA32_PQR_MSR * @@ -69,7 +71,7 @@ static void __resctrl_sched_in(void) if (static_branch_likely(&rdt_mon_enable_key)) { tmp = READ_ONCE(current->rmid); if (tmp) - rmid = tmp; + rmid = tmp + this_cpu_read(rmid_offset); } if (closid != state->cur_closid || rmid != state->cur_rmid) { diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 53b2ab37af2f..0ff739375e3b 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -16,6 +16,7 @@ #define pr_fmt(fmt) "resctrl: " fmt +#include #include #include #include @@ -484,6 +485,13 @@ static int get_domain_id(int cpu, enum resctrl_scope scope) return get_cpu_cacheinfo_id(cpu, scope); } +DEFINE_PER_CPU(int, rmid_offset); + +static void set_per_cpu_rmid_offset(int cpu, struct rdt_resource *r) +{ + this_cpu_write(rmid_offset, (cpu_to_node(cpu) % snc_ways) * r->num_rmid); +} + /* * domain_add_cpu - Add a cpu to a resource's domain list. * @@ -515,6 +523,8 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r) cpumask_set_cpu(cpu, &d->cpu_mask); if (r->cache.arch_has_per_cpu_cfg) rdt_domain_reconfigure_cdp(r); + if (r->mon_capable) + set_per_cpu_rmid_offset(cpu, r); return; } @@ -533,9 +543,12 @@ static void domain_add_cpu(int cpu, struct rdt_resource *r) return; } - if (r->mon_capable && arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { - domain_free(hw_dom); - return; + if (r->mon_capable) { + if (arch_domain_mbm_alloc(r->num_rmid, hw_dom)) { + domain_free(hw_dom); + return; + } + set_per_cpu_rmid_offset(cpu, r); } list_add_tail(&d->list, add_pos); @@ -845,11 +858,35 @@ static __init bool get_rdt_resources(void) return (rdt_mon_capable || rdt_alloc_capable); } +static __init int find_snc_ways(void) +{ + unsigned long *node_caches; + int cpu, node, ret; + + node_caches = kcalloc(BITS_TO_LONGS(nr_node_ids), sizeof(*node_caches), GFP_KERNEL); + if (!node_caches) + return 1; + + cpus_read_lock(); + for_each_node(node) { + cpu = cpumask_first(cpumask_of_node(node)); + set_bit(get_cpu_cacheinfo_id(cpu, 3), node_caches); + } + cpus_read_unlock(); + + ret = nr_node_ids / bitmap_weight(node_caches, nr_node_ids); + kfree(node_caches); + + return ret; +} + static __init void rdt_init_res_defs_intel(void) { struct rdt_hw_resource *hw_res; struct rdt_resource *r; + snc_ways = find_snc_ways(); + for_each_rdt_resource(r) { hw_res = resctrl_to_arch_res(r); diff --git a/arch/x86/kernel/cpu/resctrl/monitor.c b/arch/x86/kernel/cpu/resctrl/monitor.c index 3fc63aa68130..bd5ec348d925 100644 --- a/arch/x86/kernel/cpu/resctrl/monitor.c +++ b/arch/x86/kernel/cpu/resctrl/monitor.c @@ -160,7 +160,7 @@ static int __rmid_read(u32 rmid, enum resctrl_event_id eventid, u64 *val) * IA32_QM_CTR.Error (bit 63) and IA32_QM_CTR.Unavailable (bit 62) * are error bits. */ - wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid); + wrmsr(MSR_IA32_QM_EVTSEL, eventid, rmid + this_cpu_read(rmid_offset)); rdmsrl(MSR_IA32_QM_CTR, msr_val); if (msr_val & RMID_VAL_ERROR)