From patchwork Fri Aug 11 20:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Moger, Babu" X-Patchwork-Id: 134675 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp1338957vqi; Fri, 11 Aug 2023 13:30:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu01J+W9ATCm3KPc5LvY8ExTOulocozfl6ES9uFMJ0T7kvw7Kt1vswvOxlB8KwekeKPUDA X-Received: by 2002:a17:907:7859:b0:994:4e9c:30c6 with SMTP id lb25-20020a170907785900b009944e9c30c6mr2427561ejc.57.1691785819700; Fri, 11 Aug 2023 13:30:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1691785819; cv=pass; d=google.com; s=arc-20160816; b=PIVNRYIXapSOePHlCZWtiOxt19PVekCBPsFgN89Zauvevts/WKCrwIwPR5r6tM055q EVE5pASE9XBe2rFHNBwBuBvUEUJasURAHX1/VJu3h9Czg7tr84/FLVEvn5gg+GGlvBxz k0HFzOzuxaYvfuntwhlQtiyPc7EqYtA9mSmsvovCrNUVjsSf3uhRyhX8ZwFUN3Cd79On AD/rJloMP9f6zN5SPRW5ksJ6UMcIwSk0xXwACQNXmt7tdzt7UwfuBcJFnFeNFzCJ/4Bu EkOEc9MjN+h0mXj9ZFoJg6PQtyo8VImSdGL+3TaIHAEYCxWKLcaZ3z1nhtYxb004ovRZ wl7w== 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=PfgYOsCGtiaBFc0QyKVPj6KYurATlWLcaOnrA1ibq6o=; fh=h28vckfI3GX5WFto8VbLoaUMI0xqlhwXGWb2ZADi/Dw=; b=uBK4He8r5vxIu8AJzG/iLAc6D4aG2GXsNEZE/JL4p1hFn3CybPDzExYEOFlD50q6DP sruJOINzaNlQPqtRRd1BDBJ6NN+6Vlcykbl4lGDgTW27WhGC+5J+Ps7OsORYp13PZjwP P4twS/BnD/+42OkBe525ItmMhLRi86d37h3WDEgv414VgpCg0obKT5Z+uLFBAJqHqx8d uzsXxRheYUeCijsvmlkjrNiP1IWU+uTJYc4zQuGbH5AFPtZsBdX125dV7HG1nGI+/hCd UKxCezYJ3wsBLMM/QRWQUaVoyCT47XGjZVxUppjtFurFTdKlH4eSA5bF4KVkzYC8tgfj ljcA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="cI0nl/Eq"; 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 o2-20020a170906358200b00992e0e54464si3694576ejb.254.2023.08.11.13.29.54; Fri, 11 Aug 2023 13:30:19 -0700 (PDT) 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="cI0nl/Eq"; 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 S236424AbjHKUKw (ORCPT + 99 others); Fri, 11 Aug 2023 16:10:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbjHKUKu (ORCPT ); Fri, 11 Aug 2023 16:10:50 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2041.outbound.protection.outlook.com [40.107.223.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 172A730C8; Fri, 11 Aug 2023 13:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TohYvuRzy0colFOGkylCp0sL9OPyy9kSrYi6yvsv0Q421yUZ1zwaxmYuAr0xpgnylTSgy65Mh7vJOctc9dO+5IXWgtOlqpl1+R/tO4ePKkubHOaN3J9GmjBHjQKF+4tASWDwHTAmOaUNOpNvA5HXz16yv7Glvhx1Hhj+qdWAfIzPK9c8zePBHSqUaMnN/Kt8jRMP9qDbBUxwefY6y+lb2rCkZUa/m5aJ3VUnKOOh6oT0xj1+quTYnq5OilOWRSEd5JakeQeet89DXlorMYAN/HYpBsEsV1Rz2vkMnEgEKLPibUEmOaaPeBenqcrL29d//v7yaHppoYHP4hy4oxO1zQ== 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=PfgYOsCGtiaBFc0QyKVPj6KYurATlWLcaOnrA1ibq6o=; b=OgUUG2UyfwSKOm+X05fm761f4BhumpuByLxcUyLbTUtcqWzmJnOfUlintLk58NSsLOy5c717yVTX1AqPd1+EpBQxND2sVCBT71CYoNGnMpaxp//DWTnmz/OXZR18/VhdJLWJno/ngCw6xLrSxWzhQCX5VXjd6wh7ngFiIbUF3+8xY8xLF7XDCgEzO0TZ+NAHFUPv/cnJkU5p05lBIO5gYo0iihVDMXOlG7eriBvUIv0AAVPE7aC6BqkAauLvi1WorINWtGqt9HhZeRly+VIXaMjuXwcHEzbVCa46hKoceYv9AmaJmsZSd3/8EX9UP9sMOtk3ZkFKOOoPJqw32mbFJg== 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=PfgYOsCGtiaBFc0QyKVPj6KYurATlWLcaOnrA1ibq6o=; b=cI0nl/Eq9K+c0L4uhZwq5adBLgW3qBwuAO03lbPGbJW4S0xQ8b7JsQktzXMeHybHBcFv4Ml1Y79xzYcrjMDS/j3q1ZIN3RhPYYqlH1NAvtRVzDnpdWo1Dg+RV4GXhAY7Gas+ZAfC6IL+ayeMJZZ+knImtm8VyJlQIgWlyTI6SJ4= Received: from BYAPR05CA0052.namprd05.prod.outlook.com (2603:10b6:a03:74::29) by IA1PR12MB7613.namprd12.prod.outlook.com (2603:10b6:208:42a::19) 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:46 +0000 Received: from MWH0EPF000971E5.namprd02.prod.outlook.com (2603:10b6:a03:74:cafe::c1) by BYAPR05CA0052.outlook.office365.com (2603:10b6:a03:74::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6678.15 via Frontend Transport; Fri, 11 Aug 2023 20:10:46 +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 MWH0EPF000971E5.mail.protection.outlook.com (10.167.243.73) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6652.19 via Frontend Transport; Fri, 11 Aug 2023 20:10:45 +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:42 -0500 Subject: [PATCH v7 6/8] x86/resctrl: Move default control group creation during mount From: Babu Moger To: , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Date: Fri, 11 Aug 2023 15:10:36 -0500 Message-ID: <169178463637.1147205.7411319721706077266.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 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: MWH0EPF000971E5:EE_|IA1PR12MB7613:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bf14f01-f2d0-437a-a155-08db9aa70c2a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hZSUqi3/lsNHBMuA2zbvsGw6Hv/pQJEAaCthU6I+kfAebe/9PL65fDqk7NzGQaTpKchDZdXPH0kO+cW59UFlYqgiAHJF/MWpYirXGBR0h2j7eatMlNh1Hcj5ODie0WXeaGW7HNap7ZJLnd3h51NFxCeGXMt7d9AYVKGuAdA4gEeqR+exDW3rRZ4b2L3FoMaIL9FPEyhVFjZ66SajdErOBZP6JBb6HrZLnbxrWL7vcoeWd+D6BB4WhgCG8U8AUKfeEt4vNbXeCtCMnw0cVvslO543S2mFmcacOg0Vg7x1TGPaVAhTpnzp9WDGUJVYAiVgtECUiUzY8/6iHWSSBsu6DP5d3MNwCwi8CKx+9AG/6bW+WRj+MLBRoCrzUST5PQTq4dbl1mOVh/P6i0d/aROFHW9+x0BC5zD0EkgOKhevENr8RJpOkO77hfvvABralwKg+fqX28n+FkfIU0+3RdT0wLl0sc+/FEWBksApV67B3Jp1LX4h0Coq0toXyDUOHd6jA4Z3XplRW1N4tEZplg+FdLZztpfqB/oU1KzQLXxbcv/WxLuyt8xN/d+Fgdep6MEuApvBQe2PApCy06fBKLEzd3TIEDQJziFjzdOak+yp7UFTP8OHj3ly6/PSu2KykdzONvjfkNwvoPGyCmyENSdSgWzgKe51plIp3ABZGRoiPJOCR6Qg8rEtyup+n8ikzqFlmr4+p1r0/ktVTPZMU4LzRWmvlWA1g/gyhvxHWnhKNAonvzAvOkLEo+kleKXiTNZRVrBueKdbOdLg80mOi2OzjRu6lqcXSFkLcbNFz3nt9DE= 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)(4636009)(7916004)(396003)(136003)(39860400002)(346002)(376002)(82310400008)(451199021)(186006)(1800799006)(46966006)(40470700004)(36840700001)(36860700001)(2906002)(54906003)(7406005)(7416002)(9686003)(4326008)(47076005)(70206006)(70586007)(110136005)(83380400001)(478600001)(86362001)(426003)(356005)(82740400003)(40460700003)(81166007)(40480700001)(316002)(103116003)(8676002)(8936002)(5660300002)(41300700001)(44832011)(16576012)(336012)(16526019)(6666004)(33716001)(26005)(71626016)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Aug 2023 20:10:45.5674 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bf14f01-f2d0-437a-a155-08db9aa70c2a 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: MWH0EPF000971E5.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7613 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, URIBL_BLOCKED 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: INBOX X-GMAIL-THRID: 1773966007645981544 X-GMAIL-MSGID: 1773966007645981544 The resctrl default control group is created during kernel init time. If the new files are to be added to the default group based on the mount option, then each file needs to be created separately and call kernfs_activate() again. This can be avoided if all the files are created during the mount and destroyed during the umount. So, move the default group creation in rdt_get_tree() and removal in rdt_kill_sb(). Suggested-by: Reinette Chatre Signed-off-by: Babu Moger --- arch/x86/kernel/cpu/resctrl/internal.h | 1 + arch/x86/kernel/cpu/resctrl/rdtgroup.c | 50 +++++++++++++++++--------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/arch/x86/kernel/cpu/resctrl/internal.h b/arch/x86/kernel/cpu/resctrl/internal.h index 37800724e002..2bd92c0c3b0c 100644 --- a/arch/x86/kernel/cpu/resctrl/internal.h +++ b/arch/x86/kernel/cpu/resctrl/internal.h @@ -602,5 +602,6 @@ void rdt_domain_reconfigure_cdp(struct rdt_resource *r); void __init thread_throttle_mode_init(void); void __init mbm_config_rftype_init(const char *config); void rdt_staged_configs_clear(void); +int rdtgroup_setup_root(struct rdt_fs_context *ctx); #endif /* _ASM_X86_RESCTRL_INTERNAL_H */ diff --git a/arch/x86/kernel/cpu/resctrl/rdtgroup.c b/arch/x86/kernel/cpu/resctrl/rdtgroup.c index 0805fac04401..a7453c93bad4 100644 --- a/arch/x86/kernel/cpu/resctrl/rdtgroup.c +++ b/arch/x86/kernel/cpu/resctrl/rdtgroup.c @@ -2521,10 +2521,14 @@ static int rdt_get_tree(struct fs_context *fc) goto out; } - ret = rdt_enable_ctx(ctx); + ret = rdtgroup_setup_root(ctx); if (ret) goto out; + ret = rdt_enable_ctx(ctx); + if (ret) + goto out_root; + ret = schemata_list_create(); if (ret) { schemata_list_destroy(); @@ -2533,6 +2537,12 @@ static int rdt_get_tree(struct fs_context *fc) closid_init(); + ret = rdtgroup_add_files(rdtgroup_default.kn, RFTYPE_CTRL_BASE); + if (ret) + goto out_schemata_free; + + kernfs_activate(rdtgroup_default.kn); + ret = rdtgroup_create_info_dir(rdtgroup_default.kn); if (ret < 0) goto out_schemata_free; @@ -2589,6 +2599,8 @@ static int rdt_get_tree(struct fs_context *fc) schemata_list_destroy(); out_ctx: rdt_disable_ctx(ctx); +out_root: + kernfs_destroy_root(rdt_root); out: rdt_last_cmd_clear(); mutex_unlock(&rdtgroup_mutex); @@ -2659,7 +2671,6 @@ static int rdt_init_fs_context(struct fs_context *fc) if (!ctx) return -ENOMEM; - ctx->kfc.root = rdt_root; ctx->kfc.magic = RDTGROUP_SUPER_MAGIC; fc->fs_private = &ctx->kfc; fc->ops = &rdt_fs_context_ops; @@ -2830,6 +2841,7 @@ static void rdt_kill_sb(struct super_block *sb) rdt_pseudo_lock_release(); rdtgroup_default.mode = RDT_MODE_SHAREABLE; schemata_list_destroy(); + kernfs_destroy_root(rdt_root); static_branch_disable_cpuslocked(&rdt_alloc_enable_key); static_branch_disable_cpuslocked(&rdt_mon_enable_key); static_branch_disable_cpuslocked(&rdt_enable_key); @@ -3711,10 +3723,8 @@ static struct kernfs_syscall_ops rdtgroup_kf_syscall_ops = { .show_options = rdtgroup_show_options, }; -static int __init rdtgroup_setup_root(void) +int rdtgroup_setup_root(struct rdt_fs_context *ctx) { - int ret; - rdt_root = kernfs_create_root(&rdtgroup_kf_syscall_ops, KERNFS_ROOT_CREATE_DEACTIVATED | KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK, @@ -3722,6 +3732,15 @@ static int __init rdtgroup_setup_root(void) if (IS_ERR(rdt_root)) return PTR_ERR(rdt_root); + ctx->kfc.root = rdt_root; + + rdtgroup_default.kn = kernfs_root_to_node(rdt_root); + + return 0; +} + +static void __init rdtgroup_setup_default(void) +{ mutex_lock(&rdtgroup_mutex); rdtgroup_default.closid = 0; @@ -3731,19 +3750,7 @@ static int __init rdtgroup_setup_root(void) list_add(&rdtgroup_default.rdtgroup_list, &rdt_all_groups); - ret = rdtgroup_add_files(kernfs_root_to_node(rdt_root), RFTYPE_CTRL_BASE); - if (ret) { - kernfs_destroy_root(rdt_root); - goto out; - } - - rdtgroup_default.kn = kernfs_root_to_node(rdt_root); - kernfs_activate(rdtgroup_default.kn); - -out: mutex_unlock(&rdtgroup_mutex); - - return ret; } static void domain_destroy_mon_state(struct rdt_domain *d) @@ -3865,13 +3872,11 @@ int __init rdtgroup_init(void) seq_buf_init(&last_cmd_status, last_cmd_status_buf, sizeof(last_cmd_status_buf)); - ret = rdtgroup_setup_root(); - if (ret) - return ret; + rdtgroup_setup_default(); ret = sysfs_create_mount_point(fs_kobj, "resctrl"); if (ret) - goto cleanup_root; + return ret; ret = register_filesystem(&rdt_fs_type); if (ret) @@ -3904,8 +3909,6 @@ int __init rdtgroup_init(void) cleanup_mountpoint: sysfs_remove_mount_point(fs_kobj, "resctrl"); -cleanup_root: - kernfs_destroy_root(rdt_root); return ret; } @@ -3915,5 +3918,4 @@ void __exit rdtgroup_exit(void) debugfs_remove_recursive(debugfs_resctrl); unregister_filesystem(&rdt_fs_type); sysfs_remove_mount_point(fs_kobj, "resctrl"); - kernfs_destroy_root(rdt_root); }