From nobody Thu Dec 18 23:41:25 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7491FC04A6A for ; Fri, 11 Aug 2023 20:10:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236677AbjHKUKl (ORCPT ); Fri, 11 Aug 2023 16:10:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234770AbjHKUKj (ORCPT ); Fri, 11 Aug 2023 16:10:39 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2077.outbound.protection.outlook.com [40.107.237.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD57430C8; Fri, 11 Aug 2023 13:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SyR8FrULCpaLzDAgp9009e993JSMiJT7+GIvNvGOiYTm1Yc/c82WPwMFV+J5v0sogRwd+be6xoPjJ9Nu77U0ydNZXxNmlroMCTi52VSHVDtu14MYT+KQFku3GNN9LTGhj/AkYsKyYnSZHiS/RqMvKni5xh5zYxbsva4cS/H0peoItVUZDdY4ikGW6erhE5WMVCLJFyb9Rf2iMmBbOwCz8a4qV99W3hVTkbyN/2Cx2qjiAgDo5GAY0tH6mkEzJZfoEgk9Zsas2qgPy49jYLctoYuKagUGclt9IJrxrxvh5LVWXiTl7QF1jC/Splp3Jj9VBWIpbgFll94Bac7U+bexMw== 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=pmP59P+VoRcJuuAk9hmDW41PRaO7VF5n6xJW5fOcJVc=; b=nX3UH1q60ldgTKrVid3NR9UJbRRYJ5TFJ0yNpS/6TBfsifCNLjeNWh761VX7m/81FAg0xIrj6Xqi318Pr+KQOShoutqKEigS8VKaRGpdj8VeSdD7MxPdooNtJcvBQF2HGtqYXJFM2TN4njDK22ZMhR8eDaJwcdUjCwux8FR/a4JLJzgc/4V3vlsGl+ZtZeI7sI4b2y28YaOUuUCWpaeSoz/aI2dEnG6vnwBpea+SiMwhKK8nTnbvlkCgAMVM3yh4VNHd+nysacLyzcbYTFw9cZdMgdGH8CJr6GGdt211xlYu2EGNIiK3j2wq8mZHta07R6hwmx35KD7d83qCCSwAiw== 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=pmP59P+VoRcJuuAk9hmDW41PRaO7VF5n6xJW5fOcJVc=; b=mGsAvfZpdab+ye+vdFOfeCwCSTnQRyo50QHACx/r6lMZl6TfPoWgORoV6TEH1IG/AkCYezh8/HAjwybiyu8dF349WPZuSUrHFCY8jCTjzWNqjd38HlzVBCEzT0uZbmowVich+XHVbvT3T8YFPuptv6PpP4tJSZh8sH8yWHTNTeU= Received: from SJ0PR05CA0109.namprd05.prod.outlook.com (2603:10b6:a03:334::24) by PH7PR12MB7330.namprd12.prod.outlook.com (2603:10b6:510:20d::10) 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:36 +0000 Received: from MWH0EPF000971E7.namprd02.prod.outlook.com (2603:10b6:a03:334:cafe::7) by SJ0PR05CA0109.outlook.office365.com (2603:10b6:a03:334::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.18 via Frontend Transport; Fri, 11 Aug 2023 20:10: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 MWH0EPF000971E7.mail.protection.outlook.com (10.167.243.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.20 via Frontend Transport; Fri, 11 Aug 2023 20:10:36 +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:29 -0500 Subject: [PATCH v7 5/8] x86/resctrl: Unwind the errors inside rdt_enable_ctx() From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Fri, 11 Aug 2023 15:09:53 -0500 Message-ID: <169178459367.1147205.14975628669652538089.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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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: MWH0EPF000971E7:EE_|PH7PR12MB7330:EE_ X-MS-Office365-Filtering-Correlation-Id: 668a550d-66f6-4143-7546-08db9aa70690 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ePde88xC62ieSkVvBG/8kIyM+Cr73Hyld77lRL+o5sWzV3eISpiW0DBM7BvhFYUdOAVbnWkNhslhMzx03olQP7CCw5DGGsE0I7oeCGUn97eBy0rM0b6/7bIenHtYb2dobEgHzJsZAG1Vx+xGbSd+mKVk/cze44Z4LjcRCdKLI7R2Z6V4ZVDtlBy1wzzu8zd3VzmQjeHclsHL0OXRgr1ws6y5JLcjQwTLhZkKk2/Zq1OT2P9h8PYw5J2KsrljXpn7ruHxCne4eoCIl0i3Zs/y2trPaj0YRMUAPiAzHgUj8HlMTaBVx/DlZ0rt0y3P99UikfuVwFSzVUfTi6dQBJLJWIFYpW5vXIHMWhmQ4FxnuYTaH0g6voVTMyxFg61zDs6Gdm8twBieXJyzSh4zeGAQw/V6RetFO6uKc4ju+eDWWPMCBTZBOwsApTYn36+wjoXtT0+QFw8uCOuaSjxKa9z+YHPq1W5Gvk8l4NMBPq70Wit+cyJlo09UnzGS5eETYcaXPx7yR07BcMzziSxHvde9abRMaKkcey9djLpY5Mtcc4pV9sHvNFi7giD0g9Skjbe30q3wKQhrFshsBgcmv3HIFZxjgvsLYbhX/WcP7TDxhmIX6mGgWcU8s4517DzkLRflfzw9C9G74GVy9imo3NKBqWK0cJQQe1MTp9uYVT/A5+xS9lSp0p8ZofK9zWyxYBv4wYCIY2QHo3XE8oKfA7ONncnae5n6l2sSlAYwv/rWxLASN8BvMBzz4Kqhlb3hALtX+PtywZrewTvXtUQ97PJvsJmwUvwnBc/W12KTHX+5Zqs= 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)(7916004)(4636009)(39860400002)(136003)(376002)(346002)(396003)(451199021)(82310400008)(1800799006)(186006)(36840700001)(46966006)(40470700004)(40460700003)(4326008)(7416002)(356005)(16526019)(7406005)(81166007)(336012)(33716001)(41300700001)(44832011)(426003)(70206006)(36860700001)(47076005)(70586007)(40480700001)(5660300002)(82740400003)(83380400001)(6666004)(316002)(54906003)(110136005)(103116003)(8936002)(8676002)(2906002)(86362001)(16576012)(26005)(478600001)(9686003)(71626016)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 20:10:36.1997 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 668a550d-66f6-4143-7546-08db9aa70690 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: MWH0EPF000971E7.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB7330 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/rdtgroup.c | 44 ++++++++++++++++++++++++----= ---- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/r= esctrl/rdtgroup.c index 3010e3a1394d..0805fac04401 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2377,19 +2377,44 @@ static int mkdir_mondata_all(struct kernfs_node *pa= rent_kn, struct rdtgroup *prgrp, struct kernfs_node **mon_data_kn); =20 +static void rdt_disable_ctx(struct rdt_fs_context *ctx) +{ + if (ctx->enable_cdpl2) + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, false); + + if (ctx->enable_cdpl3) + resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, false); + + if (ctx->enable_mba_mbps) + set_mba_sc(false); +} + static int rdt_enable_ctx(struct rdt_fs_context *ctx) { int ret =3D 0; =20 - if (ctx->enable_cdpl2) + if (ctx->enable_cdpl2) { ret =3D resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L2, true); + if (ret) + goto out_disable; + } =20 - if (!ret && ctx->enable_cdpl3) + if (ctx->enable_cdpl3) { ret =3D resctrl_arch_set_cdp_enabled(RDT_RESOURCE_L3, true); + if (ret) + goto out_disable; + } =20 - if (!ret && ctx->enable_mba_mbps) + if (ctx->enable_mba_mbps) { ret =3D set_mba_sc(true); + if (ret) + goto out_disable; + } + + return 0; =20 +out_disable: + rdt_disable_ctx(ctx); return ret; } =20 @@ -2497,13 +2522,13 @@ static int rdt_get_tree(struct fs_context *fc) } =20 ret =3D rdt_enable_ctx(ctx); - if (ret < 0) - goto out_cdp; + if (ret) + goto out; =20 ret =3D schemata_list_create(); if (ret) { schemata_list_destroy(); - goto out_mba; + goto out_ctx; } =20 closid_init(); @@ -2562,11 +2587,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(ctx); out: rdt_last_cmd_clear(); mutex_unlock(&rdtgroup_mutex);