From patchwork Wed Jul 19 23:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 122927 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp2779303vqt; Wed, 19 Jul 2023 16:49:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlFjPH91Zh0vG2mWuQPj4MZQ42Q2BQ/QX5WHzpcFsSLJTeVNg9Lr3wFtVjmlsJed71tUEoYt X-Received: by 2002:a17:906:7a11:b0:974:1e0e:91ee with SMTP id d17-20020a1709067a1100b009741e0e91eemr873627ejo.13.1689810584208; Wed, 19 Jul 2023 16:49:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1689810584; cv=pass; d=google.com; s=arc-20160816; b=Yz7jVN72cFw9H6Fx9tJEfQAcOruYhZ0SJqDWxLCCywRZ6eMh4wlEdOA3/Rm9BSLbse keO/+RoY3bqJONjgQjKVm7oj3f6Xb2tnz7b9nau/pHh1Q3uB/vLGCM8resvns7nacwhs v1KgXNDjx+GYVq59nffdGgNY9Qz+uIRpDBjCehVOJ0Ua/GSOtYCMW2YxdvBCT6KhDviv /ZZQIv3cNk7tVNa8bwnGd9fh7/xkGWDw9+9oSQeQgoJ+xjGjNY/WGIelQ0Hw862Cw4xA 1zhfxUcnWj7R1iU8K7DCSUteDpe/7kBtmwjOGHWoB42Fh3O5wqRYbbY3WUrLVycCm13F /mpQ== 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 :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:dkim-signature; bh=k6dT+F33syFlQ2/KFTWohshO77y0qLiFpqKxl8jvpp4=; fh=h28vckfI3GX5WFto8VbLoaUMI0xqlhwXGWb2ZADi/Dw=; b=iH4k9C+XLu4QZaXwSQDL9lf5t9yRyLFUojr/pmuC9c/ZmGiqYB+5NIgXU0qGjFin3J NtGLB7jddtBFFdrXEefewufybo+mCvcR/Herrbn5J0psf4pqjV36Wh4X85pDwRwNjW1X /UQ77H5i3v6qSgrmz6SJzOOX6zU60ds78asB82KCCU79x3H3kao1MCJ2jesNJvEvzfu6 Cxtjz2C6uQj5vokMUd05C8hnUVY7FC9sB8hot0BKkucy38PSArPi5/pSLAAYkw1cqK1C kIhftzrpPRdoun+NxkrBMgF7ZLr1mRd+xLZLD5xZpak8OCLFErmgncGyiM2UIyFCrfns iatA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=fbELrNnk; 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::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r6-20020aa7c146000000b0051e28e8f27dsi3707723edp.602.2023.07.19.16.49.20; Wed, 19 Jul 2023 16:49:44 -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=@amd.com header.s=selector1 header.b=fbELrNnk; 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::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230314AbjGSXXC (ORCPT + 99 others); Wed, 19 Jul 2023 19:23:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230515AbjGSXXA (ORCPT ); Wed, 19 Jul 2023 19:23:00 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20600.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 288742708; Wed, 19 Jul 2023 16:22:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SaIXTEyDdlNvyFRL8GJQuAeihiQ6SgjN418fgkdCgN8ABD+nJuQ1e5LD0KEEERlUdMIA1tLZRf3eoWrybrsozlVvOVbls/11/XgWxiSbypMewk1M7AY6xxeSxbehdp+y1kSnruj9TFsRIWwBROAnZnyFjlbECu7C9QW0Ui46y7HwSzgKsHF12CHDEduY7040p+yQWb8F/jwlB5l5lmkDF3ztdn9gqOUTkii3ChZ8lklvz9RFB7cTQyjJJw7UKTs2IGoIXRN5aDmr2VkYIWruQ7ugNeNFI6OhgnmBa6h0U1gZsmo9OozBufoLuZnq2IYBf89FN17hDLXe5HCauHgI9w== 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=k6dT+F33syFlQ2/KFTWohshO77y0qLiFpqKxl8jvpp4=; b=V3dhp1bwuk/mKFH53mBqytNp96jwco/mXHCVe8W/erXm6k5+EpPSMJDlAhnCMUDFOVGIVGh4chex8Qt/T/lGMXctKdsk1wcR2btI31uLWwwFn1eKfCi/Dg9G6tTeTjjvnR2+//vDo1n5Ofm4NUO2fMBTtGF7kQB0Pi20gvhbO+rnF8B7Z/gmG5PJtOSqh4HY8LxKRPnU5D5aMQhashkR48gaBc7RxWm5H8rPxl1KKDdgg8OAEYkmsSw3tXyBVbQkshwU9UeYQnNnxFmUrnMqH5+gkBlwMHFyS5/aL0pHEy3FCNkEZd8KvXFIGmDQlimX52Ge2YSme3Cnn83i+95HhA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org 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=k6dT+F33syFlQ2/KFTWohshO77y0qLiFpqKxl8jvpp4=; b=fbELrNnkNdLBnY4Rjf4kx2Ke1gAqewrKcVNmIHDl3OFJSZenFn0LR0zIKBkjvXQ1svSMMhZmJGpQk1azIBZR7L6eN9rkIhRshIY8cm+wyptabl3v33tr5zaC1Oi80P9WDpVJ9AxQfCDIdQ+JZMjucFfAbQzSSZicL452wFYOblE= Received: from DM6PR06CA0053.namprd06.prod.outlook.com (2603:10b6:5:54::30) by MW4PR12MB7031.namprd12.prod.outlook.com (2603:10b6:303:1ef::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.23; Wed, 19 Jul 2023 23:22:29 +0000 Received: from DM6NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::25) by DM6PR06CA0053.outlook.office365.com (2603:10b6:5:54::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.24 via Frontend Transport; Wed, 19 Jul 2023 23:22:28 +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 DM6NAM11FT034.mail.protection.outlook.com (10.13.173.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6609.25 via Frontend Transport; Wed, 19 Jul 2023 23:22:28 +0000 Received: from [127.0.1.1] (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.23; Wed, 19 Jul 2023 18:22:26 -0500 Subject: [PATCH v6 7/8] x86/resctrl: Introduce "-o debug" mount option From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Wed, 19 Jul 2023 18:22:19 -0500 Message-ID: <168980893967.1619861.7249871216790436466.stgit@bmoger-ubuntu> In-Reply-To: <168980872063.1619861.420806535295905172.stgit@bmoger-ubuntu> References: <168980872063.1619861.420806535295905172.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c 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: DM6NAM11FT034:EE_|MW4PR12MB7031:EE_ X-MS-Office365-Filtering-Correlation-Id: 1d9abe14-372a-42c1-e62a-08db88af04dc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mmDWzIM/sgigR++mULfOJfVO4MOiRW6O4pgzpsu/lDv8uXs89B1DhnC50B4y1U8nkSo0Wn9qTzOr+jG9GrvOkum/vRK1ZyNhgXBU48Jyw2qvCaQUJv+VdG/T12KCEbbzPk9sLavQum2FgsqPK4fsAiHv9bGvZBW1VCF9kYCLQF47H3nrPNE0WaVXxHCV1jcleI5ArlIRuHY3Z8cFdTpNPj1rh4XsBqkxtr5i6SOru5aWPSOvpMTf1ardRRqyHUPulawCSKvL09HaypY+uTMdGXVMiQbD78ZRJODaqJBhMyW2ovfUpqVlGJ9OuNCXInQRxlhZSEl3oqDiOQij3CtuuKw+fFVDBNhaXBiJ0qsshw28p3WpsGCgVlzOAuPY/YDviBD/IIc0LqYZmTITerUPFI39sHJmhqVnmrertzsx0/Lr5ErW6NXvGqO6/Al7mVUQwMuWCS9UPgCA+WaCprNslFD3hGloOom71RqNkkMqm6JEgIEiwhy4NfWKCe04XlprLkAfiH8wFg0jNUIZx6k6B/v5fiL6949PKsfiGOJxM63hGA9TAu2iLaaapIi2dVLd8VRymj5GItnzycZtlGAnvTaMsH9qVMSI4uUF58d7EyqzBzmbjIczxoofRuQc7pc+pJcN5fpbYbNtPHj1/kO6LuyDlOmaWx8Hki50Qt3cA15azfsLitCudrTIG1kSdzze7QURp08SsgvwqZ7l7VmdnhnkocpRSLYrYgL/zSgoZTZi5V/26Mi5a1qGDsW3SKstd9AJ7bNqmScNIyBMWEgEGW7GrHjyKiphH73wrwkQLFA= 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:(13230028)(4636009)(7916004)(346002)(376002)(396003)(39860400002)(136003)(451199021)(82310400008)(46966006)(36840700001)(40470700004)(186003)(336012)(16526019)(103116003)(86362001)(40460700003)(40480700001)(81166007)(82740400003)(356005)(2906002)(47076005)(9686003)(110136005)(26005)(44832011)(7416002)(7406005)(426003)(36860700001)(478600001)(33716001)(54906003)(4326008)(8936002)(8676002)(83380400001)(16576012)(316002)(70206006)(41300700001)(70586007)(5660300002)(6666004)(71626016)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2023 23:22:28.4516 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1d9abe14-372a-42c1-e62a-08db88af04dc 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: DM6NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7031 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_PASS,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771894823061633242 X-GMAIL-MSGID: 1771894823061633242 Add "-o debug" option to mount resctrl filesystem in debug mode. This option is used for adding extra files to help resctrl debugging. Signed-off-by: Babu Moger --- Documentation/arch/x86/resctrl.rst | 5 ++++- arch/x86/kernel/cpu/resctrl/internal.h | 2 ++ arch/x86/kernel/cpu/resctrl/rdtgroup.c | 20 ++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/x86/resctrl.rst b/Documentation/arch/x86/resctrl.rst index af234681756e..5a2346d2c561 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 885b656d1088..5bc18accb887 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) @@ -296,6 +297,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 e0570bce76a2..058c1dedb2d7 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -56,6 +56,8 @@ static char last_cmd_status_buf[512]; struct dentry *debugfs_resctrl; +static bool resctrl_debug; + void rdt_last_cmd_clear(void) { lockdep_assert_held(&rdtgroup_mutex); @@ -1871,6 +1873,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); @@ -2399,6 +2404,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: @@ -2591,6 +2599,8 @@ static int rdt_get_tree(struct fs_context *fc) out_schemata_free: schemata_list_destroy(); out_ctx: + if (ctx->enable_debug) + resctrl_debug = false; if (ctx->enable_mba_mbps) set_mba_sc(false); cdp_disable_all(); @@ -2608,6 +2618,7 @@ enum rdt_param { Opt_cdp, Opt_cdpl2, Opt_mba_mbps, + Opt_debug, nr__rdt_params }; @@ -2615,6 +2626,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), {} }; @@ -2640,6 +2652,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; @@ -2829,6 +2844,8 @@ static void rdt_kill_sb(struct super_block *sb) set_mba_sc(false); + resctrl_debug = false; + /*Put everything back to default values. */ for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); @@ -3710,6 +3727,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; }