From patchwork Thu Jul 13 11:33:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311875 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 0F431C001B0 for ; Thu, 13 Jul 2023 11:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234127AbjGMLeG (ORCPT ); Thu, 13 Jul 2023 07:34:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232550AbjGMLeE (ORCPT ); Thu, 13 Jul 2023 07:34:04 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011008.outbound.protection.outlook.com [40.93.199.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B026E5C; Thu, 13 Jul 2023 04:34:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=elu7YONTaAdsMDEBKL24+Z39qkP7jrtb67p6n6tatKMRXu8pFYMFpYOeF7mc23/NWiezCQjGFMmpYDdmnLWDooYvXQv0wxs+FwUmfnqWPyKyjcCT0gkTy+KVlB8a4J1Nln0GyZm+QPeLBBm1OTO9tVxo5JIHWpedQi2N7a82rdPNWyBMh1FQk83Ors++jRrmZyjw9j+kHUnzM6U2ReNArVKmIeDhlYwGAKAm/SoT3zXbkcsL6A/TLIEUFBEFHR++F3TcpG83eHOOcTjN4KEv3S0XqrnX9xHQYcX1QFoasE2oUtGUDyehyFxSUzzyg+Fn6oatiaB6CiR/vQ49ZB0cUw== 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=eBiXm/KOAhcLgQp+cTdX+C38d/hUEhFUlc5b6OS7zHo=; b=Aqm75f6dJoHu/pX7UXIuqqFvgtbbaAlF0wSHMrhWhJ89Y6SPTouGocxxqZIBCLfPc0sZGWQzj+CFeJgT2kr2Zh8MAOduIvq8G3f6iRVV8xLLiYWQDXeMKdwSixAWDiVJ/MgZHm7+1k4ttyYPwGnINwVtbYjSZtZ+7YF9J2NXVJblo++jUF6HGPToyniR7wxmXFT0yH85JA7rKMikobxIAs8NXsQhCwM3R6wii1H6Fln/8pCnaK0gFnb9wmoA1j4xb7lP/wUT4I3djnPuVpCbtoNcYXBRT2Gyt0Xn5jm5c2HWLiBxBeWrkoKOH83Mv0MrkaN5FUxCxUb4t7udfuw7vw== 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=eBiXm/KOAhcLgQp+cTdX+C38d/hUEhFUlc5b6OS7zHo=; b=on6zZz4rA3KjK1lPbEOwpxboQSHHFxvPGThRXbvWnfkuq/6HnRQo6nXNdQY+ZbjmCVkAM7VKbyNDGQgCKnWmFU8jITb11fqW9V+OVRDc8+YYpsQkEKreEyvFwG0VFsbUzf10p/pkPIqVfeWuoC0nc9WmvUp6/4O3dLDG5XBVHnw= 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 PH0PR05MB8719.namprd05.prod.outlook.com (2603:10b6:510:b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:33:59 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:33:57 +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 v4 01/10] tracing: Require all trace events to have a TRACE_SYSTEM Date: Thu, 13 Jul 2023 17:03:15 +0530 Message-Id: <1689248004-8158-2-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|PH0PR05MB8719:EE_ X-MS-Office365-Filtering-Correlation-Id: 1b9e4ba4-9e69-4942-2750-08db83950b7d 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: rCZwQfnSCJXEbq02M4H7s5Jjr0+oo7Wmk47hYjxBfrn5uNOiMgQam66CNrtbAVugiRHfj/0tIYm1zDHaZ1SoHcBa/pd5fr2PTZRVZLGrMGTnTL4Fh6DW4Urazeqvwp76P6NSSVw03CqCk0UBQGHe+WQ1hUhQn3rMk8z7CYhWxq9MhLkPPASYgaLexV7TEdQ3cwC9fQgephixUKcHVdIjBC7O/cKNFtNWU7LOxgqHL9tN7q9sXYZsLr2v7JPxxJvmDC5bX90kIqT/RwS9pM4e8EJRVmVdFa8VGZFi3qZPDEM1IdHZ4cum+EJpCzWrq2buNJxj3PxTOvIzEnsHjelTuokd01UF0uG7VlEhkrRE85DnWz81YvgZGP8/mptNsf10gZfiwVhJh2jICTsMKvtKFKv66JFZrwlpFOfmQN8k85IsvfFZE3zRVB2lpnZGiCNrPrUcGjD/1R0sRMS4+Ke6/RQI6GYrpAElKB/g/nvT651ubSosG31hhaKN0kV/98ciatzfW4kBt5NAHe7mGReJmAIq7irZ1PjlmFmMvOlrgNauAdeWDA4h415kfjHPxi1l6isLMfUzgFIxDbAhcG9+DmAe2KSElNp2YIYLxKHiQscl+5Kf54angCWan82QfO42houBU+7jAdMcEu8pEcPiCpOymGSK/0nUEDXqTuSdalc= 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(41300700001)(2616005)(83380400001)(7416002)(2906002)(186003)(36756003)(5660300002)(26005)(38350700002)(8676002)(8936002)(107886003)(316002)(6506007)(66556008)(66476007)(38100700002)(4326008)(66946007)(52116002)(6486002)(86362001)(6512007)(478600001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hhymFcnxW++7+3/AQLnOlGq0dtDdW2jBB/i8E+Y0DWzTprSZnK3Ec7kaIuS4F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HdLrhamQaOOL4TA1zpHIymrn2Qqi3wkdWUk4Jr8XJ7zRSzk1yrbUvNJGmLv3x2cfTIR7U5x08fN2IdL/H3Mhb8l3riQj4Ah5JS28440d4fVOZahSqa8avLFT3mXibS3vM9SSzgKFROrmdmVfHoCpd7hWLYYYARzk12vp3ki1DadP6RLR2RrdT+OOWIo0DJo3NOEcOTJu1NuQWSkVfA74MOHoZtvZzfLhTgHvkzBaxbsIZV61O3KpmbGnT5/FB/nn2kcO5RQoMYriK7XRPzA6mnqA9a4Lm2lLjsKhJLAA/zSpRO+6fM8Mn+xpynAVh5M/qxcZELnTbXIWmhMdi5Foa/fkb56nVLIoZiv8z9zlWAHUPkuAwOdOuPTyYwgtGc0ZOY0kMZIbGhn5uf01zcBG+Ek9Eybr5kfsffaflcFjGgHcnVaXHT/4/lAQJqH3s90Up7w8n09CBuu7 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b9e4ba4-9e69-4942-2750-08db83950b7d X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:33:57.1132 (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: Pr55Gt8rHTiApn7kuFSz1gl3/MOMtlZA4uyc9oQkrgd7DLqRoTc6fIgKYci+na64uL/2xMJxB+9mmIMWK6GaOQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8719 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@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 57e539d47989..12ed71428939 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 Thu Jul 13 11:33:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311874 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 F00B4C001DF for ; Thu, 13 Jul 2023 11:34:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234177AbjGMLeH (ORCPT ); Thu, 13 Jul 2023 07:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234086AbjGMLeG (ORCPT ); Thu, 13 Jul 2023 07:34:06 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011008.outbound.protection.outlook.com [40.93.199.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3EE026BC; Thu, 13 Jul 2023 04:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m13SMKFIm8odZGrq72+5EnUB6DWj2kY8VwittwZPieUN78KEv/KthChX27vKPbEIdLRc7KPjxq75ggIuIpLMCK5FheBm9KWejFyH3lp8gbt5Bo/ufhAue/Gge+rNTtw/f7CUQSDcC8XSL2SkVr5qXT8ZqNIQHtIab49l+B/9Q3NslEywsNghljGsGLMuR0Z+NwNtjLhktdTVlkmNMXH41k2BEdZmsPVxNM+gcV10B8GQh8GNY3lLC9Y+gtTtHPvWU8CJY8XyunbaFL8hCNaHZVBF8Z9NEGZhDRHtdczzWh7pSEMssGLyuwuO08fJ3wIQ4s1PKEvONpQxtAN+HyE9oQ== 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=KzZTlXeNogJBViXGqA0WhbvwMo1KVjybgLRgYLle9JI=; b=fYJwBo+fUHaS+/JSPQX937hOdJtl/AbPUlQnF6CZKbPcsGiHcnTps9OW2/+df3viSgkGWOQSRnOhIEFAMLRFUDmAwzWRPxcavT4RUzXFVg6WSMTUoU5WbhWrhxilpMTjxZkDh19vzbM1iPa5HQ10+8nsH9LTarbr24FeuhsMD74wNV7QjjkcJUPOLi5CuYbXmCoN/XUfTN7lQ+D+ifZjtOTlyIJNPLjqR10l4d5VyeIfqe+omuJQbhn8t+qhtowji3hnem3tFAXfaT6PfwX4vKrZhGNbbsjfdZ1BxbPyspYAjYKHhKv0soH1dSvJMuYnjz8mESygqm+6/rDEdep8GA== 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=KzZTlXeNogJBViXGqA0WhbvwMo1KVjybgLRgYLle9JI=; b=2gxmIQdbpsdgu9i+js16ReYjwKC+2A65D79BN5zIRlO3Ga8HqP3HBPjEch2C95NJAzxR3VaXEMpEt/Gd57QfNU0DxuLuWpOmnbidMwv8fEAdEEgDswwNfhfj91pHSHbh9hgSHMhNWA3f8Ccs1GM5izibiPFHQa3lQvNvpJleQug= 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 PH0PR05MB8719.namprd05.prod.outlook.com (2603:10b6:510:b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:33:59 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:33:59 +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 v4 02/10] tracefs: Rename some tracefs function Date: Thu, 13 Jul 2023 17:03:16 +0530 Message-Id: <1689248004-8158-3-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|PH0PR05MB8719:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a311f42-e834-4ab9-0440-08db83950c24 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: PklzPtSq9GYm4sdcP5tmARNR3X0XSaopJzDKnDStyPNNqpzPqNdzMoVeoLbLOTVCqOpGYiLHPT+0yPIz45fGlv76yftGEOCbU03AdhuEBWKGJi6ee0NAst0FlfkjXKx5OFpMDv9JJZObRzV6jsWB01Esjz5X5evXM+qiRKuxyAh3aFyGRw3MKSaEB9FS7RutNpAXt7Umy/gqDkCgtR+nWh/3C9jP6IWdxsuczF2NyKOP3ziR6uioQKhAaY0ut42Oh2aSjc09tdLMGXhseiV02f20rhk1lMdAQEFGmdwL+xPSRIPxhDlNacts+/YYdgOgVN1ctAlobQ8u5cJywvkuRwTX08yAkokl9C7pNRPsvWyk5z7kGV8mhxDEOPPj62nuJ42aTpoUhmQyGYP5icRBGJbzTOc/tb3lzGA/WkZdgSWDChWp8jBnDex3lVaaGCwunsOurLDU39OPbdq0qcFNWh/lM9PxJQ7j85wiCIzXMg/8YmB0SHVDVtMc16pZd8cI2dUwjLuOAx2CkYmVDP4ImUFlqpBn42MRVGZ70Wu7UUakfSTJT3qigexWG8VRGEymlkOdCRglTeO2146Pz+V8ZvCikYt42ua+BLYUdoIVYFzkXaSWxlm/IAW+7VY7MGxN/MggTIhoeRKJ2hgDDOi+xw6FZR3N8/RUeqWf7BIjECk= 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(41300700001)(2616005)(83380400001)(7416002)(2906002)(186003)(36756003)(5660300002)(26005)(38350700002)(8676002)(8936002)(107886003)(316002)(6506007)(66556008)(66476007)(38100700002)(4326008)(66946007)(52116002)(6486002)(86362001)(6512007)(478600001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sX/qo7vrMVPG74nMJOotkgjHxJeF8a70/AAJAbbRn1Uhmxe3x4510LeFJd55q/tFyYbisXEYifvVFSxq+IfqEaJE2ydOtlkhOtU8iF1sLu+yGRMN7Sx0h+YE0IbreIkZRIODAR8cWRpbu1RAU5OfXVIJqZwg8WBVFEFYZ6oRIvygYsoQV54ljtLvmIaaKmvO2WaMc2tPzMd+D8m3hc7ZEepO5YCCYBjqdwSZ/E4I4WrUHoIxPOEDKctNA+HdO/YaXWYCL3CcBnNxkJiHJ4/DU3scdmIuUDdfChonoLTeGvQ6KwkT//m7TU+fPxKvFtK6auf8BkNPow/TfKeqFoal7A4eFVCoXab36bOO4ZrXUKH71ngtnmpu/6epFRmsAY0/IrZdYRqhiw5Njdk0lp23iKPv6Rar++l5iMyLvIl5IxxipadF0Mu4t/D+SpiGjEx24yjlWyMwd4PwR5/0o/nT7sOGquAsgvuACFYWFhPfZMX/GCx5C3B1XDBuHDIRESbe5WPnAMaE/w72gSuQDEJw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X-MS-Exchange-CrossTenant-Network-Message-Id: 6a311f42-e834-4ab9-0440-08db83950c24 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:33:58.1594 (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: usDsarGpfb0RqLH9da2mlhqJg3AQv+YTdjDYC0I24zoYIILMByd3sRTbS1egGoTYHK8psjaYKyZW88/lLHEuFg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8719 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Renaming following functions as these would require by eventfs as well: 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 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 57ac8aa4a724..b0348efc0238 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -399,7 +399,7 @@ static struct file_system_type trace_fs_type = { }; MODULE_ALIAS_FS("tracefs"); -static struct dentry *start_creating(const char *name, struct dentry *parent) +static struct dentry *tracefs_start_creating(const char *name, struct dentry *parent) { struct dentry *dentry; int error; @@ -437,7 +437,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) return dentry; } -static struct dentry *failed_creating(struct dentry *dentry) +static struct dentry *tracefs_failed_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); dput(dentry); @@ -445,7 +445,7 @@ static struct dentry *failed_creating(struct dentry *dentry) return NULL; } -static struct dentry *end_creating(struct dentry *dentry) +static struct dentry *tracefs_end_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); return dentry; @@ -490,14 +490,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; @@ -506,13 +506,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)) @@ -520,7 +520,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; @@ -534,7 +534,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); } /** From patchwork Thu Jul 13 11:33:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311876 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 80D3BC001B0 for ; Thu, 13 Jul 2023 11:34:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234223AbjGMLeI (ORCPT ); Thu, 13 Jul 2023 07:34:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234180AbjGMLeH (ORCPT ); Thu, 13 Jul 2023 07:34:07 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011008.outbound.protection.outlook.com [40.93.199.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11801E5C; Thu, 13 Jul 2023 04:34:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kxVFleAajR14KtR7DwEFEP7gZzglNqMYjC0OBtHpNkUYH5eQamyqem5ko2SgcFEoVfLpkjouCaTm1V2yOT5vCFuz5qTHWXH/3YPhVRHm9og/9fLxA1arDo16vYF2e/heaYbUVZvAjozNOHOfvVbuuW5MkwsTqAhnWq+SOsK9VFSe0LUWMQ6IIe1pKIf1OglKFDWUDeoeL8H3T8gsmjK9xWjHt+d2R3rBdMRB9n8I4MASFaW6VDKU8QF5s9zOCx7WPtAvY/H2AVcdhjOi3LSWsxw5sdeXw0KW0f3MXe1nmIwmw0vj9QaDHxOjF1/lysI1Mhdbly14tJpI1SLhWsb8/Q== 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=GsAuxbg+1+SENfvEaP6JfB4b4cPJP/4miM6CPc202ZI=; b=gP6KVN3WGhfsExC97JWionPqI8NwkBolTCXG6q7WH9X3lOvzFXZ+lVCFTF+3BT/0GQiFbol9fMqkvavAKV4hgwlUiYDGYD1Gqwev4yuav0oLvAp1N0oCeLaCClVKtA72fJeah7n49pyXPKt5GqI/mEC02PTVz79jbGG1A5FxnodqMxGN0iDQpLyxRfdV+VEfhjjUPtfIvl0ch/JIsAhzKthNgPiBYMQO310AC/qVmE6zPcdNVPtkhHfVaN17xnQgEwEA+52Mu8xR2rZz0eAdrfGzWRXMgcVr5Tw7gTWs36JXgff6+T/zLq18XgbnaCs29Kne8F7ljnEITj8wkOe6JQ== 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=GsAuxbg+1+SENfvEaP6JfB4b4cPJP/4miM6CPc202ZI=; b=AJRLpBozuKxT20xPQxv8qVuh6Z/d5teLrEbFYvnuowuXAZz6e1hmXI1SJ/lr99J0JHEWEPDz//vwv+PsFRJkRFCQvPXLjTJuA166W4LKIcajQ+95x80JITFWH1cSDEu7tWxDRNY6lnUGGLBx9U5f+3MPIVzkBca+HVX6euacfPU= 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 PH0PR05MB8719.namprd05.prod.outlook.com (2603:10b6:510:b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:33:59 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:33:59 +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 v4 03/10] eventfs: Implement eventfs dir creation functions Date: Thu, 13 Jul 2023 17:03:17 +0530 Message-Id: <1689248004-8158-4-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|PH0PR05MB8719:EE_ X-MS-Office365-Filtering-Correlation-Id: db33943c-4cbb-4747-ba95-08db83950cc3 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: tUTSzQGyD+/M+1vSNP0Agc+8lftN/iWJA7HtHDQNPyQt2+BrAjT2BUMwKkCecH+NICbCpctGaK9/051EDQJMrorTJo+JPzE5c+lL7V3Jh4lC6j82imLsFSv+df5zpnxbnSuWgktyEDvavo/KKB92sClEdmFKlLGsOAcciifUk+PHaOE2/3r6b6BX51eOYxrcWTes7IJ3hWsv9MxrI6lns9j74YsP7twq5SIWE5PAf1VwNg+LgjBsbr1rtDbWTb/jkOyoDgAN+bAjcg1qru15FYlL4M91Z1oLwGiBVyXJZw9biP1cRakvU23xJNoF0qR1F2shvz1IqSyLhBMTG7IzRzi1fd5jg4I5nXfUywJGN+zryTlYk6uTfc423/Yyc8xqVSAIf2DqZEzpY23AHejql0cX2onWNc1P1zOR92rWcT69M9BKBvg2wP4CZxZQrtAipLtl8/vn5r5dTGyCmfTnETywcekZFZEt7bLkTM5lkeQNQQogcNs0+7bnfv+WerRWdm8ZM6to4zpIL44q/tuXbtwHyunOHgIPVDTqeNw9MahfPKTO/r4Hd6UYg2PT0AxTxEUwcYuwGO1IDHtwQgKVczwizvDg9MoDtatQ5qC7nYWOGs9TX+wuzJbymp2jWGTgbj7gr7r/+myw/3BE8ulZpoLSNWQK+1xKm5MmTLhCrzu+YvdJh3AsGmmt3gz0MmxVcwoJxx15dnOb2YGtYhwbag== 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(41300700001)(2616005)(83380400001)(7416002)(30864003)(2906002)(186003)(36756003)(5660300002)(26005)(38350700002)(8676002)(8936002)(107886003)(316002)(6506007)(66556008)(66476007)(38100700002)(4326008)(966005)(66946007)(52116002)(6486002)(86362001)(6512007)(478600001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HlpRmZIJjfFrA5iCtdoZwRNJeB6V3wwDgixbcpvdVRNNPXQf8Ssus/bNtbj3GKKy7StQAZ2w0NkCiwkG2lXex408Au7mUVCGaehEaC/jJ0AG3d74xHJL7vWOpJZCaDkAJ38V9AZqiy/d4LKbarX9fEVTwwgf4bUX+VdG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lgHH0Nb3plfyldN6UXqa6QvG5XTevItF5asy88Rou7ME4qaJGL881dR8czbKmKQ5wIm9YsvQ2/cmKplr+Im4xtAcPjKRnmOVYsbVQf0iZD7/2VJvOAKT/OA3BufHlykAj0PIDbCnSoM9FRQT2pl4laloSnPGSK81Qn2vlj43KdBklIpoP4gd7fXaayHjW+0/mmDTtTTZNBnBhBw9QFMVaV7DCu2IiBWYHHTDN2bVc0oVaX5WQcqg22HKLx38kKDG7fTOgbDsQOyaT2xMK2kIPppfYBTsJj8E28Hilpwxw6XCUT8B+OrySJfrikK2Mhl7rd3VnCgtGvphclcpR3TzETJbhvm9hKpDPoIPQvoo X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: db33943c-4cbb-4747-ba95-08db83950cc3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:33:59.2151 (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: gQMdZREEp9oct6nkd1Znf8YQRLFqZIv507OP9GZOD6kwHAcGPioEHOUZKlUfkUY+ymYmwuuOpiEUI4BQBIzEWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8719 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Adding eventfs_file structure which will hold properties of file or dir. Adding following functions to add dir in eventfs: eventfs_create_events_dir() will directly create events dir within tracing folder. eventfs_add_subsystem_dir() adds the information of subsystem_dir to eventfs, and dynamically creates subsystem_dir directories when they are accessed. eventfs_add_dir() adds the information of the dir, within a subsystem_dir, to eventfs and dynamically creates these directories when they are accessed. Adding tracefs_inode structure, this will help eventfs to keep track of inode, flags and pointer to private date. 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 | 217 +++++++++++++++++++++++++++++++++++++++ fs/tracefs/inode.c | 8 +- fs/tracefs/internal.h | 25 +++++ include/linux/tracefs.h | 11 ++ 5 files changed, 258 insertions(+), 4 deletions(-) create mode 100644 fs/tracefs/event_inode.c create mode 100644 fs/tracefs/internal.h 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..4e7a8eccaa0b --- /dev/null +++ b/fs/tracefs/event_inode.c @@ -0,0 +1,217 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * event_inode.c - part of tracefs, a pseudo file system for activating tracing + * + * Copyright (C) 2020-22 VMware Inc, author: Steven Rostedt (VMware) + * Copyright (C) 2020-22 VMware Inc, author: Ajay Kaher + * + * eventfs is used to show trace events with one set of dentries + * + * eventfs stores meta-data of files/dirs and skip to create object of + * inodes/dentries. As and when requires, eventfs will create the + * inodes/dentries for only required files/directories. Also eventfs + * would delete the inodes/dentries once no more requires but preserve + * the meta data. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include "internal.h" + +struct eventfs_inode { + struct list_head e_top_files; +}; + +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 rcu_head rcu; + struct llist_node llist; /* For freeing after RCU */ + }; + void *data; + umode_t mode; + bool created; +}; + +static DEFINE_MUTEX(eventfs_mutex); + +static const struct file_operations eventfs_file_operations = { +}; + +static const struct inode_operations eventfs_root_dir_inode_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 | S_IRWXU | S_IRUGO | S_IXUGO, + &eventfs_file_operations, + &eventfs_root_dir_inode_operations, NULL); + + if (IS_ERR(ef)) + return ef; + + mutex_lock(&eventfs_mutex); + list_add_tail(&ef->list, &ei_parent->e_top_files); + ef->d_parent = parent; + 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 | S_IRWXU | S_IRUGO | S_IXUGO, + &eventfs_file_operations, + &eventfs_root_dir_inode_operations, NULL); + + if (IS_ERR(ef)) + return ef; + + 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; +} diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index b0348efc0238..7ef3a02766f5 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -127,7 +127,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) { @@ -399,7 +399,7 @@ static struct file_system_type trace_fs_type = { }; MODULE_ALIAS_FS("tracefs"); -static struct dentry *tracefs_start_creating(const char *name, struct dentry *parent) +struct dentry *tracefs_start_creating(const char *name, struct dentry *parent) { struct dentry *dentry; int error; @@ -437,7 +437,7 @@ static struct dentry *tracefs_start_creating(const char *name, struct dentry *pa return dentry; } -static struct dentry *tracefs_failed_creating(struct dentry *dentry) +struct dentry *tracefs_failed_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); dput(dentry); @@ -445,7 +445,7 @@ static struct dentry *tracefs_failed_creating(struct dentry *dentry) return NULL; } -static struct dentry *tracefs_end_creating(struct dentry *dentry) +struct dentry *tracefs_end_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); return dentry; diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h new file mode 100644 index 000000000000..c443a0c32a8c --- /dev/null +++ b/fs/tracefs/internal.h @@ -0,0 +1,25 @@ +/* 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); +} + +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 */ 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 Thu Jul 13 11:33:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311877 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 9566BC001DC for ; Thu, 13 Jul 2023 11:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234318AbjGMLeN (ORCPT ); Thu, 13 Jul 2023 07:34:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234233AbjGMLeJ (ORCPT ); Thu, 13 Jul 2023 07:34:09 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011008.outbound.protection.outlook.com [40.93.199.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A84C626B5; Thu, 13 Jul 2023 04:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Zy1SKoBXkaVSJS4RLgyw09SPnzFrWBYoB9xsS2GK2uwuNyqz0tnI1cuW2LEZkVluF+xyEZwVmDMrsKvUB+qhaPtvI6taq0SMXMn66zCez3C/fEOR7nWl5d1Ld3/wQFLTpHjB65EE5pdGXRC5kc8lzdfn9qJkbaVJWF/pDMltBI+3Y5of0LQ5/eFuCOsNq7AzhQqe6MvIPkyJ6ibiw30kx4YMlXxdxNDSpIEnRxvmeHdRMx56zPNqoUGWT/pAdOxV3cWwRw5F0qluyQswcmLaj2DEo8QhFZuBWPKQHqFRFWdcJF3F4tEB6CO+98aV7UWFNSwYw/a79USwwcMzP5K7Sw== 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=CCNzRWofBv3ZYpz5jL9vy4GWLe97GUL3JGspljJ8SMY=; b=YlA/4JYUh4X0W8nWieOWveU3YnT8kb3Fz2j7w5eQGqZHjx0xEoaghWEwyBUaspO7ia2CCDx5Bhid9SK9K20P/6eReqqPRqMEaX/gGSKb5XkIrvVVeBRdG+vCrlREzbc/OsJVFAMli74XPIBehO31Fuo+RWHWuw3YWKBUlMidx0QhIeUE9+3+faBc3kco+qjyrfCK6agAPM3hX+qsfLSjqfCJgmqsZkyVCBQ49T9RcAjhw7JmhlhZ5jVj78GtMVUiFSr1a8GoI1p8fE0gmKaFwGrsnyPBsKQ6hJTRtH0sl5XIe4jvFxhCqeZY3AoTik9WpKIyKgMy+rYgccJ5Dgszhg== 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=CCNzRWofBv3ZYpz5jL9vy4GWLe97GUL3JGspljJ8SMY=; b=n9/VNCddk8Q5mFp0cxxs1AAFeYJXCGguolQt/UMJ+5jAOae4AltUfujS7vGJSYYeO12HN98y0s7QuIZqOR0ep34jgUuB3q4IwrESVW2kYC8tl+iBX63RaWhXt9zJLsS6vjqisPM59srLfgAvp6RJi66606FPVJ2Ysk+q/ixNXuk= 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 PH0PR05MB8719.namprd05.prod.outlook.com (2603:10b6:510:b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:34:00 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:34:00 +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 v4 04/10] eventfs: Implement eventfs file add functions Date: Thu, 13 Jul 2023 17:03:18 +0530 Message-Id: <1689248004-8158-5-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|PH0PR05MB8719:EE_ X-MS-Office365-Filtering-Correlation-Id: 9016675f-566b-4dca-d30b-08db83950d65 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: N7xHGd3691aVXP9jIooK28wncynQgMGOIdn4kY0jLFhUJMTsn/8hktqB74TdBVjrfYNnbzSZYR3UVh7d/FS2iX251TT5vNONtSvaOen1d/Khpc94uftdPvrZEOArVPBaSra+jASVeKwyAYkEWvjNLv4zJ9TjFXDDwOf8yolQIjz7X8UK2OyHpqek9XVt94Jk5mwvPBOszi65SBhROppdECLXTVl1+QHJY3xiBQe826d52GNNAYZQFo5k243PioaYr5dzst+Nq38VooqnEkVI9Lch9TnmY6j/V9bBgCcRK1h/HWX0+hdXQyDqvVXat3C4AHBi7ql9Pl5zCijNun22Y5ftCbcfNZy3uKuEruN3JSRF/roR3VNnlqxP6uvdm2VJttsVVbbFcx5H0s74e97n82/hd6SKFhCidVrsh6pZ9HLMc9enF9j/R2l9EN/zxSFStNfh964cF8CbTrOrPXU+Zln5pqL4k/kfQf/N8aSer4IZVuOmxr4Lb5BZMgSF3moPpSZki/AeDWoRt2DNGtOv+Mnayoq9XPShJJM3HzKD+AYnwHu7/EB2KcgVwBEoffMGM/SlZJbTwfBAzQcGz/BI1qpnbeCdNfkVns5MU/RMt4eOtUW+qj2PlySgchhxiaY9hu/peaJ99RdAqbiI6Q+AACvfTl//oGfxjjc/zT4WXC8R+MJRm+5XX4g3SRNMzudJcefqi6yrYT7MdgZZuSY/Mg== 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(41300700001)(2616005)(83380400001)(7416002)(2906002)(186003)(36756003)(5660300002)(26005)(38350700002)(8676002)(8936002)(107886003)(316002)(6506007)(66556008)(66476007)(38100700002)(4326008)(966005)(66946007)(52116002)(6486002)(86362001)(6512007)(478600001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UUT93gTsVAD10dRnzeQgsRETPBn4ID4CxafD1t/EXQZK5BnAYNKMHIWn2MlUXBVWe7m6w6sFgt5DZCrfyOpj15XqsckqGNFOO7fmGkOrFVjzrfSFx/yTAG45zNznJSWohJWG0LXVMAhGOgceb93DmUvCD1D/bYp9ZM/1NInvclxHLjCvMqxg5Z5pm8kMCHIyJoZHeSRjbexkGkneSCbZcFS3HeBCwnjKUtA43F+g8ARvYJl710oyDPnQAaJVmz0KR7j2CwPFA9aK1GbcwsjG+LDkxcvrG8RJipeKljYFDubhpg595XPJ2R6a00rs0Yme64BbLJH4v4WMnhrwmyEvxyujRh8k86/ZfJQIaDoKyoOiBb6HUl6XSzAuoTki3rWci4HM7hZr/Y0LlTSv6a+vvC7CYa/yatdG+EyigIlh4TNm7/T1C6MG06SgU3tC8o8BPN/kbqjgrjsEs8NJhJMWt91wXrh5FFm1pp996Ie9tMQfqmXLpU2y3RZjUOTYDJq9jKBwMdKGVPDWoOMPRVDjvFyEdt6z/sXHAjXdgvzQtRnGCRuqLvMyWQk5bwM/lfQhnqT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ca-d30b-08db83950d65 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:34:00.2436 (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: TkfLK6J6ZAh/GdtfAODaQiMq46x+DM071gpHcLNR/NlDMzhjHdkethELy8ZQmzP4MCXh5pIaJWUL3f2KenXD9A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8719 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Adding following function to eventfs to add files: eventfs_add_top_file() adds the info of top file to eventfs and dynamically create these files when they are accessed. eventfs_add_file() adds the info of nested files to eventfs and dynamically create these files when they are accessed. 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 | 84 ++++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 8 ++++ 2 files changed, 92 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 4e7a8eccaa0b..75dc8953d813 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -215,3 +215,87 @@ struct eventfs_file *eventfs_add_dir(const char *name, mutex_unlock(&eventfs_mutex); return ef; } + +/** + * eventfs_add_top_file - add event top file to list to create later + * @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. The + * inode.i_private pointer will point to this value on the open() call. + * @fop: struct file_operations that should be used for this file. + * + * This function adds top files of event dir to list. + * And all these files are created on the fly when they are looked up, + * and the dentry and inodes will be removed when they are done. + */ +int eventfs_add_top_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); + ef->d_parent = parent; + 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. The + * inode.i_private pointer will point to this value on the open() call. + * @fop: struct file_operations that should be used for this file. + * + * This function adds top files of event dir to list. + * And all these files are created on the fly when they are looked up, + * and the dentry and inodes will be removed when they are done. + */ +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); + ef->d_parent = ef_parent->dentry; + mutex_unlock(&eventfs_mutex); + return 0; +} diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h index 432e5e6f7901..a51312ff803c 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_top_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 Thu Jul 13 11:33:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311880 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 46966EB64DD for ; Thu, 13 Jul 2023 11:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234440AbjGMLeU (ORCPT ); Thu, 13 Jul 2023 07:34:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234246AbjGMLeL (ORCPT ); Thu, 13 Jul 2023 07:34:11 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011008.outbound.protection.outlook.com [40.93.199.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5629C26BD; Thu, 13 Jul 2023 04:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mLYDNPI/kk79TpnJuF7Ah/JHcSzyOWyo+hBKR3eglyR6uLDHvpGgRXOLPCVFLqa0clErPOI6rcktwzlEfD12ZYSRcnlDacLyG/2LLNOFgghhoOv+RxPnG8NYgtsAJgpYVnSo4IikZokrCjB98i8B03Be33pwFuV6bw3ACTcbEh3QM+4GvU+no70VPL4lf/14QjN3nzFmUp28uP8UjUDxwNNer1OYUQToZymnoe2dhkrcBBgEWYOuuVJyCvsNC8r4sbyJUgWOOMQX/Uz2sgN2tkLrnvmjkRIB5aHk1Uk3TgtxI6zMZhr3qcA9SaLDRw1sUh03i+vYAzb6ywRq2ER8Iw== 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=KLxf/SgzKZwR9lAZZcyEKZCmnSGiq1seDxjBPzxCdQE=; b=O6XLwLKdSwdtiPQdBELXCprmGrmy+/G9M2kxCcjdUK10c4s/yj9hipoDJKX4ASxZmQrjCGZzUwCm1Xan+1YvgLPWtTrY+Su3YiCExMUrXkcG39TEY9Pd6ePY2FCznX2wBnNyQp4W4FnZpsAAJgTBUHPkEFDb2ROf1dgOV9rSdHDHcIdCnhjVqgyr4RTNwxEO5/jjQh9FtyN+yV8/UvaEkNjX28rQKo2pp9PAtdVNM9pe1iVmeeZ7mJ2RJTDaQQbA8ZZsP7ElcIHCU/LlGNXdyAlSqFa+bHPIN3uEE0yXw0SfI+7DXQLic2FP27Lmv/6Y+/vZJlpurhH42/9FOH/7Bw== 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=KLxf/SgzKZwR9lAZZcyEKZCmnSGiq1seDxjBPzxCdQE=; b=ihnaYsweuQzyoWAWh+gBr0UrsYl4PBq6dacbR3xuAK7Vrc/W/HRFuMMjO/L67lChnW/qGX5sSGbLuCAtzBY3LSoMB2MptYiwc1No8aUKYm6DRXE5YyT1f8ipW/5yOuydleT13olxsWjEf6KwyA+CTDQBh8faMNPwGGnugmveLnU= 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 PH0PR05MB8719.namprd05.prod.outlook.com (2603:10b6:510:b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:34:01 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:34:01 +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 v4 05/10] eventfs: Implement eventfs file, directory remove function Date: Thu, 13 Jul 2023 17:03:19 +0530 Message-Id: <1689248004-8158-6-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|PH0PR05MB8719:EE_ X-MS-Office365-Filtering-Correlation-Id: 973606d9-4f12-4eaf-c4cf-08db83950e00 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: zT1DP6zW6N2I+GF3PxIxdtOFw9JgsHvdc1xEgFSSYa0G97ayhT839f+OayLzGHLmcOduWZQfRZZd9yiv1ndIwwFSO30DT5ACMk4qT1pDuOD6HUHfcqjf4/sCfpual083hUF7PjfnJxO9R+pqrN8D/5vTvYyviS0r3n3zs/Q+NTcO7cn9bR7T3tKGjCi8HI+0ZoXVEHxvlpPEQ9sY5Uh3YQCWNfbd3h79PYYf/tDzbgp/WxpZOWqn/VeikfNKt7FmdV/mf+gjtTAjPOZw+QhcQtAhygEi61i4vi3r5EEeEChF+WvUflEVaSw+4TybzpbCyXNuo0ddA6Fa14M1AtMCxsyD5e5ZVRZlUP97mHYpX4xlfHEnmWBPVoLemRILmIGEfgCSpsW4fRgxNUdUmpIaGIANgMUUHVT1DHZjmlw1lglKBedbJfA55JYtW2BCSb5Zv7Agpgiz8jCpYzIMfVP6N8U1pyfHuwXs37xveQjucLnypFWgt9ITa2yWCzf3sFv/RwOUbA5l4hvI2bRtUxgfyAj70Trh//FhmGTOcXU34mVMD5fikhUZovlrkatQ8E32PomjMv9Tyc34nf1Iyv8bui30sSsk6o/mUM30/uVcGWKI5ayVX7qXLyVu5hpSDvLUjtuZxjkeeVYB7uMmtiIQaHlT54yu/4ywpUNxS5pslHaolUzXA1C9GjI2VMDdel41iSAABGzTRTzMzPIitYeIVQ== 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(41300700001)(2616005)(83380400001)(7416002)(2906002)(186003)(36756003)(5660300002)(26005)(38350700002)(8676002)(8936002)(107886003)(316002)(6506007)(66556008)(66476007)(38100700002)(4326008)(966005)(66946007)(52116002)(6486002)(86362001)(6512007)(478600001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zDeteWh1/dGgkedRhmgI+2Go1YU6OL1jStyKvkAzeUE9sdHyQuEguo1+rznXgVaorin44ciQU27tjLvwgvrfEtCr8LVlV7AmHgTlHVXE1Dz7zRTbNt4PnwwaCs0NsYYKaaHGP3pRuqKuY+ovYf6uQr+mem8TtmGBZUFnfq62NsZm6AVjwy1RSK87f1oAA8vjj8c5TtFP5YEmPF4MjawV4uPcXJLfedfQEfm9ptrvFvz/4bqjDm835c+u1Ywc5RzSvTVfH7WQKXJpf80cowNQHpQNn8Tm+TskUMRQtwOpq+5CaZ4ABiOKcl6OTHeC3mc/zbetXSiLlbLOuY0Gih8xjVSKBhC93zl0xNaw5gpimTwPZmZ6162OeWo7BAUtZSt1F0xpn9uXYAXCcdBY7rHP6mspbAQ9qAo+ZwQHIjkX46wXGWPrXJybmwoVJnLgcZg8U3ScRLbhcUXcoBCR3Y5T3orE0YHlda3zmucjS8XAOlV/3WLghtX0QshTIx6xE0SO6hv75QIgrvOlK5KePB+qbjRlDcfBT3gtBqGpDH6hwblBGxYzukmGB/SmxnoVFPx+d/SUXED3hCCoW6Lo+RWjYktpclHVV0oNW4vO9A/r1n1LoTme9HDX34HDe1KNoOeZkhjaPi+6KFPeU70TbcdeGsXDnLO3DHpX99qomdL7RF2hh4iasB6papOB2SVzGVGuhT+a1vrTkPn6Guh71/e3KxvYd1qW6k2r41Cv/6x6vIq2XmR847kuyIW3bPU9Qo/1cfTuUevidUXUUw09pgzRW+WGiAlPHvgOfBV7O01WFTY+806fONk9KYgy1shqBOCws2mvlw86Pjt+mArGnJHgdkqsLKWmG6l7SzBxfSK4O6IdY3jiMC1ZLyQQJTqBTVKEhZQLkwCGU/j6lMHCdOPViD7ftv+Is1jkfbAIDUUHAR4mmpa7UJr4owWILn2QV4I9Zs9mGINfbohQIy1XwJGhhLTvAwCUTpTq/3et5HYpJ6GwZH6ZurVI9UtjpR4pFZYFlMmO6Uh/46gIfOrbBOa7wz12AHH76EyCctU4yyEIvYVG96Y/BGTGM1AoJ9Dp7KSjEc0RWtfcXYXcM1/wOOzqYc6T4kqOSkvcCtL5FRPOmWmFxWhzfTiTkyY8GRHJn++xsiZIXJ82B1XOuHBFl/RQQ9vLE04/5zy7b5uYsucFUS/bl5t1XwxYgk9bDalvLhI5BkVvPR3BLB4rFVARoS5dZwluwKzKPrPkFQ04VaMIfh9WW99QpGozjRwG+UBCUeCRCZ7HfvDy+K6XwPnwvZx9QPTXiJ5FsNyLk9Vrs4Wf6Shev4v7WAqmdYKZv1J8QmetCKEIZEj5wIYQg030UbLm1p971haVk4AjM/4G9nSy/O7trQZ96N+2kX5aied4R5vZU+ycXiF74Fp/30hs/uNQVPonIFkeKB+VM3XJWDRKmA7eLf0tU08Pbgt9Px+BGBnxSTdeGLEbT57UO5ZQBBT2qVmGxRAlqBAQTECbOrDz0ZI1ZWfg+PtYokNXnFeCOQ5AHBNl2uouehW+5agywPoQH4gT27yB8KxFA4lI9ecAIys4s+PhbuOGgjr6uC7MGanq X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 973606d9-4f12-4eaf-c4cf-08db83950e00 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:34:01.3093 (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: V0Ug+AJtlM6hAv8KCvPN/1/gbqIBpuccZjqEfc9F6Y3N5nKOYnOhgA/kOWP2XTYhAHgaSNokQvboL2B0QcvcpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8719 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Adding eventfs_remove(), this function will recursively remove dir or file info from eventfs. added a recursion check to eventfs_remove_rec() as it is really dangerous to have unchecked recursion in the kernel (we do have a fixed size stack). have the free use srcu callbacks. After the srcu grace periods are done, it adds the eventfs_file onto a llist (lockless link list) and wakes up a work queue. Then the work queue does the freeing (this needs to be done in task/workqueue context, as srcu callbacks are done in softirq context). 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 | 110 +++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 4 ++ 2 files changed, 114 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 75dc8953d813..322a77be5a56 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -45,6 +45,7 @@ struct eventfs_file { }; static DEFINE_MUTEX(eventfs_mutex); +DEFINE_STATIC_SRCU(eventfs_srcu); static const struct file_operations eventfs_file_operations = { }; @@ -299,3 +300,112 @@ int eventfs_add_file(const char *name, umode_t mode, mutex_unlock(&eventfs_mutex); return 0; } + +static LLIST_HEAD(free_list); + +static void eventfs_workfn(struct work_struct *work) +{ + struct eventfs_file *ef, *tmp; + struct llist_node *llnode; + + llnode = llist_del_all(&free_list); + llist_for_each_entry_safe(ef, tmp, llnode, llist) { + if (ef->created && ef->dentry) + dput(ef->dentry); + kfree(ef->name); + kfree(ef->ei); + kfree(ef); + } +} + +DECLARE_WORK(eventfs_work, eventfs_workfn); + +static void free_ef(struct rcu_head *head) +{ + struct eventfs_file *ef = container_of(head, struct eventfs_file, rcu); + + if (!llist_add(&ef->llist, &free_list)) + return; + + queue_work(system_unbound_wq, &eventfs_work); +} + + + +/** + * eventfs_remove_rec - remove eventfs dir or file from list + * @ef: eventfs_file to be removed. + * + * This function recursively remove eventfs_file which + * contains info of file or dir. + */ +static void eventfs_remove_rec(struct eventfs_file *ef, 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, level + 1); + } + } + + if (ef->created && ef->dentry) + d_invalidate(ef->dentry); + + list_del_rcu(&ef->list); + call_srcu(&eventfs_srcu, &ef->rcu, free_ef); +} + +/** + * 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) +{ + if (!ef) + return; + + mutex_lock(&eventfs_mutex); + eventfs_remove_rec(ef, 0); + mutex_unlock(&eventfs_mutex); +} + +/** + * 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 a51312ff803c..2c08edd4a739 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -40,6 +40,10 @@ int eventfs_add_top_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 Thu Jul 13 11:33:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311881 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 AEC0EC001DC for ; Thu, 13 Jul 2023 11:34:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234443AbjGMLeV (ORCPT ); Thu, 13 Jul 2023 07:34:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234272AbjGMLeM (ORCPT ); Thu, 13 Jul 2023 07:34:12 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011008.outbound.protection.outlook.com [40.93.199.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB9F2703; Thu, 13 Jul 2023 04:34:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fBZYkaKD9lT0QyakyiVSz3tpOxLJ8HnhOZmqFnivj1gNogk5tUWW8ScgmiAP7VunkOGLMyR1I0/xY6GLDSNkqE6r3JMxWfYQsBJ3ZlaymVcqOgG6SCowZOX9y3DSnijN3wme+3i3RfjalEM6L38FXCEZDeXjoCC5TpTWKmAEZ0skGWUlFETz6r7UD9JTGhRUstcfayBEnNq82bA8KYtM+15zXbXMVAbvsp6l3og7GHfkC/Ce60pvC3F1duJqLV24cJLOpslDhUumJhWGqJO925UmHXmJ/Kgkw8n5po6NpE8n/bPsr4nKihPWjZLJSWUvvFTZcvLbkT9/ff+9qxmVvw== 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=za261eOrAm5M/t/4dj4NiMjZypajcEaCNE13hkKeW/E=; b=LuelkCHQBh3LgXu0oh3jX9I4SdO2LXWhqM7erdOrFnje9XJHJAp+hsRpgYAU3W1skWoMbDOSg5Htjdv0gWsq+vE64LlSFPuDOCxudqiZQSeMHhBLC9Xaaxjjk0r3kVojFO8y8DoBOQ1FNRM4rhkVeAYMnk3w9rEv0ot145z+Tdreuky31U6q/4dsssPaMHmPSN6zoJhVJJ5Sk/jcW8QyWWZVYrVj5xKQLiNgzf3UZc2P5O7bbVwdQz8DkAtO814gTAgm3FKfFmnMqJ/PVdeuFU8+iYj9OkhJ742l4S+7vxlI9se8k408bVgkQjEWus3wtZLYK4Hq9EpQh/84ii5TWg== 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=za261eOrAm5M/t/4dj4NiMjZypajcEaCNE13hkKeW/E=; b=FKzC/nC/BpT23Rm94JW/oDAurarYanNRl0A0Jg9Gp1zQ/coVsiFe2M4tpYGzW12nCQkUPoAzOVEmh19b5C9ddPr5V6RG/azzSsLAnD8aCei1fEWM2fbrzKEMEGE6+Ff+1+lz0XhbD/rqV+me6kW1HYRV9KGOn2L0gs0uJjXvbHo= 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 PH0PR05MB8719.namprd05.prod.outlook.com (2603:10b6:510:b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:34:02 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:34:02 +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 v4 06/10] eventfs: Implement functions to create eventfs files and directories Date: Thu, 13 Jul 2023 17:03:20 +0530 Message-Id: <1689248004-8158-7-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|PH0PR05MB8719:EE_ X-MS-Office365-Filtering-Correlation-Id: c2009981-6dc8-45c6-8d17-08db83950eb3 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: 6+zGcaVwFk4FnEQVZEy9AcGCNXlwmAyeIKmei/bFP95mtAOyD05MInmuBz3FieVwywbd05iGpj/qSAYkjTiTeD2TxxcEad7MyvfflJ1QqytMoDvh8VXwEwWR8euwYyx1sw2TF50sKxpe53+kBRZCA9Dlmmvy9ZSITU0FEo51nQ/RZ5WRAak43nUE7kIKEqMDHt3ig+xqYYkioWkUdbb/Z28VlqCxLMXzDRI8K6cjI7Rp4dbFaIq9OyN7YeID9vXIiFjqNKffALHCtrJXpQ3Zz17MxULlHzmC2sfZyyBZwMZbMkuBc3/Wj37H04v5uztGsCXjHgO51UY3nZM4aOTqtcB8NVWruunD+N7YehB9xA7y3Xwaa0SUMQfZIPkEPAv7XHy0vNOAesS4FnKE1GIZGoefbR56D+BjI2NHmPz6bL7cnc3057lO0lMdStDVVcAUJ/yRTwbTKcOwG0i7JHsqJaTpj2H5cQqF04D/X8Gk3+l/uRT+s/aRcrQz8JVpsLwIMtRUvsnWaFjyQLWnO2P+N5L+gRSIheEbSY+HtOQqMLFfj3ya5KvNuVOnPjdfVDoJtDzFbT2NdH0O53lonFTd/VSwimp/xxH2fUSqrEjxxibf7ZtX8qGkIaek+LNdmYRnhTFM90XxKuFjAHrXJ3NnMIWlsLgxHJXIIcOGWWxmsoM= 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(41300700001)(2616005)(83380400001)(7416002)(2906002)(186003)(36756003)(5660300002)(26005)(38350700002)(8676002)(8936002)(107886003)(316002)(6506007)(66556008)(66476007)(38100700002)(4326008)(66946007)(52116002)(6486002)(86362001)(6512007)(478600001)(6666004);DIR:OUT;SFP:1101; X-MS-Ex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QPQGrJuGACBwkQzTpg78JRp8DuKeQnTcsvE0P3PwEL/EjB9/Q4d2yPPgmSXbRCQptIb8QEfTbHLf9M+6lU65lJZRhBSRD0TPnYUaLoIl0hPELR4iW3IsB1hGduf4/RYChiof/tzF6AI2d9R9ebsp+OnoD/5v9wdJUewpUFNA22GrcWVPXfRiUm3OZf4QDrJXDgI30EA4+8u7RloSmZqvpbjETt8L8isPAnZ0FtoTJuMCl3zH7x/4xX9x9RcT19lTYUkNX2rpiiRl9deZRKpzS0octFXGoAxsSrvg/xXUAXaYdf+c4m3qTynQWDhASbsSOKjFAdS/AfmBAcVT78EGYYLgsHCZLUPQpFrQch5GudYoJO5kQi3pnQGF/hIszsOkFUdU5Yq6fb/N9uzdd1ERIB8K646x+MNZgSZ6e1eTmemJI2mrrPV/kWD9yshgFqr0zQC942dPtneu0Ne9WkPoAoZAkjx/GDEHSQGOjrxj5K98oTnhUxHChNebqtTZ+qdfUfV2SuZf0Bk+DvqqiY/6Bg5c//05kaRwKBmnQHNbxF6hI8zSnoyk+ X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: c2009981-6dc8-45c6-8d17-08db83950eb3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:34:02.4598 (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: tjO+ObImvLzZAIktIyOJOiYS7ig0F5ucOGkdy9VDEPCslpJh4vOrD8Uo7uHxysHRiFgGm7UFg5nzap0b+ETJ8Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8719 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Adding create_file(), create_dir() to create file, dir at runtime when they are accessed. These function will be called either from lookup of inode_operations or open 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 | 110 +++++++++++++++++++++++++++++++++++++++ fs/tracefs/inode.c | 47 +++++++++++++++++ include/linux/tracefs.h | 7 +++ 3 files changed, 164 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 322a77be5a56..34b5d3d8005b 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -46,6 +46,116 @@ struct eventfs_file { static DEFINE_MUTEX(eventfs_mutex); DEFINE_STATIC_SRCU(eventfs_srcu); +/** + * 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. + * The inode.i_private pointer will point to this value on + * the open() call. + * @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. + */ +struct dentry *create_file(const char *name, umode_t mode, + struct dentry *parent, void *data, + const struct file_operations *fop) +{ + 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); +} + +/** + * create_dir - create a dir 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. + * The inode.i_private pointer will point to this value on + * the open() call. + * @fop: struct file_operations that should be used for this dir. + * @iop: struct inode_operations that should be used for this dir. + * + * 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. + */ +struct dentry *create_dir(const char *name, umode_t mode, + struct dentry *parent, void *data, + const struct file_operations *fop, + const struct inode_operations *iop) +{ + struct tracefs_inode *ti; + struct dentry *dentry; + struct inode *inode; + + WARN_ON(!S_ISDIR(mode)); + + 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_op = iop; + inode->i_fop = fop; + 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); +} static const struct file_operations eventfs_file_operations = { }; diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 7ef3a02766f5..7dc692a5fee1 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -451,6 +451,53 @@ struct dentry *tracefs_end_creating(struct dentry *dentry) return dentry; } +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; +} + +struct dentry *eventfs_failed_creating(struct dentry *dentry) +{ + dput(dentry); + simple_release_fs(&tracefs_mount, &tracefs_mount_count); + return NULL; +} + +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 2c08edd4a739..47c1b4d21735 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 Thu Jul 13 11:33:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311883 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 957D0EB64DD for ; Thu, 13 Jul 2023 11:34:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234504AbjGMLef (ORCPT ); Thu, 13 Jul 2023 07:34:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38712 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234310AbjGMLeN (ORCPT ); Thu, 13 Jul 2023 07:34:13 -0400 Received: from CY4PR02CU007.outbound.protection.outlook.com (mail-westcentralusazon11011008.outbound.protection.outlook.com [40.93.199.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 182022708; Thu, 13 Jul 2023 04:34:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WviolpG7ZwHQXWkdO8fmLTtpAxdGMPHX3YQiM95HzBDsqDDjl0h9LkjmOeAefkh9m8jn2nqo2EX2VCwjKmRESO2TEOO01sw9Pl26IDEyDNg/qpm48EZZFOe1swFWvYzYt4mcGVLflS4igQEEngAZ4UqXzWuvd9EW22W3R8ZSMpM6PaiMB3G/mNtk7F7Ba4m9WYlTlB2r2OLZp4iDOIk+kxXd38el+zjLtLR0SjROqeyvrcpa/AU41qkTbzK8sp+wlILAxgN5U+59Ji65+ZEu6+aNIMRnWUDQQco/KmcasBXH1IgCAGNWHGmMCyVRPxZxW9hy8gBGoCX2Sx6eRMIN1Q== 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=jF4ddOV8P7X8cZLqZkc3fjyRoWlHKUCdIT9oKCt7tcs=; b=jiiKIFrFD6HCW/RKVxFtkrEwB9cHLxfJtmp1gaQHz9TH0w15LLlHYCovwhaDlH+jpZNis81hKL705n3caxuABDLGwbx+OpNuUcP2x9QNU0ELOlaPfHQ47oeXWbkyBr72S0CzQSs3v+84e/3rf9L2p+dU6+tAbhBYW/iPzHVItJ0OHvd+a+IOUs4/RUZ8HuS8KO0Qii914spo7gv0Pa70zsAL9WwQ5NMZv/uvVZPiyLDb4n97OLGsDYN/Yk0uJ3C/bioplg3VHxfvJuu+rC7Rj+Arlaz54nWAP37yEJJr1jHc8orPCDXPMdbSAxFQ7fzwdY1IsEi+6DkzHTY1Z0xtqw== 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=jF4ddOV8P7X8cZLqZkc3fjyRoWlHKUCdIT9oKCt7tcs=; b=sOa7m7oyYMVuQy0GCX+Dg6+dStnx6/gT8govpfP/gRri25F1tZVNy9ojaGccE+kuWCGx98iwL4WXWAph84gBAcs7iI4r5zuFRzSgoK2cK8jvSJSS4t4Gyh0e/DVriNLQrg+r9MFzlNNBZmgOH7GiU5fFUHR7zu1ToEZND6pyozQ= 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 PH0PR05MB8719.namprd05.prod.outlook.com (2603:10b6:510:b3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:34:03 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:34:03 +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 v4 07/10] eventfs: Implement eventfs lookup, read, open functions Date: Thu, 13 Jul 2023 17:03:21 +0530 Message-Id: <1689248004-8158-8-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|PH0PR05MB8719:EE_ X-MS-Office365-Filtering-Correlation-Id: 0c96c418-0deb-4c92-69fd-08db83950f5a 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: koyu4XqB4F6ShWPZwA3lUj3V+P/DNCQ5by/yb3nLjNP+c9Boy66F1AWI67q4iNVBypBMO3lZ7q6xNqsx+pxAerDkUNrufj69+Y+3fgiRrMf6wFOMV4o0fObSoWPhLCflAipNCZ2sqfymVvyXe4BqN6ToWEaY+gl7Os9km/uqFlwpdm/X7uvJ9n/CrPcA4NEDBr1Wm3eiCI3zMyI4FivIr9olrGdbHHIeUrU65CgruW0+mjQfae4mTWO6SCLDzEI+KcQ5fUutxpljfwZ2Yir9n8Ckay3Rhx09SBDM4J53sC/lUtnXioGCQ4q/orpZJX4vTDHRL/5XBahmz/8y+ho3up7dTOC4mF1lR8vKPit3UXLCGdUaLKXDKzraqBi45O5sjVrsddHPbLzlv9t1DeMaandRlplOEHibzz5F+JDREL8gNuZDW1dzssoaKoEj5elB1fNt96/JNsqappVJK05SEKBxD+4EQbe8M5LazuQFXJTlIAGIXyNvWa1NY+l4XQblcuKt4Hraesfes+l+Oa9jBrJGsYCzqFBrVQGb4SG1baQCd2P9trhZtKJv+IVAG7TzyFA3T3mRfQ7X+BqpaNkbcgp7fworBgzY7oIms3mwZ5edsQWoeq2PUR+mUGHqTqjt8N4fESXSj9wXBtb6/nMxPGRrW11ZVYWA/j4vyW+R+tc= 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)(136003)(376002)(396003)(366004)(39860400002)(346002)(451199021)(41300700001)(2616005)(83380400001)(7416002)(2906002)(186003)(36756003)(5660300002)(26005)(38350700002)(8676002)(8936002)(107886003)(316002)(6506007)(66556008)(66476007)(38100700002)(4326008)(66946007)(52116002)(6486002)(86362001)(6512007)(478600001)(6666004);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: l/0aMV4ksZwTSup8uonv1lIycBbMH8wBBLgbpZLcRWS3eBgKkfXDGuihooeUUzrMd1FoMG1ebxOv4Y+RI/ufwmWNdRLS7XYSQQ2/GSoe9lwD+Y/FTtw1A3QKNcMfdUrZU1wjFOWz63f4u6eQaKwffVqBaud+T9dcZ+p+nz0pAoxjYfdZysfVXa6k2VDpJIefsBK7mv+OPFEDZKGVA4N2gt6np0xNUwhgT/Mw822WhuyfCStdi66/EKsjYpDcdkigtVB3l4eEjj+h+xhFicYvBx37DrYAhGgd4nP+mu2lPgb9R+kifH4bwS7NbjXURkkI9PRVviJ2tThnpbVHCbxj4FQDmtalOI5Oj4N7Q2t3UhVL/QzONexD7Aw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Gxs75XF4MaX00TCVxaL7d1/26ksAuK9MKG6hV7yAtTGy14+9wX1d1cJMS/wm3b++bHBoI2u5p0R7GP1c5SdapXcHTxhKGjQjYzs3u/AakQWwWJvvZ2Cal48oDsjigLEtM X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0c96c418-0deb-4c92-69fd-08db83950f5a X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:34:03.5868 (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: RF3yz4WENlRVIOH48DbkH/rtOHJEhug3AzxdIyh2Ox5tM9Q1INb5ol0VW0VIbhHMMBMzMBj+CRWUx0waMirvZw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR05MB8719 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Adding following 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() inode_operations, file_operations will be called from vfs. 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 | 194 ++++++++++++++++++++++++++++++++++++++- include/linux/tracefs.h | 2 + 2 files changed, 194 insertions(+), 2 deletions(-) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 34b5d3d8005b..7167340ac29e 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -67,7 +67,7 @@ DEFINE_STATIC_SRCU(eventfs_srcu); * If tracefs is not enabled in the kernel, the value -%ENODEV will be * returned. */ -struct dentry *create_file(const char *name, umode_t mode, +static struct dentry *create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fop) { @@ -123,7 +123,7 @@ struct dentry *create_file(const char *name, umode_t mode, * If tracefs is not enabled in the kernel, the value -%ENODEV will be * returned. */ -struct dentry *create_dir(const char *name, umode_t mode, +static struct dentry *create_dir(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fop, const struct inode_operations *iop) @@ -157,10 +157,200 @@ struct dentry *create_dir(const char *name, umode_t mode, return eventfs_end_creating(dentry); } +/** + * 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 + * reference remains + */ +void eventfs_set_ef_status_free(struct dentry *dentry) +{ + struct tracefs_inode *ti_parent; + struct eventfs_file *ef; + + ti_parent = get_tracefs(dentry->d_parent->d_inode); + if (!ti_parent || !(ti_parent->flags & TRACEFS_EVENT_INODE)) + return; + + ef = dentry->d_fsdata; + if (!ef) + return; + ef->created = false; + ef->dentry = NULL; +} + +/** + * eventfs_post_create_dir - post create dir routine + * @ef: eventfs_file of recently created dir + * + * Files with-in eventfs dir should know dentry of parent dir + */ +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; +} + +/** + * eventfs_root_lookup - lookup routine to create file/dir + * @dir: directory in which lookup to be done + * @dentry: file/dir dentry + * @flags: + * + * Used to create dynamic file/dir with-in @dir, search with-in ei + * list, if @dentry found go ahead and 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 (strcmp(ef->name, dentry->d_name.name)) + continue; + ret = simple_lookup(dir, dentry, flags); + if (ef->created) + continue; + mutex_lock(&eventfs_mutex); + ef->created = true; + if (ef->ei) + ef->dentry = create_dir(ef->name, ef->mode, ef->d_parent, + ef->data, ef->fop, ef->iop); + else + ef->dentry = create_file(ef->name, ef->mode, ef->d_parent, + ef->data, ef->fop); + + if (IS_ERR_OR_NULL(ef->dentry)) { + ef->created = false; + mutex_unlock(&eventfs_mutex); + } else { + if (ef->ei) + eventfs_post_create_dir(ef); + ef->dentry->d_fsdata = ef; + mutex_unlock(&eventfs_mutex); + dput(ef->dentry); + } + 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; + 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)) { + if (ef->created) + dput(ef->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 it's child) + * + * Used to dynamic create file/dir with-in @file, all the + * file/dir will be created. If already created then reference + * will be increased + */ +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) { + if (ef->created) { + dget(ef->dentry); + continue; + } + mutex_lock(&eventfs_mutex); + ef->created = true; + + inode_lock(dentry->d_inode); + if (ef->ei) + ef->dentry = create_dir(ef->name, ef->mode, dentry, + ef->data, ef->fop, ef->iop); + else + ef->dentry = create_file(ef->name, ef->mode, dentry, + ef->data, ef->fop); + inode_unlock(dentry->d_inode); + + if (IS_ERR_OR_NULL(ef->dentry)) { + ef->created = false; + } else { + if (ef->ei) + eventfs_post_create_dir(ef); + ef->dentry->d_fsdata = ef; + } + mutex_unlock(&eventfs_mutex); + } + srcu_read_unlock(&eventfs_srcu, idx); + return dcache_dir_open(inode, file); +} + 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, }; static const struct inode_operations eventfs_root_dir_inode_operations = { + .lookup = eventfs_root_lookup, }; /** diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h index 47c1b4d21735..4d30b0cafc5f 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -51,6 +51,8 @@ void eventfs_remove(struct eventfs_file *ef); void eventfs_remove_events_dir(struct dentry *dentry); +void eventfs_set_ef_status_free(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 Thu Jul 13 11:33:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311878 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 73716C001E0 for ; Thu, 13 Jul 2023 11:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234264AbjGMLeO (ORCPT ); Thu, 13 Jul 2023 07:34:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234235AbjGMLeJ (ORCPT ); Thu, 13 Jul 2023 07:34:09 -0400 Received: from BL0PR02CU006.outbound.protection.outlook.com (mail-eastusazon11013000.outbound.protection.outlook.com [52.101.54.0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C702C26BC; Thu, 13 Jul 2023 04:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bnCuXYaA9Sovi+Zy1lQaopC5MRyShmSvSfEfRZwLSL1nA76/s5AzhPiDMvoXPrznwnM9ti4WIKBiCBmzTMqHCJOzTHkPFB3MIb4m/XtGwRQ4R/71lSYHGf+/dOiEMrnd/D5PgXfC4821HKzcYtSDaI0SckHODoCYCyt7Tj4kRgluPAEvKMhTIo0tQFrZQjLBn5rvNUoMA1SKlqmNY/avIFt0lEQSltTghuyJGQzkdyLFPge/c4MldFf+FrZnHu+SiSs4dGXx3V1FBImy1H9xoI+sFQJ6SvASM0TRgCgyUgvZK3QZ/PyoopkKu/m0XtC9e71+z+viiuC27v+ssQE//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=nbuhKy+qPAdxyOC3p4T5oQ+vQWR4mVCWww69MpvfbWg=; b=jGI3Zx9Eb83wlpAH09OkgJ3FMgg44YozI9AU1U0LkET1B6aUqnNYeR8pSfhBK43OQXFWxtvwgrljU9CZO4p4y59E8F26u6yFjyaGzD0aCrj2hzv7gMA5bKYnaqU2jFYbMPalyfJnkTwW1tYLrDElDhU77lGWc7OvOl62111EfA1xfCRux6WqjFI6mvWUpnqgiXTtBi9F7lHMIFOJ6TL3JB7gur6tiwxxk+WttA8zs5vmRbiFYfyY5Zx3IrlPitPjvIfsEXoD6kLUDVqX16rTYvh02L+8nEJ1z5gRErQ0hDzA+jmZvhR/AxQBDiDKPbcBRTkGgFIfTXmo9750/Y0LRQ== 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=nbuhKy+qPAdxyOC3p4T5oQ+vQWR4mVCWww69MpvfbWg=; b=QQAno0XNCDGBfK+/i3ADzhI23PLBXfSXqk3qeNAM/2JH+vTfS7viBzOFIzFsZlLFdDlcQIw1HX78lo6mBjtzQd4Cy3IAKeij3fFFH/5i53WQvgVy5iUnwbqNCIHxlCyg8vyYrXjTViw1nMaXweJ3RplrenK+vq9q6/4kExkB2ro= 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 SA0PR05MB7452.namprd05.prod.outlook.com (2603:10b6:806:c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:34:05 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:34:04 +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 v4 08/10] eventfs: Implement tracefs_inode_cache Date: Thu, 13 Jul 2023 17:03:22 +0530 Message-Id: <1689248004-8158-9-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|SA0PR05MB7452:EE_ X-MS-Office365-Filtering-Correlation-Id: 12751f85-b0d4-4f36-a983-08db83951003 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: tUDGVB6/G8P1Jm54dZiDA8AZueteLficoo84q9a9OBdnxGz/wZrz05S3opCo3VG0qZI6xxki+9ls/oCUezttGybHPeFpTwiJIetwSuM1JSboupvB6YY+JancdTQWPq/AUUZkVIFyyS6P+txDeH3XU1UvkhJCJwTFcGkvCKTw+EisvX9wIxomEBARJ13kN4+eFil4ERsLFJQTmJeZLeJVucezUUEwLfgQ8+TGoXvmeNQPgNgj9dx+2HDf7rI5h5lbrOe0MGg8Eu5AnGpleSXpKFlHgrThMORWkZH4M+hAtGNx6BuEXh9h0IO0/EdZkv6cpSu0ExPAx5D2B+++WKEogAl2FaHjwK08/ySiPejJoNBXudzcmN1J4sR54rjFToTKbqqt+IlJAZgu4vWUWLGuGWjaRgsY7yEM2bKqs8GmTtfVGN9rtHGwYi51xzK3yj8UR9ou0emBzV1qvDIihA/6bDPAyB/TVhBl2QApyMvU/HL7m3DVxokEg+KAsKi3bFu1lB0t+a9Wg6aFQ9ZR/JmtEHUUr2OaCthk7PShhf8s7t2Jej2X8yaUzgS3QGCLLLebNdwDGnS6Z/zpYxWL+3Z+RNGJkGlJQwMFFfaaut97qPxcPvd5Jzm9ZeDYzHPsn8DPWLdchdAtqq5ZyM5W24Rl1S63cmk+3jV+/6b6Db4yQF0= 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)(376002)(366004)(136003)(396003)(346002)(39860400002)(451199021)(6486002)(6666004)(52116002)(478600001)(8676002)(5660300002)(2906002)(36756003)(7416002)(8936002)(86362001)(316002)(4326008)(66946007)(66556008)(38100700002)(66476007)(38350700002)(41300700001)(6506007)(107886003)(26005)(83380400001)(186003)(2616005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 74A1lK123lkgh1W6KtpIHEzpx0jA/kGlW41mw8FwvsLPMJs0XmM1EybEuDPhLIjgSgH6Gks4KnwlbfTN41cafx8wa9BxkEGapwSUD7BkGKG75NZuX9LJgwuuntd8cvajAGnHWos2X+7zSJif8cLyhWbDLfpZ0pRGUqGWlCFx13vuOGuHCSobtLY70NiyU2syScMmRaPqyqXi5PvmCZxbUInS+2VByhtLNnYnjgQ7cpNZIHLFAGEE9cMZelwzgRu1VnGnJh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zjoi5JCnHxKninBvX+EYhFA9U6XhWhtsJdyjkIzjL/yhheUj//rdbD+d1Vzr9T6DBBxcDA+sKiC/zXZK3aKl4iFf2tV2MCmUizjprqIkRvjv/Eg2JE+GHh5fCc9XHaqdKQPfe8k+6IKYqAV0gOq6TPoKlKswZ3p6jC9wrP0DWD6H5DNER1PiA2Sz5FOCWRvONe5MDdqucjpJzFIK/sbqsLopgNqoQaay8oxs+aRMOMCx/4mmaO+VnvBpiw X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 12751f85-b0d4-4f36-a983-08db83951003 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:34:04.6505 (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: 6CGyh2zjym/NRq23RQjV4hmwNM9Tx3PgP7r5/8zOxmDUW74/UR0HeZEDHg/ZlE61ifaqwvzwjyW6SszcErvcKw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR05MB7452 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Creating tracefs_inode_cache which is a cache of tracefs_inode. Adding helping functions: tracefs_alloc_inode() tracefs_free_inode() 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 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 7dc692a5fee1..76820d3e97eb 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, @@ -675,10 +698,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; From patchwork Thu Jul 13 11:33:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311879 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 0B3EAEB64DD for ; Thu, 13 Jul 2023 11:34:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234379AbjGMLeQ (ORCPT ); Thu, 13 Jul 2023 07:34:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234247AbjGMLeL (ORCPT ); Thu, 13 Jul 2023 07:34:11 -0400 Received: from BL0PR02CU006.outbound.protection.outlook.com (mail-eastusazon11013000.outbound.protection.outlook.com [52.101.54.0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BCAA2700; Thu, 13 Jul 2023 04:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MDwEiqroHZ6PDoWoeAM2Cop4Osc8bvMcbl7x56yEGrB3IHb7q4+nwHCyKGREQc2Op+E6oe1IMGjs0vgyGWGIYuxo52pLcTyrbz5JWegtal/+boNsPlEWxk2bma1L8EmPpP4gv6dL1NqBKeGlLyTdA1UoAcCPG0LZ7VwJbvuz/7nQTYO/up17gvJurMwfWr7RCi6l357NpV1HGPvdFVHONfnaah73HYT1B7U8QVNbYY8A1CgNSoluPT1YACr86AS3ZZWEOsk6P9/Huyw+6ubtIc4N/yRJGy/RwpsJ0bf4wYDS659FpFISHylo4U+m3qjQtYjwklfsU9iJjs+M+FNEQw== 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=RSHFHeqQzYuFLfiobbSC0DLv66Cvpm38ftXy5EyG7HY=; b=cjViEEtzpkG6vO3ZAZmL8IF0nbN+QgDEdcKF2NgQ3ao6sX8VmIHhSxP2RJnJFXT7tn03JgRcu5Gc1N/k0ysre7sITuRqyBBqJk8uYV+wN58tknTJC38zA+uGvbj0906rCBFrpd8SprLuOOSV2k9qMamlukItzVInBd7oqs2WiT5Wh6zb9rjtbtVog1ZgSbGl6s3JRoOzy6iKQ4j7I9z4Tyjnoqm3HrAG9I1LhdrNOm8qgvjASxMsx+7YzGTu1bI3HrhayUCkP/S9STAB9dQZIF5yi1qmyab48FOuPXYGKKmqgmOt20PIQwIwIYsuWa17FcITKzPToydO9Fn7t/pYAw== 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=RSHFHeqQzYuFLfiobbSC0DLv66Cvpm38ftXy5EyG7HY=; b=qIsE3uGnwguagesFhX9abD4HoUo92Xhqs0Pomk8pKfAHpxm4O6ZlqXAUN5VJhD6ibO2UaevHT8G0nt0SrmmtrMkqcEBTmjWFii3gh/t+TOAiuYYvj6bchI5zWfhfAu3AWWDFLWxIDV6W26EGfRBrfd+57W2Vmfspc+FBy8VBm+8= 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 SA0PR05MB7452.namprd05.prod.outlook.com (2603:10b6:806:c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:34:05 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:34:05 +0000 From: Ajay Kaher To: rostedt@goodmis.org, shuah@kernel.org, mhiramat@kernel.org Cc: chinglinyu@google.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-trace-kernel@vger.kernel.org, lkp@intel.com, namit@vmware.com, oe-lkp@lists.linux.dev, akaher@vmware.com, amakhalov@vmware.com, er.ajay.kaher@gmail.com, srivatsa@csail.mit.edu, tkundu@vmware.com, vsirnapalli@vmware.com Subject: [PATCH v4 09/10] eventfs: Move tracing/events to eventfs Date: Thu, 13 Jul 2023 17:03:23 +0530 Message-Id: <1689248004-8158-10-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|SA0PR05MB7452:EE_ X-MS-Office365-Filtering-Correlation-Id: 68435f1f-9ead-4bcd-5f84-08db839510a3 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: w/Nh3CYNlt4SabFiXdWJYVgoR6DFgEBTapUi4MXShHVqP2OpmBCN60cpxTjs0V7jrRK1bDmy7eliKP+DCks3p8krVzG/UbHf3GbBRG0U6/E49aWVuEbWfjaSPlu3OfbfxtQZBakqR6yV/VNvC0YroR5DMXY5QwcHfatFVabAXAyYAE+Lbdmwwpxmf+YmBDb55KishN0vDScr3SZla8LAQVRHvxuSMfkcAUD7Pl/jUqUBr8FVXN/dHGaV/FckOexusMQ/a/8xjCoxiZJIBSFk39+C5LSOOxbIA4ImpITzbXP9rqdc/bT6Dn9HjMnB7ex9+mMJ1L+0kgN/JOXefXQj4TjoF0DbYo5O1HjMx3kA0r4xfv8OT7rOmQkEcTuRs05yF1SiUT0XF6JzGScp3OXXfSc8H1hg1UEswJxfAatOJBr5DOZHVDuu9TkBpONOT3I0dhTJr/T8haC38/rVqM/a42pmCc25h0H4GXsQLgIW1ySRBTYJOaYVFKsFIg8qxvWkF4BaAh1U/eqfrsrIZ2riuR3Fufoojvcil4uPEB10TJpbITTtGIbO27EXDZ2xWC9BfG5ZkyHbRSA9eDO0XOvtXdGD/DhaO1ZS4kdAUQ0mqV9c6I0I3oPoM9qMSm5/wGOOsA6nfG11d3dd6lMqr8G0NVjBqWxwmASUL0hStOAf0Lk= 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)(376002)(366004)(136003)(396003)(346002)(39860400002)(451199021)(6486002)(6666004)(52116002)(478600001)(8676002)(5660300002)(2906002)(36756003)(7416002)(8936002)(86362001)(316002)(4326008)(66946007)(66556008)(38100700002)(66476007)(38350700002)(41300700001)(6506007)(107886003)(26005)(83380400001)(186003)(2616005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S501ralJtwaTE8xRXyu0ARb2+HVzQb2mU1LCNMf1Mpf8DSLVkfbJLrHHEHzjBAVHK3glZaOdjZ6bni4J+npZipq7NBROhaDNIKD6Dz0x18baK08Y6LF8Lp2vTS5KR00/KJh2LoAKnv2lDQAhaRBKREq5IvpaKmXldTIeFBXe2awdokKMlGTagzKroxj0EAExHSpSpVtSl2zLKvY7Uz/OHW05iOoDDFn0h/UmQosgb7Cza8UmpIWQgOJqH+jF9V0Jx5YxIpnZWkmtD3BJX4eilvcrlaVsN2eam8YwRTzedEPO6gaYce26Fn2SBoGGkJnEN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2qZZingpwRyEl45d7XCi9Bz2989zkMGfGk6csIS/zdcWX78bzeFVj73CbXR+vE+PCs/rYmuk3zL3YXgg55ZtjqPkWTIl/FjNRG62vCaLrG2PqUjv+lwUAIZiG4gH+jku2OcC5MUWFjf6uwyuX9Y5wx7amDjr12Fmgrmryk+qHtQN0JizgsTe7BQwsTi+3Ril6Cu X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 68435f1f-9ead-4bcd-5f84-08db839510a3 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:34:05.6966 (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: zAOKfSDuSl9I9LuN/CK7tnUEo2/5DKTdhGD1+ybvQym0XbJrqGP+Mi6pcga0MabQKkjlcQRtQ8oJHcicG15uvA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR05MB7452 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Till now /sys/kernel/debug/tracing/events is a part of tracefs, with-in this patch creating 'events' and it's sub-dir as eventfs. Basically replacing tracefs calls with eventfs calls for 'events'. 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 | 67 +++++++++++++++++++----------------- 4 files changed, 55 insertions(+), 33 deletions(-) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 76820d3e97eb..a098d7153498 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 7c4a0b72334e..c6bb74cccea3 100644 --- a/include/linux/trace_events.h +++ b/include/linux/trace_events.h @@ -635,6 +635,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 79bdefe9261b..d9a0ec2b918e 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1309,7 +1309,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 12ed71428939..4058178de682 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -990,7 +990,8 @@ static void remove_subsystem(struct trace_subsystem_dir *dir) return; if (!--dir->nr_events) { - tracefs_remove(dir->entry); + if (dir->ef) + eventfs_remove(dir->ef); list_del(&dir->list); __put_system_dir(dir); } @@ -1011,7 +1012,8 @@ static void remove_event_file_dir(struct trace_event_file *file) tracefs_remove(dir); } - + if (file->ef) + eventfs_remove(file->ef); list_del(&file->list); remove_subsystem(file->system); free_event_filter(file->filter); @@ -2297,13 +2299,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 +2313,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 +2337,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 +2353,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); @@ -2420,7 +2422,7 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) { struct trace_event_call *call = file->event_call; struct trace_array *tr = file->tr; - struct dentry *d_events; + struct eventfs_file *ef_subsystem = NULL; const char *name; int ret; @@ -2432,24 +2434,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 +2467,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 +3640,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_top_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 +3668,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_top_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_top_file("header_event", TRACE_MODE_READ, d_events, ring_buffer_print_entry_header, &ftrace_show_header_fops); @@ -3757,7 +3760,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 Thu Jul 13 11:33:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13311882 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 EBB67C001DC for ; Thu, 13 Jul 2023 11:34:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234497AbjGMLed (ORCPT ); Thu, 13 Jul 2023 07:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234290AbjGMLeM (ORCPT ); Thu, 13 Jul 2023 07:34:12 -0400 Received: from BL0PR02CU006.outbound.protection.outlook.com (mail-eastusazon11013000.outbound.protection.outlook.com [52.101.54.0]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13A1E2705; Thu, 13 Jul 2023 04:34:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Yo9sfYO3oFr8OPAkPxMu7AxP4p0y3MCXZnbUByuHV+WSZ8VQuN8jSgxfCG7+otK78tv9YdMXY4OGLObUzkFm55RBhxSroSAJDwCWGS7jQ9DI2V4kdRM0nCwxgiv8xjP5g4qIi1pE8jrE2Pf4PacFfSNGvs4WCDfjgRZZvvYfM80EvQrAYbWQQlmZZKWuGGZV8JhU1TWPbmOYM2iq+8SM+v1lopmfnP0Nw0I1cTrhve24vdH90Al7/W+Cgge2xR72IPR5Pg2aACi1I5VZuJt0xDsql/KI81xGCeoaR9CiB4jxgu+AMbw0oU4kK0VCuVvmGNdhxPOffQuE2FZ2dwO7XQ== 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=eR9LXRcDw1z+h0pPmQffRxqFI1NP1S8UEGCiEhbnhi8=; b=JODHZLOq/A38wud7zt/qesH9kDK1awf5eXoWO0v2+Xv/OuCZCeHR6oWE0OzeMhnbSl3coeOkZsYu/MWQ4aWiplMPCDMsRUHJHAGhoSxc8FKJn9ZMkmNXH3VZxrfexCY8WzfZLNtYdp69p8llGUP2iE5xjUZTfcb/XXL99WbqE7ov6QTWv45qzm2K02Kno54+CtmKw/0upeognQC/Cqy6vE04pHSmvT/CL8ADl4y5Gp6ALgcWWXBGwtZos5nKTSBmlrEL8DC5LU9haBkosXRmdSUKwa0thAWqUZ/zBB9+uadYhsS4aW0lLX6+aSxs1hXa9vXEa4IEAaJ3Il717md4/Q== 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=eR9LXRcDw1z+h0pPmQffRxqFI1NP1S8UEGCiEhbnhi8=; b=ARTWjz8WkB4eSk7s16yhGzqPIiOiPka5fah0NMOoSSzWjkwox/KwWhud4d3GBiElhHyTz6xM4TYzzYbKqUxk8oyP9GnHs1x0ht1SOItLajdGXRff1PqrnEwZBFqB3yjDRZj6KNzmI6V73VYODqqs11FuMN17ir4sQ+l8mwYQ9a4= 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 SA0PR05MB7452.namprd05.prod.outlook.com (2603:10b6:806:c3::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6565.32; Thu, 13 Jul 2023 11:34:06 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::119b:d975:430c:e1b4%6]) with mapi id 15.20.6565.028; Thu, 13 Jul 2023 11:34: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 v4 10/10] test: ftrace: Fix kprobe test for eventfs Date: Thu, 13 Jul 2023 17:03:24 +0530 Message-Id: <1689248004-8158-11-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1689248004-8158-1-git-send-email-akaher@vmware.com> References: <1689248004-8158-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: BYAPR05CA0046.namprd05.prod.outlook.com (2603:10b6:a03:74::23) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|SA0PR05MB7452:EE_ X-MS-Office365-Filtering-Correlation-Id: b04d2070-25f1-4f31-3ec2-08db8395114a 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: 0765TfaeCQQ508t2XZGzleT/HlC3YWGu1/1hG0pxQL6jeP04xoCfYtNU6YJcB+5TSTj+2MeE+lzLlpK6SCSg5f9WSbO9esra3O4iLd3RQYTpQQC1M0NnrFb6072QW9D5KiMfS/71Vmxivadw6TmMCcaUzrOlru1RiqeN2PVb9wQoT7v2N6a916zD57dJh/iEsEAzlnG5Lon1PtPUs9kYoKcBPyszMAWpf0vyFqSjTkRzozT63ctcaS0fL1pIuVnQlZLtsWguV6V6Bg2ug7D+5ErysvutRfSTRYIfrpFBkaA3+fVr7KYMZrtStjvmj+kCPW6xmAS3BcymEPPWV02EJY/FEWTBkHNWJ+wekIetKho+FEYsSEeyqUvWWFGg0HvHbODGd+Nosv1c0D/E5F+aJLHXEH3jzh6CU5jfIG0Mfy3ZGFS7SCe70gjfcuSXn8C0N8O56LyYOzm3HPPVZYdtB8k10ueJKmJwlJo/YYDH9BQbwdk0/bYzWqUTnJgu2YUU73uC7Zu16TomTI39ghLPBV0lzqrPrI5TFXTX1SJDnEDrjFBLzn31nzYE8xicrujh+5NSAOG538ZgrTYdQ76M0y2aq/gsxwJOSDByUk2Od7920AEZBRpx01ZBidKBu2/QLXKecig7SzPlIdp9qm80+QSz/oR3X0Bk5wLlsF7s2wU= 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)(376002)(366004)(136003)(396003)(346002)(39860400002)(451199021)(6486002)(6666004)(52116002)(478600001)(8676002)(5660300002)(2906002)(36756003)(7416002)(8936002)(86362001)(316002)(4326008)(66946007)(66556008)(38100700002)(66476007)(38350700002)(41300700001)(6506007)(107886003)(26005)(83380400001)(186003)(2616005)(6512007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xLrAgYRs4dmF7hXcbbwlOzcgidYFdnxdmAWfc0QK6UyUdTJ4ynkAEgbg4B3aQshJVNSQPxOEPoOmDcmVs4UZ3NhFqd9Chg/jXlDXj+cErgErUxtsKIQmv62sVR/nE6NopBiTRi06qWfUBoDjycqWbO7b2LueRIVIzlUm+E3YwOlFJbO9HwLS/KTtgyu8P0h0W/KWFzqdE9iZmfNb2Ffax5/uwVeiXwhOrtBimU8Sv29Rame2ls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WpEsf1GkubKG8l/D+aoSDisSkp7fvD2egREBSG5Oh2uvoThGR+zjlLInVSrNy2tqUt+hsTGOJlnhUzm4KgUDYH3T6cAyPWvsDgOn7EvdBHGCQPIShlqSucizJndkhn9JW+jUpivyiWwxl/zziyAlzRn4zA8ZAruO0XfFO/DYNm/Iuujp3eDZ9HeKtThcrex7k1JxcN0RH+tueXlb3+rLKQm2s3VqV6ZmuyNIXgvVCYacDIT9yvziZWF56yQBIZ1uvbd4geYxMHyq+8UR X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: b04d2070-25f1-4f31-3ec2-08db8395114a X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jul 2023 11:34:06.7884 (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: oQZS3gxpg27KfnXTq3ymRINYc5hRXqvv1nAZyYAUEdXY4MIIUDh8u1nNVM3BbyIczetmGJAH4fPfAYagUvx/GQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR05MB7452 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@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 | 4 ++-- .../selftests/ftrace/test.d/kprobe/kprobe_args_string.tc | 4 ++-- 2 files changed, 4 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..523cfb64539f 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,14 @@ mips*) esac : "Test get argument (1)" -echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):char" > kprobe_events +echo "p:testprobe eventfs_add_dir 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 eventfs_add_dir 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..b9f8c3f8bae8 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,14 @@ loongarch*) esac : "Test get argument (1)" -echo "p:testprobe tracefs_create_dir arg1=+0(${ARG1}):string" > kprobe_events +echo "p:testprobe eventfs_add_dir 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 eventfs_add_dir 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