Received: by 2002:a05:6504:1d0:b0:1de:de76:8684 with SMTP id e16csp876521ltn; Fri, 2 Sep 2022 09:11:21 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Ygk5sPYYbZOFujEkANMo9749NZmDxxkObLDRy2IN0OHjqhaE7QD1zBIGscVmrq4jjHEpd X-Received: by 2002:a17:902:d4ca:b0:16f:8311:54b0 with SMTP id o10-20020a170902d4ca00b0016f831154b0mr36516214plg.108.1662135081371; Fri, 02 Sep 2022 09:11:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662135081; cv=none; d=google.com; s=arc-20160816; b=ovI/0qRWrNiiglPuPg7wFjg4a3EJnsTWssD/JpbgCFXI4Igz1/U/gZymiC5pBgV0Mx jqx6+rGzRETnHhS2GVD0btogxed5/ylKoWALnl3AKOt4GdeCxtSH0PXt4xe5L2s89aHi tzr3Eg/Lsi9/tBJ1idtrObo6AeC45108hIWRveraYtkNfqS3SksXBFDJ4SMiclNJFfdF Ls2fsfoRv56OSbrpcN1kN0mm+wuvcHbbEK91KVh6Xs/1rzShyVy8ufLUu9/7Iaw2tnK0 V1GBjtcw+7Ncz/ynaBABJTxHurIDk2xDxQMZbKkfohcNUKtYQvW+/K7wwMjtL4Sssxra oR9w== 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; bh=3nPIY2Ds62I5ykvYz4WFhECduZbVLi3JPpxzu2kOu2o=; b=JuTYuJh7l7WWftQppfBPksDIJ3V+JHau3i8MPB+xzCy5mFjkx9ExP8fVY6SoC5P18g 1ovqO3jVl082IyfyY0sox4hbpljoDJ1EFuvZS6AgUj1fqKIgu08SqgUrBiMcAw9TZ6uA F/+7qSr9Fk9+K2HMKAH7vj/h5vfGa+/Q8AzeUmIu2W204rqK4y1akFqavrYuz+A3PVZd nao/rwdTKq4ecJ6pRx+/IOaloXnEU/h0sb80PqVRPrEGw7R2BPjTnkposRWIpVsR10jq xBeMiJuO5qJYZKeKUW/OhypBFu/qcLr/pJ2L7F8xY6mPqsEpQeGL/vHTz+zhTCxTqW5I j0hw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e7-20020aa78c47000000b005381feef4e7si2299285pfd.320.2022.09.02.09.10.57; Fri, 02 Sep 2022 09:11:21 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237597AbiIBPzo (ORCPT + 99 others); Fri, 2 Sep 2022 11:55:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237344AbiIBPye (ORCPT ); Fri, 2 Sep 2022 11:54:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 716C5DF36 for ; Fri, 2 Sep 2022 08:49:13 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E75C915A1; Fri, 2 Sep 2022 08:49:18 -0700 (PDT) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 62D1E3F766; Fri, 2 Sep 2022 08:49:10 -0700 (PDT) From: James Morse To: x86@kernel.org, linux-kernel@vger.kernel.org Cc: Fenghua Yu , Reinette Chatre , Thomas Gleixner , Ingo Molnar , Borislav Petkov , H Peter Anvin , Babu Moger , James Morse , shameerali.kolothum.thodi@huawei.com, D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com, Jamie Iles , Cristian Marussi , Xin Hao , xingxin.hx@openanolis.org, baolin.wang@linux.alibaba.com Subject: [PATCH v6 07/21] x86/resctrl: Abstract and use supports_mba_mbps() Date: Fri, 2 Sep 2022 15:48:15 +0000 Message-Id: <20220902154829.30399-8-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220902154829.30399-1-james.morse@arm.com> References: <20220902154829.30399-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, 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 To determine whether the mba_MBps option to resctrl should be supported, resctrl tests the boot CPUs' x86_vendor. This isn't portable, and needs abstracting behind a helper so this check can be part of the filesystem code that moves to /fs/. Re-use the tests set_mba_sc() does to determine if the mba_sc is supported on this system. An 'alloc_capable' test is added so that support for the controls isn't implied by the 'delay_linear' property, which is always true for MPAM. Because mbm_update() only update mba_sc if the mbm_local counters are enabled, supports_mba_mbps() checks is_mbm_local_enabled(). (instead of using is_mbm_enabled(), which checks both) Reviewed-by: Jamie Iles Tested-by: Xin Hao Reviewed-by: Shaopeng Tan Tested-by: Shaopeng Tan Tested-by: Cristian Marussi Reviewed-by: Reinette Chatre Signed-off-by: James Morse --- Changes since v5: * Changed supports_mba_mbps() to use is_mbm_local_enabled() Changes since v3: * Added use in resctrl_online_domain() Changes since v1: * Capitalisation * Added MPAM example in commit message * Fixed supports_mba_mbps() logic error in rdt_parse_param() --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index b32ceff8325a..4ee26264ecfc 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1890,17 +1890,26 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *r) } /* - * Enable or disable the MBA software controller - * which helps user specify bandwidth in MBps. * MBA software controller is supported only if * MBM is supported and MBA is in linear scale. */ +static bool supports_mba_mbps(void) +{ + struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; + + return (is_mbm_local_enabled() && + r->alloc_capable && is_mba_linear()); +} + +/* + * Enable or disable the MBA software controller + * which helps user specify bandwidth in MBps. + */ static int set_mba_sc(bool mba_sc) { struct rdt_resource *r = &rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl; - if (!is_mbm_enabled() || !is_mba_linear() || - mba_sc == is_mba_sc(r)) + if (!supports_mba_mbps() || mba_sc == is_mba_sc(r)) return -EINVAL; r->membw.mba_sc = mba_sc; @@ -2255,7 +2264,7 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) ctx->enable_cdpl2 = true; return 0; case Opt_mba_mbps: - if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) + if (!supports_mba_mbps()) return -EINVAL; ctx->enable_mba_mbps = true; return 0; -- 2.30.2