From patchwork Sat Jul 22 19:36:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322991 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 64FDAC41513 for ; Sat, 22 Jul 2023 19:38:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229534AbjGVTiM (ORCPT ); Sat, 22 Jul 2023 15:38:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjGVTiL (ORCPT ); Sat, 22 Jul 2023 15:38:11 -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 CA3B7E79; Sat, 22 Jul 2023 12:38:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZgV2YHTQQp7UEXSxk3Yu6gt/SzG/KmKWw3f4BmqK/7srLGUFPPIvT6N/0V019SeGYameLE2lXOWE2T2NxhFZsauGBEEfOa6uMVHNzS0zbx10spqIyvGGbe6ww+8cZFWm4OduNYskOGV9Z1EJrk5ffwujhr6nBD4BFYureATnzkBi7hh2oOVgqiC7IlhTjAQu6kTtVXd5gFT5nWA2vkXVF67XChUBAQLhlvO6m5WMIYcvg/7l9pQhXdveoaiC1+FKQ9GoSA61kMWpw5wlJJBFQQ7NjZhuMiOUmLQtX9ssCIEM6cY2Fgw1URKmk9s/XgFih45Z5EGqmQQDue4c7YKpdQ== 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=EK/CPVX7KPPTFi9g8K7QxzUGBp438pRqJnXYdV6ILyY=; b=mXqpu/+F0xOrg/hPMssqrub3QiF+I/MiqPMMH373bUK3XMKzh4EsXSJq4yT0tw48l3k4hZV/to1NayPPE2QYxI2dd61/Was0icv7+5wgmL/xspRXGHaaYS+dxC79Lw5dFCNqzDMyizi2c4RxGGjZRclpENPtW10lyhUttg4tYBDiFOidZrZ+ncbdk3u4PwpALXGpPAkRGjxvSoMgEg/fT0HWgjajdpVKs/He5iK3PuGrJ5WanSpmbPv4qxmVS91KzwoKRcLnh28QI6EY+hdlVtmwIK7CEBC0M+Yx6nMgMJfxY/NA5+mPHi+TMfSMhTt3K83IseoWN8nWq7fgeJ0DFA== 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=EK/CPVX7KPPTFi9g8K7QxzUGBp438pRqJnXYdV6ILyY=; b=NmDnBJA5ry5rrD2/ShpOkvNqRXiKqpOzkU5E9uJuEJgLUCH4XJNbwt8hoR8pdT9Kor79TcMYwaW3PBkdmBfuo2jj1hvxCaVjatf9Y80HXyJSgtPrBa/SmRixn+t1836SSrzdn7tFNrQmFbBp58yI8H+mOP0lb5rXBmylmtqq+uo= 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:07 +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:06 +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 01/10] tracing: Require all trace events to have a TRACE_SYSTEM Date: Sun, 23 Jul 2023 01:06:56 +0530 Message-Id: <1690054625-31939-2-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: cb870108-8a49-4bbf-c230-08db8aeb2c34 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: 1W1sh+yRJaMuwKtdn/QqCHkiG6anGKBmfPNWai9AbYF2cudO0I1rB24zmFmOw46kflWQFEG6ogj+UbhbUdQCCawyoPqz7NpKVqAJxzdaxxedewLBZqj9P7JGwcpK46R8wr3F4+yykVoOJAUDFOVwGXQmBqsbJOm1M+oN3WwAMOieEQgflb4urJRJqbECea4IDTLNyNS/qAZ/wu1usKsRzOM2LNsi+XLeSfBsVbU+rRdqlHO8OB1/eu8OpDtZCGn+Qj2usua5oLicqeUb3HlATqOWL1fnq4FJOs0qY45CUkBjo6K494AQeGXppawcZeFoc6Jy5I5YVGN5NFoN3xtmWkgWO+JNoCTa8T7gZ/+XybSxwmNVq0URYniemcvDc5Rvx0m4yNM2i61QjLWzrpTt0+w21AtKJ7BqbAzogROxUoV/rNtK7Ej+rCeHbEgDLgdtv9CVCGScQXUtDBhlL1GcR7akNQgDyYp3k9/jJInMUMNLBCG8dLWc/4SvH5X8xyahqq2vpp6xHEW2OxuLLSfCOJDdmpxtL8wNwItKJE9lUJr+Bom7WV6sbRnhEMw7rhCR+8r8Ful0nJp/SE37PdxShvABNjGItm3KEknQYl+9a/whkCrzla2AZC0jMh6nFkl1vz7wfyJ/JgZ0OoH1P37G3SdHc05N2xbwEEhoup0sU2M= 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: gIFcETJlYIgW97M4BouGSjwXvha9DocRLbq56+P7FrvVhkC84BKjtowSa1gHXLGeFZhI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5/QQwSpo1RumskBwTepuJ49MP1XeXVh/QIfmEZJt7schamISzFn5cbR2GxsEyyChC2XZ6LdHq+ykuDUf8qTO2T5QUq/kuIkL3sIsEYPGYKHLwT+jqYauhA2ABKJYbRwGIUtkdJs3C4lSJPiw1Fi3ijE2JCBXPS2QkqqnKK9EEhGxsAT+0GANZUPR+Rn8xHR6Yx+P6xy/ljlVNNSQXNkT0s+4uz/sJeS97b+0mEstDM6wvxmgWNEXknJq7q3MmYp8dTTOK2q1zUCDdjo16QgVWIKxya+stlksTD0NimY8cRF3SAhwThcivkij/guPupW+l9x3XbNcTnm3qcIkgHaj+a96ReKYN3bINStrFw3wSY6HFSjW6qlkTAOXw3PX2XuH1lNASbQLyv7UzZ6q4hxzkfd1xXzvf8CpF+TUtnPkyMWi7IkHiNK X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: cb870108-8a49-4bbf-c230-08db8aeb2c34 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:06.8235 (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: 86WNjMSSOJSO8pi2N8UyywuuOUf5dR/kD1I2XsIZq1vKkFw7iA+ikSpGCBO5zSmDuaJzMcPY2OLebmAAb7WLqA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org From: "Steven Rostedt (Google)" The creation of the trace event directory requires that a TRACE_SYSTEM is defined that the trace event directory is added within the system it was defined in. The code handled the case where a TRACE_SYSTEM was not added, and would then add the event at the events directory. But nothing should be doing this. This code also prevents the implementation of creating dynamic dentrys for the eventfs system. As this path has never been hit on correct code, remove it. If it does get hit, issues a WARN_ON_ONCE() and return ENODEV. Signed-off-by: Steven Rostedt (Google) Signed-off-by: Ajay Kaher --- kernel/trace/trace_events.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index 5d6ae4eae510..a284171d5c74 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2426,14 +2426,15 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) /* * If the trace point header did not define TRACE_SYSTEM - * then the system would be called "TRACE_SYSTEM". + * then the system would be called "TRACE_SYSTEM". This should + * never happen. */ - if (strcmp(call->class->system, TRACE_SYSTEM) != 0) { - d_events = event_subsystem_dir(tr, call->class->system, file, parent); - if (!d_events) - return -ENOMEM; - } else - d_events = parent; + if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0)) + return -ENODEV; + + d_events = event_subsystem_dir(tr, call->class->system, file, parent); + if (!d_events) + return -ENOMEM; name = trace_event_name(call); file->dir = tracefs_create_dir(name, d_events); From patchwork Sat Jul 22 19:36:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322992 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 51BA1C04A94 for ; Sat, 22 Jul 2023 19:38:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229569AbjGVTiN (ORCPT ); Sat, 22 Jul 2023 15:38:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229551AbjGVTiM (ORCPT ); Sat, 22 Jul 2023 15:38:12 -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 CBBC0E71; Sat, 22 Jul 2023 12:38:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ibVPzTi4PilVGf/pQcIwHYdgyXrSIYl7cYHnVDZsVYkhmag20tX0FUx4PrYtqlPTBjUaw0xQ7Vo5dphxOlAvQ0MRg+zirZRE+mXL+7uDW4zDNZ8ZNmp2210iiu6fdoIpdFH+PGKFOIjIKrY3bhrXbnYh8Cds1r3kuBu6BiSGjwPSqyCzGr7MinIpqyv5JBtCfd7e7tCZtnKRdKMG+pl1QyQxCxbgK+6UuluiL1kTpaS79as+YItHEglacymQRmdzp252x9HypMd86CRfORgcy9OKdIcDFRwfzKZIpuI5XOPWJbIkxBfRYelCn1RnzQg8bSi8vz5yczbcZLLQmFl99g== 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=hXUtEczMGFElOJUhX84RQ+BxFK0f2GYe+dstmA/OSC4=; b=El6CsY4lA9e+7zhssuHFVbU3C4u8uATdTqsUCC8LWHNA/aSDh5hG52MPXjZMFzcPwc/EHE6kKpWGrXyUB8IGcC3f+giveZCjOHcQwM02gRq80OgvCKBlJKyUEPb6vSg7xN2RoJMycT1AwCPovViVP9EtxO3Pd7LKivFIcb41TluLUdxeQzM6JlY5WqxshK75/eKD/U9dhMLzvX0NxentlT0lX7Ponstk7Ke/5wkeg2ljnZmCG4fauRXEo5a8Zmw6kjoA87DIIUCErtimFHCWv38tsCA/cMalk8FASTz5wulLBDFFelQyXbb+LgJZftizoovInFmXi4gZ9iHIazWECQ== 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=hXUtEczMGFElOJUhX84RQ+BxFK0f2GYe+dstmA/OSC4=; b=PrHd7B8AN60SHbu3g/sfN5X5vDEDE6haMsmRfpPjVDzL2xYGRknemaE9lM5kdky2R69TIG/XXr+5IlyxKYKSHiLqKPSGtXjO4iehMCOLu7Hx6hj3dl/a4DWMf22Lb/1UnoGemkO7yfHxDhdpaYcUCjFUw4k03+zhsASK3clE/Y0= 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:08 +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:08 +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 02/10] eventfs: Implement tracefs_inode_cache Date: Sun, 23 Jul 2023 01:06:57 +0530 Message-Id: <1690054625-31939-3-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: 4f3a94fd-2f2a-4257-2646-08db8aeb2ce5 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: Q0C9ZgO+PcoWZRzWRz3tLD0vMJxHv325ga29qtCH7Oh746v/O63cNmzlMM2VkdVkEjdEipoxeCeRumTG8N/CiNNis93x0tz/rVq7ns+CjpcVfGSs134RWGTcJVNbx14IaA1G9xWUhAKIQFlx5MIujHVmvl/M1Wcn/yIuGa7oEYhaL6DRn0aqSZLmX5Ppsj9NRE3UulFYfsFJIrGNIW3fI09OFVTDRraO0yVE1AhJu5RRwaXRLlIa3KW6lscUJAwhEb3tuPeTnZPuZgPs0gqH59/06vXSeKEPa2caMLGwU6IgxdzmPBc6oHKtE2NkHB37ra/5Dv4dxP/cEPkHu1KMqSj3Tc1j6BQYo5hVXB3T3e8jtUEPc5a6YytnNe9Q1XiDi23yIMceab5xYQK9G72An7m3GdA+K7ou8BVX9xXm0cX90gJ4mgl56WzJ6QInLYGyXmGpGGYlSFZJS4O85FDOX60y94btMT82RWAgIrhZ0wTDHOwG3uArolQeg8zUUVydCLT3DMCHmeZh76HvxwytqHjYbKlXKsNvcmASU45leH7vpLB3b/JqnM2oUnSmGpdMQX792vQGVJkYYoZYjIwshwF5XhTJlv9uKo/hd2hMPDxf6xVMFFypxU9RxOnzxtUS5Nu5CjFGtsbVLkiEEVnEzNWluWI5Zwf9F/INZ7a2R8o= 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: ExuV9A4c62nqoTQjbP6VVRnisE38wfWHzSgsrh3JQO7MYLWkbMG9dQc0cBs1lwERgshlO1WBdaMtTsfo352EYxLezdwQDJz1G5x1ic0n/1hJlG3LgvbPhfhkIuVQ+Q0WJKYLt8yHvuZD9kcnqX0A4JoJbB/SgR9b9dlQIoz9UcWTM53z+9HBJnsa/tuRJe6jAthG2vsK91jxeqe+rFCAvB6jha8sJD/2fBUx03ZU5wQzAoD4Gw14/YGRpPMYsR7iL8vaOI4j2si90OFEnvj6riqZfJN6aqjXg0FLL1EY6xxc22p3V7/6dAPxvKO2zzM+PE3qbvhhM+X8LhSXiNDjcl9gH0KLliXBMTNWiP2aMj9N6qQ4z1xNle5ofKgZZc7HYLYCmWMkb1Z8MgE/5C+QLklQEkUrDIkvhgVvTJwcDMSad6xP4OOQWsh6W0wBC66R1CipO6IsbWqyoGqHyc1kjJ7bHXmnVLNROvCgC6A3mBgLedLzP9/UhWJubnyUD7GTRd2nDRZtzZiNnu52JUlNxYIQ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Exchange-CrossTenant-Network-Message-Id: 4f3a94fd-2f2a-4257-2646-08db8aeb2ce5 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:07.9903 (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: macxPxHJAV5/gEnEkzBcOgne5+AteP0uvNw4GrzT9ixgiY0OuhSQOzKZ/IN1LbpAP54kYo2Z22oCToL0UXKOLA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 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 | 19 +++++++++++++++++++ 2 files changed, 58 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..49b5e8949e1c --- /dev/null +++ b/fs/tracefs/internal.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _TRACEFS_INTERNAL_H +#define _TRACEFS_INTERNAL_H + +enum { + TRACEFS_EVENT_INODE = BIT(1), +}; + +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 Sat Jul 22 19:36:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322993 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 D90FEC001DE for ; Sat, 22 Jul 2023 19:38:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229610AbjGVTiO (ORCPT ); Sat, 22 Jul 2023 15:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229572AbjGVTiN (ORCPT ); Sat, 22 Jul 2023 15:38:13 -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 D280FE79; Sat, 22 Jul 2023 12:38:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mG8plX16lq8Ze5aJxdb8kHEdWAq8kgW0SRlPTv/Yo3Iq+3+U0XQ357ejVPLZbEfNSW1MGe7qHMr4CKKa5SUeLm6UOHNNzJAX8SriJDNQwj0f0eD8BHdA061yWgMtEgBthO8Acu2Srtnx+n9wv41P5nkPgUGqgeWWburzVPcB/7oZDt2Xh8MQn3NMv8GHXrlw0KWbMWTzcrDgfa88KprfVrR9N8s40y+3TBQYsYQVQvyIFptOFY9WFeLQaV+CazIHuqUVZNT3LOzDmgOTuXhrUXIHyAEpQ4y8wX1mQuKue2uA2HZYmonK30Mv1s52W3thpVGVLWDwt5thRwmVVaiPHA== 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=MoeI7FrTyh9vJhuPmPvCbdmu7ah/hzsk5uKcYHHd0YI=; b=c/L772IJRxM2WCiqIYUFqNoTAQVgkdVfro4ppvbvlYYI9V7q3f55V2Mg3LRJ95zmBhN373SvrcA8qYK94+nClnsZQxNw8+T6xjJnnjLZKNduzD3S7L4ApVoyfuWVCsH1TImHsOyZ5+4agBlo0yJagaTjlEgiwBw2vUej44s+oTV+JH7vOXHvLgPz1kZPg7cbuN/JQNc+/Kc/MNtcMrZmu00Tk1g3odyx4Eryc7CCYF5ZeG3djQmvA1+y4lwoB1Fnmb5cm6Z/2bIpWlwSJE8pZDcbracGhcoRctneXZ4iE+hPHPPgJyOcvKlIW7N37n0bLrmwpjX+c7zSvMIzoZfwSQ== 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=MoeI7FrTyh9vJhuPmPvCbdmu7ah/hzsk5uKcYHHd0YI=; b=q5wmRMdbqXEYiHyP+DTYaZDh2cfX9zUTGHxVeEYpYdswbmpodpzzhpB1OaUv3aZMFH6beXFxvKUjU+CtqaZF7P4HmEBrG5xfnRa48GgFScLEmkgIE3R06NTNyuTVWuQtK3WET6ukFJcLbX4rPFfgvx07RgKDykbytsl8RI5x1dQ= 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:09 +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:09 +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 03/10] tracefs: Rename and export some tracefs functions Date: Sun, 23 Jul 2023 01:06:58 +0530 Message-Id: <1690054625-31939-4-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: 1430422a-c811-445e-ee8e-08db8aeb2d97 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: 9osDlDdPNX74jXSHO1YI2r/Pj6TNkSiBfOXx3tZfJcbhbGbBEBS87GM6Eg+D6x++Yfud1YPLObOizwVLEvW0bbyBJevkXaGLE1kovSp19dJQ/nCsSsWQ3YPKoTV+7y1W5QjlrQwO+Bi0RuK3dEqJ+nby1xQMYKEl5hLMjbZnJaZ/R0c8gbFzdAR8QqEpgCEZDJiMB+/9jiklM0p2OHCv4zZu+GA8kDlnOTdnNfnNChUmFjl4szv4WP6TPHeeRF/ShAxSY9fvnCAyj0XW0q5KaK15O+wzTXAKyEvjOQ3o/DaZ8mQayDknNgTTfoF7jXS75wMbPvkmY8jcl1xKxBuKGeRYxeUFZttOK/9k9822lapfFYMKnqhZA9kqLHzy/YdgBXuj50uevwoq4eV9RM7SLga2MdrVZyQWzppJouU1khKJ+7B7eJiaWi7CtJNEQM2cFMzUl9JIjvPWsEsATuCrG14GoYNJGe22+G4ZaDjYOMIoOlOapxYdY/eSKjPG96YNyGHKsI9ogot9AI9e2df+8sz8vhwisGb+86itxn9GTSB0qU97ASPgfVa4HnIFw1zjpSFw8ZG3So/CTIU+pHeYNtFZJbz22VODoL4XsH6fVbbzEf09B4MgiWKB5PBayNZNpxVuFNKA+TrASXqQEGaSDc4VE1oTcUXs33WmpjwgMmE= 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: EJ7yFE+0e3lqwaFZauatECpGc5/Mjh3CxUTK4bd4kHDhu0wrxsEaoSSLgO3D0EW79XK0kKEbwCtVhSB8a/mny4dJu24kNpnkeJss4RMw6aijEY106dhs1KuGZA7YksVEhp05CBzJ5oSFNfCCyRV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MCkb2zppBak1FN9Syu4eTdCvkrqXd/HWgf3gsomU6HoWYtqlVlCbh/GKEsuzVrRTkr1OlBqHRldDD7bU0CHS1pdBIjtlvKUZS2n0lSXfR4rzo3cHkiCnIjZhLSyJdPCyhSNCJwqCFZOIt1zrHH9wRnNCkyaW9GyrUVWKPVRJkZAznBU0o91IBdOSEXzY3jn2uqQfogksJa5pwSPMSIbWOi2+HnEMK9K5z2KZEymp3EEPi09axA1OhxMv/lfAFCCwqjaQRUQfz5pKCkByRxxTjrwA5BpxClUlEXmLqtr6HCm0fXJH/xnX3RnumB/NVMRd2aqvSotVyON2y42UrgPuNRqaiQoURrNB/mqem9YcV7jVvLlTznm48wjHlHNS+Fc66Q3RE4u+LZi3fQ2I X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1430422a-c811-445e-ee8e-08db8aeb2d97 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:09.1435 (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: O5XVemESx04p9EQ1wd2dbArIs6fH8IpWMWnfOY4JuLCoGPSHLQoMojcwJWVP4x9b8UHFR72wDzqw2apC0wC5ZQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Export a few tracefs functions that will be needed by the eventfs dynamic file system. Rename them to start with "tracefs_" to keep with the name space. start_creating -> tracefs_start_creating failed_creating -> tracefs_failed_creating end_creating -> tracefs_end_creating 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 | 20 ++++++++++---------- fs/tracefs/internal.h | 5 +++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 2508944cc4d8..4acc4b4dfd22 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -147,7 +147,7 @@ static const struct inode_operations tracefs_dir_inode_operations = { .rmdir = tracefs_syscall_rmdir, }; -static struct inode *tracefs_get_inode(struct super_block *sb) +struct inode *tracefs_get_inode(struct super_block *sb) { struct inode *inode = new_inode(sb); if (inode) { @@ -422,7 +422,7 @@ static struct file_system_type trace_fs_type = { }; MODULE_ALIAS_FS("tracefs"); -static struct dentry *start_creating(const char *name, struct dentry *parent) +struct dentry *tracefs_start_creating(const char *name, struct dentry *parent) { struct dentry *dentry; int error; @@ -460,7 +460,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) return dentry; } -static struct dentry *failed_creating(struct dentry *dentry) +struct dentry *tracefs_failed_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); dput(dentry); @@ -468,7 +468,7 @@ static struct dentry *failed_creating(struct dentry *dentry) return NULL; } -static struct dentry *end_creating(struct dentry *dentry) +struct dentry *tracefs_end_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); return dentry; @@ -513,14 +513,14 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode, if (!(mode & S_IFMT)) mode |= S_IFREG; BUG_ON(!S_ISREG(mode)); - dentry = start_creating(name, parent); + dentry = tracefs_start_creating(name, parent); if (IS_ERR(dentry)) return NULL; inode = tracefs_get_inode(dentry->d_sb); if (unlikely(!inode)) - return failed_creating(dentry); + return tracefs_failed_creating(dentry); inode->i_mode = mode; inode->i_fop = fops ? fops : &tracefs_file_operations; @@ -529,13 +529,13 @@ struct dentry *tracefs_create_file(const char *name, umode_t mode, inode->i_gid = d_inode(dentry->d_parent)->i_gid; d_instantiate(dentry, inode); fsnotify_create(d_inode(dentry->d_parent), dentry); - return end_creating(dentry); + return tracefs_end_creating(dentry); } static struct dentry *__create_dir(const char *name, struct dentry *parent, const struct inode_operations *ops) { - struct dentry *dentry = start_creating(name, parent); + struct dentry *dentry = tracefs_start_creating(name, parent); struct inode *inode; if (IS_ERR(dentry)) @@ -543,7 +543,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent, inode = tracefs_get_inode(dentry->d_sb); if (unlikely(!inode)) - return failed_creating(dentry); + return tracefs_failed_creating(dentry); /* Do not set bits for OTH */ inode->i_mode = S_IFDIR | S_IRWXU | S_IRUSR| S_IRGRP | S_IXUSR | S_IXGRP; @@ -557,7 +557,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent, d_instantiate(dentry, inode); inc_nlink(d_inode(dentry->d_parent)); fsnotify_mkdir(d_inode(dentry->d_parent), dentry); - return end_creating(dentry); + return tracefs_end_creating(dentry); } /** diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h index 49b5e8949e1c..f0fd565d59ec 100644 --- a/fs/tracefs/internal.h +++ b/fs/tracefs/internal.h @@ -16,4 +16,9 @@ static inline struct tracefs_inode *get_tracefs(const struct inode *inode) { return container_of(inode, struct tracefs_inode, vfs_inode); } + +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); #endif /* _TRACEFS_INTERNAL_H */ From patchwork Sat Jul 22 19:36:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322994 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 BD3EBC001E0 for ; Sat, 22 Jul 2023 19:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229551AbjGVTiU (ORCPT ); Sat, 22 Jul 2023 15:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229625AbjGVTiP (ORCPT ); Sat, 22 Jul 2023 15:38:15 -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 04226E71; Sat, 22 Jul 2023 12:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OGq4EtVvodlCjdk7/OcQ2L5eWFoj+fFBinql67BAhBMBRNlcAgl2XGiJe0K8RWEYCpp3nNcIB55s80REnLyN/jdn9AM9U1NbA0a+cPLW3YGuTguyrXMmmPK4deScLcC2T+2C/v126dC4YtqLEoOeVktWvhf0T1aCqf5Yan6E1eUK/YuSgfzN5Vb23U0MpB6JyHL73+PGFNtoXdLKg+RiuVgcNAuNaN2Ytq7Ien228yoVKOkvhBK5MIIu1MG5uCThA8UVxbbc76qfQ5VbIBUOszsrHPbcNbLFmoBSy6REixMyKRswA2Imf2e0iZyQ3Qn3C+mGFXz/SGaiIuRtvK4ECg== 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=iCnnF7HmCpcAVudvYD3EPZkeHtk9ADrdcpxVzKWR6Rw=; b=WBUPr9IJkQ6hvXxlS1StBg5+CmrCZmIZP7fI0TV/JrffU6aSFo5BIa9kk3Kj7DTNgeRwNtK4bTkxflXJIqEzyaKvSb/pFKWsmaH5GY/55lJB1n7EzA5+J2JBhiHK3Lo9ofbdUGZ6b7UD2fcpIUacff/OMHxwZ9tuWJ8jal+8Vrxdk7Sj/mU37HI0xtpgII8uGqpwjLSmBpVW/hUkrYe/pI1SEoilRBXETr2750Wd0G9PuKYFTnsa6BY/P+gRoHpglgXOJAnvAe1kftgoH6AI1qAJmhscDcYCsjiADz7Lo1w3Y8IIJsOHm3uLEutJGtv74r/dlaCe83tm7TX720gUbA== 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=iCnnF7HmCpcAVudvYD3EPZkeHtk9ADrdcpxVzKWR6Rw=; b=BMZUs5G5soCNfLV7cDgMceE7h1IGy4b469cWJ1pIiTWvgTcaSRBC4O45BNX+4Irof/hWuS6b2ZM+eBDPdGZtjCL2xSxXnS9dp8tfTJ92RBY0Wmn/QyDf72V9BtT441DLvZ4XwoxwN702QwaxPveKZ9N8lIQgoofS1ijcRwYcQ+c= 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:10 +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:10 +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 04/10] eventfs: Implement eventfs dir creation functions Date: Sun, 23 Jul 2023 01:06:59 +0530 Message-Id: <1690054625-31939-5-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: 11e4a7df-895b-435f-1bae-08db8aeb2e4d 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: U7sO6ROECXKYAWGghfzJewykb51rAx0ZfNs1JCH5opV+4K9cyYMFX5yJWW2AEhL1SaLS8VX+7voKfR51jBG6BZMhLU2JQhGMBX5Pt5jjIDkxW6pbj99oNWL2c8fFZCpDuPSIldv/5ezKsaJWsln8CjDS1kS6LDux9TL+dnGB5MpnBFM14WeQUR4dKBsW5F/Dlqk3BWFuvq8MylEoSPM+Kl2JcnS3GFl9FEZ/rr11IgMJZZKhywc4QKsPfgPmBPm6at30Tfe253wbnd7/zru/2RjxTVeBG4m+Ld+U/5DCZwis9HKebZxGgebNKE93UA12SeAAspWrHxLtrOrYHba/5/oiOlm0Aap92AxGuLJBiAw0xeSHdJ65dkTGQnZrYE6KsXiXV0ppKlHkbo76a7gO0sKEd6sXnqZAlUVmVl8yqVA4hmKaTz2vk9YnKl8PWs5bglB+ch1pxa/V8gLDSauIp7LjsBVzd0uEhZ49wj2t2hY+3b9IZA6hs7MJ0LVUwgRRdpkzZjwUDb1isoqU2ooM/5XeOXLF5n/u330flOJ8y0/2qW5WsKgi8yTmEd7xcjAagu/RYZw5f/k2vxpSMOZ68yqiGo/soiPbUVHkl/ANrEzN0qlSAJ4hmWiQF6q3LnQfPs69g269bXRFb8Si0zAJluC06776qU11QIPy0fFO5Ly2gTvFr6f80PbTsbFEbVUmG63y7gTEzmyaUs6VH4bB8Q== 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)(966005)(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: NKbqaIsTIIUD3XUNGVCLyrPrkkE/pK+b0oTnSsJIYrVPTHKcXyzGiLNyzhkD6Wh+hpe5Nj2HmS30/g/Z8v30tRGm3Y8u8UNmgV1lIF4li5qjUp5vKegmMoPbCMEiwyvU4eLgi/WhlQjbx5HuQSIqbxNF1Hb4JatcCpmayquwNOknRjD6gpcgP1lsfILFN3yayu4eEqQSBu6jMEv73RevwbDGdQ3pTW8Wp3BdmSN58o2VF/OD46POu1+5ncQwe9Ef7cQXeghz9+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Fz8bVpLSlMNjVcGipavmtUjOnsoPm82P0hx7YTRd8fpSA+CHEm/i4qorJdTSqdFz4HQKtPPTEtuRTkf21FIdgXhnctgon1ZPNd2krNOduk3WKbYTIlkoPPuAEwcehBjdjjf03CWPnWfKIQ/kV4TdQamxLjGISr+YWZKxWyTWTsDv6FOObUFCQxNikHklqsZnTUcoNY2AP/3bmURstFeyAr08wqgD/BC8BQnvqbyIermw1eWLHlm X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11e4a7df-895b-435f-1bae-08db8aeb2e4d 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:10.3699 (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: 9ZRd06B/1ANclkOmvymm3ud9pyCYqyVfIVuY029oXr6pmTCbc8wE6xF8mxlsLJwbsqahl84MwZsl8qp5z35whA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 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 +++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 11 ++ 3 files changed, 223 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/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 Sat Jul 22 19:37:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322995 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 DE465C04A6A for ; Sat, 22 Jul 2023 19:38:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229681AbjGVTiU (ORCPT ); Sat, 22 Jul 2023 15:38:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229477AbjGVTiQ (ORCPT ); Sat, 22 Jul 2023 15:38:16 -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 7808AE79; Sat, 22 Jul 2023 12:38:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gBL3E0egpdO22eSUyornl3G0iZ3EXl61irkyEXi+jW0WKRqvzj95Q1rL0IwD9bkUytS0ERAIWqt9lVYVpU0MKKFuVqkp5NeGyB7nscz4RPHnzTLP/fgdv9jJ7qsfQyN2LwA8+q9mTXiQ3agQp96yd2L299kJS9lc+XphQfr1NLKox70uTbSi9qKnBn3BGZGWPbCwXqLSzohaMxReKrd+Ix3CaOsn5GA9CJ94uixtcOIupSS8fDbWvBcY+KSVUvbixOPNCLTfBERG/vPy1JGqlX77fLetK3msfMf/+lkYGOl2f4AwD00auYHrQzlFJ8zo9eF6TacSPZ5adIk7sQ0bFw== 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=RMrfZpD+/VgyMNu5S59jgiJp8+d66EeCuVSA16vQWxk=; b=Jh5jws7/irnrW8MKVJ96NYP27ofFQu34MQFACrms5oryxxrxPuUAxA5skAULzC2IUp/PBUbagnK2SGI+ArQZZYCtnrsKyLPrS9Ox/x+ziDS4tmGrlTo09zM5d6WpFB0aoAF4PvnARC6bI8GjzB12HBD+6r8Jlof8EvxH/hEepHllOf0wAU3NNRyN5jmSgVouWPa4mcOpsH9uXDLIndAeSNc0L/XmcsvYP/67xVmboNEzMi9qGJug6v5ycX2q+sD0VJ8NZvVsTpuMkp9jcWYHEAHuAhsbJ/K5Yj5dFzDLChmIRtsEFiKrXrPtQptDSyeZNkeSdoZb6ootA/9HEgpD4Q== 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=RMrfZpD+/VgyMNu5S59jgiJp8+d66EeCuVSA16vQWxk=; b=x/YVwJ85EFcEkmQJ5tI4ngF7U/mvQMG4O9A6jguBmZXq0U8p/YEGfvpPFNOaSdbkxf5ocE7m3yBRA1vQlSwFz3fl0npm4fnJUEaTQDK3qlEAvR9Zfu0yAx57eXIucENvJVvmEb/I+OKm2DFJwf9soVB0kLuTs2BTZgT2KIfmFnU= 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:11 +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:11 +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 05/10] eventfs: Implement eventfs file add functions Date: Sun, 23 Jul 2023 01:07:00 +0530 Message-Id: <1690054625-31939-6-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: d2afaf07-6057-41c4-a904-08db8aeb2f04 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: l4UgtIG64BScm8xUfIap5RUr1T1aPKm06DS4PbZcyFbV2gcz8MlXC32Xx+wDlrSeT/8Hu3UG8niyiiqNwo3pRnfA+Ac9mHhcUbzXI6M0+stTB1QL6tWI6fP3ymKU/TSJ5MiOYoG24D1clgcFVKucVvHKgJXW2oT2iftHNozdmqj8TALxZ8uCXoaPXuJ+wvemYA2g68j5I4yI+e88AoQJM+OUYYhHkkZ/k4/jECvtl0T4igijR6LpT2SjOeEgeiLBrJ7wLhQ82EGlGbYuiUXgAOsn1Bi4deI9Cr/nPZAeaBth7bv8b1d5gOoCBEfnQ/fYYoncuz7gWFBeFG/L17+H7KD/ZOrrdojo6pX845QwLWpALyj1LIYpHAJwscfWyjTVVa9rHKVHid2KGkgGFEuBJtSdS+9xrcifZpGkJ/5K6BLhZdoYNd74/MdtfZPcFHpRQx7BTL4i2OfVwbjbFfjby9FQFv7xWMxIVSQgjvuvz24N0WL+OQ9VUfnzZTH/4Pb64I1kLBMmacVWFEPsEnDuVfqR5FlawtY1xedhTmnPUt4nFJHep80vFqZX5hXrKbOshq1HMqE0jRNV8mh1z/kTz0MRg69GEkh1Gt4Ktj/NP7saXbrcwJ8JNEg01uR3QFuERhUY0Ixg2neouNqNs6B2o3QKlVzGBR0hZvlz2gW5p1En7CE8lLEGpqbvCs0h9UW9LkBzoNagQGRhlxCVoAt+Tg== 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)(966005)(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: kfOIg3zvq1EGDKE3QM3rx7fPVc/LLeMEUQ5PaYJPHnuTo4+6JgsxIToLQfPQbCp4MgDSWjgjkdo9GReZaTuIzrdQEnjtxtbZ/gpjMTFG8VfQhoWeU5XVoxyTgFo3n8Vak9Y2NW1ep5gGoQhZ88wwQNUbBwG0ZnqDHMT19ZOoiK1CQbaTUUpP+qVo9D3YxAe27JRlbhqmwa/vidEK0kje4labhMpRoxAWid8pWoah0HDci4ruS9gyofnelat4yC/V37wVBmPwJCM04exFo3rUDI8wNR6IjmPp64k8QZTLp4CC8dW8Ky8rSh2WBTkjGTeuMyk9QZH5ynHiXiOY0aUkHwF/tXyaqg+m1cQrxdAF2U66VrGXfIK+1APbuIannDdkePpl0rDWgHaQuIvjR0k7TDpEa9q8ByPu4dI+mJKNcMk5GdOz47f8l+KJWSfafcpj1I6743EIzYBbG4fAI8qGqAJeoGaVVwpMteBg6UL+oSY0Q5XSBFJ6X1RXHs7xt8PErHkyVbTsvcNjcA5Boq+TczpiO+3LMFzDF3BKKzygAvmKcymrDM1L8jT8vtTIE4irepmmb5r/cDFNPwsd37QEfwuVhRa6idQx+DMNn+FrTQmOPDjLU1f4xeEWjSU5cHpZnrIkygqy7zENuOct3CFyEpD0IHgj0CjCpAhXtunij3oeiSKjwopQzuDtyaPMG7qqEhKjvSxmXkkRk+JOvQtUBjNuAYaENPxbPfiNf8R7iVT4p831kkBJNhguyJdqcpH2cDOh8FHGSExFVRZeiQTuwAKoUOZl7ZjEyG+PXRJ11OuARaEvTYXdM8ixfsuEa6znpRUeg0sMfJqwc2+RC7tY1uCt9sMUELI3kJEnVjE/u1SRj3/C/mYDOHvthRM0kdEMTVYegCcbDv0iKVSn2P6bAR6QrenkpuAUdZNxHxDceDAWc9BNy3xYOz3jweHBrAf6Tu+w70VUGn46VATOvEhQMNbuutCgFVK4MqOH1mYBAyZo//BkEHdFiyXe6Dv1Har+tC7j13DILTjx7SxsN1Ig1lVRsfn1B75JWfCuv7dgdLPJjAtwgPTqNgQWGbZvlQaAmCpML/dBtsVCuYnQsTmu0HeIErhu1OSSW1qTNHZoWZd9ZKrYJvL36AfKgItQY3CPjKx92NjVqbz3RxBwZHiY1SOGOPkDU/HqIFvEd3Ms9KnU/lUg+q/cXtcQ30IxVndgR4q80xpz+4BgZNfO1Let8sEkEeO7YoivB3ZYz1Auo9sMTVTaVlyIvEGGxRaSPcX4JbCEa4fD5M1cdLPbKAD07F1UYnT99Fsj7GbHYkjVebk+PWGU+6qdvJmqHcrI5RqtNGX4Dy4UqYAjPZHf/sI0DyJr1nMrCB4pC+HueCimgRc9ONmjGvXRFO9gfUgLO86kKj8giqyKq4vGJGmaHGq9AIZrHKcj3uEMS3zz1kJes4SCfoEyFf7ctFB5LYinXPGQlHQXiHMMCxiVMGq+wJ1XFvBnvhnsLeV+j6UlIdmldUEoMWuN+SbOF5p3m9IIltEXEPRJA9WEFHw3z++RJRQs0IBOLjqmHyC3PrES4Shvo1ag1jo3JxZi3/Efr+ZXZfq9 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: d2afaf07-6057-41c4-a904-08db8aeb2f04 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:11.5256 (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: ttKTbWmplxRQecU9FjZoJUxvwXSL7cteC4w9+6ZdG31uSrUT07+Qbq82ykJgwTXAZB6lYTlIQvGPXRJvvxfUTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Add the following functions to add files to evenfs: eventfs_add_events_file() to add the data needed to create a specific file located at the top level events directory. The dentry/inode will be created when the events directory is scanned. eventfs_add_file() to add the data needed for files within the directories below the top level events directory. The dentry/inode of the file will be created when the directory that the file is in is scanned. 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/event_inode.c | 86 ++++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 8 ++++ 2 files changed, 94 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 8f334b122e46..9e4843be9dc9 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -209,3 +209,89 @@ struct eventfs_file *eventfs_add_dir(const char *name, mutex_unlock(&eventfs_mutex); return ef; } + +/** + * eventfs_add_events_file - add the data needed to create a file for later reference + * @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 function is used to add the information needed to create a + * dentry/inode within the top level events directory. The file created + * will have the @mode permissions. The @data will be used to fill the + * inode.i_private when the open() call is done. The dentry and inodes are + * all created when they are referenced, and removed when they are no + * longer referenced. + */ +int eventfs_add_events_file(const char *name, umode_t mode, + struct dentry *parent, void *data, + const struct file_operations *fop) +{ + struct tracefs_inode *ti; + struct eventfs_inode *ei; + struct eventfs_file *ef; + + if (!parent) + return -EINVAL; + + if (!(mode & S_IFMT)) + mode |= S_IFREG; + + if (!parent->d_inode) + return -EINVAL; + + ti = get_tracefs(parent->d_inode); + if (!(ti->flags & TRACEFS_EVENT_INODE)) + return -EINVAL; + + ei = ti->private; + ef = eventfs_prepare_ef(name, mode, fop, NULL, data); + + if (IS_ERR(ef)) + return -ENOMEM; + + mutex_lock(&eventfs_mutex); + list_add_tail(&ef->list, &ei->e_top_files); + mutex_unlock(&eventfs_mutex); + return 0; +} + +/** + * eventfs_add_file - add eventfs file to list to create later + * @name: the name of the file to create. + * @mode: the permission that the file should have. + * @ef_parent: parent eventfs_file 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 function is used to add the information needed to create a + * file within a subdirectory of the events directory. The file created + * will have the @mode permissions. The @data will be used to fill the + * inode.i_private when the open() call is done. The dentry and inodes are + * all created when they are referenced, and removed when they are no + * longer referenced. + */ +int eventfs_add_file(const char *name, umode_t mode, + struct eventfs_file *ef_parent, + void *data, + const struct file_operations *fop) +{ + struct eventfs_file *ef; + + if (!ef_parent) + return -EINVAL; + + if (!(mode & S_IFMT)) + mode |= S_IFREG; + + ef = eventfs_prepare_ef(name, mode, fop, NULL, data); + if (IS_ERR(ef)) + return -ENOMEM; + + mutex_lock(&eventfs_mutex); + list_add_tail(&ef->list, &ef_parent->ei->e_top_files); + mutex_unlock(&eventfs_mutex); + return 0; +} diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h index 432e5e6f7901..54c9cbd0389b 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -32,6 +32,14 @@ struct eventfs_file *eventfs_add_subsystem_dir(const char *name, struct eventfs_file *eventfs_add_dir(const char *name, struct eventfs_file *ef_parent); +int eventfs_add_file(const char *name, umode_t mode, + struct eventfs_file *ef_parent, void *data, + const struct file_operations *fops); + +int eventfs_add_events_file(const char *name, umode_t mode, + struct dentry *parent, void *data, + const struct file_operations *fops); + struct dentry *tracefs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); From patchwork Sat Jul 22 19:37:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322996 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 7198FC001B0 for ; Sat, 22 Jul 2023 19:38:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229609AbjGVTiW (ORCPT ); Sat, 22 Jul 2023 15:38:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229668AbjGVTiT (ORCPT ); Sat, 22 Jul 2023 15:38:19 -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 DE3CE10C6; Sat, 22 Jul 2023 12:38:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZwSq8VfyNqBm0A3xaAGf7mVUNO4cck2G1mbhhqpBX77rYAXeiu7Ryjc+3gaTL6/DTv83yFFydPkfAyjzshrBapZRy8R7YYsk5q1tvNlP+PGISjgbMjEJSs9dIiv8omNXHZtO0w5AYQB1htOXd7sWOQB8mzqnAwgfWddBBswcYXPTb3ASfsXCJK66uwldTkUUpUQcbxqLQCzY8L8QuBYkAbXpd8MJnDj9SXDJKg8DiX0+hhncFa7TIj8IRamK+hKSjjCaLPlNViNlRi0sLdKGIZzxrG2CfJG2/FvuS53/5epGJURKCgsCpn4xCnR8pFtNAw8XHWFGpm0ngTu1+s27Ow== 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=YOtqtJs8MLO8UMW6/gM93XTEUi9kA5V5H9NcrDO1YAA=; b=k+v0E3XDkpp4+05FA6gROkRldEH6CJlDl8aEiBR4egAPsqBPvW8a7nSorW1c80ZaHb+fKaSqgKpwszKTzG/vpKVmxODhJC3EbVrNH6LYrIG5n1zsvV6eSxbUpc7DOCmoYk7y8PWgAuVFeTeaGgcznqRH+0Oy/eX7Z7Fzh2ujlEHHOFbU2XA4xyNGHBN7bX0AlXT9wHVgmnXwSS2hqAH3OPBN06FA9lJr7FaSvJuDBI0BLVFXT+q0b8tN5gicWlOpt8991HWhTX2vGwsGIaSLSNHsoYXCdlLg9Mv4bk/wKEYJrVAfNDfDnLw57Z6Kf904SRCdbO/HFxM/R3V2ThgUVA== 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=YOtqtJs8MLO8UMW6/gM93XTEUi9kA5V5H9NcrDO1YAA=; b=yCTXpWifJTYmf4WhZ4g/qm1HWwMTO3ZUqy48ug0liUL8migYhEpPXyCip0lyKVkWgYor3IEWi0yEzd0CdcwFb/RnsjqyD5Pl2nVH1r+PCpug01NPoV0o6CxH8z6UgSNmNhKqkRMGgMzQdzE6BdRYPwOcFbuuNVv/Iz1UcWpLiAI= 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:12 +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:12 +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 06/10] eventfs: Implement eventfs lookup, read, open functions Date: Sun, 23 Jul 2023 01:07:01 +0530 Message-Id: <1690054625-31939-7-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: c10f742e-82ac-4bbb-6dff-08db8aeb2fb7 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: 7WyepY+3g77jQrfp1iK9Ui/am7LL1O1D3goitreJ2zKu/uvWMuhYXTozx/i4qvjbEv25uTdeMW7CIzmXxQgD9R6Wi6NQSoFK10f1c/CM/Pw35zuJpmGU8sBweC/HQ1wEtZFZUU1+xXVxt8JDg1ByRRYSB4fieXHrG+1TmIF/hF4HemPgPLbzk6b8INYJbWpZ0QUC5Bwqkn4pAf1KVPlNCwRli2atXyY5HVAmtL1Tp5WM1RBiwwgJGvsxjJQmle96SaZOXr+c2YmHbpBjq29jmEzhCrWcx58Z5bRoy3e2Eq4P7lkV53bMRK1ndnE0DLzWldHJttBwvLnV+/y4dXFzLZSO6DQ1vRo+N0KBrTqnG83XiCNB3Pb/q3ocET4rJIg385PvCxY13ICuZEtzWD5jUod6ND7StFFOoVDAtmTs/ZwYoJJ6ato5hwI8psJUeji3r1YOCUXQEedqbgWeVHilbZ82XDVkn53ow6S2c2tPNCRFkeie2eeezr9WThC/STqrup0SWU7+LAe1GK+Y9/VhFSqRfvvQ6GtGRs6IjpSEr+GR76oDdGIGBsJ+kqw57/XfssgQJi/pPgyVyKDTJzJk26A+nDtuBpjW7KTtI40xA9vUmnj9MScfhblMK7wIf3Hi3iZ3JDs6g766AWp/Qu9sUmuWblmnGjMrmYvoJoFAwLQ= 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)(30864003)(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-Exch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x12kOEFgcJBHkOs2SRE8BuY9Q4qUJx9PSVq4s+yl0FeoNJWD1qpEQ8aJS0kyk2wulezJnMfr8ui6t8X5q2JXJmWA7gsKubeVg6659zig0TLjTc+lkekZdl8WziSvqFJl1CdLHVIe5U6Zz9NFXM84LkehnNZ33Q1ndJTxahX16jTRVaOM1E0h+bsSm86Mudlrv8V/sxh8X/uiBO6DCHGyRdCI8CSd53zaKqWz4jhUNWk2JzSH9JWvf1Kpbadpx/b0h/yLkuTCO4WmwH461ay1VbnaR2WKuDEsk5nN1JwO+B85yXdG3wPwNcPC1s+4uu+CbmkAylt82nhwwU3rEDAWs0Lx2TGnr0wiH5DTZsVvCp+jUtV9cxOIlDhuxmN9Jdz2EHTF69ba2njcLXGQAyrMm3kOLt8+enQJ4O5y6YIgDdUwmoH0lZZfCIS2SPaTNirnMpIoxiHmOCT8bCPbTKXjEzuvLGPQGAUO46EoFGgWm2BiBFms12Qia3B0iGjzkESHb1LlzCchSuaTXdi08XNRBT1TX31s8gLTROKDSd X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: c10f742e-82ac-4bbb-6dff-08db8aeb2fb7 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:12.7123 (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: isJVlWwIV8g3J3hhhUSZERxs7ieXOhGqKY4A1o6ZJbEdVclt7Qo0zJuQSc0qkOx30EAt2Akgfbfn0HE1ZpX/5A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 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. 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 | 312 +++++++++++++++++++++++++++++++++++++++ fs/tracefs/internal.h | 2 + 2 files changed, 314 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 9e4843be9dc9..a3c1b8bf7192 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,328 @@ 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; + + /* + * If ef was freed, then the LSB bit is set for d_fsdata. + * But this should not happen, as it should still have a + * ref count that prevents it. Warn in case it does. + */ + if (WARN_ON_ONCE((unsigned long)ef & 1)) + 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 +487,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 +515,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 +564,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 +603,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 Sat Jul 22 19:37:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322997 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 9BA23C04FDF for ; Sat, 22 Jul 2023 19:38:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229656AbjGVTiX (ORCPT ); Sat, 22 Jul 2023 15:38:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229483AbjGVTiU (ORCPT ); Sat, 22 Jul 2023 15:38:20 -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 3F0FA1729; Sat, 22 Jul 2023 12:38:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WSdWTbIU6OHfMdQWixsSnrekBm/oeRtn1zhR4IU9zad2osmCbJ9fS44CFanog25qtezqL8uFQUnjlj9IzTe/URDmJHCj9z2VQHMaWYmgvxBYe8HFfhZ21Dm+6jhmiVhGRvJTRgG2omNpPiA6tSWmd4seKqbCQTiicUizlEmLNMkf77KJaiF+RG7PHinV7Mx+zP8wSiFxhFvj8QP3tT7wWvVR0bo14RxQ5Fl0M9mtEt7bAP8TU7A2rlKXH9ktNelykFwNefeDCHv82kR1Kdmet72Gr5cD6pZ2I4yOXsg+XL0/XU/uNO3Bu13Iu2HMhS6TyYp0AONb7yzERzfLXpEh+g== 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=tlOVHAEMMJ3T4ltouvj/h6bm6UkWmSFFTtpIqzlH/LE=; b=ib33VbQjdvwBqCq9l4oE3TH6S0E5TMnhHvg7M0Zhm8Jj0sCJVOpvK4EP9achYzGDn/89LgtbuPAU9Zep1h+qUpewqOCQWmcfHxy5dxKYv0+qjlNUY8r9yZ7HgihOkKKC3FuuMiyMQuneFySjGi15M6eGmDJwQ0j0y6o1GJdOCg8PKv/QVSVGzefQVUSG8sLgM1Xn9K9w90MnJEcSZ3RIblBeB1s3zNhTJU9QDlbb+VK3VbykrCWn7iJ4MKVnZYfZsIy9BlFQkiQxYNy9W9kXSB8LcPq5FqAOO4pdFZ2GBAoDl9BKUgr6/0QY0n6xLy2OCZsaV04D1C2DW+hkUB9udA== 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=tlOVHAEMMJ3T4ltouvj/h6bm6UkWmSFFTtpIqzlH/LE=; b=xlie9hCbBdIbAhmk5bFiU1vb9PZfneXw+NS1LphVNSTQklh6zGrMXMeIKaphMPkitcm0mYXKqd10C9aoSHwXz+FE6m20BTaGK1mCNq54ScANNANoq1q+Xxw/NJ/nJqYqEZ4nDpnSiYL9IHObQ6UlcQgcLzQoZuJksE3xGpPQO2U= 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:14 +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:13 +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 07/10] eventfs: Implement functions to create files and dirs when accessed Date: Sun, 23 Jul 2023 01:07:02 +0530 Message-Id: <1690054625-31939-8-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: d543070d-006a-4f31-d3e6-08db8aeb3067 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: VMH24bYDHZSk8VNSdKbfOWgxZGFPOwh2bMc5kSDfXX7xGA0kl2EkPFStL7tL1mdA4zZBVWNjow+rb7QMrG4G4UHtWQSBlTyFCOfrSxJ6gcwj4gNaUbanoUuEJapuhVbPZVhTUOShvu6uPhqXUhZmFsmYTpQraSq4rcl4hiyOAkvj74VF5+wIs/0ay6dp03xgx6OC9q0jYq/sXxicpuzULG+xguAr3AMvrnKJcoyg7Cm9WoXETaQoGSwheu+XPnvn/kslnq5muOSARifG5UD52W1PVOYRjzy904eXJ4ClVsME2cwIDDc2UxvrDYrXR3oNArmQ1V9EcgLTzLCTTZMJxJFYTLXW0jgsjGXBfn2+IWypy7sZ7ZR3nRlh6eb0dcoQ6aGlCB8JFRNKF8HTE9lanqMVHJhRpE743nzJYkOwj0wm9I55iBEfA83aYK0PUGfvGL3puIbOTYQeZkx4FQonjKe6p1kKKd747CnYbvQmYLnTjqDf60ebyccgzRKCpsYasi8EbT2JIrG16KREP/qZFdXX/X/M8v21unCikl93MnqUgeQ3posnr7kTHQwuuWamHO/RIsXrnbGc8iEfBfwxf7Arcfh5FVv7N3NUlhkfLNEytSyrMvEJ21+T0qBrro69Ias+WOgGzdyPpAGTrZ0DTlwoFcQqyLKirjgYHY2bjOo= 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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IRl6CRkW0dst/TtuJOhxdW7t5oOcvn36+C3JR0VXoyHPW+aBJtJx39u5K8E0/iy5R7uwGe7/bDtVFlIS8Dsiw0SNbSTT4FVzGCDl9RUdiFC96bHsNdktdl8ZXRuwLPChnTkOupkWn3N0Jed5GhY7GcGTzQ8TMxnmHQn/s2Vpe+ELN64fO67MOdYCRtjcoBDZeStXx7KAtiGGtrrfXjJj0s0XIdAWIkse3REugyryBHgVvHT9KJmXFxKo3wbvWuy0eN1bdWALtd8rHtIO7dqmoxq7pIbRjuNSGmANb+lhZTHUkUk+onHIxydImVvsjzPyVYciMj5kj9CCtpdYYAyXxe309R5rgLarI0untdjXoTTwN8ZrEXFc4/B4y+CCvpDu/Hf20Ax8cvLz8b9EOVM68qw3LedI/hLxKTTeesv4XHj+JgkPOcbX2mqoO08jSIHJPgZ2w54swdj9CsTUoxhqi1WyxQ1eybnqmsyvRaFlv0MOA/rkJQ7FHjUUKEM7iIQh/G5F/Xqhr0xs3xB86VrW/f5KartUmrVZRuec7Vm713TqGr0wFKHXyNT2npOGAMqmvFeFecCADSgzdrFazauycBpsETsghQ X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: d543070d-006a-4f31-d3e6-08db8aeb3067 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:13.8631 (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: D0kK1Df13LbMse67JzReL1rYxHM5qqWf2tjRsB7BnlGI5i7C2CxZXP0ZrnU08T5Dk/2Fsd9xhKJAbbwD+z9i+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 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 | 55 +++++++++++++++++++++++++++-- fs/tracefs/inode.c | 74 ++++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 7 ++++ 3 files changed, 134 insertions(+), 2 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index a3c1b8bf7192..af70d6ffb923 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); } /** 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/include/linux/tracefs.h b/include/linux/tracefs.h index 54c9cbd0389b..cdb21d63a127 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -23,6 +23,13 @@ struct file_operations; struct eventfs_file; +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); + struct dentry *eventfs_create_events_dir(const char *name, struct dentry *parent); From patchwork Sat Jul 22 19:37:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322998 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 77F73C41513 for ; Sat, 22 Jul 2023 19:38:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229727AbjGVTi1 (ORCPT ); Sat, 22 Jul 2023 15:38:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229684AbjGVTiW (ORCPT ); Sat, 22 Jul 2023 15:38:22 -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 92A5010C3; Sat, 22 Jul 2023 12:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KB33Lg1QD8Sil54cLLBaQn6X5EiE6akaPZnruNDwUXfVwxHhV8OPvZuHSkDiZYQIRfEkJrr/sfnriis0MENWN8hqW3O43ZgJEWRX7JySMGVhVEA+SV1amkxqQVTfqrrLoWUHX4ae2TCNGgg8bhmQJrvPtN6MlZJH5vhMYfWym7L4iQoOx8gJdVykc5bXNHPHoUoNrd3LBM0JmFCTqvFE+5rhn6/rCqWzr7SDMR6dTInWVhvBnH8tXs+jb70xsA99bGFzzAKAss55jR9CZOiFXhgnDAcCdyjPfQWtAFIf0mGtXRiBIiPcxvMGf0uYXem2+cdzRKBF+GNlkCzMwqMRiA== 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=Huyy63JsflVJ8V9KkJcwW9V2AQaIzlqWfzoZVmQVpB8=; b=K66KmE1n/fBMhtdnDhiFh4+9NNi4y5SSEauMS8XsglRQuIAIEhAz1ltDFQNkXqlYEc8iPOiRqvqCu/sL9cXqPCBMq0ZWppEa82PyWaoFlJMCNcnqdiMGyC36i7TvEdWFta14S3xTEMEu1h8h0tDvmL4tWqCaOjkkYDp0hcgXPqmr2OTLP8A93l1htfru5Kh+0no+V72HIDj8G1CdJmrtFkeNZuDB/zTOlDzOMuTE9z8GpcGwX66tHz7HnY1K0JmYpsvRGIle1qBcM2b78y6lR8gUU2d4tmF5Tt8SH1h5PatbzLGak7Kv1R41RAt9vKWIBkdU6VrDG0frcS83y9BTdg== 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=Huyy63JsflVJ8V9KkJcwW9V2AQaIzlqWfzoZVmQVpB8=; b=DZxexpTwh8nVmzm6JRTJhDzg1yebaJbIv0TaNrZ1nO21E5oDlgJNJw2QX0JwkxxfAJypbNco+KVFRHaGyRdTS1aEQIkz9Zg6weBAA5BR6R9KC+dhTu6EkuTXNelqamQuRr3ryMZ4I2YB8M/Lqz6S+wCcoL2yw9FXf8w3eO2SmXQ= 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:15 +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:15 +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 08/10] eventfs: Implement removal of meta data from eventfs Date: Sun, 23 Jul 2023 01:07:03 +0530 Message-Id: <1690054625-31939-9-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: 35b2dac3-1680-4ae9-9c0c-08db8aeb311a 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: VgCLRxag7TKyafJOAre8O/hcOy6C5mFrlZDG3k24afp4o/A980/uE3YD7EGw8B+i7RhMgsAjPneW9ozYDWjQxsyjjuK9sBSlVUfuPiWcbtS1A6RGALy1H6BVj9pq+cQNR8093J248HTIPuVsypKhhIAwIaqmnRE2bx32M/PRoDpL/3skKmr/R+OlK7NN01FFRPq2eHG81ohctixyJe1oAoqBFwcPx740up0dpGtmZ9iJOc5oJspAl9iRU9f3BhmJHd/W+8RtEfHpqZufwrE0288a1NRVX2XxXpdILquRZQhorxhIs55Dw5ex3AQqRkIoFwFB2ZyOzAt3bAJJSGZ1Qw9xFYHo39jihbNkUqoTyraT0L/zpAJhxjNLDrrTN6seutz7VzWJebIe8K0P4ykXIm2ilOaGzSCmV0F0mNaeuIgWH5mKhumfdT+T+wNSvJ2mwAaNJL6asakZSGOlTA+C+X8oSWgKfBtWxn7dnJ29ezoPLEt4GsMzbTmOERtC4XxBYgPtA2WGsZwDeUTSC2ot6OI5k9NUFj+9oAZCQ/UNS0TJ1q2/JsL+jYY67Cl2s9yAUE3Nsxgmd9/ZTbwN1rrC7n36WvlTNLcuELW3EaeVEhf5lysoXN2owMbjXEZNwy+/kC/qQDdx+ZSGz1JuN4pIKbHPCtrNtYnsQdw/aZs7NWKbvRdx4t//un3GY1AodCtGtOBhiVIX77zBYBdNNP6KEQ== 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)(966005)(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: UrvX+TExv6GZlWOQ7IhQTapv3Zh1F3zzEVJ8O4qylOfGk5nicqL2fmep2kQlIvYFO/JZf2NceUPPw4D8hisI+R4Qr8JiTFASWIdhGtoe87UAj/9GODh2Eyo27ju9u5zOf8evnPn8fGGtds7uKijsKB1wgocD8jf3f5U819zKXDplHxsp1k6DyAIQu1rvD2oLnXnOhtWbrqrpJhYQjMWBGNynnGYySgm9wJc7mn53Nb+/M1f+ZQua2TgNoFITE50C/kI1gA1B8UFNb2ZByW+HHbP3DNQZuPFrGOeRm4uuq6WFx5nQcz4p6lDfVkVVW/BA+7mf3o/SIOo91pR2Zc6Dv6K+iWR9SRl1KWOeNPGdvzliy2gtE4vpiXLULj7FnIFCpf+gN+Vjoef1iIRbyIklvpFH8xS9czFJUwhqVPiamruZfJw+FvoBkbka/fzafsmgbxI6r14omoTRkCeJ44B/DDQvqEAmVQlh3/AUzBZsZXePbvMYiWuzNp6KiulzhxEnkbXJMFCyjX3W8XC0v4ZhBY4TSQNriFLARB5/2YkF+1KyX8ERBOfNbK2h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id: 35b2dac3-1680-4ae9-9c0c-08db8aeb311a 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:15.0268 (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: SQ50TwjrWaRJrQOJ/yfp2ptUgFVblxigj44zeFS9UqREIC3MUl75qDtCl+dh+FphSZLyt2xfkp4U4PJdmPIT4g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org When events are removed from tracefs, the eventfs must be aware of this. The eventfs_remove() removes the meta data from eventfs so that it will no longer create the files associated with that event. When an instance is removed from tracefs, eventfs_remove_events_dir() will remove and clean up the entire "events" directory. The helper function eventfs_remove_rec() is used to clean up and free the associated data from eventfs for both of the added functions. SRCU is used to protect the lists of meta data stored in the eventfs. The eventfs_mutex is used to protect the content of the items in the list. As lookups may be happening as deletions of events are made, the freeing of dentry/inodes and relative information is done after the SRCU grace period has passed. 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-kbuild-all/202305030611.Kas747Ev-lkp@intel.com/ --- fs/tracefs/event_inode.c | 135 +++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 4 ++ 2 files changed, 139 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index af70d6ffb923..918a1973d3ea 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -658,3 +658,138 @@ int eventfs_add_file(const char *name, umode_t mode, mutex_unlock(&eventfs_mutex); return 0; } + +static void free_ef(struct rcu_head *head) +{ + struct eventfs_file *ef = container_of(head, struct eventfs_file, rcu); + + kfree(ef->name); + kfree(ef->ei); + kfree(ef); +} + +/** + * eventfs_remove_rec - remove eventfs dir or file from list + * @ef: eventfs_file to be removed. + * @head: to create list of eventfs_file to be deleted + * @level: to check recursion depth + * + * The helper function eventfs_remove_rec() is used to clean up and free the + * associated data from eventfs for both of the added functions. + */ +static void eventfs_remove_rec(struct eventfs_file *ef, struct list_head *head, int level) +{ + struct eventfs_file *ef_child; + + if (!ef) + return; + /* + * Check recursion depth. It should never be greater than 3: + * 0 - events/ + * 1 - events/group/ + * 2 - events/group/event/ + * 3 - events/group/event/file + */ + if (WARN_ON_ONCE(level > 3)) + return; + + if (ef->ei) { + /* search for nested folders or files */ + list_for_each_entry_srcu(ef_child, &ef->ei->e_top_files, list, + lockdep_is_held(&eventfs_mutex)) { + eventfs_remove_rec(ef_child, head, level + 1); + } + } + + list_del_rcu(&ef->list); + list_add_tail(&ef->del_list, head); +} + +/** + * eventfs_remove - remove eventfs dir or file from list + * @ef: eventfs_file to be removed. + * + * This function acquire the eventfs_mutex lock and call eventfs_remove_rec() + */ +void eventfs_remove(struct eventfs_file *ef) +{ + struct eventfs_file *tmp; + LIST_HEAD(ef_del_list); + struct dentry *dentry_list = NULL; + struct dentry *dentry; + + if (!ef) + return; + + mutex_lock(&eventfs_mutex); + eventfs_remove_rec(ef, &ef_del_list, 0); + list_for_each_entry_safe(ef, tmp, &ef_del_list, del_list) { + if (ef->dentry) { + unsigned long ptr = (unsigned long)dentry_list; + + /* Keep the dentry from being freed yet */ + dget(ef->dentry); + + /* + * Paranoid: The dget() above should prevent the dentry + * from being freed and calling eventfs_set_ef_status_free(). + * But just in case, set the link list LSB pointer to 1 + * and have eventfs_set_ef_status_free() check that to + * make sure that if it does happen, it will not think + * the d_fsdata is an event_file. + * + * For this to work, no event_file should be allocated + * on a odd space, as the ef should always be allocated + * to be at least word aligned. Check for that too. + */ + WARN_ON_ONCE(ptr & 1); + + ef->dentry->d_fsdata = (void *)(ptr | 1); + dentry_list = ef->dentry; + ef->dentry = NULL; + } + call_srcu(&eventfs_srcu, &ef->rcu, free_ef); + } + mutex_unlock(&eventfs_mutex); + + while (dentry_list) { + unsigned long ptr; + + dentry = dentry_list; + ptr = (unsigned long)dentry->d_fsdata & ~1UL; + dentry_list = (struct dentry *)ptr; + dentry->d_fsdata = NULL; + d_invalidate(dentry); + mutex_lock(&eventfs_mutex); + /* dentry should now have at least a single reference */ + WARN_ONCE((int)d_count(dentry) < 1, + "dentry %p less than one reference (%d) after invalidate\n", + dentry, d_count(dentry)); + mutex_unlock(&eventfs_mutex); + dput(dentry); + } +} + +/** + * eventfs_remove_events_dir - remove eventfs dir or file from list + * @dentry: events's dentry to be removed. + * + * This function remove events main directory + */ +void eventfs_remove_events_dir(struct dentry *dentry) +{ + struct tracefs_inode *ti; + struct eventfs_inode *ei; + + if (!dentry || !dentry->d_inode) + return; + + ti = get_tracefs(dentry->d_inode); + if (!ti || !(ti->flags & TRACEFS_EVENT_INODE)) + return; + + ei = ti->private; + d_invalidate(dentry); + dput(dentry); + kfree(ei); +} diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h index cdb21d63a127..166d38e6c584 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -47,6 +47,10 @@ int eventfs_add_events_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); +void eventfs_remove(struct eventfs_file *ef); + +void eventfs_remove_events_dir(struct dentry *dentry); + struct dentry *tracefs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); From patchwork Sat Jul 22 19:37:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13322999 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 36E5FC41513 for ; Sat, 22 Jul 2023 19:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229824AbjGVTix (ORCPT ); Sat, 22 Jul 2023 15:38:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55960 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbjGVTi0 (ORCPT ); Sat, 22 Jul 2023 15:38:26 -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 225EEE79; Sat, 22 Jul 2023 12:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oX1JeRb7augG5XO7TjKZIIBeTNoS9ttvBSS0kFWuT7AFiRxaIQv0E2XE9C/IhtxRcbL4RlXKiC+N6cLwazsM6EB/hqNNsE0bCnGhhhMMxmz1nsr0t+hkrOWIpR4HxEnV0Pz2LQQkXfEJq5sBIaSNT722F3vlOxNf//knQXVOQhYBedMmk/xzqWSbR735rif3d/Daj3QiFf6PCR5F3+8HujvUzZgZvIXgu5PLkl94Sar+vYOvLyAGUKOzxKL/6iF8ec1p+0F7649E0xebHh1NN4K5MjebNGfS0UY7RcKxvCL26bO8C+ezAdV81wND4ZB0V9cw0I5nmIUDOwqz1ceVtw== 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=3F1k+N2gh2hEJw/eY1SUF6bR19C9iVwStsiERKKGwM4=; b=AmMBWqwKRkZVKdiDLSMq9tSTPL+T0FX/AOyMdqNLoiyPFJESHE82trmbjHnTkH53N84P3WwBt5R0QZ08nac2U2rYF6zMTfPxKtljliSWAL7Xr6SPaBa+Y6iGA63DhAikrhia05SuYm8fN+CigRANrJ5sokCZGILh47BQ8q7oI57ZG3u1aB8PdlfML+vq80fP6dGi++TAKdd0Vfd+qk7rG9pqxeCfBkxo9Rvy3i1WHnXc9BmYcv+NsouH2LnIa/FOnm7s9jRCjittaHdcA5TErQz3xjG+NkQK06k6PJgs8Fyt8x5wPKhziRBNVL89p7bQYhj48Dsex9kLA/LdMgurTw== 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=3F1k+N2gh2hEJw/eY1SUF6bR19C9iVwStsiERKKGwM4=; b=o3ylPn8LHPp46x8Ze7OdW5iRlLIZmY/DO8F44nrEhgwbfBbI1BkT5Wam93vTcVivffRllobcJNbMkk655QnY8chj+8WBHGixoz4hQ/B3GQKtxUUYoHOzTnc0r2iWhtmMyk5lnMnqKoJjmBW8zSQEO9WOEdJaB/8VAhYaydqQFS4= 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:16 +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:16 +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 09/10] eventfs: Move tracing/events to eventfs Date: Sun, 23 Jul 2023 01:07:04 +0530 Message-Id: <1690054625-31939-10-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: 2d83a1d3-f8ab-4c54-9ff2-08db8aeb31c8 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: oy8xO1cDDqdaQVys6cLYu5YszdtvT9Ef94oJ586NIokvD/lyuYbOEuj7teeXBLts85lFcd/F1tl22sjrl+T/ZTM4AoHvT1IQLv965W4MWYlVtRV/CDFypL03KT4x3P5T8KwJuU69tQcXW7+AtaT/7UvmrT9PTwOe7nrwkZNWE/RsIFvTdym3p915zQjTkNhgMo6yaNDWIbJZD8QD9sZlS9N0PgGr+kRwlQZOoEZoR3nArprlXOlwKlH7vv6kMTOlxm4t+Zsdm2vDidaSocR0+CXUgRjEZyeK45Se8ey2WI05XsJvV82b7mjdymT/pR3ClqcHOv7OgcAbQ4+WiHQpUOZPff8VKCLx4Yp+8ApkxFQw1QvAyj4AGbON9wcPOvl8XCdz2EwADbJVRSSXwq4KBxLTxsWnGY8BQegzyZH9OQ3wbPi2USeao/ShIrn16BzuSnjYLfbWvhCv34NVUu5Z6m/fqnaoc22kmDdcniQ18ARcurk9JHu20+elLXaSoTiFxqPQF+t1hFo6F1CNfssrWP9dAuzJlnaYJBmR7y8Kth5k7DqWSQ22boz/ES+lew7CfJ3pPf0TRZzm3rUgVt5Z+Gz64RySPTGTik8od/vDv1bNmdrJovr4iUGJTdGUJhWUPhhrqBhHKaNwx2BP/Yh3DWjqxbpQfbtEpk3xsYA7t+4= 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: e4JrxSVaER4Vba8zeyg4mz0PV0TDjYNwfIrVdOxxadL0KpuAaG2VwceHuESZKIKpV87fdy2QfL/orIRiVh1XP6FIFTJLyL1eCZft/vUl20N+DIzvGM7rVpotqVB7rXkMtzNTK1+by0eAFopWQjmpFiGn2tzt9/nDtrbu6DE1jHI6eDoyWMyjiI68tmfaTcUMKBK8JCWYcuEYKSNgStPBVKg+TgLfuad1Gndd2WvKU1OB7viAygRNx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J+oQWd/b23R3Yl1GF6d66TkG4kgo+6APyEjX2n4GJIZM5LLtgT4ByE7jSp2ofay0KWy2K62rrcqdZ3ff0sgxISQJjjCAv34/mpGg6WzWvXgnDXfd29Jbuyh9ddOTkUZi8c5wJo25iV6Stl97D5GGoH9/efIeLgzOcHaBrjVoVJMsMgR1+TvUAU1udOoLMxgKZ7kmOiTKTXxk41O5WEXRWzJPVYYzINssXQa1BwM5hg8AdHDDVEeLR7WHGoCSHQRa8qk0ZGQRmaUuSsZ X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2d83a1d3-f8ab-4c54-9ff2-08db8aeb31c8 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:16.2250 (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: jMsIIXpGL2d2u+2juIRpC7QpiQc297vSwNlSjsQdRBYhB5gnGedObIIyL0ewQt4gBypTTDX9c5cMbjxU4MvSYQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Up until now, /sys/kernel/tracing/events was no different than any other part of tracefs. The files and directories within the events directory was created when the tracefs was mounted, and also created for the instances in /sys/kernel/tracing/instances//events. Most of these files and directories will never be referenced. Since there are thousands of these files and directories they spend their time wasting precious memory resources. Move the "events" directory to the new eventfs. The eventfs will take the meta data of the events that they represent and store that. When the files in the events directory are referenced, the dentry and inodes to represent them are then created. When the files are no longer referenced, they are freed. This saves the precious memory resources that were wasted on these seldom referenced dentries and inodes. 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 | 18 ++++++++++ include/linux/trace_events.h | 1 + kernel/trace/trace.h | 2 +- kernel/trace/trace_events.c | 65 ++++++++++++++++++------------------ 4 files changed, 53 insertions(+), 33 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index d9273066f25f..bb6de89eb446 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -374,6 +374,23 @@ static const struct super_operations tracefs_super_operations = { .show_options = tracefs_show_options, }; +static void tracefs_dentry_iput(struct dentry *dentry, struct inode *inode) +{ + struct tracefs_inode *ti; + + if (!dentry || !inode) + return; + + ti = get_tracefs(inode); + if (ti && ti->flags & TRACEFS_EVENT_INODE) + eventfs_set_ef_status_free(dentry); + iput(inode); +} + +static const struct dentry_operations tracefs_dentry_operations = { + .d_iput = tracefs_dentry_iput, +}; + static int trace_fill_super(struct super_block *sb, void *data, int silent) { static const struct tree_descr trace_files[] = {{""}}; @@ -396,6 +413,7 @@ static int trace_fill_super(struct super_block *sb, void *data, int silent) goto fail; sb->s_op = &tracefs_super_operations; + sb->s_d_op = &tracefs_dentry_operations; tracefs_apply_options(sb, false); diff --git a/include/linux/trace_events.h b/include/linux/trace_events.h index 3930e676436c..c17623c78029 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -638,6 +638,7 @@ struct trace_event_file { struct list_head list; struct trace_event_call *event_call; struct event_filter __rcu *filter; + struct eventfs_file *ef; struct dentry *dir; struct trace_array *tr; struct trace_subsystem_dir *system; diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index e1edc2197fc8..956938357774 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1324,7 +1324,7 @@ struct trace_subsystem_dir { struct list_head list; struct event_subsystem *subsystem; struct trace_array *tr; - struct dentry *entry; + struct eventfs_file *ef; int ref_count; int nr_events; }; diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index a284171d5c74..85f9a99bb506 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -990,7 +990,7 @@ static void remove_subsystem(struct trace_subsystem_dir *dir) return; if (!--dir->nr_events) { - tracefs_remove(dir->entry); + eventfs_remove(dir->ef); list_del(&dir->list); __put_system_dir(dir); } @@ -1011,7 +1011,7 @@ static void remove_event_file_dir(struct trace_event_file *file) tracefs_remove(dir); } - + eventfs_remove(file->ef); list_del(&file->list); remove_subsystem(file->system); free_event_filter(file->filter); @@ -2297,13 +2297,13 @@ create_new_subsystem(const char *name) return NULL; } -static struct dentry * +static struct eventfs_file * event_subsystem_dir(struct trace_array *tr, const char *name, struct trace_event_file *file, struct dentry *parent) { struct event_subsystem *system, *iter; struct trace_subsystem_dir *dir; - struct dentry *entry; + int res; /* First see if we did not already create this dir */ list_for_each_entry(dir, &tr->systems, list) { @@ -2311,7 +2311,7 @@ event_subsystem_dir(struct trace_array *tr, const char *name, if (strcmp(system->name, name) == 0) { dir->nr_events++; file->system = dir; - return dir->entry; + return dir->ef; } } @@ -2335,8 +2335,8 @@ event_subsystem_dir(struct trace_array *tr, const char *name, } else __get_system(system); - dir->entry = tracefs_create_dir(name, parent); - if (!dir->entry) { + dir->ef = eventfs_add_subsystem_dir(name, parent); + if (IS_ERR(dir->ef)) { pr_warn("Failed to create system directory %s\n", name); __put_system(system); goto out_free; @@ -2351,22 +2351,22 @@ event_subsystem_dir(struct trace_array *tr, const char *name, /* the ftrace system is special, do not create enable or filter files */ if (strcmp(name, "ftrace") != 0) { - entry = tracefs_create_file("filter", TRACE_MODE_WRITE, - dir->entry, dir, + res = eventfs_add_file("filter", TRACE_MODE_WRITE, + dir->ef, dir, &ftrace_subsystem_filter_fops); - if (!entry) { + if (res) { kfree(system->filter); system->filter = NULL; pr_warn("Could not create tracefs '%s/filter' entry\n", name); } - trace_create_file("enable", TRACE_MODE_WRITE, dir->entry, dir, + eventfs_add_file("enable", TRACE_MODE_WRITE, dir->ef, dir, &ftrace_system_enable_fops); } list_add(&dir->list, &tr->systems); - return dir->entry; + return dir->ef; out_free: kfree(dir); @@ -2419,8 +2419,8 @@ static int event_create_dir(struct dentry *parent, struct trace_event_file *file) { struct trace_event_call *call = file->event_call; + struct eventfs_file *ef_subsystem = NULL; struct trace_array *tr = file->tr; - struct dentry *d_events; const char *name; int ret; @@ -2432,24 +2432,24 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0)) return -ENODEV; - d_events = event_subsystem_dir(tr, call->class->system, file, parent); - if (!d_events) + ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent); + if (!ef_subsystem) return -ENOMEM; name = trace_event_name(call); - file->dir = tracefs_create_dir(name, d_events); - if (!file->dir) { + file->ef = eventfs_add_dir(name, ef_subsystem); + if (IS_ERR(file->ef)) { pr_warn("Could not create tracefs '%s' directory\n", name); return -1; } if (call->class->reg && !(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)) - trace_create_file("enable", TRACE_MODE_WRITE, file->dir, file, + eventfs_add_file("enable", TRACE_MODE_WRITE, file->ef, file, &ftrace_enable_fops); #ifdef CONFIG_PERF_EVENTS if (call->event.type && call->class->reg) - trace_create_file("id", TRACE_MODE_READ, file->dir, + eventfs_add_file("id", TRACE_MODE_READ, file->ef, (void *)(long)call->event.type, &ftrace_event_id_fops); #endif @@ -2465,27 +2465,27 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) * triggers or filters. */ if (!(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)) { - trace_create_file("filter", TRACE_MODE_WRITE, file->dir, + eventfs_add_file("filter", TRACE_MODE_WRITE, file->ef, file, &ftrace_event_filter_fops); - trace_create_file("trigger", TRACE_MODE_WRITE, file->dir, + eventfs_add_file("trigger", TRACE_MODE_WRITE, file->ef, file, &event_trigger_fops); } #ifdef CONFIG_HIST_TRIGGERS - trace_create_file("hist", TRACE_MODE_READ, file->dir, file, + eventfs_add_file("hist", TRACE_MODE_READ, file->ef, file, &event_hist_fops); #endif #ifdef CONFIG_HIST_TRIGGERS_DEBUG - trace_create_file("hist_debug", TRACE_MODE_READ, file->dir, file, + eventfs_add_file("hist_debug", TRACE_MODE_READ, file->ef, file, &event_hist_debug_fops); #endif - trace_create_file("format", TRACE_MODE_READ, file->dir, call, + eventfs_add_file("format", TRACE_MODE_READ, file->ef, call, &ftrace_event_format_fops); #ifdef CONFIG_TRACE_EVENT_INJECT if (call->event.type && call->class->reg) - trace_create_file("inject", 0200, file->dir, file, + eventfs_add_file("inject", 0200, file->ef, file, &event_inject_fops); #endif @@ -3638,21 +3638,22 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) { struct dentry *d_events; struct dentry *entry; + int error = 0; entry = trace_create_file("set_event", TRACE_MODE_WRITE, parent, tr, &ftrace_set_event_fops); if (!entry) return -ENOMEM; - d_events = tracefs_create_dir("events", parent); - if (!d_events) { + d_events = eventfs_create_events_dir("events", parent); + if (IS_ERR(d_events)) { pr_warn("Could not create tracefs 'events' directory\n"); return -ENOMEM; } - entry = trace_create_file("enable", TRACE_MODE_WRITE, d_events, + error = eventfs_add_events_file("enable", TRACE_MODE_WRITE, d_events, tr, &ftrace_tr_enable_fops); - if (!entry) + if (error) return -ENOMEM; /* There are not as crucial, just warn if they are not created */ @@ -3665,11 +3666,11 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) &ftrace_set_event_notrace_pid_fops); /* ring buffer internal formats */ - trace_create_file("header_page", TRACE_MODE_READ, d_events, + eventfs_add_events_file("header_page", TRACE_MODE_READ, d_events, ring_buffer_print_page_header, &ftrace_show_header_fops); - trace_create_file("header_event", TRACE_MODE_READ, d_events, + eventfs_add_events_file("header_event", TRACE_MODE_READ, d_events, ring_buffer_print_entry_header, &ftrace_show_header_fops); @@ -3757,7 +3758,7 @@ int event_trace_del_tracer(struct trace_array *tr) down_write(&trace_event_sem); __trace_remove_event_dirs(tr); - tracefs_remove(tr->event_dir); + eventfs_remove_events_dir(tr->event_dir); up_write(&trace_event_sem); tr->event_dir = NULL; From patchwork Sat Jul 22 19:37:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13323000 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 A5969C41513 for ; Sat, 22 Jul 2023 19:39:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229809AbjGVTjE (ORCPT ); Sat, 22 Jul 2023 15:39:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbjGVTiz (ORCPT ); Sat, 22 Jul 2023 15:38:55 -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 E1A5E2D4A; Sat, 22 Jul 2023 12:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jkk40yO5q5S3nM65is2CLVR+lfFlLGGIKNHccwd6CJc+xg/nnpapMXN2ZS1F1VE6RQb0FDwktWuMjduDM34xdg9ZEcg+YOkftu7D8VtlJq3zbDI8i3kl56//mix5KFlDrbFZYKQdvkfgjV8j+q9FLzO7jVBO4WtrN1zNtmy+eR1Z3Y29lTjX8PRwjCiWAKyGhRkO2zZvULY7IAiVMvZii55cJhNW0qZ4jJcEAIJoBd0aL8Kbm9S0fNn6s6g1FEwVqo48aUCxZX+CWdbVMEJpSm3IeCpf16ykO7Xd++toGGUI8BwLY5O94P6h1XeYh9b+uuuF7jNWR5YlSUE1cDdqjQ== 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=Gu6tBcrLe1mXIsnZ09rppoHbJ0C/dNsmIChXZ8c7NwVPgPGgwIYAmWRc1AJszz7S7gHHuEv1N+7h6BamQ57Ty16HfX8n5CYr72XYFef50EALzbwWz4iOQsiidfBRwjTZp5LyJTtg2ai8ECXAgAoUfxsHNRp39mA9mRkC8nEDIdAEFJ+cqMamopFqc/Evx1juE8o4dWLt4LY2VrIbG/iJnYh4/Dj8BfnEHd+lRMHtIgHqtkGXJNquJ4aQOlX/DgiZke7iAztnfPDjsGDlOPFZOemxFi+eDMMQEu3oKnW/oEa4K9WkZTZdiL0EYNovrR0BxzxP1grlA04RSg0CJ8Rw6A== 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=ZkC3TuTpvsYrF8TpZbi0wG0PhkwI29/+ExRImZ3mJJLiBPczzzWHd8kbhFGO1j0eJoCHkLp9lLhrAIgANe14OOsRp3HwRYTv7LI4VPUlkUnUX1GzgQ4LAYas9htoceCTEZ2osEfUXYlZYRbupDgo5XK+DwPX+R0rPLfK5bpvoWA= 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:17 +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:17 +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 10/10] test: ftrace: Fix kprobe test for eventfs Date: Sun, 23 Jul 2023 01:07:05 +0530 Message-Id: <1690054625-31939-11-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1690054625-31939-1-git-send-email-akaher@vmware.com> References: <1690054625-31939-1-git-send-email-akaher@vmware.com> 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: 30b7927e-359c-4fa4-9070-08db8aeb3282 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: 1+pcTmXboTrXxUTIBXFmzSAERLH1DmkMfTsBKp1uGmbVzJxU5XQCwaaKwEAqyfuZkSBYi+zxUqnst5vFnlYEfBkcYh7SAES637MSCYwn82Eowmsl2jKQQixvrnSAzanzFG3vwWS3IEt+qJ+EdNGHRg6GoRytNN5jkmVINViU/hNP9wqRUO7zUy12v3aIQ6DetSE1eun4aiSQAIKS5XzipMYoqx+eAMWQpvLZ5b7p/g52XKmQmrpHFRkHrDlp9EyDuyyTbb+qlR8MsSI1avE6+svqXrxf59XPDoKimPoNPpTJ7hpOW+Bi6hNIRV7bHU6q95E6q+jbPpGtQArl6/0xzelWB0KctEb3oOaYb/D5cWkrwul+lSH77jWFttdnHG7DhXxROHBgHDPKtJTt4r31tPonQOFG5LTmcZt6Ws0NgOfO20atqkiGmDRpWch4PiaIdNUn4IYgecD2x/qGaNmW3dfduIdDfGpoLbplYhXVF4A06lrgSdj9vY1Iu3t9u80dvOH1EVeQ+oDfaPPQcciGvYzggUIVDbbMKFJuWaDs5Ab8zkdRP88CXp7L+/lV+xSofdzXhhXs+whGQFilvIdLQkZhQ0u4tzwAGGFhNdtbvMSB8UnnZfoiTAPC2Y4edowmIfjeKHUCkgQafBidk6P7hGylg+n3tIDuZTckG9+PbJ0= 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: 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uBYHyALpIRWwrQthRXjYiDIMLbMVXDIr3sE72QZMpS6RmktVCzf5fgRLmyW3RM3sH6DQJj9ipul6OKUOjKb8ImeLXKxKnUQrItk5dTBtyRgOuVJIBB3DlaHnRMEh0nc/99L7aNWQr5tzCwlVV4OYvtABSNh74wKPm/T8Wz2f9VEao3FCQ4UA9CNfGNJS38CDQhNkBv8uoRmQ7gXQ4dnvchXNiS6JZNjiSS8EUidOk6tsBQdA79WeRKRnfjp9JQNnpBFQb+Ee13g6WjJ7ilG/5vB2HJTWm27f/9WvZ8IfQVjhnZeVBgmHYLnOmhe6yElydBW+hotQ2JIIMHwPpfA3w0zFHGVDppsmK5w8BT3l2CiG9DZ5XDF03z+lJDvhrXDQ7bDpI1RW1SD9gqnzd72Oi4i5158o6tT+IPMiwyokzapSNB7+YhMzZjVe5YLiUOVLym5G1w+2y8PxQi0gYsTSXluPrRxX3cMKkKD6PoPhVd78xCiSyjlDfb8E7pDJNH08H/GbrO/+Q X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30b7927e-359c-4fa4-9070-08db8aeb3282 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:17.3818 (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: tvoJlwS9Kb6ZfU3yaNpdtkVqi4g0gpZ5UF0ZtVxA4FAK8bU80YeGMLlyovX1/AaBpKxxoS/wmuxBeu+mWo2OCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR05MB9005 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