Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp805061pxb; Thu, 17 Feb 2022 15:22:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrHyQ4G/noDUYaolz44XHYDzqNiX5BLUtmN7LteJIqPGovPcwDCPCdB8SUHHiAlTadzIW/ X-Received: by 2002:a17:902:a585:b0:14d:58ef:65 with SMTP id az5-20020a170902a58500b0014d58ef0065mr4955135plb.139.1645140166369; Thu, 17 Feb 2022 15:22:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645140166; cv=none; d=google.com; s=arc-20160816; b=dfouqCgC8Eys/iTuS700p0hGX9NLaat1Q/re35/yO3q46f1vzyRA4TyyuXMuR7Nhoe KQLhKSXyH9VdWYdkXGLt/gNtW6z5oLksTF5LSXNVxcSm1EOuunIFoJ1YTucy3qHtRgkL ko1eKisc+YfwVeYZV2twfchPtMOerpeuVttf2i7Qr5pHqv2aJbD9X7igFKCiWJdi4zVX gOoZ/H0z6E4z7aIJFgYwQ88k/Wh8bAoGW55O8FrtbhdQ3vsibk28Bo5+igCs7cfy8ely IRtKu6b0ry6Kc5xG3QcSoAadQh9CJp++TZmuyzG3yCPsOPDaMNv8adLVV+xii9kO3GVa vYdA== 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=EwmEEtuTxUTxkXfjI0HA651jgfxrcHABfQAeX1ovPvw=; b=vKEXtBFrBFKr39uBr3mG9PPFeHt1/yboHA+uSTrrCXriQEo8opiJ3cGBL6jxDKYzaM c9rmYEdL6salNpBfkFZ77ZyaObV7UDPTe6tBLlKtun6qDW+ccxx8NHQMfSPGrF6X2yox Zv2XPwI6CfLfjq81eclPr8VtazJzq1LEmmLtEb8FCir3BZsom9SEUWwLmqr3nuLONCnL XreqtUxApcIP12IyTTaGB9pMYLjtLFMiFcSlTZK11JFDbqOjTgL3Zc6g6HxoNKbP08nS x3i/ww1vS7NKQf79l8hHoMdGzYr4QXSF9xYQwQCBiI3gBLKvNwww99gBasVO/8Gw8Jt9 ID1g== 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:18 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id 131si1041935pgh.546.2022.02.17.15.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 15:22:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1416C40914; Thu, 17 Feb 2022 15:08:35 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244330AbiBQSX5 (ORCPT + 99 others); Thu, 17 Feb 2022 13:23:57 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:56354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244275AbiBQSXv (ORCPT ); Thu, 17 Feb 2022 13:23:51 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E6B273879F for ; Thu, 17 Feb 2022 10:23:23 -0800 (PST) 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 B47701597; Thu, 17 Feb 2022 10:23:23 -0800 (PST) Received: from merodach.members.linode.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 84AE23F718; Thu, 17 Feb 2022 10:23:21 -0800 (PST) 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, Jamie Iles , D Scott Phillips OS , lcherian@marvell.com, bobo.shaobowang@huawei.com, tan.shaopeng@fujitsu.com Subject: [PATCH v3 10/21] x86/resctrl: Abstract and use supports_mba_mbps() Date: Thu, 17 Feb 2022 18:20:59 +0000 Message-Id: <20220217182110.7176-11-james.morse@arm.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220217182110.7176-1-james.morse@arm.com> References: <20220217182110.7176-1-james.morse@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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. Reviewed-by: Shaopeng Tan Signed-off-by: James Morse --- 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 22ebfdb4472d..7ec089d72ab7 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -1922,11 +1922,21 @@ static void mba_sc_domain_destroy(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_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; @@ -1934,8 +1944,7 @@ static int set_mba_sc(bool mba_sc) struct rdt_domain *d; int i; - 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; @@ -2295,7 +2304,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