From patchwork Fri Oct 13 20:25:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 152721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp2136566vqb; Fri, 13 Oct 2023 13:27:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHlBrK0DkxPhi9QApxUHahx1U9ipnhhmcFsVmhWZtHGdM6N3wuUvt0Ei8jGBtJADnmMM37 X-Received: by 2002:a05:6a21:a5a0:b0:15d:a247:d20c with SMTP id gd32-20020a056a21a5a000b0015da247d20cmr36448639pzc.6.1697228841552; Fri, 13 Oct 2023 13:27:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697228841; cv=pass; d=google.com; s=arc-20160816; b=HdwBJWKXsoK1/YyzLHPOQaXvkkXhvdTh8MfD+m4LFX6aa6hJGLYRv17ZeTu1tpVDjh qwNWKNCSuH6Jo/E/ohnvWtG5Hcva5SrJ8qLGhf4BIFfEMfRDOftW2rpjBbJUeua+bkKX LdF8nYjP3gtJgCPs3GnwhnC2qK5PX0ULBLMnBf9rS3XRaZbeJJZjQAsw2s9UVUIspX/4 FaDaScSAcYiNP8kTVbC8GTPW4Fn32vWfDaY1l6RCs1S0RztbH6gSZPWtXxs7Mh4YLjtm YFkG2zn7E/diH3O+3Snsp8NDseceE2iD1AVz8/KK3RJyjLwBEsCaw4h+tHn7dp4HN9zU Rrgg== 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.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r69-20020a632b48000000b0057751b7788esi5351150pgr.488.2023.10.13.13.27.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 13:27:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; 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.33 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 lipwig.vger.email (Postfix) with ESMTP id E2B4680AE80B; Fri, 13 Oct 2023 13:27:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232242AbjJMU0f (ORCPT + 19 others); Fri, 13 Oct 2023 16:26:35 -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 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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 13 Oct 2023 13:27:05 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779673430174397429 X-GMAIL-MSGID: 1779673430174397429 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;