Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1390083rwp; Thu, 13 Jul 2023 10:06:43 -0700 (PDT) X-Google-Smtp-Source: APBJJlFX7lzvp8KXVXbJxg/7TxA/cTS+yG03UU9iEscqDU5BanVTsxNUuk6ndH8TukqI0BXqWGST X-Received: by 2002:a19:5010:0:b0:4f8:6833:b13c with SMTP id e16-20020a195010000000b004f86833b13cmr1817972lfb.14.1689268002756; Thu, 13 Jul 2023 10:06:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689268002; cv=none; d=google.com; s=arc-20160816; b=FGtWb2w1qUv2Bsza/kRK4ELk3X8O0t2f0tMjzBmPEJqOO9CV6ny+VApqk4Su8dM+hL ePch5AcykNATf1T98vSVbb+jC7N5xbM7H8BUda3gyDI1zjIg1tl51xhAi473J7ioVAlO rhnyNE9PFJHfVumNzydJdfPHwdu7F+TEXaIm8Id22b1K2kRDwCpsnnW19aCt9wl+yroD IL6MHfn7Mazac3J01D/qzww8hJbgua1AWtExEIFtLqHtGY7ZltXBGsf6l2P2Z5JpWTfV 7O0YsIgwfBoWmP/FJdADgV8jJ2BrxkrOSZbx6qBJzuoZF1LGXn72mLBvgW5/tiR37Nui oWPw== 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=6jCOvqkD2wvqoDe5OjWbohp1M6splslnnme7XkZRjhY=; fh=g0WKEVDdB8sQamShH39vSa8SoB8TDPrv8hO7zbxV08s=; b=g2V+wsIg5NnbjXNP40OhvGe8A8pOzveDlSFkrQ0zMM85wm/bKzf4ojWIe8/E7qNl0B Mj04LXiZusLCrNuaLhSdamyFUQyZPDxClrT5HAA98lvfXSOd2KQMl1UaMz/S5tkrxiO4 TTVcyBLzhAQvj42aFhhlKfWDJIKbvv97GkBb/dk2nOtUq31/sq9mE0/Y6cZfqFTF49s3 ZBpceiEr1hFyckf4QuJUFFah2kexfiFzblPz7X0aIM4f0FBJ3gWg7ltG2m+IoFF1zLKa ndOQ7v5YrO/wlZju5BpeO2eA+O6snY8LXC9iowBnlSw8+RYJnMpJA9s7qup7eCmHS0Uw U6YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=V5f3mOwa; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f20-20020a056402161400b0051e2340fabcsi7306804edv.322.2023.07.13.10.06.17; Thu, 13 Jul 2023 10:06:42 -0700 (PDT) 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=V5f3mOwa; 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 S233671AbjGMQco (ORCPT + 99 others); Thu, 13 Jul 2023 12:32:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230151AbjGMQce (ORCPT ); Thu, 13 Jul 2023 12:32:34 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F7571980; Thu, 13 Jul 2023 09:32:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689265953; x=1720801953; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=K8r2UZiAK+1TfFAtAuBZuyucEeCR4YldPD7156Ve6Xo=; b=V5f3mOwaYud4fz5CpYXkdFI+Y4WDAE8OpTqfdXEBhyjYG7huAQTDDEsm KLuifvno5SeceIqCzaZ9/F+yu/kSkXqGRxwaUmFuXVxdR7ZYC5pvQGJKj gD3hsNSeE9wJ/7YnIbbz9sVJIUbVo56yjrf53Fh+Et8SnH450ze+1GIjH yhxV1x9io2q+TCiOE62suxdO3BJAy8/TeohsFeHaSqOpgQcWtMc3Zu5xl nUFPuLlWyDaCBajoyi1WbjZKKoh84DyPu7SIjWeikCL/URzZ2OWV4zVBh O5MNjHpiPxV7pdFK3P7MYg5aqLVWAiMlIVATU08VaGzpW2HfoRdt4LirR w==; X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="362707635" X-IronPort-AV: E=Sophos;i="6.01,203,1684825200"; d="scan'208";a="362707635" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 09:32:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10770"; a="722046383" X-IronPort-AV: E=Sophos;i="6.01,203,1684825200"; d="scan'208";a="722046383" Received: from agluck-desk3.sc.intel.com ([172.25.222.74]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Jul 2023 09:32:22 -0700 From: Tony Luck To: Fenghua Yu , Reinette Chatre , Peter Newman , Jonathan Corbet , Shuah Khan , x86@kernel.org Cc: Shaopeng Tan , James Morse , Jamie Iles , Babu Moger , Randy Dunlap , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, patches@lists.linux.dev, Tony Luck Subject: [PATCH v3 5/8] x86/resctrl: Add package scoped resource Date: Thu, 13 Jul 2023 09:32:04 -0700 Message-Id: <20230713163207.219710-6-tony.luck@intel.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230713163207.219710-1-tony.luck@intel.com> References: <20230713163207.219710-1-tony.luck@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Some Intel features require setting a package scoped model specific register. Add a new resource that builds domains for each package. Signed-off-by: Tony Luck Reviewed-by: Peter Newman --- include/linux/resctrl.h | 1 + arch/x86/kernel/cpu/resctrl/internal.h | 6 ++++-- arch/x86/kernel/cpu/resctrl/core.c | 23 +++++++++++++++++++---- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h index 25051daa6655..f504f6263fec 100644 --- a/include/linux/resctrl.h +++ b/include/linux/resctrl.h @@ -167,6 +167,7 @@ struct rdt_resource { int rid; bool alloc_capable; bool mon_capable; + bool pkg_actions; int num_rmid; int scope; struct resctrl_cache cache; diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 38bac0062c82..67340c83392f 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -438,6 +438,7 @@ enum resctrl_res_level { RDT_RESOURCE_MBA, RDT_RESOURCE_SMBA, RDT_RESOURCE_NODE, + RDT_RESOURCE_PKG, /* Must be the last */ RDT_NUM_RESOURCES, @@ -447,6 +448,7 @@ enum resctrl_scope { SCOPE_L2_CACHE = 2, SCOPE_L3_CACHE = 3, SCOPE_NODE, + SCOPE_PKG, }; static inline int get_mbm_res_level(void) @@ -478,9 +480,9 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable); r <= &rdt_resources_all[RDT_NUM_RESOURCES - 1].r_resctrl; \ r = resctrl_inc(r)) -#define for_each_capable_rdt_resource(r) \ +#define for_each_domain_needed_rdt_resource(r) \ for_each_rdt_resource(r) \ - if (r->alloc_capable || r->mon_capable) + if (r->alloc_capable || r->mon_capable || r->pkg_actions) #define for_each_alloc_capable_rdt_resource(r) \ for_each_rdt_resource(r) \ diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c index 6fe9f87d4403..af3be3c2db96 100644 --- a/arch/x86/kernel/cpu/resctrl/core.c +++ b/arch/x86/kernel/cpu/resctrl/core.c @@ -127,6 +127,16 @@ struct rdt_hw_resource rdt_resources_all[] = { .fflags = 0, }, }, + [RDT_RESOURCE_PKG] = + { + .r_resctrl = { + .rid = RDT_RESOURCE_PKG, + .name = "PKG", + .scope = SCOPE_PKG, + .domains = domain_init(RDT_RESOURCE_PKG), + .fflags = 0, + }, + }, }; /* @@ -504,9 +514,14 @@ 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) + switch (scope) { + case SCOPE_NODE: return cpu_to_node(cpu); - return get_cpu_cacheinfo_id(cpu, scope); + case SCOPE_PKG: + return topology_physical_package_id(cpu); + default: + return get_cpu_cacheinfo_id(cpu, scope); + } } /* @@ -630,7 +645,7 @@ static int resctrl_online_cpu(unsigned int cpu) struct rdt_resource *r; mutex_lock(&rdtgroup_mutex); - for_each_capable_rdt_resource(r) + for_each_domain_needed_rdt_resource(r) domain_add_cpu(cpu, r); /* The cpu is set in default rdtgroup after online. */ cpumask_set_cpu(cpu, &rdtgroup_default.cpu_mask); @@ -657,7 +672,7 @@ static int resctrl_offline_cpu(unsigned int cpu) struct rdt_resource *r; mutex_lock(&rdtgroup_mutex); - for_each_capable_rdt_resource(r) + for_each_domain_needed_rdt_resource(r) domain_remove_cpu(cpu, r); list_for_each_entry(rdtgrp, &rdt_all_groups, rdtgroup_list) { if (cpumask_test_and_clear_cpu(cpu, &rdtgrp->cpu_mask)) { -- 2.40.1