From patchwork Tue Oct 17 00:23:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 153827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3808763vqb; Mon, 16 Oct 2023 17:24:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEhO2QI4NXR+znoVY1+Oa8HcGNisBB7UXC2tdrJulbSGRAdgy7BpDqAmlt/ANZipoEcZsFA X-Received: by 2002:a05:6870:15c2:b0:1e9:a8ff:67e3 with SMTP id k2-20020a05687015c200b001e9a8ff67e3mr803157oad.4.1697502250742; Mon, 16 Oct 2023 17:24:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697502250; cv=pass; d=google.com; s=arc-20160816; b=uVZCnCjfsJG6TnNUQnxMvEFLkUBgnGblwWW7uHE0HBUWfVdbnLaU6Ht4C20zo8+LAt Cruub4irvQ941YfWhbh+EVErrIv/wN9xeRim3MKvK/QKCzMCBADI6ggQ7NCpS0omtGHQ dTi83+dpQXJi52ipiwy1+zHTKKNRir1mf/F+3jg+RJqTPLzhQg12pE3TpzG+XS0TVGzu +sR4QQdpVVzeIHa0sJ/kbrQfwhQPlJ5MEC9UIeojHDe0njMGRgsg//9Fpr8uANiA7vUL SNWrjVsg2PVJKc6WOzbMUU+eu6LcJp/CX5EuSUXHufsj4c/AuamQBYGRwOPNeqCd/EGv anjA== ARC-Message-Signature: i=2; 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=72MrqNYcsnHSFp+uENMG+Qqh6S0Q0xiw1rzfBZDVBHU=; fh=a8QQDpsyeps30vd5Li+WI6v6dtcd7xKVvftia9bksQM=; b=fvMMekxsrxvhKCuz1Zsl6CEY/vcb6FeXATXik9XTyzLJQ0lnArIG2rcF9+SmLguucT yEI3fqiyvg1kH/c7bfJjCqYMxUnFLadMhXlc/mBxJyPg8J6vAOyohw4VlzAQcB9L7eLg lcb4BmECimkiotikLBUXaoIrl3JB9W7j/kxbIneVT4YdGqSVujqQSkOFaWUCh3PJ0cCB zAnCmAdm39knSUuyBlNa33Ftq8fTaRHms0GO1FOUR3BeuqerviiBm2EiEp3dceprYGfH DXKE0/i2Ysrnio7dl2daJOdH/MpkyYyAJvgZ5ZmZYd+ujUeqL+TpZyrRnWElvv/qBet1 WGZw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0yROQB7w; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id n28-20020a638f1c000000b005af44ed3142si528583pgd.413.2023.10.16.17.24.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 17:24:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=0yROQB7w; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id AAA738043AF4; Mon, 16 Oct 2023 17:24:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234264AbjJQAX5 (ORCPT + 18 others); Mon, 16 Oct 2023 20:23:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234255AbjJQAXp (ORCPT ); Mon, 16 Oct 2023 20:23:45 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2065.outbound.protection.outlook.com [40.107.94.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1CC3AF; Mon, 16 Oct 2023 17:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WwOekzxqO7MMYVnVny2M0vPBUtrfMZkEJ9Up/tn7sYEVar+Q9R2R263kDN4gm5Xuj/pi5F9doxAkC1JmsNT6uveNcZqIYGgXWx0yjMzwNO8CBv4MxWFamyL6+Q4tfGRW8mD6nY02g+TjDI0/uoM7lrWHbu0aNxvnxGzn0KrepXw4gc+x7zmExrMG1jQ75clP5d7AL5ji+JuaFtrjmgHT2f0ot7ZEtsx+YRVfoO7nLx8mrDFjSIY5yPZ5UVQ3AAh6H4TBP63eBdBNJCCljSgRhQnYUDuk46OyDGGtaG5ceEar5SUXo860WK9i4dhSHQiQzKJiolAUceQFObSDv1T+aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=72MrqNYcsnHSFp+uENMG+Qqh6S0Q0xiw1rzfBZDVBHU=; b=itG9YjfK+Hob5yUkENWtCvXWdvfeue/NqE1+wSsZnzqviXIall9+mUBCHvlxauTewGSsBT3AvNV105vwshI6qLnLqyhcT1/+lgYXhXN0ahoofxpT+l+tiYNKXiG4QxL4r2nUdmbGhmjxIDOE+U08fw7Ca6Q+EknZg1nMUFCEy1w29MhZ4zv8SdJoF6dSe7XnaTwCgZoSfYyYhfuoyZjDqm3TCepEaOOFwJAAHTKkjO5LYluMIkiWEqk2yiRDeAsbiwoKMW6mtguGgdOnydURRL0H70cHIqv00Y/dEGJUD0zV6NJYWdS2gvAoNfDQZeKhlgVbGx6JwRk16v0R9wVo/A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lwn.net smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=72MrqNYcsnHSFp+uENMG+Qqh6S0Q0xiw1rzfBZDVBHU=; b=0yROQB7wN4NPD4Tm0IC+oyOaXw928zYAfm7+GnKZYeq7Wmrq2fxks036v9R0JrZsjwjvgo1BAQqEufDHsgURRL40sAhaqWe5biDfgT+fbi6ZmgKA1+Jr2goQ0H10c67XYCokn+J9SngiYlbbO4YavsbTG4bfKlPTySz2O1OQU5Y= Received: from SJ0PR03CA0158.namprd03.prod.outlook.com (2603:10b6:a03:338::13) by SA1PR12MB8986.namprd12.prod.outlook.com (2603:10b6:806:375::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Tue, 17 Oct 2023 00:23:39 +0000 Received: from MWH0EPF000989E7.namprd02.prod.outlook.com (2603:10b6:a03:338:cafe::d1) by SJ0PR03CA0158.outlook.office365.com (2603:10b6:a03:338::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35 via Frontend Transport; Tue, 17 Oct 2023 00:23:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by MWH0EPF000989E7.mail.protection.outlook.com (10.167.241.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Tue, 17 Oct 2023 00:23:38 +0000 Received: from bmoger-ubuntu.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 16 Oct 2023 19:23:36 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v14 6/9] x86/resctrl: Introduce "-o debug" mount option Date: Mon, 16 Oct 2023 19:23:05 -0500 Message-ID: <20231017002308.134480-7-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231017002308.134480-1-babu.moger@amd.com> References: <20231017002308.134480-1-babu.moger@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000989E7:EE_|SA1PR12MB8986:EE_ X-MS-Office365-Filtering-Correlation-Id: 38eec518-9363-411e-8db5-08dbcea74f2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CxzTCSIJIA9l1op4QORC9CKVPfUFs/MBAoOFt79Tkm2V4sXd7dlcmPt0beVavgWSrYsibEOPcK+PBYEhOptOLxmfDLYzGqWpwo86ENcYdr5rWt4fA2FSSjHL7e8KtGyrSYHNW+ZvYQLnhZGSWg3DjJDdPvVDO+t+jaaciFW1lpC6n6Yko+/yKiTpki5z8naRFv5ctFwyYaMuKzPZ/Od6N9OO06gvTqwhD4LUFV+/G7m+yLISf/GaQF/9CQbspQdV2UYMm+gODn4myxoiQ97T6RXyk5rjPfmsUf9kPeHluma8ThSd2iR5gBZ2p+PVFbBOW6T656I6wjhfVGl3xx1kAlax3xxiV5UtrFxMkfQ/KMbd8MLiKr4hCn0Cu5d48MBc71Oux+nE1/9vwP9kfULGqv34pAHD3Pjth1bnF7cKM3QZIm5JcEOOCG7DZ3+tbT8n21Ez8Ahu2XyuUnMpLtGZdn3NPE7PTdtDBkLVRP3LOa6+ihqvxlpAb3bXmQx8BGxmzRbuE72wnnYADpMK7HdMHAhZHjrATsjJ9qqhVHfjK37gFPzALpxqdJ7VAlVaH5Q3I/RnRaMeY+j4DyOfSTA35u1S39XGaDJLjDh8UcpUU2JpgrT/KPNkjyfJXkXDD0ZwFGoZfjFytXJyF3of2YrROmWJOPPImL/jDn7Hi836ZsasWKPZgNvVP8rX4sJXcbhj8mTaOyITWRmHQXoNEX+ZesM17lE4AonF91Sefr57JF6mlsZPFHKv+eA8lm01aGxHAO9+C0FqB9tokrgNNvsj+A== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(39860400002)(396003)(376002)(136003)(230922051799003)(1800799009)(64100799003)(82310400011)(451199024)(186009)(36840700001)(46966006)(40470700004)(478600001)(70586007)(110136005)(70206006)(54906003)(6666004)(26005)(16526019)(1076003)(426003)(2616005)(336012)(66574015)(7696005)(316002)(4326008)(7406005)(2906002)(8676002)(5660300002)(41300700001)(44832011)(7416002)(36756003)(81166007)(8936002)(86362001)(356005)(47076005)(83380400001)(36860700001)(82740400003)(40480700001)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 00:23:38.4542 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 38eec518-9363-411e-8db5-08dbcea74f2a X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: MWH0EPF000989E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8986 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 16 Oct 2023 17:24:08 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779960119938532158 X-GMAIL-MSGID: 1779960119938532158 Add "-o debug" option to mount resctrl filesystem in debug mode. When in debug mode resctrl displays files that have the new RFTYPE_DEBUG flag to help resctrl debugging. Signed-off-by: Babu Moger Tested-by: Peter Newman Reviewed-by: Peter Newman Tested-by: Tan Shaopeng Reviewed-by: Tan Shaopeng Reviewed-by: Fenghua Yu Reviewed-by: Reinette Chatre Reviewed-by: Ilpo Järvinen --- v14: No changes v13: No changes v12: No changes --- Documentation/arch/x86/resctrl.rst | 5 ++++- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 18 ++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst index 178ab1d8f747..68f11611f341 100644 --- a/Documentation/arch/x86/resctrl.rst +++ b/Documentation/arch/x86/resctrl.rst @@ -35,7 +35,7 @@ about the feature from resctrl's info directory. To use the feature mount the file system:: - # mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps]] /sys/fs/resctrl + # mount -t resctrl resctrl [-o cdp[,cdpl2][,mba_MBps][,debug]] /sys/fs/resctrl mount options are: @@ -46,6 +46,9 @@ mount options are: "mba_MBps": Enable the MBA Software Controller(mba_sc) to specify MBA bandwidth in MBps +"debug": + Make debug files accessible. Available debug files are annotated with + "Available only with debug option". L2 and L3 CDP are controlled separately. diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index ba4611111212..b816b902b5c0 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -59,6 +59,7 @@ struct rdt_fs_context { bool enable_cdpl2; bool enable_cdpl3; bool enable_mba_mbps; + bool enable_debug; }; static inline struct rdt_fs_context *rdt_fc2context(struct fs_context *fc) @@ -248,6 +249,7 @@ struct rdtgroup { #define RFTYPE_TOP BIT(6) #define RFTYPE_RES_CACHE BIT(8) #define RFTYPE_RES_MB BIT(9) +#define RFTYPE_DEBUG BIT(10) #define RFTYPE_CTRL_INFO (RFTYPE_INFO | RFTYPE_CTRL) #define RFTYPE_MON_INFO (RFTYPE_INFO | RFTYPE_MON) #define RFTYPE_TOP_INFO (RFTYPE_INFO | RFTYPE_TOP) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 55da93b5ca53..84e0f45578dd 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -59,6 +59,8 @@ static void rdtgroup_destroy_root(void); struct dentry *debugfs_resctrl; +static bool resctrl_debug; + void rdt_last_cmd_clear(void) { lockdep_assert_held(&rdtgroup_mutex); @@ -1892,6 +1894,9 @@ static int rdtgroup_add_files(struct kernfs_node *kn, unsigned long fflags) lockdep_assert_held(&rdtgroup_mutex); + if (resctrl_debug) + fflags |= RFTYPE_DEBUG; + for (rft = rfts; rft < rfts + len; rft++) { if (rft->fflags && ((fflags & rft->fflags) == rft->fflags)) { ret = rdtgroup_add_file(kn, rft); @@ -2395,6 +2400,8 @@ static void rdt_disable_ctx(void) resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); set_mba_sc(false); + + resctrl_debug = false; } static int rdt_enable_ctx(struct rdt_fs_context *ctx) @@ -2419,6 +2426,9 @@ static int rdt_enable_ctx(struct rdt_fs_context *ctx) goto out_cdpl3; } + if (ctx->enable_debug) + resctrl_debug = true; + return 0; out_cdpl3: @@ -2623,6 +2633,7 @@ enum rdt_param { Opt_cdp, Opt_cdpl2, Opt_mba_mbps, + Opt_debug, nr__rdt_params }; @@ -2630,6 +2641,7 @@ static const struct fs_parameter_spec rdt_fs_parameters[] = { fsparam_flag("cdp", Opt_cdp), fsparam_flag("cdpl2", Opt_cdpl2), fsparam_flag("mba_MBps", Opt_mba_mbps), + fsparam_flag("debug", Opt_debug), {} }; @@ -2655,6 +2667,9 @@ static int rdt_parse_param(struct fs_context *fc, struct fs_parameter *param) return -EINVAL; ctx->enable_mba_mbps = true; return 0; + case Opt_debug: + ctx->enable_debug = true; + return 0; } return -EINVAL; @@ -3723,6 +3738,9 @@ static int rdtgroup_show_options(struct seq_file *seq, struct kernfs_root *kf) if (is_mba_sc(&rdt_resources_all[RDT_RESOURCE_MBA].r_resctrl)) seq_puts(seq, ",mba_MBps"); + if (resctrl_debug) + seq_puts(seq, ",debug"); + return 0; }