Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp1201703rdg; Fri, 13 Oct 2023 13:27:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJ0ghHZHzdKMeW8CvY7XWFe/p0lq6AaSMlXwmptwbFNBpkT2Fpj8AhnEEfZ0L2nKZeF6qL X-Received: by 2002:a17:903:22c6:b0:1c5:9d00:be84 with SMTP id y6-20020a17090322c600b001c59d00be84mr1647938plg.33.1697228834655; Fri, 13 Oct 2023 13:27:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697228834; cv=pass; d=google.com; s=arc-20160816; b=0R+6r9bYEh536p3uzoxzxWcjzFVEyMY8YL0/qXxdkrtdN+vi2zGf+h83yABECnDWOJ jR1cN6ksKEObTnnoV+qzKwQ+J8LB9MH7v7gNCkv5WNKBy1k/IXqbyEWgDhREy1DfRstp X5reN1wQGNGAAAnS/P2q9nEBF7MG1epxnCIRVadB2vfEzL2gq6WENCMEzdwXNREGD3zV Qg2BXkZFsFvcPkTIrICVWiFPcbcNwYl73htpWk3kriqNNtQXIV48Ji8EbOuJzMgwFsmn QXHRISiE4zUmjKe/t0fWHWr+b2GDzeE8vTaPW5cEzPRaxHkv77lZ/bILpswNGT7y6uhM xfZg== 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=dpG86LfixhfZA2Z5Qcg7xJc1kk3UM5piBnHQAQ36ZBI=; fh=a8QQDpsyeps30vd5Li+WI6v6dtcd7xKVvftia9bksQM=; b=zYtmCCVTHqwhzCxmyvY1G5S3+CMBFq1v6N7jQy7CWarVIR3s8Pa65EXQHfzKuR9+0t 2yUDDyv9i5bwYKsIFfAQl8F7Yk9emW9gLTZZRIHQgS1U86JzoCkYCH5mTRZj6qesT5vR xFnQBJDt1t6J65hlys/qdU2AjorRznutwzn0zytTAr3DTJR6/o7PM6KriEDoQ6QHapDl HMMwh+sHgwDsaHHpBRuAJTDDOC/vUA+OgoYpQ8NivGf9FynwHiS7cP6Uu+17Z4qWu9yR fRbyBy1kd61N+lQI9HkJOSyUNr9af4ss1s6lg/Tlf+Z26biz6kY+FTw/YcXpfvSoVipz V4GA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=RmvlmSlt; 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 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id e8-20020a170902744800b001c9ce2b6b97si4826157plt.198.2023.10.13.13.27.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:27:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=RmvlmSlt; 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 23.128.96.31 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 3E094822B711; Fri, 13 Oct 2023 13:27:12 -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 S232206AbjJMU0e (ORCPT + 99 others); Fri, 13 Oct 2023 16:26:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232124AbjJMU0Z (ORCPT ); Fri, 13 Oct 2023 16:26:25 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2084.outbound.protection.outlook.com [40.107.220.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 926DCD9; Fri, 13 Oct 2023 13:26:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hutBAgPQfPJwS8RS21lj+//HDHXFj/eGbZ7IGAcEqLNagoClEStOJX5MjExbWar9bASodPzVETTtIWtJtZTtNA1Dpog/0/6Pdmy+kJn51UXIe1G7aekJYg0AY9Hc9/cg9oi9gzoHtS4y4seYtU79jtTLx3j89cz2Htjnl1KWAjhYngiARx/yObOYCJTWnaZmD/rZ8/tGhiJAVCsJjGEwcHVMkdO0+AQqKIqlaqqOCa3aWzlMoKvbHjo7VFtZcNwPbSB9j/d/1lyFeEUblyb5YNQbfOLxalJQ2Yi/VMfdeCuRf385JZ2TBMmdrgX2/qYP1w6UGIg7jp1JCILtCYnYZg== 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=dpG86LfixhfZA2Z5Qcg7xJc1kk3UM5piBnHQAQ36ZBI=; b=XLiomrK6HSyJ1xu2OeE4Uw1r8FDZKZzzhx76MvevUPRSqoIJSbKaNGkDaKophjx8i7FGfPCTjQjfcQMtR8z40DBTq+wzXrIlwHNGGXSF5XPAGPRMUHiI1B6RFkVC3EJ6Su1dg5aoc+AHHiPy9fMpBbMFPuWX6ipQu5XIzKl7+NeJur97AywLJqKS+JqeN3QIherFccs98AnMo2mGQTACkAAjy0KF8ibih2LCUAQos9Gdls3QC2529BcAmAE/RdiYJCTTqCUfLotngNV/OtCnjXlipW7m1KS8eNPPJbPMk7cvu+jOtPwygaza2afhFmcQd7mZoiFZT6p8LnVpQjUcGA== 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=dpG86LfixhfZA2Z5Qcg7xJc1kk3UM5piBnHQAQ36ZBI=; b=RmvlmSltmOFgZDl0hN5DrS5ADRM8JQnr2vjdj9qtyPVm+ESxIwdJTLy+acf6J/c6fcz7dSKkOCL+H8yCFFxsrUXqTOtRfU1EN39Izqrl9DHneVpN5dQ5KM5E2cwww35Qv63N8O53tHg5sxQBmE6MiBR9SVxQpdZx/Y3vkB6hJg4= Received: from DS7P222CA0006.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::23) by PH7PR12MB5653.namprd12.prod.outlook.com (2603:10b6:510:132::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.38; Fri, 13 Oct 2023 20:26:19 +0000 Received: from DS1PEPF00017096.namprd05.prod.outlook.com (2603:10b6:8:2e:cafe::e1) by DS7P222CA0006.outlook.office365.com (2603:10b6:8:2e::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.27 via Frontend Transport; Fri, 13 Oct 2023 20:26:19 +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 DS1PEPF00017096.mail.protection.outlook.com (10.167.18.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Fri, 13 Oct 2023 20:26:19 +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; Fri, 13 Oct 2023 15:26:17 -0500 From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v13 05/10] x86/resctrl: Unwind the errors inside rdt_enable_ctx() Date: Fri, 13 Oct 2023 15:25:57 -0500 Message-ID: <20231013202602.2492645-6-babu.moger@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231013202602.2492645-1-babu.moger@amd.com> References: <20231013202602.2492645-1-babu.moger@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit 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: DS1PEPF00017096:EE_|PH7PR12MB5653:EE_ X-MS-Office365-Filtering-Correlation-Id: 73fe8f57-d24e-42a8-bdc7-08dbcc2aa895 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MSBG9hWwM0wUrhXE73bEuwszL5wUEBnJWx7ZPmJJPmrPOMWAsei3dyEJlRMJGKM7npnHZZi5KyutiSahe8XrRUitUK5lFu+s1IhG/RpE3ZZ+hCApyagvOwdkKjeoSZnVIUVObQR3bOd4V+1jPC4hNCTzSQfbwCMHXwiBzZGykzTaGTJNaIwjONb0jRWc9eykvUIhVfSqlSp34Ty1fjzDO7a+U6YCgMzB8OT2nFORqxWNI8YKOnZVbg3UqQJHeuofhs3pIgILyQlycFXowEuSDTXTofY6ygCPqS8tiMN0cF0G1gTBTQcYGSyKe7m1FngsVx1e5Cd8VBH4eIqMX6tU9JV1APZvDdM8VIPralfdiIXS1EWnx9weYG5XpAMCqksU4xX5+oDupbFrjcl9r1k21kCBG7bf0xRPMQCqBCWhyjH0aMcJWOCyxO1yzlbpsDcnrdU7B1Dl08aRTOwHWK+6iQ2pogMNJFwNXeNqQbC0W2792j7K4skZH+V8xYukaPZI9KwIjd94bVy3uP4FMIAP0I2huzxNpvQlmXMLG9d1Wfqr/ZtOY0g/LKJDLzmcS7z4GugiyDEGZlUUSghMz0piT/CfmElqIwxuQXe3h+893sx80+u4E597lOA1XbFlPuBGLarEfrAB9eXk58BsBsGZf0vB3WvkGHJnUOTuRDQJMEwkQDe1fwpbzsd9alH7f4qGh/fCcqQvDM/15Tvky2+G6nZjiq1J9riy6K59AreXm33T9JhoHssuxIM2wYlIG9Q0MRgBjtXxPkDC46owPrCyzQ== 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)(39860400002)(346002)(376002)(136003)(396003)(230922051799003)(64100799003)(82310400011)(186009)(1800799009)(451199024)(46966006)(40470700004)(36840700001)(40460700003)(2616005)(1076003)(41300700001)(66574015)(26005)(7696005)(6666004)(2906002)(478600001)(7416002)(426003)(47076005)(7406005)(83380400001)(70206006)(16526019)(70586007)(5660300002)(336012)(54906003)(8676002)(8936002)(110136005)(4326008)(316002)(36860700001)(81166007)(82740400003)(40480700001)(44832011)(36756003)(356005)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2023 20:26:19.1198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73fe8f57-d24e-42a8-bdc7-08dbcc2aa895 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: DS1PEPF00017096.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5653 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]); Fri, 13 Oct 2023 13:27:12 -0700 (PDT) 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 --- 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; -- 2.34.1