From patchwork Fri Jul 28 18:20:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 707770 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 3AEF4C0015E for ; Fri, 28 Jul 2023 18:21:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235967AbjG1SVY (ORCPT ); Fri, 28 Jul 2023 14:21:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235923AbjG1SVW (ORCPT ); Fri, 28 Jul 2023 14:21:22 -0400 Received: from CY4PR02CU008.outbound.protection.outlook.com (mail-westcentralusazon11012009.outbound.protection.outlook.com [40.93.200.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B728422A; Fri, 28 Jul 2023 11:21:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AbHXSB6lK+GYztEgq1esT45tQ+bSTT+z4FBsKiNEIN8vN+DhptNlA1AbSN0qlJw/Mmdb+HdHC6yp5Wy95eIakQwmVI48gWQSUAgBYtuBxoMckcACyk5fmgnSGvXpN7bTrqXcyo4hnUFv95xgyF4Hj7lsy2mV5RGKagX72FvNk4twihzSgUmH7xh4PZZVOHFdyujU0m3pKPDUBh9JI08s0kzbQRKAGjxWyke7CDlpCgVro2JZGfnZl6M75jcfe9OnhCOoTRGB8Vll3U0xqrkbtrfInS1oed+Cfmolt/39FDIZaLTx2O1vjiuhjIjm1Ntw5mnS27B3Z7JHDSrYWWVDmQ== 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=h9dr8VcqHnHafKIs/SE0VyRBuRoqJbRFE8lhfXDwGdY=; b=Kj9GTXmM1o/Rs1Wr7xYcDP+UW0KHfR2yh2u+P87TysT8l1uJ9pM1rVPuu9gqVSF744RVUQ/AUDpfrN954nweaYZSbaG+fOimbUYRzZowtVyKRYLk5xj5GsjRq7LcJ7PeAHL5AR1oPJRA+EyNcABW20E5MbUleayV65eumt1I3r9x3u8CVgzEM3udran7Cog1OrGfE55z7Q68XrgmlhM3fQbc2mLRvInU/1bN2GeaySLW0AQIFKAuk+eyOnvlTtrB+gH9SbCkJO4B8Yqcb36rBJR2AvEc6a4DYOlNrMd6lQlKM84qoBMUtr8mXy95z1FEsUxEY+xigzkudN+s8roBSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h9dr8VcqHnHafKIs/SE0VyRBuRoqJbRFE8lhfXDwGdY=; b=g/xUxHe1wz1UZCEchaoEwf4bzJvDxOQZv0jVH0wWj8QLmB3AhfRc9zrt/f9cLrclFD47LLSWpJ6sWmQmcF94C/1yXCCZpoLbSYrJ02YExP0XHGoL3K5ZhwBu45Un2BTTJDIX50AqWhMc5VvRPTowe8eYZu1A9wSx2oxPYcpiNwg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) by SN7PR05MB9264.namprd05.prod.outlook.com (2603:10b6:806:26c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Fri, 28 Jul 2023 18:21:19 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0%6]) with mapi id 15.20.6631.026; Fri, 28 Jul 2023 18:21:19 +0000 From: Ajay Kaher To: rostedt@goodmis.org, shuah@kernel.org, mhiramat@kernel.org Cc: chinglinyu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lkp@intel.com, namit@vmware.com, oe-lkp@lists.linux.dev, akaher@vmware.com, amakhalov@vmware.com, er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu, tkundu@vmware.com, vsirnapalli@vmware.com Subject: [PATCH v6 02/10] eventfs: Implement tracefs_inode_cache Date: Fri, 28 Jul 2023 23:50:44 +0530 Message-Id: <1690568452-46553-3-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690568452-46553-1-git-send-email-akaher@vmware.com> References: <1690568452-46553-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR11CA0090.namprd11.prod.outlook.com (2603:10b6:a03:f4::31) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|SN7PR05MB9264:EE_ X-MS-Office365-Filtering-Correlation-Id: ad2bbd36-b5c7-4bb0-64e5-08db8f977027 X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yeo7xqc1M5VtVu436TWhqr1WYzwFuX+K7vR+PYvyQb8lDPthRdUHKbDm42ydIZHucVcX/5p7nDa4kbcMfZ7B+CW7YA9azo7Or2aEL5kXMDBLXhqJqOIwks6v/asXtHFRZh/DB82Ld4V4G5PaNJTcLOl7a5mnvG1qZEzTl+HxovZ206hc7ZKy8uGnn3uMfanxvMP4FnBiFDlh4M/lOG/VipAsfJ7s2FbNVvbZEPnmp/qkZFsADPyBOySdfMKkYqglFbGjP6tsHYyGG4kk9N0MbkA8eSXN8Ap7NS1roNJKKPMcdTbrYmPD47E25Nct/LP50a0HjPwDmOI1fzRocZbYHzqLrzG6lZKZP3zes0YqV1upweoZOE89Vnzxx8KYzsfQ8li15GwmEU7DnOMYlwLsU7xwIaB7U6FI5398RIuN4CybyJagp7XliMnUYS0W1bzYo65DqSn2BHIyJ8uRw1a9o14tSmi28pYBa3GOfcR5Y/vBun3wy062Y5eJSLYLfUzAvWiXZsZy4WB7XMHwNoBpLHmwZA1s9MDazUYh1PTsKsK224j80sJ9+qZpJlGF/CUckD1uv2hXoaRSPGHOieierGpwOVAfdXz7S7z1gHaaxhpGToUDT6jozlr8omAQjGXXxrw99gLFi++ZIrImP96L0khjWVjO5eEhcFKejEsPFb4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR05MB8703.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(366004)(451199021)(2906002)(316002)(7416002)(8676002)(86362001)(8936002)(41300700001)(36756003)(6512007)(5660300002)(107886003)(26005)(6506007)(6666004)(6486002)(52116002)(83380400001)(478600001)(38350700002)(186003)(38100700002)(4326008)(66556008)(66946007)(66476007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FT4kDbKFeog1QQTHAEjr0zKDhcWf4NAqNAqgf0atGwUCVt1vg5G3/EHSnsDC7tA/SDn1Z/YV8TvIL65P2AfJTmimQ6O17t2xr3o9yO95rJFcSF1A6HqYFsAp0rkCHii5iWvtks/70BUx/kol3+scWhWA/tNk6LIIJaPvwTza/kD1Z0shXbEy6GAQzawP6BLU73htIlRswe5tLBFqW3RhqM2EqUuvQ+JEy3ntSrS4/V0F0ZXeOTmMwFRJW2hNp6qCM84pbOttTB+bVSUwBYV4SU/ugA1vuZ0xpcAVtlxMSbDg82b9eb146C7Jouu6bZcNaib5jHnJ7RX9XmQsSNsG858SD9JXx36w0HMHMd2EoYpJkJTX7CkjTRupaCNIwCMbqTOnMG0v9dxmvhcxQ487b+wUUz9BUE2yvkmon0oNsIVpqeFmLP79/jV3iSPGvACc9asBLqUdlGFTQL5bcgSp6tHtjFhrrEPoLJBj19pDdkEkigmPdRPu8EkN7cBTlN54ZLm+72Wf3oLiy5JacbwnMJUTjYGwt9yqYLpkqUqnrgpMiNormERxl2ueeknCczQQ7iBcTg0guP76MWuNf0uoRVpN9r4vTNRqLCmYUQ3HGKOMzMnrfx3VX38tocRRhY33LY/y3DVUDucGn+8d/1bneE+LjWXP3IbVZ/7BHoDdMNqnCoieKrjfDPfB08BZv/VlFWth32tw3L3kgVfYvZLtvF+2s/YzPSYsSL0418KByIPASqUKa3hck6dR++A3PDriRWVdCQRIfX1ZWeRVYihYepfT7QvfryUKb9Ps+9wDoAqCiZO2MrJ9ZxCv0FlGytc29+8OZMLaE4JrA+SUOYdsUW9+NrZW/XF4y9/mq9Df3riZ5Xs3afpKjXsCAjkFfl+HjAZwRW/b0EQjwzTgEMfhs2cc5JMswU2iqlnK7p2RBwry2EAelp8IxGbSaaOaiL10S6waB2Xm8UQORcWsNmknJTeljDyEgwI1cd86fx9Ho40XMVzpDJk+aPE/1VgUgTXy1PzW67CoADgW/IZLbHHDNuBfBsNNQfSMMmHXRuuCKtL16OHKENLULjGzgbxzdJWOzHSzLwzgd+LEHgb1SRKWyMAKe66hFnS2zgAolaOkFRtMLizBSb5uaCoUYPfxnRQvg/pigigEnHN9I40C5/YCaUiH+buS+bcEP45cO73Mxdc2zIIHd1X6zKWgoMKH5MSgfHSuwRdhEXL5BWj048EM/hU28WpZ0UvM0yNM2RX0xCHmhAVpqsFdZQznHu/7+PU9DOMzea9dz7mCyz5GE3aVvL/wU2IyMdOrsoTSPw0OlCIR/YGcLZymIi+xvJI3lqlvkPW1R51GNWhgEhpoNEL9XohODnacJjdWvIaMuFoMJZbbnJ++kVgH7aPDNPRqRHriitrsS1Oj22lYnoFdsGJujjVmyxc7i8uGFb1XbTyD7c8ysnj6qr4IBSJhe/XGtXz/Ss7el/uf34jLY6Ff3BjADH5oxMySkra7wLacCBqGXDwLRpn5Nmv1xD0d2jv65oimw3S9towP9nWwztm35gSHshdVzjVU6olcIaSqV49tNNviwmL8XXzwXaU76w0rj6SJ X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad2bbd36-b5c7-4bb0-64e5-08db8f977027 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2023 18:21:18.9072 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ckH8W+j2TocyhhE8cWr03ICvNYJh5h9KNKjUquNF2vjOk+oIv65/6kmik5lOL+G66uAVz6I3ea8wY5htajpnzg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR05MB9264 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Create a kmem cache of tracefs_inodes. To be more efficient, as there are lots of tracefs inodes, create its own cache. This also allows to see how many tracefs inodes have been created. Add helper functions: tracefs_alloc_inode() tracefs_free_inode() get_tracefs() Signed-off-by: Ajay Kaher Co-developed-by: Steven Rostedt (VMware) Signed-off-by: Steven Rostedt (VMware) Tested-by: Ching-lin Yu --- fs/tracefs/inode.c | 39 +++++++++++++++++++++++++++++++++++++++ fs/tracefs/internal.h | 15 +++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 fs/tracefs/internal.h diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 57ac8aa4a724..2508944cc4d8 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -21,13 +21,33 @@ #include #include #include +#include "internal.h" #define TRACEFS_DEFAULT_MODE 0700 +static struct kmem_cache *tracefs_inode_cachep __ro_after_init; static struct vfsmount *tracefs_mount; static int tracefs_mount_count; static bool tracefs_registered; +static struct inode *tracefs_alloc_inode(struct super_block *sb) +{ + struct tracefs_inode *ti; + + ti = kmem_cache_alloc(tracefs_inode_cachep, GFP_KERNEL); + if (!ti) + return NULL; + + ti->flags = 0; + + return &ti->vfs_inode; +} + +static void tracefs_free_inode(struct inode *inode) +{ + kmem_cache_free(tracefs_inode_cachep, get_tracefs(inode)); +} + static ssize_t default_read_file(struct file *file, char __user *buf, size_t count, loff_t *ppos) { @@ -346,6 +366,9 @@ static int tracefs_show_options(struct seq_file *m, struct dentry *root) } static const struct super_operations tracefs_super_operations = { + .alloc_inode = tracefs_alloc_inode, + .free_inode = tracefs_free_inode, + .drop_inode = generic_delete_inode, .statfs = simple_statfs, .remount_fs = tracefs_remount, .show_options = tracefs_show_options, @@ -628,10 +651,26 @@ bool tracefs_initialized(void) return tracefs_registered; } +static void init_once(void *foo) +{ + struct tracefs_inode *ti = (struct tracefs_inode *) foo; + + inode_init_once(&ti->vfs_inode); +} + static int __init tracefs_init(void) { int retval; + tracefs_inode_cachep = kmem_cache_create("tracefs_inode_cache", + sizeof(struct tracefs_inode), + 0, (SLAB_RECLAIM_ACCOUNT| + SLAB_MEM_SPREAD| + SLAB_ACCOUNT), + init_once); + if (!tracefs_inode_cachep) + return -ENOMEM; + retval = sysfs_create_mount_point(kernel_kobj, "tracing"); if (retval) return -EINVAL; diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h new file mode 100644 index 000000000000..954ea005632b --- /dev/null +++ b/fs/tracefs/internal.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TRACEFS_INTERNAL_H +#define _TRACEFS_INTERNAL_H + +struct tracefs_inode { + unsigned long flags; + void *private; + struct inode vfs_inode; +}; + +static inline struct tracefs_inode *get_tracefs(const struct inode *inode) +{ + return container_of(inode, struct tracefs_inode, vfs_inode); +} +#endif /* _TRACEFS_INTERNAL_H */ From patchwork Fri Jul 28 18:20:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 707769 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 29D7AC001E0 for ; Fri, 28 Jul 2023 18:21:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236070AbjG1SV2 (ORCPT ); Fri, 28 Jul 2023 14:21:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235989AbjG1SVZ (ORCPT ); Fri, 28 Jul 2023 14:21:25 -0400 Received: from CY4PR02CU008.outbound.protection.outlook.com (mail-westcentralusazon11012009.outbound.protection.outlook.com [40.93.200.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D53C9422A; Fri, 28 Jul 2023 11:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JAbCn5x4cxl9ahUDoklJ/nVln2T2hokyHmSUBv/dZYP60YSkBjWDZbSZGMF53kbtBv7IcJY3aoTbiehnvs9brwUfmUbondmbhL/Grpz3k2eXUJzEpQFql7/scExiH+iaJWbq4WhfDTqV26r7E9klVtqFnT3uJilparEqxOemQ27VGuMimuNqUsxcpNXZhGV9MeNzGafxy59iwGeX7gQqslay81UUtOvaqqfFVTvFYNkja9ZC58c6Ww+iK9Yhor0T9gDeYYsGliaH6bbRrGmDkgjkltvQZUmKng7a9F+DxhhAkwSdc45oP1JA5KDWoGI3k77sAAL5/Z50x6f9DtRryQ== 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=pDvwg1P4xmQElgMzF3qShwdTNxBZYbqmBfS4jTzgkyI=; b=WU2Pcc3FNIKdEhKFsz0482ykID+pDbDZFCtKJhcK5ozY9oeOfcT4/PahjLd2VGhuP6n/t2pAaK8ZK0/Achwlu6G1Ri1lQ5tFaMVc8ditSQHNBeaaxszrm7XtEJcOfCD/5xZdQ+umMgMS5gbm5XN6Nc62ruZp6f0LBGyjC6U2AC+U7CV+5P/8TjHTAY6iD/H5IZ14k0MQI8lCeqfQZ7ug7B2Quee2FoTWv9tnGMCkKtX+zkzl7qaZ13zfCn6zhKoEkutaQOLjmKwWj4ZGnOt0wOpWUX2H8vBAZJpL65CNZten+JUlE0Tz6B5xDScbA2nstzPRv2uhIsxB3UZBWVdCTA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pDvwg1P4xmQElgMzF3qShwdTNxBZYbqmBfS4jTzgkyI=; b=QDtrTegGEq5HK4aCaMsu32D5VS5SEEDPTGRazmHe7bjHvKP3xH07oOoQBbdfNWrBJ6Gp5VahWgztkCsC7O3dNUMRZwg8erhRjjN/h5AtGpx50SRPmwCPmgF5klG76Ku+S8pEJbLWS8f9l30dKHEZYpgiDJfpybPqeOxbKVIgKOQ= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) by SN7PR05MB9264.namprd05.prod.outlook.com (2603:10b6:806:26c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Fri, 28 Jul 2023 18:21:21 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0%6]) with mapi id 15.20.6631.026; Fri, 28 Jul 2023 18:21:21 +0000 From: Ajay Kaher To: rostedt@goodmis.org, shuah@kernel.org, mhiramat@kernel.org Cc: chinglinyu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lkp@intel.com, namit@vmware.com, oe-lkp@lists.linux.dev, akaher@vmware.com, amakhalov@vmware.com, er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu, tkundu@vmware.com, vsirnapalli@vmware.com Subject: [PATCH v6 04/10] eventfs: Implement eventfs dir creation functions Date: Fri, 28 Jul 2023 23:50:46 +0530 Message-Id: <1690568452-46553-5-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690568452-46553-1-git-send-email-akaher@vmware.com> References: <1690568452-46553-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR11CA0090.namprd11.prod.outlook.com (2603:10b6:a03:f4::31) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|SN7PR05MB9264:EE_ X-MS-Office365-Filtering-Correlation-Id: 924ed8dc-6989-4012-f484-08db8f97716d X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B62boKZSBGYM1u0UehmQC+FAzeFkaQUTOACtIF9igRduVS3akKk1lQgY/lzF/7BjwjIMcLaGc0oxfwVdJYLwNQTn17010KL+Uj15xyjH+AbvvripzGsh3Xb7pVCHDYHw6RDnEnwfcDmAMdAMTseaB8GNvapwTgKVOq6aoyjrEaRANmU6+9upoCps9pVDH3RMuqPJD2fjtPr8+6EjNFZebGoaimGcyK5hP90+m9NqA6dbVPMY7uiLRWTyJdkTcI88eTR/5g4fllbyIquiw/N6Xy/0/QxYbnpc0WAsm2aM2XXCcfWC8ZvSzdqlOl/9a1SnOExATvLWX2t1jzE6penHU1TYQtVoLMGeXl8TfYWYUdXP+bhNiQmFdhsbWtZSX6P+EVzDkGo9RLp+yDBob9pPV8LawCJ6aUfFONOcKqW2vvbXPn6v1yP7D1nMl4ABDNlsMi+Ty+Ca9XtIGd1qa78FNo3Q1AyhZ+5ozlEosUiKBzhvGplbNop0DtwW34ffHoszYZehypxcgzG6IY5lvbS1HstF3j7LHRsCSmUVLXagl/rVXvrVMVYdt2q1JTTewsessBoIrDhIc6RRdt6cTn48z8WXCgPGUUAa/8o0Z0qz/tgYnv2RRa4qYP0qudv6nKOmRYJ9VOAL57SYfHBdb39oiYRCTEluNtONf83euCuIXqjOe8bq+aeS7JollblvbnnJmWaFbmMX49XzXXfYF6F1ZQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR05MB8703.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(366004)(451199021)(2906002)(316002)(7416002)(8676002)(86362001)(8936002)(41300700001)(36756003)(6512007)(5660300002)(966005)(107886003)(26005)(6506007)(6666004)(6486002)(52116002)(83380400001)(478600001)(38350700002)(186003)(38100700002)(4326008)(66556008)(66946007)(66476007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GJtRE3avbmPr7rFo+ARLsEdcoBAp7QBqMs0aBU//lVLHt8nMvpBWPPDZXhotcqr/CFNfarEVh8Y7pyeO6qZj5RdMHfvPSWFdVJofuKOJxOzWqChfeeQmFfvUqVwWhMlt57pmqbpqupPGkWolvWWgo0s40R5woKy0tzI6hVxocaR0Nl3hTRuXgXmhuW4EcGZzIKvSmKNcXHt4HCOcMymstJDo2DgyjAxRNYUPPbmK9oqfeonC1YnfxiEa6O7HaC4YEO/rxnCR1MKTHoyOIMrOVFHR+aWJSkzE5gd5MYIyo76+TnW+/RW1NARnZ3dx37vu7YlRQngktPe8KS2gC0jM1f6ExlzeCcP0U7lulDNT/gCQG5qGphOxHuOiGiPR6YPPZxVAon0Jg/V5T+7aagVz9ebzQdQWoEYPTscJCees8WWrqL/TmaT7g76/FAVdfka6cQ3XKcjdZ33O/ABEob2OPzTUk39tomlAgLpwKdBas8EjL0C36QHPS5JC1K0YhKLg1K4K0XlNtoAKgXEWyiYQp6sECKAXYpjNxYrP+/P7D8OgSVKVXN9HFSd1Y5X60qMqaBdJ9rdlGxQnTM9q0lisSGFXDiowhhI1GwQ97AKZ/D//uMwxHU4Kj7+D99bVhKhCvWsVSR43s9c+biVHVweHiJrmieM94HqTf/5cxadTVbIzy6QQJikR1JpNRohgGsygK4gedOHlfGPYJLOi50jqBji16LBxVuOMFekwOC/xXqfJXqxYInwX5udmfv+UKgYYFN7MskByHZBdRCYQsQdUjX9qDFYEO5AmONSMK6Ou0af/cmWj1zSYRwzpJ+90c3XmF8gizrr+9JoIiPlF/TU+wlZlPoFb6/SQA9RfQeejW5b93mu2V7Spa630xsvy7cBf+jlcHGojST9sr/F/9g9ZKGUrr1iXSvqk+acIYqdaSHZyB/PdiYwDUAa6K3A+zyIqyeptF/gwNIa9qZqW+tXx47D8anIcKBoJV6PQGy3oBHyeZnCVXBtI5OaJF74rqTPtnuzjSOa0FtZyVFMXGtFlBNQxvpgNhrkmt8Anz+ixSNtrbn3zHd7+Y4qoiKU7lby7pUbwAXZKNIkiNjOyMEWbYjO4mmuAMtSzFpw94e24kWR+sp9pPDH69QUlrV5XtphdmBPp/QM+3PPMRm3NNCrMfbkj8Tynl0E4IQ9UAuIa2UnW67QnoRWIPDBuOnsJ4cr+nT0Sgnr36++bgpMdTfq0e2HGE+AoOwsF88JMFjTvk1W8CcDcv2ad1PcvnMIhAMUPEw+/keNDG5oyEaRCu1mwJ+slR2eraMCS5XroUiS6QYx5GslEnMGQWMxjyS4sqRqQVfbqJZZpGB5KbzDg4uzH0OijGp8X7CJupBc90bCfPv5Dl40hTlL7uwXSq2lyBnuw5qiJPIB+5sg9m+kJ84V1e7Qneh+mkNrFdJx2dS6dCpsLzyHt06Hk/PAE+sOqjr0WCo6axjPNMVkqf5UTr206P+uxcCyJPmxgivC9qFfOboIIfj+y7h+qv9ghgTQJ13bw+R6GiKQvzikVdoppvqxgBM5ZFy/K6w8PmTdLTVEyf6h0VZIpzJmUIXGmQoBGqbhT X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 924ed8dc-6989-4012-f484-08db8f97716d X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2023 18:21:21.0476 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8OLh2rceS+0LIrdUzdyaTHYS9fVbxoERGnRsMsceA8QKAN/sq2MruZP9LC++5NrM8kUbeI60EUbbqVfSG5T3fQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR05MB9264 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add eventfs_file structure which will hold the properties of the eventfs files and directories. Add following functions to create the directories in eventfs: eventfs_create_events_dir() will create the top level "events" directory within the tracefs file system. eventfs_add_subsystem_dir() creates an eventfs_file descriptor with the given name of the subsystem. eventfs_add_dir() creates an eventfs_file descriptor with the given name of the directory and attached to a eventfs_file of a subsystem. Add tracefs_inode structure to hold the inodes, flags and pointers to private data used by eventfs. Signed-off-by: Ajay Kaher Co-developed-by: Steven Rostedt (VMware) Signed-off-by: Steven Rostedt (VMware) Tested-by: Ching-lin Yu Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202305051619.9a469a9a-yujie.liu@intel.com --- fs/tracefs/Makefile | 1 + fs/tracefs/event_inode.c | 211 +++++++++++++++++++++++++++++++++++++++ fs/tracefs/internal.h | 4 + include/linux/tracefs.h | 11 ++ 4 files changed, 227 insertions(+) create mode 100644 fs/tracefs/event_inode.c diff --git a/fs/tracefs/Makefile b/fs/tracefs/Makefile index 7c35a282b484..73c56da8e284 100644 --- a/fs/tracefs/Makefile +++ b/fs/tracefs/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only tracefs-objs := inode.o +tracefs-objs += event_inode.o obj-$(CONFIG_TRACING) += tracefs.o diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c new file mode 100644 index 000000000000..8f334b122e46 --- /dev/null +++ b/fs/tracefs/event_inode.c @@ -0,0 +1,211 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * event_inode.c - part of tracefs, a pseudo file system for activating tracing + * + * Copyright (C) 2020-23 VMware Inc, author: Steven Rostedt (VMware) + * Copyright (C) 2020-23 VMware Inc, author: Ajay Kaher + * + * eventfs is used to dynamically create inodes and dentries based on the + * meta data provided by the tracing system. + * + * eventfs stores the meta-data of files/dirs and holds off on creating + * inodes/dentries of the files. When accessed, the eventfs will create the + * inodes/dentries in a just-in-time (JIT) manner. The eventfs will clean up + * and delete the inodes/dentries when they are no longer referenced. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "internal.h" + +struct eventfs_inode { + struct list_head e_top_files; +}; + +/** + * struct eventfs_file - hold the properties of the eventfs files and + * directories. + * @name: the name of the file or directory to create + * @list: file or directory to be added to parent directory + * @ei: list of files and directories within directory + * @fop: file_operations for file or directory + * @iop: inode_operations for file or directory + * @data: something that the caller will want to get to later on + * @mode: the permission that the file or directory should have + */ +struct eventfs_file { + const char *name; + struct list_head list; + struct eventfs_inode *ei; + const struct file_operations *fop; + const struct inode_operations *iop; + void *data; + umode_t mode; +}; + +static DEFINE_MUTEX(eventfs_mutex); + +static const struct inode_operations eventfs_root_dir_inode_operations = { +}; + +static const struct file_operations eventfs_file_operations = { +}; + +/** + * eventfs_prepare_ef - helper function to prepare eventfs_file + * @name: the name of the file/directory to create. + * @mode: the permission that the file should have. + * @fop: struct file_operations that should be used for this file/directory. + * @iop: struct inode_operations that should be used for this file/directory. + * @data: something that the caller will want to get to later on. The + * inode.i_private pointer will point to this value on the open() call. + * + * This function allocates and fills the eventfs_file structure. + */ +static struct eventfs_file *eventfs_prepare_ef(const char *name, umode_t mode, + const struct file_operations *fop, + const struct inode_operations *iop, + void *data) +{ + struct eventfs_file *ef; + + ef = kzalloc(sizeof(*ef), GFP_KERNEL); + if (!ef) + return ERR_PTR(-ENOMEM); + + ef->name = kstrdup(name, GFP_KERNEL); + if (!ef->name) { + kfree(ef); + return ERR_PTR(-ENOMEM); + } + + if (S_ISDIR(mode)) { + ef->ei = kzalloc(sizeof(*ef->ei), GFP_KERNEL); + if (!ef->ei) { + kfree(ef->name); + kfree(ef); + return ERR_PTR(-ENOMEM); + } + INIT_LIST_HEAD(&ef->ei->e_top_files); + } else { + ef->ei = NULL; + } + + ef->iop = iop; + ef->fop = fop; + ef->mode = mode; + ef->data = data; + return ef; +} + +/** + * eventfs_create_events_dir - create the trace event structure + * @name: the name of the directory to create. + * @parent: parent dentry for this file. This should be a directory dentry + * if set. If this parameter is NULL, then the directory will be + * created in the root of the tracefs filesystem. + * + * This function creates the top of the trace event directory. + */ +struct dentry *eventfs_create_events_dir(const char *name, + struct dentry *parent) +{ + struct dentry *dentry = tracefs_start_creating(name, parent); + struct eventfs_inode *ei; + struct tracefs_inode *ti; + struct inode *inode; + + if (IS_ERR(dentry)) + return dentry; + + ei = kzalloc(sizeof(*ei), GFP_KERNEL); + if (!ei) + return ERR_PTR(-ENOMEM); + inode = tracefs_get_inode(dentry->d_sb); + if (unlikely(!inode)) { + kfree(ei); + tracefs_failed_creating(dentry); + return ERR_PTR(-ENOMEM); + } + + INIT_LIST_HEAD(&ei->e_top_files); + + ti = get_tracefs(inode); + ti->flags |= TRACEFS_EVENT_INODE; + ti->private = ei; + + inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; + inode->i_op = &eventfs_root_dir_inode_operations; + inode->i_fop = &eventfs_file_operations; + + /* directory inodes start off with i_nlink == 2 (for "." entry) */ + inc_nlink(inode); + d_instantiate(dentry, inode); + inc_nlink(dentry->d_parent->d_inode); + fsnotify_mkdir(dentry->d_parent->d_inode, dentry); + return tracefs_end_creating(dentry); +} + +/** + * eventfs_add_subsystem_dir - add eventfs subsystem_dir to list to create later + * @name: the name of the file to create. + * @parent: parent dentry for this dir. + * + * This function adds eventfs subsystem dir to list. + * And all these dirs are created on the fly when they are looked up, + * and the dentry and inodes will be removed when they are done. + */ +struct eventfs_file *eventfs_add_subsystem_dir(const char *name, + struct dentry *parent) +{ + struct tracefs_inode *ti_parent; + struct eventfs_inode *ei_parent; + struct eventfs_file *ef; + + if (!parent) + return ERR_PTR(-EINVAL); + + ti_parent = get_tracefs(parent->d_inode); + ei_parent = ti_parent->private; + + ef = eventfs_prepare_ef(name, S_IFDIR, NULL, NULL, NULL); + if (IS_ERR(ef)) + return ef; + + mutex_lock(&eventfs_mutex); + list_add_tail(&ef->list, &ei_parent->e_top_files); + mutex_unlock(&eventfs_mutex); + return ef; +} + +/** + * eventfs_add_dir - add eventfs dir to list to create later + * @name: the name of the file to create. + * @ef_parent: parent eventfs_file for this dir. + * + * This function adds eventfs dir to list. + * And all these dirs are created on the fly when they are looked up, + * and the dentry and inodes will be removed when they are done. + */ +struct eventfs_file *eventfs_add_dir(const char *name, + struct eventfs_file *ef_parent) +{ + struct eventfs_file *ef; + + if (!ef_parent) + return ERR_PTR(-EINVAL); + + ef = eventfs_prepare_ef(name, S_IFDIR, NULL, NULL, NULL); + if (IS_ERR(ef)) + return ef; + + mutex_lock(&eventfs_mutex); + list_add_tail(&ef->list, &ef_parent->ei->e_top_files); + mutex_unlock(&eventfs_mutex); + return ef; +} diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 7dfb7ebc1c3f..f0fd565d59ec 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -2,6 +2,10 @@ #ifndef _TRACEFS_INTERNAL_H #define _TRACEFS_INTERNAL_H +enum { + TRACEFS_EVENT_INODE = BIT(1), +}; + struct tracefs_inode { unsigned long flags; void *private; diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h index 99912445974c..432e5e6f7901 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -21,6 +21,17 @@ struct file_operations; #ifdef CONFIG_TRACING +struct eventfs_file; + +struct dentry *eventfs_create_events_dir(const char *name, + struct dentry *parent); + +struct eventfs_file *eventfs_add_subsystem_dir(const char *name, + struct dentry *parent); + +struct eventfs_file *eventfs_add_dir(const char *name, + struct eventfs_file *ef_parent); + struct dentry *tracefs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); From patchwork Fri Jul 28 18:20:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 707768 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 8A059C04A6A for ; Fri, 28 Jul 2023 18:21:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236268AbjG1SVr (ORCPT ); Fri, 28 Jul 2023 14:21:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236068AbjG1SV2 (ORCPT ); Fri, 28 Jul 2023 14:21:28 -0400 Received: from CY4PR02CU008.outbound.protection.outlook.com (mail-westcentralusazon11012009.outbound.protection.outlook.com [40.93.200.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C15F2423B; Fri, 28 Jul 2023 11:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j5se+9Jx2nFhvZYj2H9dllrNcGjDFYwjtnSy5foRXsujs2Aehfgl8MtUkXassmy9HYdRn6HyL8XsSQDoLQ7s0nCk5eZE8AFHbzcE+oHnUEj8aJPQP9JuHvQVPImIQRQ89ujoGJxQf+hk9qNvkEbLE7Y6v7vmWvv8/WbxOG+33Y75HDjkT4USEN0PwWPrmWgedvgHvUHa7I0P7K3pCGvOylAnmVCqwYIxaZH+VpYK8NchtNeBMnjbtAJGzLP8TQXdwi/DhDUot74O6B2X8F79TNw4A7audgel7h2Vdk8VldIH7EW8rcsyD3jV9g13hMj6Ai2PEtqGIzvOiHbShWC7FA== 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=+j2ECXuIFgkHJbjiZKpVjXM9BCd/BAVHq0XLry5FGY4=; b=V/Zv47yjS9IRgzr2ihnG/+kpN+IgNqFmJgALcrrihkIfAC4vx2WtReKIAo72lsdFNw/FW298rVCmprBelo877wcm9ycd6PjE8xf5tWARJhk26VCZ8Q/4lQYl0MY2eSTklDQ6C8wCy19E/hJ10yH+v2aQPET/RhykENJ3HLiIjA/P4LPLBJAc1x1TU3TDaSF2QG8fLdv3ctPwVKDrCvQ15VaujGfMsSuk9Yw3vr2+3x6ULhaHceHxUQT/4PqpghMA/b4Gmy/1/VEBdvjbDZCmmnurDtNS8DRHJOURmbUNrIIxc/dW+J7XONMUyceyKzqTLrXllV3RDKeXjbXXa9PUrQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+j2ECXuIFgkHJbjiZKpVjXM9BCd/BAVHq0XLry5FGY4=; b=JPsfjpYjPjdalwVh07Hblyg6m1iwkqs4ksPdG5AQO5lbhCC2ewV7yPezOzZjvptOf6W/6rMEH+7S68BsSA/3eK3eSs6wyXTtPUmIcirxJiFggilvcCysBLLvQ2Usg3vWZejqWbXVmwDah2G1Z66oDu5TeYAan4nkRhoxXUx3sGs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) by SN7PR05MB9264.namprd05.prod.outlook.com (2603:10b6:806:26c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Fri, 28 Jul 2023 18:21:23 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0%6]) with mapi id 15.20.6631.026; Fri, 28 Jul 2023 18:21:23 +0000 From: Ajay Kaher To: rostedt@goodmis.org, shuah@kernel.org, mhiramat@kernel.org Cc: chinglinyu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lkp@intel.com, namit@vmware.com, oe-lkp@lists.linux.dev, akaher@vmware.com, amakhalov@vmware.com, er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu, tkundu@vmware.com, vsirnapalli@vmware.com Subject: [PATCH v6 06/10] eventfs: Implement eventfs lookup, read, open functions Date: Fri, 28 Jul 2023 23:50:48 +0530 Message-Id: <1690568452-46553-7-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690568452-46553-1-git-send-email-akaher@vmware.com> References: <1690568452-46553-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR11CA0090.namprd11.prod.outlook.com (2603:10b6:a03:f4::31) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|SN7PR05MB9264:EE_ X-MS-Office365-Filtering-Correlation-Id: cf4bb05a-5850-43e7-e9ec-08db8f9772b6 X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CzckxtOfM6/N62vvwWXevr8yNLHfYj4MjUzvRKaP5dEZZ4AAxHHGP7nNkRLjDP0Tqcbal8qCINwz/8+IbtThqmDl397e6b/yaXL/306nHE1+TXLDCwOknCKJwAN9xeihouoNt00afwXuY7bjCpKvXHdug37CCxz3O+7QzotshOORJc06gUkwvGEzIIEAyVgKE3s5TPz/G/W+xDwRscTYBIM+Xg3AkKmA+buPQouYBfh+qbgNtHCtD8R5IHhNyyQ6sVtmZomcxkrIU7RVERFxMkD/lKhxMxMaq/jx7Tv9q2nnDwzqhMomLYxdKHOC6hrcoH8UG/xIeecX4cn4UaiM/WACmvGF+oI00YQQuiifjyCXeqbqY89leS2eQgESv49CJVHZ9fckxDmIMPX8cS2VVlifiobLDeCaR86Aw7QDWvEQsl06/pxsFxlq/KtNLVF0lQc7GbiY0r0ndyHVK/b2pzzZzuPopyygvtyGlc0JiHTiQunNF9BMHjMfJ4UQfBj2MA1E9IwpbqII4Se+O1d91aB0pED7AWt8QGQaf8A+qpMver4fquIwZ5w39hyR7zrd/fSME8Bhu7Vlrtib6IGaXLCwe9vNWejTpHoVGCGRO8dkcc74asArAWeqq/d4UawuEYYZ/hK5KTZmJSCCDZZfyd33gM3LfyL1WDtk6aqnok4= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR05MB8703.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(366004)(451199021)(2906002)(316002)(7416002)(8676002)(86362001)(8936002)(30864003)(41300700001)(36756003)(6512007)(5660300002)(107886003)(26005)(6506007)(6666004)(6486002)(52116002)(83380400001)(478600001)(38350700002)(186003)(38100700002)(4326008)(66556008)(66946007)(66476007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UoxCbgPLM5eSJU9QFXpLF1kauc137RZW9mVNPypDdGIFT3v/YYLUp4Y26GuqQukgcOX0+aQoLiEEG3f8+9D8hcmRC9ZXEdtyVdUXPrA3Ds7M0uf3ZBZg10zYplwZlI334Aq7EnQKKPldzhfgZOvXcPd17Lr6s2MC3/fTAtWAW1kosK7SgcSPCuDboX1+Oz+561TP5svRT7Y2MqBUVqKxQf6cW4Jq3pY7tJGZG67jVOcbnvhwr4jX0Go84dt9z6Mb2zdHIT9WuvQaStMn6p9uy3TvQdFXYi35vBINGiAYmj3HiUnwwLqoRkQPJzm4NKIW1nW8ejqbppofnLHe7Oojt4OQii6fjMqo0HtKcMp/57884cVUk9XJ7oMbJQHiMQS7yWCDNAfnS39WQNmYbpnXu3eTuqwC9POKhZkx5Z+oLveAsN3hO9yYs69DhpdISnm5dfNWLKeW9lQSYossO9zhSkZsxtpK2xDL0V/2HtRSzWQeVtrNJ96QJS7wBQHGwx2IYwhlFjKT1T+MK4U3begqIQaq6Gt8FPKinJKS2e9qHSFa2Oo7moPD+p9AZJKTLDfIQbE9GJD2dFC9cEcvaIHOMWBiIa7zEVcC3/9AULNiDo2GmAdPAHryJuM7MK0792l1bSThNE7V3vqBmYAEFUAihpOQYB6DKa3G4jhScE6h8ARigYEn4qjBjXjyNTUlIv8qb2ee1APcxbuCfp66Ql5Ai0Q1iKQdqzBCH/XnmUkPkbKlLKUpPm8t3xmhNB7sN15kh9GFsdHqZcjOkcpOtNOhaE1S8awqiVufC1upg0k07RKBN7/SciCuaGoD9EPjGWS6VGVyhTjBzK0RHFZoT/GmWGVHhXfZ+R4ScNCgkYAiFiqgm0hjK6Tw2aaFVItd85lqJU7/WsEf3GhavF4QVbqn+okwGN4aKLSryMUV+AB9RrF8Mm+ApLpL6GGohDX0XBJ+BoA6VnpcJlVNPlzQKEmDyiGBNLInfZkv4n3uEsYvfuSE1J2DeONpYKt67cDB7TXSo4x9e53Pu5MLeSAD9Lx0tjvVW9i4CqF3tWnqFwIVr+S4LhHJbt/RczvneirhTAliltwsdOhhdg7oNN9ScINc5VxZKrHhm9UCq4vcpIO14pPIAx1hCtRMdd/QO89bOUwxMA+bB0gk7Cy8fQ0Cz0RTlrdxNUbWJpVJ1J+lZXvhavzC339Tj+Q2LwNx6BH+3I78uvNMWyo4sB6hddR78ARq4TvCUq42LiiwChpjzbMlsxpovPzwtWqiNXazkaFP/0Uv+qaML4ePbtKJCiLv7EE4h8F6z2UK0bv2HtHRHhkjUVFxUxXpE/uLF3pqkkuNZXAE3LwycwgfOZoYfULOY6VJ8aa68HD40oMvbXP/4AApnijPG2cfUy5hH0PWhN9rkzhXmMcynPWQP6B3UQy8x+xaevJ34dDhnFD3FA99PrLCSxt9rncjUOYKTpsNpT/uYV2a3ISX6i20zxeZaS6pHKkV23bW8IKsr+mqecLpqRmsEebyZd9kAeZ8veLvbnFphvxOrIfZLd6c4Ef8z+ovdF6izTU3h3F5KxPNrl74yaNI8cSx1gsx9zCOxI7APobPkaD4 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf4bb05a-5850-43e7-e9ec-08db8f9772b6 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2023 18:21:23.2154 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wFxjxJYruT5vWzIwHiUxYrnlYJiEQkGDT+a2YREBKX2H6v2CJq8TBMw7A5Wv8E2JYV710fTtd81uSkLzfqftWw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR05MB9264 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add the inode_operations, file_operations, and helper functions to eventfs: dcache_dir_open_wrapper() eventfs_root_lookup() eventfs_release() eventfs_set_ef_status_free() eventfs_post_create_dir() The inode_operations and file_operations functions will be called from the VFS layer. create_file() and create_dir() are added as stub functions and will be filled in later. Signed-off-by: Ajay Kaher Co-developed-by: Steven Rostedt (VMware) Signed-off-by: Steven Rostedt (VMware) Tested-by: Ching-lin Yu --- fs/tracefs/event_inode.c | 304 +++++++++++++++++++++++++++++++++++++++ fs/tracefs/internal.h | 2 + 2 files changed, 306 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 9e4843be9dc9..24d645c61029 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -31,6 +31,8 @@ struct eventfs_inode { * struct eventfs_file - hold the properties of the eventfs files and * directories. * @name: the name of the file or directory to create + * @d_parent: holds parent's dentry + * @dentry: once accessed holds dentry * @list: file or directory to be added to parent directory * @ei: list of files and directories within directory * @fop: file_operations for file or directory @@ -40,22 +42,320 @@ struct eventfs_inode { */ struct eventfs_file { const char *name; + struct dentry *d_parent; + struct dentry *dentry; struct list_head list; struct eventfs_inode *ei; const struct file_operations *fop; const struct inode_operations *iop; + union { + struct list_head del_list; /* list of eventfs_file to delete */ + struct rcu_head rcu; /* eventfs_file to delete */ + unsigned long is_freed; /* Freed if one of the above is set */ + }; void *data; umode_t mode; }; static DEFINE_MUTEX(eventfs_mutex); +DEFINE_STATIC_SRCU(eventfs_srcu); + +static struct dentry *eventfs_root_lookup(struct inode *dir, + struct dentry *dentry, + unsigned int flags); +static int dcache_dir_open_wrapper(struct inode *inode, struct file *file); +static int eventfs_release(struct inode *inode, struct file *file); static const struct inode_operations eventfs_root_dir_inode_operations = { + .lookup = eventfs_root_lookup, }; static const struct file_operations eventfs_file_operations = { + .open = dcache_dir_open_wrapper, + .read = generic_read_dir, + .iterate_shared = dcache_readdir, + .llseek = generic_file_llseek, + .release = eventfs_release, +}; + +/** + * create_file - create a file in the tracefs filesystem + * @name: the name of the file to create. + * @mode: the permission that the file should have. + * @parent: parent dentry for this file. + * @data: something that the caller will want to get to later on. + * @fop: struct file_operations that should be used for this file. + * + * This is the basic "create a file" function for tracefs. It allows for a + * wide range of flexibility in creating a file. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the tracefs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, %NULL will be returned. + * + * If tracefs is not enabled in the kernel, the value -%ENODEV will be + * returned. + */ +static struct dentry *create_file(const char *name, umode_t mode, + struct dentry *parent, void *data, + const struct file_operations *fop) +{ + return NULL; }; +/** + * create_dir - create a dir in the tracefs filesystem + * @name: the name of the file to create. + * @parent: parent dentry for this file. + * @data: something that the caller will want to get to later on. + * + * This is the basic "create a dir" function for eventfs. It allows for a + * wide range of flexibility in creating a dir. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the tracefs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, %NULL will be returned. + * + * If tracefs is not enabled in the kernel, the value -%ENODEV will be + * returned. + */ +static struct dentry *create_dir(const char *name, struct dentry *parent, void *data) +{ + return NULL; +} + +/** + * eventfs_set_ef_status_free - set the ef->status to free + * @dentry: dentry who's status to be freed + * + * eventfs_set_ef_status_free will be called if no more + * references remain + */ +void eventfs_set_ef_status_free(struct dentry *dentry) +{ + struct tracefs_inode *ti_parent; + struct eventfs_file *ef; + + mutex_lock(&eventfs_mutex); + ti_parent = get_tracefs(dentry->d_parent->d_inode); + if (!ti_parent || !(ti_parent->flags & TRACEFS_EVENT_INODE)) + goto out; + + ef = dentry->d_fsdata; + if (!ef) + goto out; + + dentry->d_fsdata = NULL; + ef->dentry = NULL; +out: + mutex_unlock(&eventfs_mutex); +} + +/** + * eventfs_post_create_dir - post create dir routine + * @ef: eventfs_file of recently created dir + * + * Map the meta-data of files within an eventfs dir to their parent dentry + */ +static void eventfs_post_create_dir(struct eventfs_file *ef) +{ + struct eventfs_file *ef_child; + struct tracefs_inode *ti; + + /* srcu lock already held */ + /* fill parent-child relation */ + list_for_each_entry_srcu(ef_child, &ef->ei->e_top_files, list, + srcu_read_lock_held(&eventfs_srcu)) { + ef_child->d_parent = ef->dentry; + } + + ti = get_tracefs(ef->dentry->d_inode); + ti->private = ef->ei; +} + +/** + * create_dentry - helper function to create dentry + * @ef: eventfs_file of file or directory to create + * @parent: parent dentry + * @lookup: true if called from lookup routine + * + * Used to create a dentry for file/dir, executes post dentry creation routine + */ +static struct dentry * +create_dentry(struct eventfs_file *ef, struct dentry *parent, bool lookup) +{ + bool invalidate = false; + struct dentry *dentry; + + mutex_lock(&eventfs_mutex); + if (ef->is_freed) { + mutex_unlock(&eventfs_mutex); + return NULL; + } + if (ef->dentry) { + dentry = ef->dentry; + /* On dir open, up the ref count */ + if (!lookup) + dget(dentry); + mutex_unlock(&eventfs_mutex); + return dentry; + } + mutex_unlock(&eventfs_mutex); + + if (!lookup) + inode_lock(parent->d_inode); + + if (ef->ei) + dentry = create_dir(ef->name, parent, ef->data); + else + dentry = create_file(ef->name, ef->mode, parent, + ef->data, ef->fop); + + if (!lookup) + inode_unlock(parent->d_inode); + + mutex_lock(&eventfs_mutex); + if (IS_ERR_OR_NULL(dentry)) { + /* If the ef was already updated get it */ + dentry = ef->dentry; + if (dentry && !lookup) + dget(dentry); + mutex_unlock(&eventfs_mutex); + return dentry; + } + + if (!ef->dentry && !ef->is_freed) { + ef->dentry = dentry; + if (ef->ei) + eventfs_post_create_dir(ef); + dentry->d_fsdata = ef; + } else { + /* A race here, should try again (unless freed) */ + invalidate = true; + } + mutex_unlock(&eventfs_mutex); + if (invalidate) + d_invalidate(dentry); + + if (lookup || invalidate) + dput(dentry); + + return invalidate ? NULL : dentry; +} + +static bool match_event_file(struct eventfs_file *ef, const char *name) +{ + bool ret; + + mutex_lock(&eventfs_mutex); + ret = !ef->is_freed && strcmp(ef->name, name) == 0; + mutex_unlock(&eventfs_mutex); + + return ret; +} + +/** + * eventfs_root_lookup - lookup routine to create file/dir + * @dir: in which a lookup is being done + * @dentry: file/dir dentry + * @flags: to pass as flags parameter to simple lookup + * + * Used to create a dynamic file/dir within @dir. Use the eventfs_inode + * list of meta data to find the information needed to create the file/dir. + */ +static struct dentry *eventfs_root_lookup(struct inode *dir, + struct dentry *dentry, + unsigned int flags) +{ + struct tracefs_inode *ti; + struct eventfs_inode *ei; + struct eventfs_file *ef; + struct dentry *ret = NULL; + int idx; + + ti = get_tracefs(dir); + if (!(ti->flags & TRACEFS_EVENT_INODE)) + return NULL; + + ei = ti->private; + idx = srcu_read_lock(&eventfs_srcu); + list_for_each_entry_srcu(ef, &ei->e_top_files, list, + srcu_read_lock_held(&eventfs_srcu)) { + if (!match_event_file(ef, dentry->d_name.name)) + continue; + ret = simple_lookup(dir, dentry, flags); + create_dentry(ef, ef->d_parent, true); + break; + } + srcu_read_unlock(&eventfs_srcu, idx); + return ret; +} + +/** + * eventfs_release - called to release eventfs file/dir + * @inode: inode to be released + * @file: file to be released (not used) + */ +static int eventfs_release(struct inode *inode, struct file *file) +{ + struct tracefs_inode *ti; + struct eventfs_inode *ei; + struct eventfs_file *ef; + struct dentry *dentry; + int idx; + + ti = get_tracefs(inode); + if (!(ti->flags & TRACEFS_EVENT_INODE)) + return -EINVAL; + + ei = ti->private; + idx = srcu_read_lock(&eventfs_srcu); + list_for_each_entry_srcu(ef, &ei->e_top_files, list, + srcu_read_lock_held(&eventfs_srcu)) { + mutex_lock(&eventfs_mutex); + dentry = ef->dentry; + mutex_unlock(&eventfs_mutex); + if (dentry) + dput(dentry); + } + srcu_read_unlock(&eventfs_srcu, idx); + return dcache_dir_close(inode, file); +} + +/** + * dcache_dir_open_wrapper - eventfs open wrapper + * @inode: not used + * @file: dir to be opened (to create its child) + * + * Used to dynamically create the file/dir within @file. @file is really a + * directory and all the files/dirs of the children within @file will be + * created. If any of the files/dirs have already been created, their + * reference count will be incremented. + */ +static int dcache_dir_open_wrapper(struct inode *inode, struct file *file) +{ + struct tracefs_inode *ti; + struct eventfs_inode *ei; + struct eventfs_file *ef; + struct dentry *dentry = file_dentry(file); + struct inode *f_inode = file_inode(file); + int idx; + + ti = get_tracefs(f_inode); + if (!(ti->flags & TRACEFS_EVENT_INODE)) + return -EINVAL; + + ei = ti->private; + idx = srcu_read_lock(&eventfs_srcu); + list_for_each_entry_rcu(ef, &ei->e_top_files, list) { + create_dentry(ef, dentry, false); + } + srcu_read_unlock(&eventfs_srcu, idx); + return dcache_dir_open(inode, file); +} + /** * eventfs_prepare_ef - helper function to prepare eventfs_file * @name: the name of the file/directory to create. @@ -179,6 +479,7 @@ struct eventfs_file *eventfs_add_subsystem_dir(const char *name, mutex_lock(&eventfs_mutex); list_add_tail(&ef->list, &ei_parent->e_top_files); + ef->d_parent = parent; mutex_unlock(&eventfs_mutex); return ef; } @@ -206,6 +507,7 @@ struct eventfs_file *eventfs_add_dir(const char *name, mutex_lock(&eventfs_mutex); list_add_tail(&ef->list, &ef_parent->ei->e_top_files); + ef->d_parent = ef_parent->dentry; mutex_unlock(&eventfs_mutex); return ef; } @@ -254,6 +556,7 @@ int eventfs_add_events_file(const char *name, umode_t mode, mutex_lock(&eventfs_mutex); list_add_tail(&ef->list, &ei->e_top_files); + ef->d_parent = parent; mutex_unlock(&eventfs_mutex); return 0; } @@ -292,6 +595,7 @@ int eventfs_add_file(const char *name, umode_t mode, mutex_lock(&eventfs_mutex); list_add_tail(&ef->list, &ef_parent->ei->e_top_files); + ef->d_parent = ef_parent->dentry; mutex_unlock(&eventfs_mutex); return 0; } diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index f0fd565d59ec..9bfad9d95a4a 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -21,4 +21,6 @@ struct dentry *tracefs_start_creating(const char *name, struct dentry *parent); struct dentry *tracefs_end_creating(struct dentry *dentry); struct dentry *tracefs_failed_creating(struct dentry *dentry); struct inode *tracefs_get_inode(struct super_block *sb); +void eventfs_set_ef_status_free(struct dentry *dentry); + #endif /* _TRACEFS_INTERNAL_H */ From patchwork Fri Jul 28 18:20:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 707767 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 ED5E1C41513 for ; Fri, 28 Jul 2023 18:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236362AbjG1SVt (ORCPT ); Fri, 28 Jul 2023 14:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236151AbjG1SVp (ORCPT ); Fri, 28 Jul 2023 14:21:45 -0400 Received: from CY4PR02CU008.outbound.protection.outlook.com (mail-westcentralusazon11012009.outbound.protection.outlook.com [40.93.200.9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0982423C; Fri, 28 Jul 2023 11:21:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C2TtkS0oBcYA+9a9s6+GLSp7emEUUNIy29Iy2NpxGO0YhEU6e8aifaSdvecm6tpNYIY/K6VOGRH7QxAF5ulEC6DgWyK6wCmW521217nMZ6exd4zt+rQ2UTWb22G1/yd2mmt1tHZscMhdylcQejyaRLRR0KnkqVL/Qd+gsl5InvtfVeIlH/H/KSLfR458cNxcrJekxIyeR8Bz0u4a57hgX+5sZmxSIn710Mv6zCAzm1g2EvieaHVmH4pj7QqyaR1HuXmfSsprVBpry1hydnI15zsYsIMRAu1/mEoKZYjTCMkMAXvgxigHHKByc9FJA+c48ivDdo8HWf0WNj9W5ABwJw== 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=RpztRKNqiLZRLmIX3tLph7rQE+3o6etfWtzVfR7fqTA=; b=M8Px4ZgDRsmNQe5O/HdLPZWxqNDJUTJwShUtlXrCm+G4CWnd9vt7xxHaToA+xZiZ/JJHraPLIL/gvugOaBiOvbjxkUcQkzZH4kGgLdZ1psHgtSFGqKCiSZ1oE5tTwCceKU53FMhC/YlHoS+kyQ/pv6xNNHOHubkLA8zo7cW2X5Ko4QRH/N7ETc3c93dX0W8fjk1PYpFkPXGIejtmPjbnEWNUcEjRMZhbgMCMk4K1R2Pnx2fub1u65l771rdH19BKbi9UVKiB3eHl8n1AazpTl+zruJxXoGSIAGcici+HCKeJj/d21AAyLTySg0AwidScCaP0L9b1Xh1qQ9SBDXmppQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RpztRKNqiLZRLmIX3tLph7rQE+3o6etfWtzVfR7fqTA=; b=WZdYvfVy76WKBu2jmUpwTjTdN2aZ6ON5tX19yVlwE9m/XXBSgm4yzTxJEWsKm/Om5922MybSUHPA68ak7IDkQxRpetccX92RV1uXvrfr/iDbau9YBz9ydfYNnxzKxkyuOe9vc4tEgJsPBbh2D1HgiN2fgIagwjLwccmLkU5/qq8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) by SN7PR05MB9264.namprd05.prod.outlook.com (2603:10b6:806:26c::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Fri, 28 Jul 2023 18:21:24 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0%6]) with mapi id 15.20.6631.026; Fri, 28 Jul 2023 18:21:24 +0000 From: Ajay Kaher To: rostedt@goodmis.org, shuah@kernel.org, mhiramat@kernel.org Cc: chinglinyu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lkp@intel.com, namit@vmware.com, oe-lkp@lists.linux.dev, akaher@vmware.com, amakhalov@vmware.com, er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu, tkundu@vmware.com, vsirnapalli@vmware.com Subject: [PATCH v6 07/10] eventfs: Implement functions to create files and dirs when accessed Date: Fri, 28 Jul 2023 23:50:49 +0530 Message-Id: <1690568452-46553-8-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690568452-46553-1-git-send-email-akaher@vmware.com> References: <1690568452-46553-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR11CA0090.namprd11.prod.outlook.com (2603:10b6:a03:f4::31) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|SN7PR05MB9264:EE_ X-MS-Office365-Filtering-Correlation-Id: b10deded-9f54-4f4e-64ac-08db8f97735b X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wq6rwrf16G4IvavG8jzAaFYT8Wrc9CsoLuTpMWWQQPWKoGP42OekXhqpLOKoZilF6xY1AiwlPvL2N0TLEGBJg2hx4Q9lul7R/cjzCkzxKVIK3LIOeqr6vD/H9EzO4pyFprMSONNpr9EvrxlEoa6qWh1CjcJBjuG9PXccL6UMwy7asRdet6wxhtaByYAuo/6ZdPeqTQrauIFEK28hD2xmRhgJiXeeC1p+u0QKRjxOf+VUgET/bc7Ae8VkV1Et4wyIego6H/0e4Ll/8fW5wPNQwmX0X/25fzGNSR64h0mVQesymu9zgNGJNKNnX44Ls3k+QATfmfG+dYxT3DJ9VySLJjlK47YTejdc0/3BHpv77tC4ulVJW546lkCCrHc8tNvH/TMMPT2BrSHh2ORMVZs0C6lxPt6xYY+IBby3fz8CtAxA7/+utABsdcXlOswzGgO0/V+Z2ZM83qk8cym/NPtT1xW0kqjsJt2bnl+jLbAKdZTj8ip5n5DnB7BCMGr0/O70C2Ff5EiKxteOylBe11GtgGGN53VDI/CQdoVchxRJGrin3XWDMetjxjlpcgPYO67UX6wA7rGQKdgY2qu7H7luWdWmFHkLa05XqS+i7OUTNkCld2ZyYSCJGKI+Q0Z/JDiND/Ezao17JBtCMGM3f73LdmWAzeJ4oy76iN8sDRxnpIU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR05MB8703.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(376002)(396003)(346002)(136003)(366004)(451199021)(2906002)(316002)(7416002)(8676002)(86362001)(8936002)(41300700001)(36756003)(6512007)(5660300002)(107886003)(26005)(6506007)(6666004)(6486002)(52116002)(83380400001)(478600001)(38350700002)(186003)(38100700002)(4326008)(66556008)(66946007)(66476007)(2616005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: JXwZCoywUvmNXIhVFD0ZQuD04cEFKDOktZohw43+WNXY6cT4g30u+mWnwUT0Yyemg+fHJHafSi/+TVDjrYRnKlP0CYD0PPyOU/sQDB+EDQDu13Id9YVe/1ktay7U8VB0I/ZgX0rdCKqB6n6rlvFMnfS0ApZN8qhiJlk/tqx0l03VURJMz2ire1nkgeMyOaZoC4dxN07QD8A2sT/G+FeQN9yb+14S00mtY1F6QGuRShpNHQZ95klJwDW+OAFq1GPDwu016Z3iqXykDbbc83wFG8UypMP9SNyhn/B2HMW/ICL97OBCfdoEpgCwuMFSB5NC0Z5YICIt8zdsJLppUVHu3xJcpTzGlMknj5PocvVznT6WbAXioUpuLQ1lOunJqSFvtMFcOH4jAHBUKaXTb611AiTBxxZXxmtsm4e1KkSjV4Eyf1XI3PYJM9I9CjLbN4x6rrYRem+2Zqqr3eKrXX8LRKqgBdiYBjzqsmDU8zy/F7gPC3AFP3iqitHcflQWgeMBanGpusFC/Ct1+LrMZ61auIExB/yWa2/nu9mN9rFwZWvHSOoa+VZU4iuev1XXmJS339Rd67rFl3vheS6v2tB2vQjJnG8USZjFHS1ywMRJUVCQuajZXEJ04Q7H3PNmjpoCRjKZEn2AZupqxTUVFCcJMB7SKlpGowAzrfBLYWQLYixT47Vo4ZA5/jdBvL8G4mXOGcLas/iumV5BVUWSX/9YiZfFa1/pi62CVcytI7mrtd6Q0eFiR1VlztEsHhJL/PEHwNi7gBJjLcVHWNnmmENkQmLFVu6I0hQ10JYVx7bbjQWFVIuv40wcJWUWGA+AnQ7ZfupCwwBu9GPWhlfZPKv4H0+w/otUO3hn+2PlTvxoob3BqejwNcJ4g2I1nkjJFGOxLSHV0VEFKmZq9h0/QDz0KiVYu8+O5crA3b/HqxUMogFr5kQT1CDD0E/pMqqQ+ZHfbJY+TPktlzKX6qcvzjiyclc4QstVTTilR3yCGmKSrv9gFFDDWMI20E6upUb/EyT5IBILmbPXygyGJYsQ5kZuXdLYKhgjJKNtMtwgmwe/pmrrGGrFON8NWLYZKMUTAsIR+6vspLPNANcVSGGNY7Oqu6faC61sMuX8ZsNaw3S66CGhCot33Aw6n7DbkNPQZaad/zf44AqURR76oOmhWWbFnXlnIbZxYB8BwUzCvlHtug9k6Y+ec9AiA1GcU/hcCK7pwybpOlJp9sIOn3lxGg4gEv1ZCFaXU9+il7eNo5baiYYLG9i8rBoYiVMVvVrNVjdG5R8vMiOVSERvHAsJ8XCP1GR3myNrQ08BmTkeVgcJiKN25101zu/ipful4hWcZN8exLugfkaC0+wuKq+PbXfEzCR/C1GjeTMEyukKlCEGndQbRcfPBIYYYORLWvZB6EOSUiIOAkofIRv7UyVBzeS6IpkYCuQ+A0hmRRPQOP0Ox5cqFPeIfnruJ4MuKOgGU8gU+QnmoW5DCU4NVXqywZnbcJCGlczZjkOE0IGidD1xkMuGFKYkb7U6iNqJW7/iQ/0B66LFz8h0nQQCcR7kTJiRC8/H6eFlwYO74IoFGPy2LKDNyHsoUPqVedx9VNtCu8Ot X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: b10deded-9f54-4f4e-64ac-08db8f97735b X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2023 18:21:24.2871 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Bn0TbqD5mp0Iu3LaTCkejSjQOnLV7Viz7kETC3ZDEEIdvRywF72a3svJQYBnUKZP4ZaQYWewVTdGMXc37u2s9Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR05MB9264 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add create_file() and create_dir() functions to create the files and directories respectively when they are accessed. The functions will be called from the lookup operation of the inode_operations or from the open function of file_operations. Signed-off-by: Ajay Kaher Co-developed-by: Steven Rostedt (VMware) Signed-off-by: Steven Rostedt (VMware) Tested-by: Ching-lin Yu --- fs/tracefs/event_inode.c | 61 +++++++++++++++++++++++++++++++-- fs/tracefs/inode.c | 74 ++++++++++++++++++++++++++++++++++++++++ fs/tracefs/internal.h | 3 ++ 3 files changed, 136 insertions(+), 2 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 24d645c61029..5240bd2c81e7 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -101,7 +101,34 @@ static struct dentry *create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fop) { - return NULL; + struct tracefs_inode *ti; + struct dentry *dentry; + struct inode *inode; + + if (!(mode & S_IFMT)) + mode |= S_IFREG; + + if (WARN_ON_ONCE(!S_ISREG(mode))) + return NULL; + + dentry = eventfs_start_creating(name, parent); + + if (IS_ERR(dentry)) + return dentry; + + inode = tracefs_get_inode(dentry->d_sb); + if (unlikely(!inode)) + return eventfs_failed_creating(dentry); + + inode->i_mode = mode; + inode->i_fop = fop; + inode->i_private = data; + + ti = get_tracefs(inode); + ti->flags |= TRACEFS_EVENT_INODE; + d_instantiate(dentry, inode); + fsnotify_create(dentry->d_parent->d_inode, dentry); + return eventfs_end_creating(dentry); }; /** @@ -123,7 +150,31 @@ static struct dentry *create_file(const char *name, umode_t mode, */ static struct dentry *create_dir(const char *name, struct dentry *parent, void *data) { - return NULL; + struct tracefs_inode *ti; + struct dentry *dentry; + struct inode *inode; + + dentry = eventfs_start_creating(name, parent); + if (IS_ERR(dentry)) + return dentry; + + inode = tracefs_get_inode(dentry->d_sb); + if (unlikely(!inode)) + return eventfs_failed_creating(dentry); + + inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO; + inode->i_op = &eventfs_root_dir_inode_operations; + inode->i_fop = &eventfs_file_operations; + inode->i_private = data; + + ti = get_tracefs(inode); + ti->flags |= TRACEFS_EVENT_INODE; + + inc_nlink(inode); + d_instantiate(dentry, inode); + inc_nlink(dentry->d_parent->d_inode); + fsnotify_mkdir(dentry->d_parent->d_inode, dentry); + return eventfs_end_creating(dentry); } /** @@ -234,6 +285,12 @@ create_dentry(struct eventfs_file *ef, struct dentry *parent, bool lookup) } else { /* A race here, should try again (unless freed) */ invalidate = true; + + /* + * Should never happen unless we get here due to being freed. + * Otherwise it means two dentries exist with the same name. + */ + WARN_ON_ONCE(!ef->is_freed); } mutex_unlock(&eventfs_mutex); if (invalidate) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 4acc4b4dfd22..d9273066f25f 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -474,6 +474,80 @@ struct dentry *tracefs_end_creating(struct dentry *dentry) return dentry; } +/** + * eventfs_start_creating - start the process of creating a dentry + * @name: Name of the file created for the dentry + * @parent: The parent dentry where this dentry will be created + * + * This is a simple helper function for the dynamically created eventfs + * files. When the directory of the eventfs files are accessed, their + * dentries are created on the fly. This function is used to start that + * process. + */ +struct dentry *eventfs_start_creating(const char *name, struct dentry *parent) +{ + struct dentry *dentry; + int error; + + error = simple_pin_fs(&trace_fs_type, &tracefs_mount, + &tracefs_mount_count); + if (error) + return ERR_PTR(error); + + /* + * If the parent is not specified, we create it in the root. + * We need the root dentry to do this, which is in the super + * block. A pointer to that is in the struct vfsmount that we + * have around. + */ + if (!parent) + parent = tracefs_mount->mnt_root; + + if (unlikely(IS_DEADDIR(parent->d_inode))) + dentry = ERR_PTR(-ENOENT); + else + dentry = lookup_one_len(name, parent, strlen(name)); + + if (!IS_ERR(dentry) && dentry->d_inode) { + dput(dentry); + dentry = ERR_PTR(-EEXIST); + } + + if (IS_ERR(dentry)) + simple_release_fs(&tracefs_mount, &tracefs_mount_count); + + return dentry; +} + +/** + * eventfs_failed_creating - clean up a failed eventfs dentry creation + * @dentry: The dentry to clean up + * + * If after calling eventfs_start_creating(), a failure is detected, the + * resources created by eventfs_start_creating() needs to be cleaned up. In + * that case, this function should be called to perform that clean up. + */ +struct dentry *eventfs_failed_creating(struct dentry *dentry) +{ + dput(dentry); + simple_release_fs(&tracefs_mount, &tracefs_mount_count); + return NULL; +} + +/** + * eventfs_end_creating - Finish the process of creating a eventfs dentry + * @dentry: The dentry that has successfully been created. + * + * This function is currently just a place holder to match + * eventfs_start_creating(). In case any synchronization needs to be added, + * this function will be used to implement that without having to modify + * the callers of eventfs_start_creating(). + */ +struct dentry *eventfs_end_creating(struct dentry *dentry) +{ + return dentry; +} + /** * tracefs_create_file - create a file in the tracefs filesystem * @name: a pointer to a string containing the name of the file to create. diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 9bfad9d95a4a..69c2b1d87c46 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -21,6 +21,9 @@ struct dentry *tracefs_start_creating(const char *name, struct dentry *parent); struct dentry *tracefs_end_creating(struct dentry *dentry); struct dentry *tracefs_failed_creating(struct dentry *dentry); struct inode *tracefs_get_inode(struct super_block *sb); +struct dentry *eventfs_start_creating(const char *name, struct dentry *parent); +struct dentry *eventfs_failed_creating(struct dentry *dentry); +struct dentry *eventfs_end_creating(struct dentry *dentry); void eventfs_set_ef_status_free(struct dentry *dentry); #endif /* _TRACEFS_INTERNAL_H */ From patchwork Fri Jul 28 18:20:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 707766 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 53482C001DF for ; Fri, 28 Jul 2023 18:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236430AbjG1SWJ (ORCPT ); Fri, 28 Jul 2023 14:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236289AbjG1SVr (ORCPT ); Fri, 28 Jul 2023 14:21:47 -0400 Received: from CY4PR02CU008.outbound.protection.outlook.com (mail-westcentralusazon11012003.outbound.protection.outlook.com [40.93.200.3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22432449E; Fri, 28 Jul 2023 11:21:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bK+MaAOySfGSCciXUTt1JLQOPNbFNsLlG5fmWdQqam0xbslQ8egftyEKs4/6DlKTahE4DT31HqQWl+FnjEg7iqzh8ietR6LrSXxuJ1a04ZBWkOWQMc/nJwj2VsN7eutIPp/NMUjkkdylTTqaWGpNfYp+uZDvyDliR5oXmMXDreGywuCrNDdwEL+v9W7H1KzVTwE2qrfIcqXDCSpmI4ZdzGpG6XJTaGpwgpiBO9C5oYT0V9Bp946VY+ZBjlLagVnFLc3M80FbB9fwZ1muVDZJdBmkisW3ZPNMVYeGoA55gnIJxR+ZYqcAvzHC4RV/r5qNzuZM7ubmHrNbaGzHKhmB3w== 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=RD4e/LRWicfReGBTq2PmuuNab6VTlR+NonQSH7Pjua4=; b=iWFvEeMiri/Sgg2f42bl9B/Jk0JN3ywmmbNJdn0Yr0WlANeFoggHFhoqoPxAghjQLQRtkkxtvpj9XEMd9b4jZKTShFYUDqhz2TrGyVCaV65dMpBSGlKHv56lNC38b988MV9GREem/vnFU7qM9jZVNMxhc+LHzZej+GGVoIfWqmsG6QqOkTV7tlLrZWrvmslMOW7Uyi8W6DWwNaHFBfkQH55bJtt7B5+Hy2ZEu82Aw4OP9Nz07Ngjz3v60JFVuLOvP3qkJqZEsc6EKIyGBe0SKL6gPZq86Q0jxF19qSe9RjdSQDNNxzVEPiR6BkAvgRxuVbeGNK5Aog40cVQvUA0LyQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vmware.com; dmarc=pass action=none header.from=vmware.com; dkim=pass header.d=vmware.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vmware.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RD4e/LRWicfReGBTq2PmuuNab6VTlR+NonQSH7Pjua4=; b=PtQBvSxG3QPb6XlUjGkieI2ZD8EfdqDRAtn9RUyABNGfoBhL1xEPeCJsljBCGt3okwAx7ZiZLTkqURJGW8ooUPrXrgIdWmpjpLlV51llhn4XCM2sv7qgJ1j/yfK7kjS0xWbcC8bM17o81geZBYVPKvoQmZgeXyErBgFJ/fivWs0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vmware.com; Received: from PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) by CH3PR05MB10004.namprd05.prod.outlook.com (2603:10b6:610:123::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29; Fri, 28 Jul 2023 18:21:27 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::b5d8:98b9:6ca7:94f0%6]) with mapi id 15.20.6631.026; Fri, 28 Jul 2023 18:21:27 +0000 From: Ajay Kaher To: rostedt@goodmis.org, shuah@kernel.org, mhiramat@kernel.org Cc: chinglinyu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lkp@intel.com, namit@vmware.com, oe-lkp@lists.linux.dev, akaher@vmware.com, amakhalov@vmware.com, er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu, tkundu@vmware.com, vsirnapalli@vmware.com Subject: [PATCH v6 10/10] test: ftrace: Fix kprobe test for eventfs Date: Fri, 28 Jul 2023 23:50:52 +0530 Message-Id: <1690568452-46553-11-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690568452-46553-1-git-send-email-akaher@vmware.com> References: <1690568452-46553-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR11CA0090.namprd11.prod.outlook.com (2603:10b6:a03:f4::31) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|CH3PR05MB10004:EE_ X-MS-Office365-Filtering-Correlation-Id: 7c23c12e-33f0-4f27-995b-08db8f97754d X-LD-Processed: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9Cx0OD1gnshYb+MH28H6wbcb0IOB2gW6ZJmYg/ssTouclIvuv+25T90VLhq1IJDXarkjUdJ1vqEgqZc7gNCzbUDV7jqXCC2iXjFRkhE7GEgCBXHWhHQvs9tNJ6V1xSWxE5X0A7L7E9onvkTw9WfqDsde4lNHq1IgyX5jmVj01jN99L1doXLjcmyTtlWSJTvfLt/uzulVkq1wlw63wt7VhSEXIlU367LhrJWHPJ3KmFXF+KM7gU0L5WKo9cwu0cvwNMl1lxhB6I6O3UVIkDp6k0Mxe0vShB3/PVqPGYZ5muef5TdOVgteSaI3fXdfmCdKu0WOppFCLD3o6HydTeOrAKWpokmX9p8tfqLSx5qzU7OgBc3XTgbfb/1fwoSOMIPUB5RDrviG5fZsXMN/AU5piWwel3XVhobYw0KfBjO6F0wzZ7qr7wqWvw7VoqpeSVqd+dhuA9I/oQiRmgk2s0Cm/kSpE6Su9URUImSmowb2LOskC6ldvRJNFPFBVPRiaQusn1i5VUmO7W2xKEZJchn2bIKtQ4mvPpspxdrGWdtMm6nqHHYK+WnNhp1yeuPT/By9kpTK/V9J9uyPXoltprM6LZZovouNtgk/ZsvCSCxxbs051slFjHC1xaG5qdIs9swTQWgsxKfELasNBhKYuhIT7i0CL4rjVY80//FCGS8KYvQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH0PR05MB8703.namprd05.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(4636009)(39860400002)(396003)(366004)(376002)(136003)(346002)(451199021)(83380400001)(66476007)(4326008)(316002)(6486002)(52116002)(6512007)(38350700002)(478600001)(38100700002)(66556008)(2616005)(8936002)(8676002)(66946007)(41300700001)(5660300002)(186003)(6506007)(107886003)(6666004)(26005)(86362001)(7416002)(2906002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: fm6cEnzwFEGTRRo5xfjGZxwESvYZ5snQhqfeLnT2YJhztqv9V/Ab4d2FhnlATaNl3B1ZFdOtn/mSLNESGTQOn2h1ZKLiMrwJzeEDgjKCvmpL/Oiy+eDzMcKExaVeMyfc1IXowJNj/7XhcFoUpjnLijYnJFLQzPokKeKUHv04r+fDUvxzLfto+pL1QmDN+1+TL6m3gN+YfPF54IPrvPC3BxX7dvoGIdwJa1RZwZpAKx03IMOE2YPBs5HFbkv5z3KEh2sx9hj+y3GZGUtz5NUhM4ii8Djy1LoywkDZFCnofGCLo2X57Y+qrgadeIuR4MsWOxgl/JITaMCfPkNDidMGjtp2jm7kjgrkFVnQcq9nvG4c2TomV1Upr0nj2fBFu34Zi1QANxcUC/d3C95x4d0ECvIahYbOL2v0LrOIOQDdIj0XxN9GP+G0zeyp1HuegrI6/5V3Cl8oQWI4bfUGlKdaepxtdHQm0NknhC8exhnOkhjueKUlZu3Nm6i+A20cvDmG0hocnY4vBNQzgIqXqcTuyGBNfuouwDMcFntU/d7IfWe4PaHenW7kzeYxK6I8RZR4tIAVuD84Cocia+EWanUaN9ARLA9335bomqcyZvVH53765w05n3/CPau5/CrOny3vJRbUV7gAfqeyifSwxb6DfYWTFyzfUGs0YUXt6o65z+cswbywg3EzORcvUsjSZrLUcJAxuzmlhlpRhcQNHNpy5WM7ep9vWK4rBUEE7sX6lbQjZFb3Q7TSOe9vOEuicFulscpvRSZ3CAVGJLrMbo1aAZ5ctxN/Pcv09ct7ao96A/Oufj6G/ezfORqLkk/urnpmK1AEnVEd/ZemNsbeL6DYLM7LVlPiGG116baKwVS5P8EgxJXSF9a4IfdMrihzp516VZT7lcZsXzlteTj/s81/aTBbhb/JG9U8Z0/B47zA8icdPOyfBwHka0u65XR5vU2gvvCt2WwcBV+cCNAQEbjBXfuXTu7vHKn+M4UxPDxjKfrV8U1hMgqMgfnw8KVyziHwcqnlKX4dF1i4qdZ/AYtTpN2DKMYSjJ9i/LgN2+B/FX+R0FOHwMEvhQdWGnz8/ymzRylosgnL8xZ8XfHEZuImOdqdFjWn+JvA1jfSvkvCdW8elN3rJKAPBJ2WsADsJNOC4hql2mAJc4VCmCV7ebNW1dqCN7KN6SdOqmcLCSuADOKHKL+P+HEK3D7Z9I2U7w4eUiCxTNLhr3aQsfxPpWuMRqFIkyWKJs5auNMJW5MfNmdUpNA81y5HI81MiFrOzbtaxTX+x5sW0YrK0nV+EDHZT5nv9alOHzsoi4ADYbCKe5+WTXTs4PgJA9RPeur2elb7t+bAN7vyyJ2yVDqRzcn+rS8foBnMce40Y+qxK64Ba+Z9/NyNydSGiumIdaqs9hrWozGvs7f1AufqMF0kgdYNPh74mKwq1PVaJBU+heMM7ipHEDIyLDGll1xQa68T87ZW8nfEKsMo5vNTFHb90CA4n5E+ANwK0PermoapTDQouiWbzRhND5UWJWxqFZMqu34C+giyAd+lRS6NYw5y2r2oyVlT38xqSV7eDupA6JBCOwYtNoEJvsR2iwyrr/qwnIWS X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c23c12e-33f0-4f27-995b-08db8f97754d X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jul 2023 18:21:27.5461 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b39138ca-3cee-4b4a-a4d6-cd83d9dd62f0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5klzU3tdRr96XM8Oj63Z/4njnIlRFeMsHwAGYSmmwiYu2EpcZwx4nFiRtuyOo7vPJH3TnzmE2umBDLZn0td/6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR05MB10004 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org kprobe_args_char.tc, kprobe_args_string.tc has validation check for tracefs_create_dir, for eventfs it should be eventfs_create_dir. Signed-off-by: Ajay Kaher Co-developed-by: Steven Rostedt (VMware) Signed-off-by: Steven Rostedt (VMware) Tested-by: Ching-lin Yu Acked-by: Masami Hiramatsu (Google) --- .../selftests/ftrace/test.d/kprobe/kprobe_args_char.tc | 9 +++++++-- .../selftests/ftrace/test.d/kprobe/kprobe_args_string.tc | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc index 285b4770efad..ff7499eb98d6 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_char.tc @@ -34,14 +34,19 @@ mips*) esac : "Test get argument (1)" -echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):char" > kprobe_events +if grep -q eventfs_add_dir available_filter_functions; then + DIR_NAME="eventfs_add_dir" +else + DIR_NAME="tracefs_create_dir" +fi +echo "p:testprobe ${DIR_NAME} arg1=+0(${ARG1}):char" > kprobe_events echo 1 > events/kprobes/testprobe/enable echo "p:test $FUNCTION_FORK" >> kprobe_events grep -qe "testprobe.* arg1='t'" trace echo 0 > events/kprobes/testprobe/enable : "Test get argument (2)" -echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):char arg2=+0(${ARG1}):char[4]" > kprobe_events +echo "p:testprobe ${DIR_NAME} arg1=+0(${ARG1}):char arg2=+0(${ARG1}):char[4]" > kprobe_events echo 1 > events/kprobes/testprobe/enable echo "p:test $FUNCTION_FORK" >> kprobe_events grep -qe "testprobe.* arg1='t' arg2={'t','e','s','t'}" trace diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc index a4f8e7c53c1f..a202b2ea4baf 100644 --- a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc @@ -37,14 +37,19 @@ loongarch*) esac : "Test get argument (1)" -echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string" > kprobe_events +if grep -q eventfs_add_dir available_filter_functions; then + DIR_NAME="eventfs_add_dir" +else + DIR_NAME="tracefs_create_dir" +fi +echo "p:testprobe ${DIR_NAME} arg1=+0(${ARG1}):string" > kprobe_events echo 1 > events/kprobes/testprobe/enable echo "p:test $FUNCTION_FORK" >> kprobe_events grep -qe "testprobe.* arg1=\"test\"" trace echo 0 > events/kprobes/testprobe/enable : "Test get argument (2)" -echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string arg2=+0(${ARG1}):string" > kprobe_events +echo "p:testprobe ${DIR_NAME} arg1=+0(${ARG1}):string arg2=+0(${ARG1}):string" > kprobe_events echo 1 > events/kprobes/testprobe/enable echo "p:test $FUNCTION_FORK" >> kprobe_events grep -qe "testprobe.* arg1=\"test\" arg2=\"test\"" trace