From patchwork Fri Aug 11 20:10:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 134704 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1361874vqi; Fri, 11 Aug 2023 14:20:02 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGtayza21bRMa1IQAtllu8N51R2ZO1h9PO4I4P16k9r3CumDwSYS1fG9/A2lFbZuWL9xORX X-Received: by 2002:a05:6808:3a8d:b0:3a3:7a28:f841 with SMTP id fb13-20020a0568083a8d00b003a37a28f841mr3355332oib.41.1691788802495; Fri, 11 Aug 2023 14:20:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691788802; cv=pass; d=google.com; s=arc-20160816; b=pcLBdy7frHKmIO74GlEwDFgh+NmIYBk2A8DdMe7NVtZsYI4yaTSuaJCC2BKSGWl8+P 6go1yWgnrMx+AHKTLDBeLQ4tv9GLQIpQeMcix4z6W5So63Bus1QP8BOpoCxkPlXlBUfS afz/SP7CFY9qasluAGdziP4PfMsEO1tg0L2IBUMZ2TBcU0wruRQbsxkatNd8hQKeESwz B0izcJNxKd2YDwR36L10JQy3eHLiQlo2pvGBKhjqxjccwl/qFEoUqigneP6341mFoqJJ KULnEY5RjaDBQ2+keEbXlZqjKnJ+8zpX86D01gzvXUVxOYSunOphG2K1mu+4dhZFkBxL c9lQ== 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=U4IhmNsexbxxmpffLsCR8dkV/Tuq3QoG6vGiVUEFgpg=; fh=h28vckfI3GX5WFto8VbLoaUMI0xqlhwXGWb2ZADi/Dw=; b=MRm6KnyYR5ps7MkfyfTkf1gJDSo4O8AeuzD8wmtJZXfrst39TeyU2PZH5NZR9aQT8G UvdP0xIiXePBTHvmykwEURBAGmHxQBt408DcUOXozXARZjSSlkn70ifV38C2FYHf0sdB LRjDLNB5XFY9l8jefdaH+YBOx5K1YFUrAel4pEg0/xuPBRooMHe5sqttn/zbTwRMZYut hbq7mCMoM2NQf0TUDjha4N/W6BZ9SfWfRxVUbvdJFh23nyrqdbP0/4IdmdVt+fDq5k/q jGm08YBOZiSibsKjqN6qfhdDZhKSeo2tXwcy9y1vgeHDVM92YLGhulsaq8wgyLDpEpUn xwFA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=jTLi3mRC; 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 a4-20020a637f04000000b0055b766191f4si3775957pgd.218.2023.08.11.14.19.49; Fri, 11 Aug 2023 14:20:02 -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=jTLi3mRC; 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 S236669AbjHKULB (ORCPT + 99 others); Fri, 11 Aug 2023 16:11:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235816AbjHKUK7 (ORCPT ); Fri, 11 Aug 2023 16:10:59 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2081.outbound.protection.outlook.com [40.107.244.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BBEC30FF; Fri, 11 Aug 2023 13:10:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NY21Ek9G4PuepjwBMYHgEVdC/9rSwgjcGuJdtECU6QQNFU30sElhadKQaazwuV5/nIUtVYXQC9YcO0kaCLzlUb31J8vFIheZTH+NeDm5uyHgfgZoqFtRmoEL33D5XM9ueYzSZNsqUXnXW1OADMpg4Vox4MyjnDgTKThq25/9q7Ez3x8MfYeRbGIVVCvJB4P2DNCcqboOTaLG9kVJurvsm3k/lxgNMcxTAQkWD/YvbYbQ3nGAovuPuH7Vm6hg2buseTXUAA7sO4kITk2sZ/1wQjcKsU2DnDXVlJb9S1RVq2+NNL1oKsHFOeUwc+8A3xd3JXzh1HDkMUqRPU3K5huT5Q== 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=U4IhmNsexbxxmpffLsCR8dkV/Tuq3QoG6vGiVUEFgpg=; b=TZCBHog1gUXYVI70oQ1hsYq2pPMljonPaVJe74AcQOhFpSu8maFSQJdaL7iAFl7+aZQiimMbZ9LKlCWMBZZ8dDSdPeAzuTNcOhgWAgmaftVbUtbuSvVz2vdqavxTkG/SwkTOBKV+jtocSqEXTP/mnYXGsMuEhdhfPpEM5BUtfiNkaAlYr4Xsp7qW7GIahiHIX7I/BRM/juwkJitB2NNGWCCe/zCstIQTgrzOuDuBQxZe23JcnkYYuMsLRVotjGQtJNPxYsk6uWNUzaTby63PU4H90N2yJmdwkwjnKl8udBsDbVE5zxsXoz+IC0p6RDr1ot8R2t0ebZfUz682lYR18Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=csgroup.eu 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=U4IhmNsexbxxmpffLsCR8dkV/Tuq3QoG6vGiVUEFgpg=; b=jTLi3mRCk4HPJrP1TnvLl0/U04rwk62j27lhqsfCMvAEZ8SSmHTiIupaxEkKfsy9lG/9sdmlUn/BbmRauinwbome0pOWaOryMqd3Z9DrQfBYRh0P5Umdn9fKSyJbri8OiarzLNEooWz8geIlBFrklkNNz7/uyYsgJOdfsmdeGGs= Received: from BYAPR05CA0047.namprd05.prod.outlook.com (2603:10b6:a03:74::24) by SN7PR12MB7835.namprd12.prod.outlook.com (2603:10b6:806:328::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6652.30; Fri, 11 Aug 2023 20:10:52 +0000 Received: from MWH0EPF000971E5.namprd02.prod.outlook.com (2603:10b6:a03:74:cafe::b8) by BYAPR05CA0047.outlook.office365.com (2603:10b6:a03:74::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.16 via Frontend Transport; Fri, 11 Aug 2023 20:10:52 +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 MWH0EPF000971E5.mail.protection.outlook.com (10.167.243.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.19 via Frontend Transport; Fri, 11 Aug 2023 20:10:52 +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.27; Fri, 11 Aug 2023 15:10:50 -0500 Subject: [PATCH v7 7/8] x86/resctrl: Introduce "-o debug" mount option From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Fri, 11 Aug 2023 15:10:49 -0500 Message-ID: <169178464934.1147205.6915303244307989200.stgit@bmoger-ubuntu> In-Reply-To: <169178429591.1147205.4030367096506551808.stgit@bmoger-ubuntu> References: <169178429591.1147205.4030367096506551808.stgit@bmoger-ubuntu> User-Agent: StGit/1.1.dev103+g5369f4c MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MWH0EPF000971E5:EE_|SN7PR12MB7835:EE_ X-MS-Office365-Filtering-Correlation-Id: ce2fc9e5-e71e-44c5-b156-08db9aa71024 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WFf5qI3QWM9N7faX3miY5cREpsG4x8hX/2AaHehbR47evfCb0Ug2LWH76FuAYy0qV1PEBAAtURfHby1EZF4PwSZYO1bYeIF9njR2qSxmh6/YajvJoQ6xUlyhvrl5RYgTdYjpDkRH+ALBUjcSlSAiSGmlspytiYYlOnAapL2TYam4zfgToG566sj/csDNgesTeYX3iz0fEvrLlj7Qn522LtfJd8mL9Njk2hm5OGvLBPEN95IbToqOzmvxijFSLaLEXvSI7KdJUjTtKBLvMVW5oSQfLFgbevBJjRBEFgxUNZoc0zMNYZ/ezNtmXHfJytWW6QmaP7flmi7TUfBnPVjeIORpjY/74P+u5ygrwD3s3FRaTgvXWx/cKicmcX3PJH6j8yaHMzROeKniz4F6UgqOAloKlNGKRqohn4BJYA3a1/+2AmJKxMGMt/Sd9AblIRFHiAveGmwOsemUBf2SBo1hEEzSRYPgSXT3Z9wx5zeGOkIzL2ZWX/aZBPUE5lwg2DWI9lXo2P87jTOS7MojVKX2tv2+S7956mA+0V5+kTHiW2oVPhg6nJzqh+bmP0+PiIhMnec9cEmMZRPXwf3dtBZ2ud/gJlfi+b5sk/qUx7OqjJBQAYZ0v6tnEJaJrKjWoisGq6hMh/k0ZHBg+ct635q8gKVdPxlm9a4YnWJ50XOBRqWM9bWKf3xaZw3JIWy6EYTz9YRn76DTCXBW1WxP/IDbNIKI5R2r1ArooxoxK5mK57UVF7z7qcClYnCcSuTEMw4l+x0CZ5kd/P8/aLTAec5KbJrTxO66WIv0fXFVRmMWW9I= 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)(136003)(396003)(346002)(376002)(39860400002)(1800799006)(82310400008)(186006)(451199021)(36840700001)(40470700004)(46966006)(4326008)(9686003)(478600001)(54906003)(110136005)(70586007)(316002)(70206006)(16576012)(5660300002)(40480700001)(41300700001)(40460700003)(8936002)(8676002)(26005)(86362001)(33716001)(82740400003)(336012)(7416002)(7406005)(44832011)(16526019)(103116003)(36860700001)(47076005)(81166007)(356005)(2906002)(426003)(83380400001)(71626016)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 20:10:52.2394 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce2fc9e5-e71e-44c5-b156-08db9aa71024 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: MWH0EPF000971E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7835 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE, 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: 1773969135399128459 X-GMAIL-MSGID: 1773969135399128459 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 | 21 +++++++++++++++++++++ 3 files changed, 27 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 2bd92c0c3b0c..4689e87ec638 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) @@ -297,6 +298,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 a7453c93bad4..6b7e914657fa 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); @@ -2387,6 +2392,9 @@ static void rdt_disable_ctx(struct rdt_fs_context *ctx) if (ctx->enable_mba_mbps) set_mba_sc(false); + + if (ctx->enable_debug) + resctrl_debug = false; } static int rdt_enable_ctx(struct rdt_fs_context *ctx) @@ -2411,6 +2419,9 @@ static int rdt_enable_ctx(struct rdt_fs_context *ctx) goto out_disable; } + if (ctx->enable_debug) + resctrl_debug = true; + return 0; out_disable: @@ -2612,6 +2623,7 @@ enum rdt_param { Opt_cdp, Opt_cdpl2, Opt_mba_mbps, + Opt_debug, nr__rdt_params }; @@ -2619,6 +2631,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), {} }; @@ -2644,6 +2657,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; @@ -2833,6 +2849,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); @@ -3713,6 +3731,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; }