From patchwork Thu Mar 2 20:25:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 63563 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp55076wrd; Thu, 2 Mar 2023 12:29:47 -0800 (PST) X-Google-Smtp-Source: AK7set/f9XXoswx3QvOmdOdnZeZOZxlACENCn150C2Q8gtTiH+QGk6ql1NxD75HV/NT9eLNjGgWm X-Received: by 2002:a17:906:4b4b:b0:8b1:77bf:3bdd with SMTP id j11-20020a1709064b4b00b008b177bf3bddmr11924737ejv.36.1677788987604; Thu, 02 Mar 2023 12:29:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677788987; cv=pass; d=google.com; s=arc-20160816; b=SXbP3bROYYOXHMjUJAt7Zk2HVBNNCxntLxOt1j94VO7jSK2/BdKFuasJ7Qi1aGsvuw zudIeM0xAt1U8/QAqU9pobXo9a4Uvx7dxW1ww6TFGt6PYJuTxY/mATrYOdIN66ZlfYmV 65gwqR0lK0L/tl/UsHSZwtIKLk2j6f2su0ByEckfDxMxE7ueKwwyBIHyh54K4yvkQNuZ Mq3jD98/HKu0DWAjy7xoDey1PYLabpqjkzWVgr6a4VKYe7Indn8rNlYWRI61q3fE2PJy mN6rhMkrhfOvzBXvwuGyBZ9uq6CCSufvzJ2nM39XUXpPCmlGh6O5QLZu8PQAEEWOPlge F1pw== 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=eO6qZ4CmidKPoh+G1DsI+9CoKSqfSijLIjt12ZB+cu4=; b=D/nsgRjZEpVjocTtDrqTngb4H58viSCMvplupJ4m1Rl9dRIpqW8EFgTzQza5gGx9Yf 1fFJFWyAG2gfg58OgYPNkMOsowSsPBiWqpz1QYYefSE5Y4ZQmHIWo9CJD1OwxTzQd02k xd5mY3JxBDrz+97imNyRrAGnVZUA6GFgDkLTHg5iWlQV6A+45fKQjJxjWoQ01tLfUlF9 MtFDarDBKdGMy5o/XOQwWtRJZXdXls0i4u9mHAaPPjqDARhqpbugAT6iCq/w+88Y9VoH 07MJJRn1HZCUwbjWV6xx9pH+e6xT8UfD49KcuTgbsU1QTd9DDhqKe9NKnEPDVn4nMugD Xq4w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=B8gwZZLp; 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 p20-20020a1709060e9400b008dfe8ec40ccsi172088ejf.814.2023.03.02.12.29.25; Thu, 02 Mar 2023 12:29:47 -0800 (PST) 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=B8gwZZLp; 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 S229890AbjCBU0N (ORCPT + 99 others); Thu, 2 Mar 2023 15:26:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229895AbjCBU0A (ORCPT ); Thu, 2 Mar 2023 15:26:00 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on2059.outbound.protection.outlook.com [40.107.96.59]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F462521FA; Thu, 2 Mar 2023 12:25:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mp0XneEosqS8ohwEmaBNwian4YyAs+ZkNrgw5h5wCkX13D+SveZjoFPGPKWQlSVJ78Wp0rTjuWWbqp3x91akhfHVVQKsMDZ2UA3XNycbcxFVbTvcyyz2jD7sRrk+iAbRHFqdYALkugBlO+371Rzi0TqU4Y83oBemovCCVd4NwFgjnIYin6sg0EYVRqiL1zY/yRQRlmZIVEjjPkz1et7v+WboRt6wSSfTbQpRJthjdloMJxplJLv+aZZCYMJUPthtWrR6lRHqGwxcrMlaISKA0mVgcI6t+bUu/V4hbCnoSIRYynigC+Qu5T94BbyzXtYwfK9PiIKdlMBtATE1htDgQA== 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=eO6qZ4CmidKPoh+G1DsI+9CoKSqfSijLIjt12ZB+cu4=; b=OLS4MXBqKxCLoIuIpg2HIKoPmuiTdgxW8sAbEFJibom86Ebi82Lr2AJUUz4wdyedQQZOTHWYbnfZvDVtIoAp0N8sg4JDGz623kXuGx4ZTc288VSPDBMOVRwbJg3uTicBf4v8teW+1KW8FyAXGfBYLhHGbVbFJzrVU2P/6MdMT16AjzaHsgTOXOZcLSTpC9JEM1oLxgRxrDcLusZ6wOZhqtVh7NjW9MKbvfpUl+GyHNx5JsLZeQrO8GpQ5p5gS35lovWwvOTofI1s+P8g9xe+/HfvaayocUEBy8gOGMbN32duxw4lSjpG4n/CpMf6Qb1GniV/dw8DTiYzEF3WLVOksw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=quicinc.com 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=eO6qZ4CmidKPoh+G1DsI+9CoKSqfSijLIjt12ZB+cu4=; b=B8gwZZLpxz/69Lnilcm+I0qawck1JukfqAQCNOVuZVNlF4vhBrpFmVeH7krWrGBTj4ycifwP+GR4IUGyYnjLePoLJjQOhteoKTB5rmcCpHe0LZLxJyoJ8V7HRZujx+2hE+02Ll4dR4DHqXqFirQAEbLV53uoYzW48hM1oA0/Tts= Received: from CY8PR19CA0037.namprd19.prod.outlook.com (2603:10b6:930:6::11) by CH3PR12MB7667.namprd12.prod.outlook.com (2603:10b6:610:14f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19; Thu, 2 Mar 2023 20:25:48 +0000 Received: from CY4PEPF0000C970.namprd02.prod.outlook.com (2603:10b6:930:6:cafe::b) by CY8PR19CA0037.outlook.office365.com (2603:10b6:930:6::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.20 via Frontend Transport; Thu, 2 Mar 2023 20:25:48 +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 CY4PEPF0000C970.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.12 via Frontend Transport; Thu, 2 Mar 2023 20:25:48 +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.2375.34; Thu, 2 Mar 2023 14:25:08 -0600 Subject: [PATCH v3 7/7] x86/resctrl: Add debug files when mounted with debug option From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Thu, 2 Mar 2023 14:25:08 -0600 Message-ID: <167778870823.1053859.9940104139782066465.stgit@bmoger-ubuntu> In-Reply-To: <167778850105.1053859.14596357862185564029.stgit@bmoger-ubuntu> References: <167778850105.1053859.14596357862185564029.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: CY4PEPF0000C970:EE_|CH3PR12MB7667:EE_ X-MS-Office365-Filtering-Correlation-Id: c51c3882-3c0b-4167-f604-08db1b5c4f35 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u5m3pFvpMKl7PKA0A+xgTpoZAf+zFjoWX+8Qza/ARnlH0wWHflm6h3ytLPc9/xCxrjPtyDJMO1+PR1UBfD2phOcfrdsx7/n5naMDcFImzwn2m3zljmKsf6s7L1lko/7bryqhe2hWYDhpXhOAloJ8Q7lacgYi6hWqBCVe6bTuJSW0y50eIdKtxu3J8UbroGIxQHPKIf02lI5czOBAKNeu4LCzYbjZ53Nq5KexxPqzTm2qd7N62NnS5D86kP2jaXPnz8Fh/EYjU7y855M7h+KCAfrX4d0uqcLhXG6stPp0ZmSzyRFEyYbah+8JM5Y1GtcD6/pinJIS5+7owfpID1wV3NmYdyTTMyPpnwViFD+ciPlbBaZjEJ+Je+GrI5KKYbDbfs7n1KaHq3iXvpaEor5iFmHFQUS4SkAF5o6UnPoDkunp49fhGNbsA8ebIL37kRZ7LggyXxOK+oCl8cCbRxOChVHVjhB+1U4wqYuJx/BKsmeiRzXx4puqb94mKEa4pxax8adTmuTOe74Me9y91rcSudxX1LksWcseLFsT3lZAGJnwVD0uerZSPhw5Cj/u2wTkGpuD6AnZypk8gIba0gxmUkQ/29crokYH1dXCzOgmlUnhrEX/NxxRSkcq/CsLiB9W2iQx6FtSmrAgaxpHhGnSPjICfgkk3I5NCTqUoBltFloFta5KoOHxm2ICkmmV2z0VMz1luELZTomV8S4f2+GlawvPmBA+bJB0aI0BqnytoslC8yhfr6QlKXvQ8TwA9Piu 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:(13230025)(4636009)(7916004)(136003)(346002)(376002)(396003)(39860400002)(451199018)(36840700001)(46966006)(40470700004)(82310400005)(33716001)(41300700001)(8936002)(54906003)(40480700001)(16526019)(40460700003)(336012)(9686003)(70206006)(70586007)(186003)(4326008)(86362001)(8676002)(103116003)(2906002)(47076005)(36860700001)(44832011)(83380400001)(7406005)(426003)(7416002)(316002)(26005)(5660300002)(110136005)(478600001)(16576012)(356005)(81166007)(82740400003)(71626013)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 20:25:48.1996 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c51c3882-3c0b-4167-f604-08db1b5c4f35 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: CY4PEPF0000C970.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7667 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_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE 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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759289265254256231?= X-GMAIL-MSGID: =?utf-8?q?1759289265254256231?= Add the debug files to the resctrl hierarchy. Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 48 +++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index a1f13715a65c..790c6b9f9031 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2400,6 +2400,45 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn, struct rdtgroup *prgrp, struct kernfs_node **mon_data_kn); +void resctrl_add_debug_file(struct kernfs_node *parent_kn, const char *config, + unsigned long fflags) +{ + struct rftype *rft; + + rft = rdtgroup_get_rftype_by_name(config); + if (rft) { + rft->fflags |= fflags; + rdtgroup_add_file(parent_kn, rft); + } +} + +static void resctrl_add_debug_files(void) +{ + resctrl_add_debug_file(rdtgroup_default.kn, "rmid", RFTYPE_BASE); + resctrl_add_debug_file(rdtgroup_default.kn, "closid", RFTYPE_BASE_CTRL); + kernfs_activate(rdtgroup_default.kn); +} + +void resctrl_remove_debug_file(struct kernfs_node *parent_kn, + const char *config, unsigned long fflags) +{ + struct rftype *rft; + + rft = rdtgroup_get_rftype_by_name(config); + if (rft) { + rft->fflags &= ~fflags; + kernfs_remove_by_name(parent_kn, config); + } +} + +static void resctrl_remove_debug_files(void) +{ + resctrl_remove_debug_file(rdtgroup_default.kn, "rmid", RFTYPE_BASE); + resctrl_remove_debug_file(rdtgroup_default.kn, "closid", + RFTYPE_BASE_CTRL); + kernfs_activate(rdtgroup_default.kn); +} + static int rdt_enable_ctx(struct rdt_fs_context *ctx) { int ret = 0; @@ -2413,8 +2452,10 @@ static int rdt_enable_ctx(struct rdt_fs_context *ctx) if (!ret && ctx->enable_mba_mbps) ret = set_mba_sc(true); - if (!ret && ctx->debug) + if (!ret && ctx->debug) { resctrl_debug = true; + resctrl_add_debug_files(); + } return ret; } @@ -2831,6 +2872,11 @@ static void rdt_kill_sb(struct super_block *sb) set_mba_sc(false); + if (resctrl_debug) { + resctrl_remove_debug_files(); + resctrl_debug = false; + } + /*Put everything back to default values. */ for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r);