Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp1470471rwo; Sat, 22 Jul 2023 14:26:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlFtZufM1yJuyVOuvgcPvC1zOEMplUKeqhMZ/KqSFBV9dBZkeOUpD4bhKhjMAZbgYj30rpkW X-Received: by 2002:a17:907:7759:b0:992:630f:98b6 with SMTP id kx25-20020a170907775900b00992630f98b6mr5432803ejc.37.1690061203926; Sat, 22 Jul 2023 14:26:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1690061203; cv=pass; d=google.com; s=arc-20160816; b=B3TEUlX70RnU6Gk5cf1TrYyCTb5fGCejVUTqnvuW9zIeZHXSSymZXNwkgwaH0z9zvH hU2xfHY1siGzpbO+L+BfznbDWsRQ3ampl6NBSCklOHfFKHKA3U/PSJ0I5s/1utGDkFA5 jcLqAU0F00LHPvyylssQu9HOdVLVEj4V2fIWkSpVve5f/LANQCOhgxQk8uIluZIm1YnO ix1nDloMjeThCDFlrx+3z0Kd4W5kD/teMhwyWxLoHvSNb5oOuYwfFLkm+CbC/JaPFAbm P8Qy8JqB06aBjm+j20Mqp6OCR5r9ewJPlAay6N+ESNo9MDw//7QuMTWDgqWZFTdnLGuX 0RGg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=t4WaK4KxTRuWh5daClVlTC1EezEIfNyBJPG4+QQVqkU=; fh=7B0bo5Lktx/E3x4cyZnYBPjkhxB/DDkp5SHWooMUZqE=; b=tbsBSTNeuj/N217Edx/5YEbxCd+l0FFL4zQV2pjEMN649/PWsDxlolOPRoYXB7AVzQ y7HM4PWp6vQQgtr866mXOJTTVWbZrUHkDjqd1UZ3JspQ7ycLjxv0SRfMOq8rC6fCdDJr UVqDgEaKw1oxpVLt8hDSupncCGR3JUDaZnpM8qAHu1lH1SdkS9VQdFzGr4NNUHmjUGUE RpOBmOIo5+lrY4Aouf47mYsQ4TtgSOCvJt+oe69w646g4DrPq6DlOn04yW6tIlK2iIHf ZcTGsBjbrX544Dfa5PYGZw4c5KiyFW2u891KmWeJxtit1596lf9K5mz8x+xjVHGWZgZf 9KQg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vmware.com header.s=selector2 header.b=zas4uUZD; arc=pass (i=1 spf=pass spfdomain=vmware.com dkim=pass dkdomain=vmware.com dmarc=pass fromdomain=vmware.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=NONE dis=NONE) header.from=vmware.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g15-20020a17090670cf00b00992cd4e0b83si3919813ejk.426.2023.07.22.14.26.15; Sat, 22 Jul 2023 14:26:43 -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=@vmware.com header.s=selector2 header.b=zas4uUZD; arc=pass (i=1 spf=pass spfdomain=vmware.com dkim=pass dkdomain=vmware.com dmarc=pass fromdomain=vmware.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=NONE dis=NONE) header.from=vmware.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229553AbjGVTiM (ORCPT + 99 others); Sat, 22 Jul 2023 15:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjGVTiK (ORCPT ); Sat, 22 Jul 2023 15:38:10 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011013.outbound.protection.outlook.com [40.93.199.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EC10E71; Sat, 22 Jul 2023 12:38:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S84v/7vIBAlFLdNhS25O9zn0GjollGMwPpa4Amqh6rFEDzGXlb4yenVQepPOOXBldVNWxf3uvvAG/ZeNcOleeSPZjLqirYRdtzphsO/6k29mU+U4+K4BEtGZd3sIsv8r19R4WmnHDFT4q5LSQ+y4z79Ff3OLsJ4eRMZ1Eypd09e0zbp3DlHt3/hK7HH0VCIwGLgL+ZLHkd0BIyTaLprMAszaD0d0UCOVgX3eiGJoj9lNeSWVdM8XOfYOd1fBwXezH3hxISLlFt197E9fpVnTKW9oQgJVv6VSTyQZmdl9wW3xuORu2/IFxWcQo13fN7QhbuQXE99fDuaoWr83lYQ1Dw== 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=t4WaK4KxTRuWh5daClVlTC1EezEIfNyBJPG4+QQVqkU=; b=KrzXFYZStwYqO7Bx0oJE3FlVKXr+Wuwu3vMdKkgqpBSxolllUBh6FXQPk513mq7BCTbPY/KHqNoaC8zYqrekcaYot+CUwxxC4o3i6YtVNQMWIpK+tO5sXHOaEgl8iV+LVtyuzipCrL3qBUjnGL+IpZL3eflww2eX7m2OX7j8Knf0Nx/B8+mWjejhrELwdjDRhhnWsiYA/oNQUiaBj1fn6GZAR6RrbT+0Ac+ZJoauK6zUV4A50f7UuT886Wyk8s5OOodrijCpxs4qivZKRjT/iXL8CPmuxUci7hblCl0MYh1MhYFXzUYUrK6UyuB8qLnD/+SbI67koGW06fKcv/MU9A== 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=t4WaK4KxTRuWh5daClVlTC1EezEIfNyBJPG4+QQVqkU=; b=zas4uUZDMt+4uiby3IugkC3CPELe7al53+eFvXYmwLF/HJYC5mKkhSrtcTljnEvowqUryTeBVceBXjgG7QwRldPZkUzNmjEfr8QdRQ/oKsamuT7cyTDq38mx745VaGBMEdSjyDm652cyt4DfF77mUaAIf2nAKH0dw835l7Se6Is= 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 MN0PR05MB9005.namprd05.prod.outlook.com (2603:10b6:208:3cf::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.31; Sat, 22 Jul 2023 19:38:06 +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.6609.026; Sat, 22 Jul 2023 19:38:05 +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 v5 00/10] tracing: introducing eventfs Date: Sun, 23 Jul 2023 01:06:55 +0530 Message-Id: <1690054625-31939-1-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 Content-Type: text/plain X-ClientProxiedBy: BY5PR20CA0009.namprd20.prod.outlook.com (2603:10b6:a03:1f4::22) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MN0PR05MB9005:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d231707-8548-4ac5-bf77-08db8aeb2b67 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: 5Wox/cW2yLtKpLFLkl7MMTjqNQMrFe66Io5EAX8C08dJ/L2QVN6KaTGS8FKdsSqNf20taiopFvMP0qVBMU8dVuhZ6aXg0LjW4sKfbP5OWJiceZvxg4RzJNRfivP9KwyJnhLgyMC+KOV4Y4tNmxcD/FAhrUp4GWHrVrcwa6MCIjjdDrYmwz040BRG/izuuIQ4l0YDao1m2c3VXnrtolMKELgdiaZmv66z/utBVJDhhdpTm7ERiauuTaspQCIahLIIzoRuPUXvdj7pQlxih4kFQmq+wdOrIXd7M6HVEt2heJib13/vEfbbIRIb8L8ZpsYPlYGq/fZLC3L65q0EpCzGby6xHwBDR4r8+dfAjTy7siS0Rx8XTnb+b2p9jvylPHwoBQFHTanMT7vgBGB3QtWhCBaWe5ApQNnRDJJQ2VHvMprWmp4MRBwnULcS8Ev5nkfk9vuOBnc5TFs6bCbyRbWQIYcP9jtSJLIqx9V//aWygv7zC5F21u+AvX/rF4E7JT7h2JxPhqBlafoWi/GlXax2SbV+Kp/pjYtGpwsrJ0iCdsHc+cSwMTsCPV5Cictjgn8on1fFeXPf8Io21Ke8e8too80ITCMywGH8kWyRmmaavdphNzhRujmaxCCMAVX6pMHsSYkLf+RE3ijhw4nh5KCMQVXeAZB+jacX5m68KhJOwrQ= 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)(396003)(376002)(39860400002)(136003)(346002)(366004)(451199021)(6666004)(52116002)(6486002)(6512007)(478600001)(186003)(2616005)(6506007)(26005)(107886003)(2906002)(316002)(41300700001)(66946007)(66556008)(66476007)(4326008)(5660300002)(7416002)(8676002)(8936002)(38350700002)(38100700002)(36756003)(86362001)(83380400001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?oDRDV9l0uGMme2yf0RlrNUdQALgDwFo9GabXrVs1o72YIxwP3Lwwg33gYjSY?= =?us-ascii?Q?g5Hiwh3neOA7uGn85ISVI/5K9iom34M1UNkWzmIXBhdzymEfRIGS12NWVJXt?= =?us-ascii?Q?7yjGoXOYVlIxsr/6OH6MnHdNkbW5pumY488O5YNUTzUbazLx243Q4AiJFQUE?= =?us-ascii?Q?WdEPkgZ/EpKpyImJhTT1Krw1ETSLaXwwwlSbovN6+p2Z++GxGKdaa9UrZlAk?= =?us-ascii?Q?yFOPfv2D4kOi5IfwOiilOBO+VL0X7uDBlyl/dUzSlc0zZQ5C301AkPym2oHm?= =?us-ascii?Q?4KlbuOjGduAI7VXU3U6AFOnDme1hJZvc9BqDWZEFfg08lkTjxJ+yTKZqtTYd?= =?us-ascii?Q?YGX6ITJCst8TSvNQcy/9mNr19/5aes9Som9DW5/mokjgEGgVjq3i7Jb5HwCS?= =?us-ascii?Q?0XAJCRdpXnJhJicWEPj39AB6YlnlRxjCHQPSxsLRzaX4DBw0b/qoDvdIFQ3B?= =?us-ascii?Q?3Hi43t/ogSpLDMc4tS/GlnbCa1mXA1q1sy1F6shhDpnzojWPG1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fIV+U+lJ0nnWBN6SuX39QLTCu+Iut78E098tvHldRn?= =?us-ascii?Q?0JUAPFP3NUDLnUseDzxQd9FU+1kydyvKnYg9rYUqJrCAAkefoheCA6JlJgbn?= =?us-ascii?Q?4YS+5pOAY9rz3hGFEX9e6LnQrCDqt7DOOm2X9rQSoJK7uO6rdnQ/Z94RtpA5?= =?us-ascii?Q?NnISQDrsw9DuNP080QZGRg/VW6waVpesRsO7T5Y5?= X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d231707-8548-4ac5-bf77-08db8aeb2b67 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2023 19:38:05.4875 (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: WR5rUv7RTHCshkSIf0Lv/M2cp4Rmbre90ClUA2MVsl1d4vBQAVQtt6YMv5YU4CEEArrX8XUVPoKA61hi8MrtqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham 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 Events Tracing infrastructure contains lot of files, directories (internally in terms of inodes, dentries). And ends up by consuming memory in MBs. We can have multiple events of Events Tracing, which further requires more memory. Instead of creating inodes/dentries, eventfs could keep meta-data and skip the creation of inodes/dentries. As and when require, eventfs will create the inodes/dentries only for required files/directories. Also eventfs would delete the inodes/dentries once no more requires but preserve the meta data. Tracing events took ~9MB, with this approach it took ~4.5MB for ~10K files/dir. Diff from v4: Patch 02: moved from v4 08/10 added fs/tracefs/internal.h Patch 03: moved from v4 02/10 removed fs/tracefs/internal.h Patch 04: moved from v4 03/10 moved out changes of fs/tracefs/internal.h Patch 05: moved from v4 04/10 renamed eventfs_add_top_file() -> eventfs_add_events_file() Patch 06: moved from v4 07/10 implemented create_dentry() helper function added create_file(), create_dir() stub function Patch 07: moved from v4 06/10 Patch 08: moved from v4 05/10 improved eventfs remove functionality Patch 09: removed unwanted if conditions Patch 10: added available_filter_functions check Diff from v3: Patch 3,4,5,7,9: removed all the eventfs_rwsem code and replaced it with an srcu lock for the readers, and a mutex to synchronize the writers of the list. Patch 2: moved 'tracefs_inode' and 'get_tracefs()' to v4 03/10 Patch 3: moved the struct eventfs_file and eventfs_inode into event_inode.c as it really should not be exposed to all users. Patch 5: added a recursion check to eventfs_remove_rec() as it is really dangerous to have unchecked recursion in the kernel (we do have a fixed size stack). have the free use srcu callbacks. After the srcu grace periods are done, it adds the eventfs_file onto a llist (lockless link list) and wakes up a work queue. Then the work queue does the freeing (this needs to be done in task/workqueue context, as srcu callbacks are done in softirq context). Patch 6: renamed: eventfs_create_file() -> create_file() eventfs_create_dir() -> create_dir() Diff from v2: Patch 01: new patch:'Require all trace events to have a TRACE_SYSTEM' Patch 02: moved from v1 1/9 Patch 03: moved from v1 2/9 As suggested by Zheng Yejian, introduced eventfs_prepare_ef() helper function to add files or directories to eventfs fix WARNING reported by kernel test robot in v1 8/9 Patch 04: moved from v1 3/9 used eventfs_prepare_ef() to add files fix WARNING reported by kernel test robot in v1 8/9 Patch 05: moved from v1 4/9 fix compiling warning reported by kernel test robot in v1 4/9 Patch 06: moved from v1 5/9 Patch 07: moved from v1 6/9 Patch 08: moved from v1 7/9 Patch 09: moved from v1 8/9 rebased because of v3 01/10 Patch 10: moved from v1 9/9 Diff from v1: Patch 1: add header file Patch 2: resolved kernel test robot issues protecting eventfs lists using nested eventfs_rwsem Patch 3: protecting eventfs lists using nested eventfs_rwsem Patch 4: improve events cleanup code to fix crashes Patch 5: resolved kernel test robot issues removed d_instantiate_anon() calls Patch 6: resolved kernel test robot issues fix kprobe test in eventfs_root_lookup() protecting eventfs lists using nested eventfs_rwsem Patch 7: remove header file Patch 8: pass eventfs_rwsem as argument to eventfs functions called eventfs_remove_events_dir() instead of tracefs_remove() from event_trace_del_tracer() Patch 9: new patch to fix kprobe test case fs/tracefs/Makefile | 1 + fs/tracefs/event_inode.c | 795 ++++++++++++++++++ fs/tracefs/inode.c | 151 +++- fs/tracefs/internal.h | 26 + include/linux/trace_events.h | 1 + include/linux/tracefs.h | 30 + kernel/trace/trace.h | 2 +- kernel/trace/trace_events.c | 76 +- .../ftrace/test.d/kprobe/kprobe_args_char.tc | 9 +- .../test.d/kprobe/kprobe_args_string.tc | 9 +- 10 files changed, 1048 insertions(+), 52 deletions(-) create mode 100644 fs/tracefs/event_inode.c create mode 100644 fs/tracefs/internal.h -- 2.39.0