From patchwork Tue Oct 17 00:23:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 153822 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3808599vqb; Mon, 16 Oct 2023 17:23:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEd2hXiiGJJbijnvo+IJruajId0oAL6/ayjhY60z/Bty8rjLzXZ0I6u0ZOCdqEGZLP9rNG3 X-Received: by 2002:a05:6a20:7d97:b0:171:947f:465b with SMTP id v23-20020a056a207d9700b00171947f465bmr656667pzj.4.1697502229201; Mon, 16 Oct 2023 17:23:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697502229; cv=pass; d=google.com; s=arc-20160816; b=paBUxi1sfXq8qGW40GBvHD/lBMjqG4y1ET0s1z+D+IL4uT7rB7gCYf1odqrD2VR+eF k7Y380MLDpQb6B54ZCID/m+5Ohb9ivfYHKActEjWrxqmEaNk6gJ2bvcDsYCOICkNyS9w F/D+FjVvOqh+vcBkvw9vrvcR/FO3Cl7QBuu5rSPyM7YaISn1XehLb1KYe8fQeAafN/7l P8mDflmLkfggvueqqNXo7WCIoH++eQBfWVp75fsthVYR0p/9hJsxPjVqMGyGn8RqIXzn mWNS9YCNmw1ZdFNoXXNSImwCidpYzeCsHo0aEfuM7P7KyCgbunQxYsdIY7p8obB2hMzM 5iqA== 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=h+0ZjoMvPgCvWePnSut5vWYUpmpoW76ZIIFUVe/KzTc=; fh=a8QQDpsyeps30vd5Li+WI6v6dtcd7xKVvftia9bksQM=; b=no0VduFTzh8w3WDeyM96kMi7eavY/Cj1XE/507wDVzTd2qDSrrx0X0XdgNE6wiBHxI CmDcDWko3vlHE/gY5sFFRrxzkH74w6IBzcruO64IDYdHRfG1fDaFqCWJowpePJueRPvU ppXgwhJRlH4FV8LS91brggi/KXkjqJhtSMZy3Sk3+PglJ/mRwH6rdvF5i/WCkH5CxovT e+KCvR9XUaKW82Yo/HBdH3IsyE3T00NNVlfVUdEAD3OC1hx2YpsSYklCECxLbJZ2gVZE Onqv10rCZFXBU+AHHW4SkXTyLSmmTHnyIs+2Y9TRT4OdOPxt8m3eq40wByZ0Gh9rZZz9 hR1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=hNyG28sk; 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:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id k4-20020a170902d58400b001ca119ef46csi485123plh.478.2023.10.16.17.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 17:23:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=hNyG28sk; 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:7 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 snail.vger.email (Postfix) with ESMTP id 684C98025B75; Mon, 16 Oct 2023 17:23:47 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233835AbjJQAXo (ORCPT + 18 others); Mon, 16 Oct 2023 20:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234236AbjJQAXm (ORCPT ); Mon, 16 Oct 2023 20:23:42 -0400 Received: from NAM04-BN8-obe.outbound.protection.outlook.com (mail-bn8nam04on2056.outbound.protection.outlook.com [40.107.100.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCC55EB; Mon, 16 Oct 2023 17:23:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awxrZdRKvZ19kVTWaSshHtQc8EbyysepKqnCaKzYTZxiLvN5Fx/uXyX09IdZC9/4bA3L4EFSIszYjVOehM2lut2blbaXEPgJX/CAqTFz6Yhbrfhy+QpoBBsWCpbH5+yfGxfz5Hq1x5Jq1eZPHhZwrSq1ECEPgyXI8IXr0eNHIubU+UdmXIC7id6Oip0jrJMxztuj/iVfCZy6zCApF4v1SXKPPOZnIBHF+cbHIOV4vM4ncHcCN21qJ5WJXicyQKQyVchr3ewtafNEuZCbbBLcWZkdKc8UWI5TSincIx4aOQDIGILN9yza2YDZsdmrUKO34wHlrZ0QOPUW3HiekaoaVA== 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=h+0ZjoMvPgCvWePnSut5vWYUpmpoW76ZIIFUVe/KzTc=; b=ImA1jfeu34WrnAvuUgrQGDzQ2eFDXDuzTgeH+SdQv+T+Tfun0zg1MQM+yrGhotCnOeiQhw8cMh5x/lsbk6CIdY5FTeom4JZsWG6cZ0AJ5DepWKc1wRnZP4zw+ZjEwaAi8IJJipVFMYlx1msT7UXpRSgpXK6h0F13hhQ8fzh/DlnRLfuQloeJSoc2H9C6/XoduLBasBsbrF/N0Q7k13MNBSXaIRite+7FYUCIaGumcLDyN+k+PS+avNq/nvZfHgAtQEjwoIlj3l6S+lhzq368fRgvIuHY2WA3kRQulqkZevSesD1AnPVa4dhv+kPcYIPMGxtivUxj2NrpjFwf6FMJOQ== 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=h+0ZjoMvPgCvWePnSut5vWYUpmpoW76ZIIFUVe/KzTc=; b=hNyG28skuQOcQx4cOMKzlr16km99yIHHXW7YgQO/nvf3mqjSAKyaQB71E4jGfsAWn8viC5YkkbUFF8gTOXahavVPpTG+agzf6RJCrV5lgD9EkkZPyWveob0MPb+MTAqI8egXZQFlix80ruFoNN6BxUGrm4NklrgAqVnzQmc4k0w= Received: from SJ0PR03CA0157.namprd03.prod.outlook.com (2603:10b6:a03:338::12) by CYXPR12MB9338.namprd12.prod.outlook.com (2603:10b6:930:e5::13) 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:36 +0000 Received: from MWH0EPF000989E7.namprd02.prod.outlook.com (2603:10b6:a03:338:cafe::83) by SJ0PR03CA0157.outlook.office365.com (2603:10b6:a03:338::12) 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:36 +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:35 +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:32 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v14 4/9] x86/resctrl: Unwind the errors inside rdt_enable_ctx() Date: Mon, 16 Oct 2023 19:23:03 -0500 Message-ID: <20231017002308.134480-5-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_|CYXPR12MB9338:EE_ X-MS-Office365-Filtering-Correlation-Id: 6e88a17f-bd04-4c93-60de-08dbcea74d9c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QQTy8Tllm2g7be9+eCdm1vRl4wUlHq5yTaRmLLABx6Hr3HASEoFUqtfCpBwwNKAZVefbrbpKPW1brBlvO6ZYl5QK3eaPl+0+Go53JnUiA4IaoCrmh8bqel9jopR+rKREpvKymoZN4ZVbyC3IlQ9fNMWn8gBeET9DNvaDz9TnX/KxNb8dwwC2aSHkQvnH2wcNU1WUfgil0Y84460mbE94f0Lhzf6YptD2rrxYfcjBTOXbrEeNR6903E2UP3VqzjcQN0WKY7VFNysMLNYKZHas8zv2OA6TC4eD5nTKXkyEBwm5qrQYKy055+K4CgiGvcdZ4KkceUvDnLDOfsx6qt9hv7My7wH4J6e93YlYEVNPaEYuQZ5pTLXb0uaHiGv2DZaZBbXwMdmILEV6SUregjNiTspDz9r+8CP0YZCi/bXL5EzH/5Wl++zt6bMyJA35XW0yQixCe8lR3fpVQwaBHn/e/EY0tj88rd9nMQJOQR4K9pQ/OKebH3cQWUlxj7JbxW2LKuuK7XOJOmVX/y9rDpY3EDRfod7MU4r/R/jD6W43YlnK6cwGzQ/s4S/qIAzBTBui5aPMczwAOcJKSCZVnSvwOz2Ux+JZk3JnJAK439Nz6EvkH4elTaUuAoA4p7XOuaX7f/HsrXvGkZECVNJXtoszV41eI7WhvB0tm4Kfxy702donFvw31Idiv5m+d/1yHUJ0KNM7jUjs2oaXsg//+RZnYBxcz+IARHS+GxwGgfjnVAH3+2Q0DJyo6JR6FGCUXR3mbldFlaDpPsv9Ej7zFs7jTA== 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)(376002)(136003)(39860400002)(346002)(396003)(230922051799003)(451199024)(64100799003)(186009)(1800799009)(82310400011)(40470700004)(36840700001)(46966006)(40480700001)(40460700003)(478600001)(110136005)(70586007)(54906003)(70206006)(6666004)(83380400001)(36860700001)(47076005)(82740400003)(356005)(2616005)(86362001)(316002)(16526019)(26005)(1076003)(7696005)(66574015)(426003)(336012)(41300700001)(36756003)(81166007)(5660300002)(8936002)(4326008)(8676002)(44832011)(2906002)(7416002)(7406005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Oct 2023 00:23:35.8448 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6e88a17f-bd04-4c93-60de-08dbcea74d9c 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: CYXPR12MB9338 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 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 16 Oct 2023 17:23:47 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779960097602550650 X-GMAIL-MSGID: 1779960097602550650 rdt_enable_ctx() enables the features provided during resctrl mount. Additions to rdt_enable_ctx() are required to also modify error paths of rdt_enable_ctx() callers to ensure correct unwinding if errors are encountered after calling rdt_enable_ctx(). This is error prone. Introduce rdt_disable_ctx() to refactor the error unwinding of rdt_enable_ctx() to simplify future additions. This also simplifies cleanup in rdt_kill_sb(). Suggested-by: Reinette Chatre 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: Removed the redundant comment about cdp_disable_all().(Boris) --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 53 ++++++++++++++++---------- 1 file changed, 32 insertions(+), 21 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 125d12d8f4b9..d1b5fd70ccbb 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2308,14 +2308,6 @@ int resctrl_arch_set_cdp_enabled(enum resctrl_res_level l, bool enable) return 0; } -static void cdp_disable_all(void) -{ - if (resctrl_arch_get_cdp_enabled(RDT_RESOURCE_L3)) - resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); - if (resctrl_arch_get_cdp_enabled(RDT_RESOURCE_L2)) - resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); -} - /* * We don't allow rdtgroup directories to be created anywhere * except the root directory. Thus when looking for the rdtgroup @@ -2395,19 +2387,42 @@ static int mkdir_mondata_all(struct kernfs_node *parent_kn, struct rdtgroup *prgrp, struct kernfs_node **mon_data_kn); +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); +} + static int rdt_enable_ctx(struct rdt_fs_context *ctx) { int ret = 0; - if (ctx->enable_cdpl2) + if (ctx->enable_cdpl2) { ret = resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, true); + if (ret) + goto out_done; + } - if (!ret && ctx->enable_cdpl3) + if (ctx->enable_cdpl3) { ret = resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, true); + if (ret) + goto out_cdpl2; + } - if (!ret && ctx->enable_mba_mbps) + if (ctx->enable_mba_mbps) { ret = set_mba_sc(true); + if (ret) + goto out_cdpl3; + } + + return 0; +out_cdpl3: + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); +out_cdpl2: + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); +out_done: return ret; } @@ -2515,13 +2530,13 @@ static int rdt_get_tree(struct fs_context *fc) } ret = rdt_enable_ctx(ctx); - if (ret < 0) - goto out_cdp; + if (ret) + goto out; ret = schemata_list_create(); if (ret) { schemata_list_destroy(); - goto out_mba; + goto out_ctx; } closid_init(); @@ -2580,11 +2595,8 @@ static int rdt_get_tree(struct fs_context *fc) kernfs_remove(kn_info); out_schemata_free: schemata_list_destroy(); -out_mba: - if (ctx->enable_mba_mbps) - set_mba_sc(false); -out_cdp: - cdp_disable_all(); +out_ctx: + rdt_disable_ctx(); out: rdt_last_cmd_clear(); mutex_unlock(&rdtgroup_mutex); @@ -2816,12 +2828,11 @@ static void rdt_kill_sb(struct super_block *sb) cpus_read_lock(); mutex_lock(&rdtgroup_mutex); - set_mba_sc(false); + rdt_disable_ctx(); /*Put everything back to default values. */ for_each_alloc_capable_rdt_resource(r) reset_all_ctrls(r); - cdp_disable_all(); rmdir_all_sub(); rdt_pseudo_lock_release(); rdtgroup_default.mode = RDT_MODE_SHAREABLE;