From patchwork Thu Jun 1 09:00:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263195 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 E2AD2C7EE29 for ; Thu, 1 Jun 2023 09:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232419AbjFAJBN (ORCPT ); Thu, 1 Jun 2023 05:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232417AbjFAJBL (ORCPT ); Thu, 1 Jun 2023 05:01:11 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013010.outbound.protection.outlook.com [52.101.64.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33846B3; Thu, 1 Jun 2023 02:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hhvKQKcUWqv5o0Jy7Cm8AFn5ECxGdJys13f9DfsryCFGAkzA8q1qxq5J5PCAj4DrPWhQEHjkL2aQPsNJETRWDDPZBJIbEF/t5LnQ7eYHeSFuVGNXsI+XNjpdwRUlP4vEYSANBy0OmW+epbn3TnZQSjdogQYhlGTulsAbmnlv5Pc4bQ4/qSyzMa5dqlYlFtctAzb/LFqY26AiHTAkXY0Q40jHrWBP6YnuB0OiJ5tFk0yONZPZb56m6BvjjxUsv19wAqXRpU8XJzWZjfOQ7BrJ1uVd6RIlmnVcsuIe13eNRSsHJhtstoAu6vOvd0EyD3adjxBM12QAmOEp1NTKvu/6xg== 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=odhXvJEkAt78N5rSyxi7b4WKu//jCy/HfoNyhQ1kxcE=; b=d5XHbFIHeZjQKdPKcgx9YwCTggufuLueubj5dKmFw/GuSZf/3SRce2u2AzDxvRoZfAaHhh8rRq+AJ9F9jtfxeRWoKcamAU0bbDGayrz27DrTsgcvAxWFWfimrpHPyc7GFViJTuTU6saiR91XInXLQrd3do8n8oqnJPvxHOPwc8mLN/ylewBgEblxW3MiktNEBG7OMv4SfOBKt3JdQUicDwZ+87iJiuoEUNvYAdWxN+p5dH8jHmmwa2Oh3u5TFPB5usTX0cD1uBHJG8B9dZ+5H6C9Cwun1uWb0j5d7x8A6kTTihBUjegn3xCvJx579X5HuvPDzmLIkjviVXHsVq5p+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=odhXvJEkAt78N5rSyxi7b4WKu//jCy/HfoNyhQ1kxcE=; b=tmNNKVZvg0v0M+4y5MYoZvsau7fNyTPPx5yJR2VB8xnV3vZo7qd4oNh5bSQtG1JJPw/94pXwRhVskyDJgjbBHSSyf3TuzOz/Rs7IAwJngucW1kFn4Bywe9cwXw7kuz3MsqrlKHpjkrgsfp7icWbCKjbwfZNWyVq43J04dRXhG44= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:05 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:05 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 01/10] tracing: Require all trace events to have a TRACE_SYSTEM Date: Thu, 1 Jun 2023 14:30:04 +0530 Message-Id: <1685610013-33478-2-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: 75a50397-3b12-4630-27ea-08db627ebb7e 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: vVxtnxS/cQHF1zTyqa9Xg4WzyaD5eIpkKIHlpjIjeLeCSUBVqTgIKmvm8SpYzmzXKnIHeAacx0Unp1fYPjEJVHVA9bKa4waLM4wcjZgZugu3T4z+O0n85s/oNT7lfCU5OuxKq7mYOLe02W6wfNLsG/Ro72/sOr6c63yEf5Attdk9FGyLlJhfaWBCUpDPOAmd9pMyMOH2RPbjLckaMe9oXuyRr+CZ+uVhW3DIQqNM1yURFKjbl16qtrnf13R8alh4lWgBv6In9S7QvIc2VuhdeYd8kWOIwGxcfXm5I4m4Jw4SkrGdxx99rziln6gbXKwyR4Ga7ge9WvuZ+eWSm8mQNeY0bbHxFWfBfJyb/GzRTXFkJtQ8mrLHvY5I71N5KEIl0JpX56EV0NFm8ZnFEUcNx86AC39vxEGG5Fja4MDnTD916jranwUwf88gRLvQ8VnUGUH/0FwSgwkMHp9vdrneZ8ZW9IyRHK0UIlB+g44XQfBXhtoM2C/UUN3/TnTKOCpfvX6ELxkSX7bLF9SuGPu8Z/Ut+xPpmlA856jSptwM7WsBxzJAQAvAGpCBRiUgqDMNV3VGfOI/QhJwkAU7bPmgXE6Hrod4+1T8fvCKusUJsPDJiD8HWQiWiYWScdVdIvFp X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TKXRfn/QKf2VpDWQQ20CGNBy0thXzD4aqOxamPPmVrNZ5ksiyde+IFNRukBk8JpV3tCezstetkzEMG5wQZIxQt4rbeyQOGNwfe2kxah+VH7X/7i7s0yet5U/of2TBcd0fUu4DzntQhT/kye7hAfsgdKg79p9Re45mMswiZQ+ORzDZKFedeW/4KoLH4LKbgQ/9GIUb9lo3qPxP0aasoSeN3OmVc7F+i5F8sfVUj4zHv4LtUeT+6PNTEvRjDbywUL+w0zLYoBN5h+yEr9g6qt6muudLXQz4s7JM7+rAkcvRiVwEbm9HONWO5TqhZ5EbNR9/cLRgKVmipvK5iLGB9ZDQdBeJImiVqA5fF4sj2frRmB/lvS/OyEThR3xGPsXNdTjm4nfPkvNxx1Y4HToGkU35abFhWkFhfj3d4E7agomMg9RkFKKf6YYJKNONAF+spk1uDWSUfip26gEuK4yXaoHMsoloZ/KjwDhEiKjJiuWpSsPrBsTcJTI1XGDIHN/NxwWvu/jCrm62D6iPPVCMyLWCoh3UQ5z6S+YJKQwXqgrWgi1WO0LDM4Lbxs4QEOhDhbnIQ3D9DSgAnohTzjjVSljvTJxromo1oBQVKFiSmHissvMp19/Y9ateWyH3ZoW4sBYk0B6vsdzth6KSr/nV3mrFasK22ID/HM8Q1+nvyKaFTzNlIpjG71eFQd7gg6GH064/AFLLSbzPa1gd5O0qcYquIP/ryuzbmwEeT7uxf2lNTPx7xIVAJPCJRWblzhvPxiYAnhpmJJ8+n015s33tEI/EbaOqJDJ//qYrsa0nRnfh5qAa5cg5xsm/Xi2g37UppXUKOS36+Z0lDIRE7mAZVH5pTSnjwPQ1+KKqjSnrEIVVGC4pJp5+oubwIygSRnD9MIy4hcHGJ3pclsw4T1ammhIqpnrn5RZDsKwmev4BjPrp3IuCJYUP289W/0t/a6mSy7SgdOVTANotFcNHgqsem0ZqA4A/4ftqQWVTrHRUFK+6lXthBL29NH7b9klj4+yVzIDtYMD0d7hJjhT287EnifWAWH0YO757iwhH5tF99jbO5QI+u4WqFEGK5nItjvXCZ9kkUDMjykkjCL2+23xHqi7mMhgeyWTnZYD/FTz9QlxhK+DYbB/IK6fkmKu8IpHPOvhTs0jop1wK9h+yr+8lONZrc5yv6Ff2Au028Z/E58cJ2Jr2Qivi/zMu/fT+pgbu2pD5CQWSdcoDiemdcEjfMeoFLin1C0pZ2HmcaE1FXltDUIwWwj/Tdj121O2LiJ1RAfUmcyqTUgeN230iElYL+6+n5DbAFzJzNGDPreLWDsJW/twSqku3xyydKc0DVwDHIvzDjifxhWFpPNtEaoAhhipCfmThfWZXkhsTIfeXVprjAOPrDRLDkzNLK2B0htYqWrz7WPvmObdbKGIa+v58vDf3tfaeET79+W+Xg7TgTEr347JPvLQYGYp/OpEmw4awhreUc877n6KvO2hKK0H2BH51w5TPF0BFLPuzvWp0gku4MtDx+KrtrZxGoZQBypaNeVS6w0viU135GIP/QESPflwtOBwrYs2uOyX+DfrWiGrPYr0QzkSknB5iV0/J/5zo/8a X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75a50397-3b12-4630-27ea-08db627ebb7e X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:05.5598 (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: 1yXTtUdSNZcUD/pW93GEcHJkpgotJF0bMpr1ZU4pCjbKZr2rbW//LyVmSOiVB88H4R47prD8nvi0qPRYzdHxxw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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 654ffa404..16bc5ba45 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2424,14 +2424,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 Jun 1 09:00:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263196 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 09EE4C7EE23 for ; Thu, 1 Jun 2023 09:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232461AbjFAJBV (ORCPT ); Thu, 1 Jun 2023 05:01:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232464AbjFAJBQ (ORCPT ); Thu, 1 Jun 2023 05:01:16 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013010.outbound.protection.outlook.com [52.101.64.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1032BE7; Thu, 1 Jun 2023 02:01:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kLMmGwbsq6VOTiV4DpuJxcT9mHeDxDR5gafxwCeKKzv/v8aXXabPgxX9+mnVHuWnsHO1uM2OwzFfjCRHwIn/wXZ2cXKsCeM6SxZfeB1lhkb8796qSudl/vFtBhvscL6ylvc6iIUPukvwfkzljQ/i5c+d2lIkfcPnl5pbjlbNSSXh8zaVTLfrxi1UAHneQAOdUxoD8xdlgQxY2vIQRkXoxJLbWrJNeZDrUJC2HU8oAM89AlNrcgsE1eTNo6+5L0LWzRdBMke2QuvD6kn/BJGGGl2wNbzadZhk5Mk71FMPhO6zA1EwCgKRG78txepM5c7LQ6IXGZBTksQAo75Lc8eEcQ== 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=VqnypT5cV3uH674kkDeSLFcG0cpa0F83Tc9rmS5VldI=; b=dB/hEWEhFhlTjGsfhiXC6EW/K2QglIZYtwFYU40AZ/1I6LJA3tGK8PTX3FN5M9SAgZXDtygAdpZvpSgnrZr0V/nSkqu3Xkuq+rFUbhT+kMsb8Eib7hdvit/YjRorCAhuFKRu7f/eD73KQk+wMoQv3xDL0L7t5rvem5RKDtaGMirhTzCD2aHYPrm7tEYNIGaZ+nsQBvSbVDbXfumWZNM+waOEsjTuFUt3j/KyTm0o2VgLu8YhogB+rjAOuHn6sMAIUqXBmI5Jaof0Fp71XaV+NIi+Tkni+6cjqHiIfxYFOrawcy1HR/8Qb2SL2vHAjNybW92eD1WcH0H4eGgqTxZo8A== 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=VqnypT5cV3uH674kkDeSLFcG0cpa0F83Tc9rmS5VldI=; b=uxaBZCGrKdTxpPNs99cdo6QzdNIzi27DrtD98ZHS5F1bFMH+2AQPg09G646xzXLoafYeEXql6sytyjqRSOEXR59Zfo9IP58rtpPy4g0RgWUzhzwZiBw9cNcSxF6BTUSykrrx0YNmObbJ/ZQENeTQHhqZ0hZB9cvZeWl6IMP4jDk= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:06 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:06 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 02/10] eventfs: introducing struct tracefs_inode Date: Thu, 1 Jun 2023 14:30:05 +0530 Message-Id: <1685610013-33478-3-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: 47556847-b537-4ddf-54e1-08db627ebc14 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: ccznUqMGkyOV08tSwKhasf+jUfAWAxQu+xJWqN/JqjjRb4QljVZjNI9dYotGfEToTmmQsPragMRLMS8033oBbygvLUDLrdiZQST3JNKXDm6mhAZ3VEv1WSmc1UZfZPq/OqQu+3nCF+Fw3hHA6TYiQOsrNqfjJ5S3k+Jn/nkv4w4SZZ0MHdsZyPrRVkUgA06467nFKyJaA3o4o1YHvF16BdEf2n+rOupOCnFVRLVQgwfXSw5NdzQLSZW7syWMEV5G1zaSzkwL9QrSDELxdZNinNFGOTtHA+cZsPl06pA+uMDgv5tf1lFaGYzZJaiQ9ZZnoZxzXLqaZIbw4rvEwAIE1bj8rIiuA/TDIqgkCB6l/5SFCYl4USjFDCCM5Bv0T47/mxBE/bfvTy0iOuAXR+YIwdJy0FvnVBbFokffTMk8UpL2yIF4OmReR3eayt84waEi0dWAA6wbLrSoP4r8UKLujWm/43Zb59fcx1l3C3Q8a/Xzcqcqub5MKJNqy6oYHJFtHrSF+CroakQw/X9+sPL/LHqBJdvemeNKw45KxJ0z32OOoHY94bhjElPpjjUB2oMuJMUN0EKPXvt8Xxtdvt05ncUkjx1KemPo424o385lwQyV8nU+MJ59IdeOmmK2va0H X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /bpdYTwVCv3niqn7AdXnfXaq8Z+nhpuZP/Bx5d2/zbthkRZFm1jH6jOktJ8HIC3BSNMfdnhQjDryxMEBttHbk7xKSvqdyXBawF+U6K/Cmr1tHzVfKXsyfxbP9gm7LNJ67HvNYFJMOZ9HR1F5PJ1Y+Yj7SOdMLAH2M4nKnuTtTi+oHnVJWaXUJ4igtg9ohMjlhJkhjJazH7heB3KAcEn6nSMglYrcIdbSFCeSeLNxAUJh7U9aXuCGYro8speb0iUdZAjwpXRAxeNG7Na6bAUjoA8x4WE1lVT1nANKSsYo01VAD8HzvwGhHyaUucpjXkcTRbN094q2nyms1sKxXCG8UVSZTgoAAaCdDdO3XBaNk6O0yc+d5qgOCpzgRPxZj8wdtKlNGgCTVGjUQ65ujaIaI8fjau5jn6gM2W26BZtojZ35JqWYeN5NJo0hUlN4c55Xz2j5UK5Hcfdhw8VKVxapBh4S7rc1L/TD7vcTLQ/Ji8qBUyT2y+z8s+nfaHAgBIv3gDKegz/sS0rMhoOKbj5TmfF8hmCK3WaXRbPBKDzhI0OjEKlDxJEGd51BonB5Seuj4nMr7o6fHim2XHLrkaiBWvjzFGoP0yLRBKKrDq+QiLCLfD3ecBxkgfImLFadScxdL8ArU6lvHh1sx/fcCJqSVgd3TcwMZIRwgUbqZ+z5MelyeNhDNKiWwM2GmszJ97kNiTyADwv2S175481BIYQutr0kbpkLMkIBV24IkeYpSL3Y9hXzRMAH7ri1VRPPqPHM9giqXoVPRAOKAZrNzWbWh2IQHlE0avAfmeCLzASfX8KjmtKHVDW0JL3mABuDIy76cko3tam7psbaQ4Bz621JCQZSz3kasIaILiG2Vq9jhXBvyodBAO//0oQkApzrj7Q1HbVToLgLpmZGFJjjPXJHRyu0pWPvtWNRBngKdKinOXDeOfcoQ+glP5r2cIfQQW/S13wmkt+I3yfCsuC2Doozt6eZ81BAgISwfAYaPZv4thV0Ac14C61I8bb7gkakWpVYr4/LUGIr0m68Wz5l7OgivI3iu72JwYvtvWFQ0watBbwJ2dupxQ7vf8fIvQYqBRNPYkVFu3tUWqWWdre4ZABoaTQKDqOWnakZEqSFFdPLj7cHloCgRI7utvi1QZTWAimX0hQPh6TIEkla3wHfayRnKAa9eB8qUXVoyP0jA5IPzCvnKcNI71FPx+Pz/2UnPD2yLPtaXenpdVrvmABZ/DCru8AIv2xOXWwVSy2XEp7P3FeL2NwBtvLbnE/JQz6SSFWzArqW8T7HDT+zD7Yuzi/VQ+pSTFM0UuurmVdtoKpfSwUkqEoFANJs/1a4khxrQqsFKfmFCvIb23sAG7w31FVBU0dInlGZ2ySfwthBkpyJKq1gNQo8VQxR9e/nL9FroLw0DYHXHDSZGIgdiHOqsm2RIQdeaIJNNhUCme4qezo4QKqN2c9grG2PC7gXO8/e0/wpJ3glpTgWaZxL83fcXXwWeHZavgdvfv3QQAlV/aoLXOvannKcZoSai4Q4BUU3p3EiKiY4j8HGdRDyYvufTOVK8l7v1Rg7SYtuI+ufFvVTAqcOGg4I65JaOfuPcdtlM784 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 47556847-b537-4ddf-54e1-08db627ebc14 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:06.5827 (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: wRNCnwg03jRRB4JTf6SyEIxb7iaKczufgujwkMCvR72sXqnvRwM/B20717GwsvpAk+PWya7q1jgf5ZHOOBb/zA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Introduce tracefs_inode structure, this will help eventfs to keep track of inode, flags and pointer to private date. Rename function names and remove the static qualifier for functions that should be exposed. 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 | 21 +++++++++++---------- fs/tracefs/internal.h | 25 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 fs/tracefs/internal.h diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 57ac8aa4a..7df1752e8 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -21,6 +21,7 @@ #include #include #include +#include "internal.h" #define TRACEFS_DEFAULT_MODE 0700 @@ -127,7 +128,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 +400,7 @@ static struct file_system_type trace_fs_type = { }; MODULE_ALIAS_FS("tracefs"); -static struct dentry *start_creating(const char *name, struct dentry *parent) +struct dentry *tracefs_start_creating(const char *name, struct dentry *parent) { struct dentry *dentry; int error; @@ -437,7 +438,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) return dentry; } -static struct dentry *failed_creating(struct dentry *dentry) +struct dentry *tracefs_failed_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); dput(dentry); @@ -445,7 +446,7 @@ static struct dentry *failed_creating(struct dentry *dentry) return NULL; } -static struct dentry *end_creating(struct dentry *dentry) +struct dentry *tracefs_end_creating(struct dentry *dentry) { inode_unlock(d_inode(dentry->d_parent)); return dentry; @@ -490,14 +491,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 +507,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 +521,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 +535,7 @@ static struct dentry *__create_dir(const char *name, struct dentry *parent, d_instantiate(dentry, inode); inc_nlink(d_inode(dentry->d_parent)); fsnotify_mkdir(d_inode(dentry->d_parent), dentry); - return end_creating(dentry); + return tracefs_end_creating(dentry); } /** diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h new file mode 100644 index 000000000..6776b4693 --- /dev/null +++ b/fs/tracefs/internal.h @@ -0,0 +1,25 @@ +#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 */ + From patchwork Thu Jun 1 09:00:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263197 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 DE386C7EE29 for ; Thu, 1 Jun 2023 09:01:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232470AbjFAJBX (ORCPT ); Thu, 1 Jun 2023 05:01:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232471AbjFAJBW (ORCPT ); Thu, 1 Jun 2023 05:01:22 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013010.outbound.protection.outlook.com [52.101.64.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 98C0313E; Thu, 1 Jun 2023 02:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JiOy7XiUkYNMYv8q9t2390swVr/GPFtsJe9tDbjyA1nrJp3xC8znb48hKRfJgGYU0SfhZDmIRCABNU4BCrOnSdFy20v+HvhvG/2zZdF6SXGeq9Z/jW/qVQg89BW5LgKOjFdQ+fh4nZ+PTZcZjTi+9/Be5qa+7Jq4NlpfL1yKhEVaJ+a6dcG7iC2qOC4JD0/TntgnhytjjaGYEyM6HBmxLYAnS5F4+FXbAPvA+tU7TXVGp6b9jxrPVww/LyCahog3YSMGjyo9Z48N/y4br4a6vCS7BylUlrbQ+joe8ew8w65sJ+SYnQHFVwl7rXpGyZgbMNEpQ9WXGYwULZHKiPRSAA== 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=IJd11CAc5dheYgkR3ktRnnrrHtK+8Ah9gcB1WzL+714=; b=l5MpVT/H7jDDg1ES9lpAAlirQf4st/H5iQeFggbAMkzjoYKeK2zrEg2JYMR+Fx7wWqVRNCiNvUBSdZ/SVortQ+dFbLCBcnayx0STy1EoZt9CTQyQPCCX/pYej07MRU1HXJxruvXzC2o/owk53iEkaZMq8kqU2/WGRWt8TZRFFwTWVUIgxnQwGIHDoxWXQTlxTksz8AKQ94jJ38z/NjVO5Kcefo8/ZGXRcoMRtthPXXCioKuUCoPz9fBrDKDRvhfQwQA1bDGpqP5c/e0GMJTQQoDBnHlczN32YkEj60pSqK/VSsioYfkDfcIkHFLvgHK4bpqEc+R3DE1LhU2qgYyw7Q== 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=IJd11CAc5dheYgkR3ktRnnrrHtK+8Ah9gcB1WzL+714=; b=ZAkQVMIXV92l2zwqOdlSLyC2mMd5yYRz7vizvpBEE/N3qsflg+Kc0oZrWk/mB1fJAgWzuhuvFg5lv8Ug6ViqDSeDgxIRNIm0oWxu3BoFANnJMZ7DN3be7lFJHnNbTfAabY3upbtRBVm1fq8RkGTlaQ71eDJM7jCGINre0KMmyvE= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:07 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:07 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 03/10] eventfs: adding eventfs dir add functions Date: Thu, 1 Jun 2023 14:30:06 +0530 Message-Id: <1685610013-33478-4-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: 11bc62d2-f35f-4ce4-e418-08db627ebcac 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: 0CB78mF8vG5vRqOm7CXzp5XO6ccKb5yXKCSv8vMyKr2ip+lL8qp1bh0XMO4ExhQ9Z46kfkWooePX0XB5xAoF6bgLqPN1ivdCuLzLPdegOqVhxEIENPcUjpuF8wShVds2KpbKnCQmqOdc+sExM/bn3A2aKn0KYYo8LnT8HRmJ40cliTNtN8FOTWpdMtbETt87sYla/bhbvXWsALdXhEFMY0Rawc5bHxsUqjoB+HVg6nHm3VRhLjI/OXz9O0aqSKT1+48rb7IoOQO8aZekTmo/wRknlezTsPsylTYzbGocvtycbPo90uZfaFv0+FAVON+aheSE1MnlDF70qWOX15XTo7AURzCq7QkwdQSDhqLvgJaRpGu1aof4TL2g1iwz6aDEP0IF3jhMHjYnMM+W2HZ7ifZxbQy8ERzvwFqm8fyzUpVj/8fNqdu0FWJJsi3flAPUH+6MQeJfRTJ7IHlzHTLiNaShw+GqzGrs6gF8MPj6hjYHKoVTA2HoRB/dt9PbY46PfYP2fXglKdhM805KemKRq+xa1ZYNZnfojzNHRVxCyiWzrEiM84ruG+Vxx7Wpye0XBCGk3zVlANxAbcsYLko/txcJkwgzG9+zu44M2qdhuV3DFmjHvlPhYP71+GEf/82eLCP6ubFAjEvFoCF8QcB5cIGutEVHPyKYkvOQey8CHac= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(966005)(83380400001)(4326008)(66946007)(30864003)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cR1D4IIeVKLPAgK+FVZtBvkWLKc1pVh+DK2icgJ77m7OhYXy2VdvqoBMGVprjSl9NaMnjvZTNjoVFgUlciGtS0VekbyviwBZ+H0C+DWPKfI4yqWSYSitVCv9+UOvZnosB74NFVVn5HMsgIPY8E5AuX2UaVQ3focLAo66nmsRvX8uWscJvd/xbvsRG4cwGmX/1SFZ7Fa2JkUWsyJF7Cy6PnWjJRBLQCkhq9zbVYLbFSEXOB4NkSPzWcUN/s2Db+FEwEww84XoQptEX7g7yVaAKARRjgNj58gyWoNbjTuRu8CYpC0vWUEtUcJ39PmKeEOQ74Z8DgB3wPJY1FpXroamn1k5YWXwg5rgujo663dS27/nJe1Q5XNlh/bwJVc8jGcXonvCI/JecjkpBPAlZ6SvXj1vwBQk94ReFgfyJbnkh5sDj5BPCXEQCNW24DUqSqHeAlU9SfCML5i7bJdiMQI6yJBhofx8FN8mY86lGgKlLjwCsN4/xSuR0gThWebobV0ozvcDnUGhseJKVEFkl5M6cIRcH06/yj/BR2ERarYAntTCWPPtfFJpDCCGWu2PvqRSm8E5oHPWkb2jBsGNOtkUNTqW3l9k8zOJiSzCCt5TTsU5DAsTw4nudEZOTOgrkECO5bl2xvnjiKp0ZzvfOuIFna2Bp/pR/qTOcrrqEO5se98Qp1c4Hfxuo3ZM3ZtqGjtC7N5/FzTrxOT7+b/foHG45hgOxVQbLq750Lwv1OC28w2YVp13wEwbc9dBMttvCAiXIlhzgEOtR5F9Mhm2+AYovyDwiN5E+ry6+Qi6evP6bzamZxn7TIrzKPQ8pE68ekKitr0iJj7waLDjkSnOxhfRKxAHETtqnb/FWUBxcbMCKdb0ITCc5Ab5V3DjS0nKLX/wRGBU6OsO2HmJF1Dir7tLLbRuYUQLk223KNRAWQDSk1KNryuMSQaN/FG9H5Bqk2vdS9yD8C3UeJMbe7OvljB1L511oaVcd48ANppI29EvkBx6D13zKcGFEdMVjfpjdt2XsCaPD16bSvDxNCrk385gW2wrjZs5blQ3weNA6BUJRqlRuI7ReRpglT0vuBfIu4gwald6sLY9nihWNvl/HbqJTekkV7DJG9VOMFn7zOrqaenpVbRiD/QuEp1mIDXCZOPH/Gb9BCRH4nNKhpho7wdDeedNaOy7rEXMHTaiy9fDUi7EH8ENrIoWQAdZUbHcobHCa0HJ1qstv6EdpOBtJREEhlvu+88ptesFD+AbZsAug2ilR/Df66Y+T2/tfOYNJu5fSOYf9M1iJkB8Ii2HqG4d9UAicuV/RBwiGdtEdvGu8iaIgEN3DiPLl60NS9NjFt4Wip+XpJCe6NBD0QQgW76ZdSw9/x4TuzQlclxsuK5GNs1Xo5WbpKgCp5ESylbWNWLID0WPx1/waNyvz3e1irCD1T+0LwzyN/WlkY0xIh29AN/WDJzhmpCoIt0K/oVVeIdofOcYiUxScJP8TrflYmBzpub2eOUNhHCCYtpq3XM/18vHNm6UOw/HdSIlzqGqKcPCN+Ccupv5bapTOWSX9jiTpkWPl74Vk9qot4BNafmVEzzXpmHiK8q2cm52flRzvIl3 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11bc62d2-f35f-4ce4-e418-08db627ebcac X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:07.6305 (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: CBMT6FQM2bYaxPWkQdFxQyqX1MvBLNOq6fq6vazEp4R7uOBedSI2Dm6ittMoV8KbP5j6QzFn5Apj8yWwTTu7ZA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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() directly creates events dir with-in tracing folder. eventfs_add_subsystem_dir() adds the information of subsystem_dir to eventfs and dynamically creates subsystem_dir as and when requires. eventfs_add_dir() adds the information of dir (which is with-in subsystem_dir) to eventfs and dynamically creates these dir as and when requires. 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 Link: https://lore.kernel.org/oe-lkp/202305051619.9a469a9a-yujie.liu@intel.com --- fs/tracefs/Makefile | 1 + fs/tracefs/event_inode.c | 272 +++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 29 +++++ kernel/trace/trace.h | 1 + 4 files changed, 303 insertions(+) create mode 100644 fs/tracefs/event_inode.c diff --git a/fs/tracefs/Makefile b/fs/tracefs/Makefile index 7c35a282b..73c56da8e 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 000000000..a48ce23c0 --- /dev/null +++ b/fs/tracefs/event_inode.c @@ -0,0 +1,272 @@ +// 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 "internal.h" + +/** + * eventfs_dentry_to_rwsem - Return corresponding eventfs_rwsem + * @dentry: a pointer to dentry + * + * helper function to return crossponding eventfs_rwsem for given dentry + */ +static struct rw_semaphore *eventfs_dentry_to_rwsem(struct dentry *dentry) +{ + if (S_ISDIR(dentry->d_inode->i_mode)) + return (struct rw_semaphore *)dentry->d_inode->i_private; + else + return (struct rw_semaphore *)dentry->d_parent->d_inode->i_private; +} + +/** + * eventfs_down_read - acquire read lock function + * @eventfs_rwsem: a pointer to rw_semaphore + * + * helper function to perform read lock. Nested locking requires because + * lookup(), release() requires read lock, these could be called directly + * or from open(), remove() which already hold the read/write lock. + */ +static void eventfs_down_read(struct rw_semaphore *eventfs_rwsem) +{ + down_read_nested(eventfs_rwsem, SINGLE_DEPTH_NESTING); +} + +/** + * eventfs_up_read - release read lock function + * @eventfs_rwsem: a pointer to rw_semaphore + * + * helper function to release eventfs_rwsem lock if locked + */ +static void eventfs_up_read(struct rw_semaphore *eventfs_rwsem) +{ + up_read(eventfs_rwsem); +} + +/** + * eventfs_down_write - acquire write lock function + * @eventfs_rwsem: a pointer to rw_semaphore + * + * helper function to perform write lock on eventfs_rwsem + */ +static void eventfs_down_write(struct rw_semaphore *eventfs_rwsem) +{ + while (!down_write_trylock(eventfs_rwsem)) + msleep(10); +} + +/** + * eventfs_up_write - release write lock function + * @eventfs_rwsem: a pointer to rw_semaphore + * + * helper function to perform write lock on eventfs_rwsem + */ +static void eventfs_up_write(struct rw_semaphore *eventfs_rwsem) +{ + up_write(eventfs_rwsem); +} + +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: a pointer to a string containing the name of the file/directory + * to create. + * @mode: the permission that the file should have. + * @fop: a pointer to a struct file_operations that should be used for + * this file/directory. + * @iop: a pointer to a struct inode_operations that should be used for + * this file/directory. + * @data: a pointer to 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 allocate the fill 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; + ef->dentry = NULL; + ef->d_parent = NULL; + ef->created = false; + return ef; +} + +/** + * eventfs_create_events_dir - create the trace event structure + * @name: a pointer to a string containing the name of the directory to + * create. + * @parent: a pointer to the 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. + * @eventfs_rwsem: a pointer to rw_semaphore + * + * This function creates the top of the trace event directory. + */ +struct dentry *eventfs_create_events_dir(const char *name, + struct dentry *parent, + struct rw_semaphore *eventfs_rwsem) +{ + 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_rwsem(eventfs_rwsem); + 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; + inode->i_private = eventfs_rwsem; + + /* 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: a pointer to a string containing the name of the file to create. + * @parent: a pointer to the parent dentry for this dir. + * @eventfs_rwsem: a pointer to rw_semaphore + * + * 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 rw_semaphore *eventfs_rwsem) +{ + 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, + (void *) eventfs_rwsem); + + if (IS_ERR(ef)) + return ef; + + eventfs_down_write(eventfs_rwsem); + list_add_tail(&ef->list, &ei_parent->e_top_files); + ef->d_parent = parent; + eventfs_up_write(eventfs_rwsem); + return ef; +} + +/** + * eventfs_add_dir - add eventfs dir to list to create later + * @name: a pointer to a string containing the name of the file to create. + * @ef_parent: a pointer to the parent eventfs_file for this dir. + * @eventfs_rwsem: a pointer to rw_semaphore + * + * 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 rw_semaphore *eventfs_rwsem) +{ + 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, + (void *) eventfs_rwsem); + + if (IS_ERR(ef)) + return ef; + + eventfs_down_write(eventfs_rwsem); + list_add_tail(&ef->list, &ef_parent->ei->e_top_files); + ef->d_parent = ef_parent->dentry; + eventfs_up_write(eventfs_rwsem); + return ef; +} diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h index 999124459..aeca6761f 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -21,6 +21,35 @@ struct file_operations; #ifdef CONFIG_TRACING +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; + void *data; + umode_t mode; + bool created; +}; + +struct dentry *eventfs_create_events_dir(const char *name, + struct dentry *parent, + struct rw_semaphore *eventfs_rwsem); + +struct eventfs_file *eventfs_add_subsystem_dir(const char *name, + struct dentry *parent, + struct rw_semaphore *eventfs_rwsem); + +struct eventfs_file *eventfs_add_dir(const char *name, + struct eventfs_file *ef_parent, + struct rw_semaphore *eventfs_rwsem); + struct dentry *tracefs_create_file(const char *name, umode_t mode, struct dentry *parent, void *data, const struct file_operations *fops); diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 79bdefe92..b895c3346 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -359,6 +359,7 @@ struct trace_array { struct dentry *options; struct dentry *percpu_dir; struct dentry *event_dir; + struct rw_semaphore eventfs_rwsem; struct trace_options *topts; struct list_head systems; struct list_head events; From patchwork Thu Jun 1 09:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263198 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 79C25C77B7E for ; Thu, 1 Jun 2023 09:01:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232483AbjFAJBZ (ORCPT ); Thu, 1 Jun 2023 05:01:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232479AbjFAJBY (ORCPT ); Thu, 1 Jun 2023 05:01:24 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013013.outbound.protection.outlook.com [52.101.64.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF7F318D; Thu, 1 Jun 2023 02:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J65KaQsKduLVvu8RAkFfNQ5NOzwIDdBibWhvubI89egSgyS861I1Bglo49EcEoMKUcPPhkBqSqmizwCVa2ayxs6LcWMmi50mrdF84QpZ6Ar1hiUjmxQgJ0GlQI8g6POG/Dj0p/Vp6QGyR/7CFzA0MYifikaanfK7pCzhvoNAnoyIXu/V0/cFkalCHb2uK7KWYG4m05qUYRxPgV8gTD11LCPaGR/gAV6Ftoh2gpgOgEUEblKHVnvjKioItxhNg3AzyugxPeJhdgyk7BTtBjEtZpSL9skKypk6gmAh0joNcpcwcPAZVSzeRlpY79Rkg7k/fKJ/lG8ZEhJRgA2pQTNtVQ== 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=GsLlpR9iDNj7N0wDvwwEXuC2d9AucQzonSxF8qegTZo=; b=GY+PqAgKPB2f9bwyvYPoT9hqLzhe+x0LDW3pMbeagwSsaYXBQ92NylX2kBtBZ9aEauFDbnzj0nDjoYKUJ/1cFHmzFvSobxpCc0OZ0ZfZ4lY8u+rbO2XcTllgix8UFZa/xCESIWesYaN6oVleeXpnBpukZ9FikutdIDT1WfeWt+RDakmCMJDFjezHikTaunQnX4Cz5xocLDzIAvOl8FGVQqzt8YCkfLbM7Z2p5dF9FWrQavLqTtlWGQoNk+5Cv/67JuQk1S3RGHQWiqx9iFIvv9yzRUo3txNdcZQqQMYHuOd7/8wqljHCyEUpbmz4svjhVmD81bN8QDLJ7+x9HmNz1g== 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=GsLlpR9iDNj7N0wDvwwEXuC2d9AucQzonSxF8qegTZo=; b=ALcO5DKoKouHwxvL1/RiCZTjoDB5Z21azr2C6ULzUNuhtC9X/8kBe6Xw+R3jqGpz45tZ8qUAtQqX0XKNxugVVP+x1JAXJooPjtItjn0CkAMKAxmA0PTESHMwGmQj6j3JqaDB+1Ha2Cg8iuC3A6xXV/IkG4MflC5zkHXMu39hnHE= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:08 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:08 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 04/10] eventfs: adding eventfs file add functions Date: Thu, 1 Jun 2023 14:30:07 +0530 Message-Id: <1685610013-33478-5-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: acca4f1f-f360-458b-fc49-08db627ebd4e 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: E9gMnap/s4K9tn6eA8mOESOsLTUPKvk3cE8jgz6xC+yZYv8w/tXkOKIdjdkZg7+srQYZNQtZ8owPsvEbX9nheBvueYOIuFWFWyLzzrok3T32umVJa3USB1sm5J7U0IVy7tluebbAWG2aeHYg6FuOV+O+XuNN2eX9/OmUdRuja9jYZ+ouZ1uASR7dj/3Ce+N/O7lmukfchKVCaXBieitfkvte+4FLS1fKSg3H+tEhToyuNYeax5GYfGte0kbQmV8Fyea0fRZk+mQNOSZAU3hCh9G4llzSx85vJ60A4rquOEpxORFWkRh5TtuRXjBz+Wtk+x6top3/lvwAXceG01fe86uavcrgR0CzhbKNHDSnJQqiCSwVPuKtRCArhp8/qe6Q+fSrfSFID9hFicPnJvQE7BPzd+waZIhpTsHWokCbYKKVX8OqHCBDtqmm+r2Lc1sFL8neDtGB7RipVzVN1o6AKk5wuOoYPHRIuHlUCkg6AaibT3en0+FyHQ03VqoUkq4d3QTwcVJC/B3Z4soTMESDtpv/7Nf2WQNCSUVLQtsGwJyaxkdTiFOJddPTV1d7lKwCcv9XW2Oa4EyOzZbHq1p+azFQJwRytkb4dio8CoUwepkTdZDO4kQXkkh6xHEjCjFu6ow1UIKgw1efKClzWwrcFuhpo/0FCn+TdnnXGCAm5rI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(966005)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: lz7Rea2M04lnAMbCBbs0aVLCG4okEagDGICep64pPGZ6vW9GP0NKcn0uj3OIBXc0Z61nsa2mVMXUzsyvQx9k3eaw3N3TyxkaCe5Se24N2jktgTU5V5DXAo+BTGaDKLeU1MjoUdNGKwIk0g0yR1orPHuaSnSE1g4CF/FR2BokIX2XA04TFg45zfZC6QiP+aoydebKXdqPoGu3S72FKveVIV5Y9yALvTwKWnsKq97hIRBvs1ayAwfs/zyBa1+MyE3cT/zb00BGRzqAtWVBhCa/kWrSOQN4HtwVYadQfjEfHgWXm5p76ULkuNTwI1qEMLLIwpJwqmskuuHI/93JBxVimQee6zlkVqU9r4HaTpqdIbwVHvI22MNJ03q8Mi6vDcJ376vHT8vHlnMaSZvfVln7B8L64iicyqgQimaVOKNi9LZtXtWyzfNxjJYX/7QHOkuwfDEBU78cqKS9kV2W1RlWBa5615BFZ0VQ1heZpsvSPKhkkuLn2kSTCZpEhMco442WbNkyLFzgS3CCZ7UiglVs6n7asFoyBkg4XdLRqg9iZbrv48NnH9jRnjcj8e28PRD1UmeaO+UGtL5MCHdkoI7WjxYeUALfslejK+XZRi8x3FDKZYubHeTXFE8aO85b740so8HmU7dmK12+Dxs/QDpa0fTvN9I5O35+rIc0yg0kp3EZUp4dusGWITSGuFjAWPuZPQemiz3Er7KK3HkNtQuW77dUV0FmrW9OLwZw9Dm7ad/RbjKXMicSYHpUW1mXWjWXHmIt6cshXgIiqfzK8KgcMSXabbC5KbJeFz29tU2VEhbBAXIoqDHd9NFvoGZATxgnpm+O9GQUbnq/bA6O2Aq2I/VtMYZVkSSGg/+G2mACXXSoc239OwQv8T+nQ4vmskV3IpcwZ7HLa9RrALHG92p8jcCp2rkd2hv9fHiY4fD6QppiKHXq0kE+6Ed8+JHyAIQSBS7Pu4IARq7gUbMRexj9pA5ruJiLVar6Yhi33itD++kKBBAITTMVO/VsqE5hbADgBbfYJmdnU3cWolxlAkPbXDPh9D736qjFq130UHil4qH3iswVPcUZUjY51SI/jvLJUSut6ADJUDAf852DFtUz6rjH5MhWVbWpiVO6jasmS6y5OXAanP+gKSydmCue3sMdEbH+Tey71yZedlQ07M8RSipqXYkVJ/tjK4lLDpGgjQtyPTZ+rgnLUciz267QJ2ESzNsQdMH5BHoBmE7Uo6Az3BG1WH4vvMwGQkLZvgj1v+RcfKt7LHtz5jb9PHWBaWxylOHP4U8/iT1bvMHwHRM+sEUvVxdqobHsogPk3XxiDRiqBmW6YQsGfGJ81q3n2k6shNTivVUNotb24GYEEjNJ35t1Z4yKkzyTgKMy/gN9v4aOauNTIEAR3o5LGTP+XZkavOylaefTs1bjC1LCF9l3kK3czfs0JVOjRbtv7uqPW3g5+LdvfwYYhbo6QCnrBoLKMqMLdr4CXtxDebNOZvBpYfi83cQuB/rnRRBY269Wy+7N0dKXlS+yhjej6xb6pFF4Fp7IYGSvYLJ8h1A/wCZsNwVybq0IeWyRfDT5HnM9pT6mi2ybfvNOWLMwObNN35Nq X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: acca4f1f-f360-458b-fc49-08db627ebd4e X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:08.6084 (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: 0QdaOPpbajV6csH2YgMXrv1GR4CT1p66SfM3TmSpr6RvGM+rJUCHIs3CseZNxAMzUk4C2mru61keFSvJfbOOwQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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 information of top file to eventfs and dynamically creates these files as and when required. eventfs_add_file() adds the information of nested files to eventfs and dynamically creates these dir as and when required. 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 Link: https://lore.kernel.org/oe-lkp/202305051619.9a469a9a-yujie.liu@intel.com --- fs/tracefs/event_inode.c | 94 ++++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 8 ++++ 2 files changed, 102 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index a48ce23c0..17afb7476 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -270,3 +270,97 @@ struct eventfs_file *eventfs_add_dir(const char *name, eventfs_up_write(eventfs_rwsem); return ef; } + +/** + * eventfs_add_top_file - add event top file to list to create later + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have. + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is NULL, then the + * file will be created in the root of the tracefs filesystem. + * @data: a pointer to 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: a pointer to a 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; + struct rw_semaphore *eventfs_rwsem; + + 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; + + eventfs_rwsem = (struct rw_semaphore *) parent->d_inode->i_private; + eventfs_down_write(eventfs_rwsem); + list_add_tail(&ef->list, &ei->e_top_files); + ef->d_parent = parent; + eventfs_up_write(eventfs_rwsem); + return 0; +} + +/** + * eventfs_add_file - add eventfs file to list to create later + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have. + * @ef_parent: a pointer to the parent eventfs_file for this file. + * @data: a pointer to 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: a pointer to a 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; + struct rw_semaphore *eventfs_rwsem; + + 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; + + eventfs_rwsem = (struct rw_semaphore *) ef_parent->data; + eventfs_down_write(eventfs_rwsem); + list_add_tail(&ef->list, &ef_parent->ei->e_top_files); + ef->d_parent = ef_parent->dentry; + eventfs_up_write(eventfs_rwsem); + return 0; +} diff --git a/include/linux/tracefs.h b/include/linux/tracefs.h index aeca6761f..1e1780a61 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -50,6 +50,14 @@ struct eventfs_file *eventfs_add_dir(const char *name, struct eventfs_file *ef_parent, struct rw_semaphore *eventfs_rwsem); +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 Jun 1 09:00:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263199 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 62A6BC7EE29 for ; Thu, 1 Jun 2023 09:01:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232506AbjFAJBo (ORCPT ); Thu, 1 Jun 2023 05:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232494AbjFAJBl (ORCPT ); Thu, 1 Jun 2023 05:01:41 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013010.outbound.protection.outlook.com [52.101.64.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 642B6129; Thu, 1 Jun 2023 02:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ChreMwsM1mAKDoSy4HQvX+hGWKyK/sWugxNMg3w6lnaQVQndWoFrAlSTVXQ89t40oneWXwTwnYiVrlsFqOipYrFxP6AsxQnLzc4DjsURyBJSIZwoFtbfuYCDV1dnftMhNwyn6T2PpXdz/D85F0OjuY8sISdehZx7uItcouB426tk6rGjnfoiuBIOh/haOP6gi9R4zaUlqg+ZsDYQ7oLzVLcS4DCXSiCwNH+TtWhE11tG9UvTEKxHMlxGkrxeFRlQe59eplW8D/Syh+KC3X5+Hr0Cg6vIwPH9rITMzZs0djrZTweyDp434PQKsuc92yorm2wxOMDBb4NwGn2wzEDH5Q== 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=OKQ39MLJrYfw3rrOHuty+6vC4CA9YsPn8r5/EP5y9V8=; b=dGccKH6pdLAdLZnAtOn1LlXEBB8J5SNSI0jjoklAnDgGNgdP4mqNn7rFTehQmdsmmU2nSR6ZgIi8qkJqhmoG/kt7S7iyGZqkKy2tO/1BJLwjzDuhzOSEFgnPJsyJ05V16jwyBneF5xUy7+B8NdykZVGCoNjmF135863Xxgywyd5JrwgaEJV5AZXm9E1qoaGpd4e4X9tv6tx8IysYhbNe/dbaecK2pb0dSA+mDx0MIkmwAFwcGExjzaG3WRdkgcuKOip5G+sjgt+VV9/CssedpbfQrdDhHSiu7Pc7vVTPnd0BPJLJPzQgGi6SeKlNoPdhwfYeil+rjl2pJqjJ0kcw7w== 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=OKQ39MLJrYfw3rrOHuty+6vC4CA9YsPn8r5/EP5y9V8=; b=I2KsqTBtzLgXej5cKIUYCQKgn9r/fSSHtG9M9ugJNuMQs1FWWgW2VyEegCBfLmHKnSxMnH+LFHXV/UKBo1H4+wsCQCTwgZi9GWskk9Hmi3r3ACUcVh4u+xvkJJvaQq/reIBeIU4o1kM0cGAGNkWehVovMBHeLpfK/r4TQ9sG5NE= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:10 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:09 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 05/10] eventfs: adding eventfs file, directory remove function Date: Thu, 1 Jun 2023 14:30:08 +0530 Message-Id: <1685610013-33478-6-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: a8bde3f0-1f5f-4217-2960-08db627ebde5 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: TXf8Q5wI63j3XCVnJMLa5z+1MGKh7Tdz6JkXwM8OXol6GpIgr6MvjEaKlAboTgi+f2XKGAAbsfSWGzsoVVX1TJpmHPlXVrrfAzqHpzMoUuFY8LUWF/TWaanK41bbwuaNay2CV7LCLr/gpbR8lXFZg1w6mai0faH5HVr7JJ7Xp3j5ltbuJWRXQGUMAxJhrfRtH57KsFToOGJqd/shlD3IiWUdfwyJwIzcbTwB1Xj8h4kVH+sVFI3mUZWQmq2RXmzU3T+q7cdVB6eqYGhmbdBeMqInhKUqyFHer4+4uEWMvv4T57cXKmMP8xNfgOz7AbhllUAKnmKAO3RqdWdtENMRUNICcnxgg55OMDDXsxpTBX1KpMyhcSLhBPsw5jyTAxPacF3kuR56uMf1D97xF3mqG7D7RbdtN6LbOexXFUdHrQ8xj3ds82sYjBnguIg72ReCCSfTRLdE+4dcd/zglgqva2z/Koo/yq03pJ+MNceDADFdhuydsplpJzpGNg/Uix6CNtMgWBaTOMVASVgLw9v3O7W8N1anDqp9A7eZ9WWvnuy7e4/6TH26hckfYxc+vtyMpOSWZA7dQoxyqtZIoscIHmsDM5qHim/CQYgKD2RV944vdpQOezri1hAkIDXw1i9RhnzCUXi7Sb+XHD+Hn/TNjPLWmc7+wjcVzBrljZRua6c= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(966005)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FlsSsJnKDRnQIqLwcHM38euJaU/6gWUzOPtv4/Kw5Vqp59BsVUE5ADP9YwoCU81TnfeFJAOvFBxV+mh1yvAqYjgb+YDIfojMAwsT+4/it1bdKwisDI7GoLmwjg8cK9FUAKbkuZw5DqQoVfORtR0DuWmfO40rAYNdeXGuFUIpS0HLqWrUgdGTPMgRQQ4PS7y/Pg0kdQ/EcCjdQjHLDfAB3CrApYxprTEEftTRs6kvq3ZF8A3ooAjklpOnfIDtdonfaPOLHjeGR75LG0pOTEEEeycQtPIoLWivEZAt3T+7KNmXHc45dGXRv+Y0sb8IdRJk+IPGT5Ta+Furf0U2zK+ZTxBAPyPKCC+8zN4YN1ThtoZBhKmZvbME6jAGBB5skEQpxI8jCCWDnyzK//2GUPeeQ3utqgW/4fEduUrp8cEjkDBY/cZYcBYyRrc3w7n1bHeyRtVsfY8dywlaybFR/eGvAvOyzaMXXgYOB5JlU0hzewvybuI4CRFj2HtYm4F3ZCdm+27FfFVTzS3JYEQG3/UywVzX1VP1NpcczhGkwUiRMe4sdKo008AT1nSfXuQmuexyD6GrdqUUuFokb0BR8dwW5BONVvqYNj3jISaF2nUAEYA/vttvJ2hyKPA8S+bUDiAZ9r85Mae0LYwgI3krAVML/2zPOstPZuzKSI7pAx0ceUeJ2W+hXmBCdCwXLG5XpaSyhslWGnih0GQeVd3PiJLKPsi6CnwhH3TUl1i4+zEbSZkB1v6lCI6GgWd1CMtNLkE8k6jq/4kL7HK9dRsntPLo41d11ibw+WnpE7tSksHWtoCVCRopDuncZS+GnSR8LfsDn6U1qV6T82Ot4NoSZ1POqWfxPXZaQzMw7bIV3uaWO2HfVyhswddZOwKLN36b8Azu0bKj4HR+kcn6lsm9HWpec006gWwwAP9n1bZnb2ZbpKc0ehT8n3v27LY+iqsAcIe3in9/90zo077I4TiwYM2Km2AvXp59AM4TneEcdHrURrKw6WTB3lpZv3qrMO5zt6HEnQYyDXEgeUq1owaA7h6iN4jXiuM12kdZ2tcNYcEuN81TcGcA7XzryJ3e9B5BpgEiKVuxvxxQGWPiE0ak+DGaVhetauPWws/S9+1oAW/WVN8iXxODFplaHFB0POek0zxRfHZrt0H8T9+BXYpNo4rLV7MfDEJyWKHe3reWJHxnPa6IjZCp02dhdMNaQfkM3LFILqKcb82Ct3bT93kKumAdWYt240NkXgh983+NYdTQQUhrGHn9K8HA3bY80caIO3ZCxWrphatMRfpbySDJouZQcxAdHtP4eRpMsskkgGIYcsOV8pY2DdkkIyel9FxD7XYcGW2giGQA58IzxmBvhmQCrrsfhF7jJM/kTOtzN+3VtCCpzN8LAPirP6+Ikn8un1oJUE1zfb0AUZtcHHrsxSsRd38oI3qAYmdMAKrNu4P65mrhEZTtfqrJ+qeuQfoIvnAh0hMJBaDQ18MdMBE6NPOTdy2T469h6TH+yCsuSwMEbAZSeByY2hnwjVMARsaZRzN57FgNmYdDJRt6ixkoYP63QjRIW8kbPSTSwoCOJyBpX5i6j3i91DhQ4Dde2fMJJwOO X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8bde3f0-1f5f-4217-2960-08db627ebde5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:09.8600 (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: Kncdd5r/GlqhjAnLbt68O9MxfEk8w0Wqihmby8oB3enroWx5Yh3jkeA97h6suPppMqndOXPWIiufgaM1E+Benw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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. 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 Link: https://lore.kernel.org/oe-kbuild-all/202305030611.Kas747Ev-lkp@intel.com/ --- fs/tracefs/event_inode.c | 78 ++++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 4 +++ 2 files changed, 82 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 17afb7476..874ef88bd 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -364,3 +364,81 @@ int eventfs_add_file(const char *name, umode_t mode, eventfs_up_write(eventfs_rwsem); return 0; } + +/** + * eventfs_remove_rec - remove eventfs dir or file from list + * @ef: a pointer to 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) +{ + struct eventfs_file *ef_child, *n; + + if (!ef) + return; + + if (ef->ei) { + /* search for nested folders or files */ + list_for_each_entry_safe(ef_child, n, &ef->ei->e_top_files, list) { + eventfs_remove_rec(ef_child); + } + kfree(ef->ei); + } + + if (ef->created && ef->dentry) { + d_invalidate(ef->dentry); + dput(ef->dentry); + } + list_del(&ef->list); + kfree(ef->name); + kfree(ef); +} + +/** + * eventfs_remove - remove eventfs dir or file from list + * @ef: a pointer to eventfs_file to be removed. + * + * This function acquire the eventfs_rwsem lock and call eventfs_remove_rec() + */ +void eventfs_remove(struct eventfs_file *ef) +{ + struct rw_semaphore *eventfs_rwsem; + + if (!ef) + return; + + if (ef->ei) + eventfs_rwsem = (struct rw_semaphore *) ef->data; + else + eventfs_rwsem = (struct rw_semaphore *) ef->d_parent->d_inode->i_private; + + eventfs_down_write(eventfs_rwsem); + eventfs_remove_rec(ef); + eventfs_up_write(eventfs_rwsem); +} + +/** + * eventfs_remove_events_dir - remove eventfs dir or file from list + * @dentry: a pointer to 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 1e1780a61..ea10ccc87 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -58,6 +58,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 Jun 1 09:00:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263200 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 4979CC7EE2A for ; Thu, 1 Jun 2023 09:01:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232541AbjFAJBp (ORCPT ); Thu, 1 Jun 2023 05:01:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbjFAJBm (ORCPT ); Thu, 1 Jun 2023 05:01:42 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013013.outbound.protection.outlook.com [52.101.64.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3774A12F; Thu, 1 Jun 2023 02:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NZxhvLhWeFvLZ1/XA3oZHSnSxzZqJ/uc8rNl4aFf9vCYqfti90Vm0zbR6NhoJm26EbZUYVhuXkYI7dy6McLukZliMYPgg1eevndxDhvAzk9jynE5reTmyYlt8cvWHWEbvLOhnRFxODujrlRUbWyWw867AMPQBXuaf/QmoU56gmeN0RQ4dJwkDYrcigaAPCw5U++h0dzxVST/ni09hzS++2pfELbFsmLKaInGCR3kbxK3chX4hzS+iRozgE4u02pHjcx3CVlNkIfLKI6s3XQ/CooeFeLsW/uEj3EsZX+tAwgf9zcLzLJvigZDkAEQd929AMeR9hNfwxX9cPKKCuVJiA== 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=Xih5OExW+DnTJV1GC776YEU7McEv0s7u1IdLzCNQJsY=; b=EXNZsGKu4Bgmt6Zqqo6obFDu/VDqh64c0+0u0EVBuYnkNeU2iQrO8Vdvb/nvUZ3sngKPykXO3VVn+bXsO/AqyUzPEDPoLF19gzCcnLmt3gP9fmZx+MkS+3U/gltTmD7u5FrBXsTgjD4agnVdbgxo4KTG7yVkR+ngf/i6e9iLlQpLFJ9HONSDh90DWK40IqiyZc5goSFcJJRqNk3sw/L7KSGJFwM//zTirt1+/NJ7yx2exD6AlAT09X6rfdtu/Ud7aagFye3UBzw/EcTaRe+/ccA6ZJV0B1RL2QtT+ihQVvGEfnMwhAHWH7FxJBYQkkG+IbqLCN2GXGEsFxEJzwMK9Q== 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=Xih5OExW+DnTJV1GC776YEU7McEv0s7u1IdLzCNQJsY=; b=f6No3xTZO9ph7WDaVCmMe0OY0Wq6wJNGubvHOlN8WrfNdpKo4wLkMnnWLuLa2djjn8CR2K0EW1mbqoWX1sZlUu1SGcFfJu2dR/mnNmySSJx0/2ftO5uftAfaIP+DeBlO7gqv1r3iMWY8Thyz7BgI5A+FCH8TwmdlEKvJcek/Rtw= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:11 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:11 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 06/10] eventfs: adding functions to create eventfs files and directories Date: Thu, 1 Jun 2023 14:30:09 +0530 Message-Id: <1685610013-33478-7-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: 0b0196e7-80f1-46c4-eb66-08db627ebed5 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: Btx8s1BgBwLiY64PiXFNajvqlnv4XL0gu0slidMxUTOXerNzCc2v8duj8YHFpkgTit0H7KkQGsECLK+I/hQJJ+OA5bK8hHfDk3s3bM+nGMZa455ak5vWatbUTERdGm0HeNM8P+M8WAVBPtoriLL3rQiCTlb2Fny0lHeD8XyKumJPLfCLoqhnqQa9Alggf4yrINYQjArbl2dguWG0B7u1Uu7x4/E9xbs97Ss9i61k+xs3V23pj1HfbHGQaKZewn9rX35AfH24EI86o2BFOcMeoE2eYpJ3hA5+FypWvVDxKSXzlWVzA57MZR/j8u7cNqi0dqQeB/ppGd5aWYuuDQBjNAXY4eEIYn4NmZtY+1HG7NpTNeBsqP9D31ebrPKSDSgIPyhBKZxwVE9RbylxVJ9Jhu6Ulde8xu1lVRFpe/2ucB6Om+jOBFCssmqlKymUNc3UGQ/26/o6WC3XbF3iIGj3EWjq75Sz9EaKMhzqJb/b38/f9HhGVx31JlOKl2ReMem0fpw8VEeGpSl57Ru1w6HRGmbIpx3zW/tjXIcDtvhH63bRAoWKtzBnqkRVjgZeuQzdW0//nMDoagpoCyKWFA50c6GYAJT8XJKy7qEPSRq0CKy8ixieZ38nv8KjcImL88O5 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: S16VEb4GUSA5WsB9QdF1DWXiZcTOGYtFMsTlW/a6JywCBaScL9on0dllnZrv6UWeK5si1J71R0tmZE1xX7QhxSJad5xvwHUEz+FYNDFJLMvdHgtaGI6cDja/htHEvHkugTwe//MJtrCj5iKhP9/fSVSpqr4S6RCylZmOk8I+V+lfrD6uGobenvhf09gQJH0x0Pn42o0M7O4be9EsUijOrq+zeWG4YrXQGJOggC/PtISJezwY1Y9E66PHJsHlISj6xcM9r5HpJGMf7dQ5nFCF4hwvjwPfYUNISzJ6DbY6d1/YPShkkFfsqNiAOaOnO6edjLgPrVgNQAknfKJDXlSJpViLJJB6pYv1J70sGA4LVcCn4XgNlB2K8HNK4F8tC68LgaT3zjF371dJ8tG4H03LO14vGyvt3Dbu+oYORk5ei6OXxre28FZzlGs6xbX2+6/AUkcujk5/WkAA7exs7VqJcM9ULdmNqTA+fT/clwiNL2dJ3V4s9H2H4Fd2t2LBlNMvcR7B4e1wlRwGBda+gTZ8snShySrvsZkHtNw4kl+HMt+tWFrDMq2V3fZW2G0EQH0VQRj4ajeOfByJvYXPb4BxPh0R1E6GQEJnyswoI3WWS8XAV7/Bw42esrv+zwdOrnwd8o5FXEyKnz1bDcf6HW1FxoVNK8Oby7OVuwrtZl8+yUkLjngTf3bqTmDkX+jAf7PGww/g9uZMLEmjOsYDK0VS5U3je/TnhE4IpcZXn5/J7oXPkBPloXfYSreKNtaoh3Qsd2KwOmCmujphbWXID9ycDZvVo19L8QdXeBBAUgO4Q+Gvj66TdERX1iqQVNzDvjUpr21JHlX7ZUqGlyjq6U8Z8c23ad6DciAz/Zp+spZmPKcVy8A7Csg6Ex5Hw8v/kfksHFGxBP5TnJ1XIqy1xz18h+6OR1Stds7ws3Fg9Z5IbsvdE/nhTWwdQFAEck9nflJ2St0U95/SQXoZgODMrIkStu/a+q0B9husorN+RC+X2YlUd0/WN99NCR4U3qDNLlRiVWvaTWoc9mUzipSaOZFs1rY2TUCn0CB96yaDb8H9TkWzpiZfC5tIUEpA6OjDSLazXcMUmfP3Rdh5UJMALQizvi5bmrLhOUJpI86MsnNyS2pvwU3MAqIclX/3StaEjqsnl7AGAVOj3ixO43pxwRPeGwYBSbHLu0NjxD1tJGFn1qidS0MsCzEdZU7/dEh9Hc3qJHQTVey/T2R5KbZ3IjlTq1y+1zaS8nYejRBFTUUPjgaNeD7aj3Oj3AgiWxrSuRHnuZotswQtEcJdYt+Y4UXVEuruEFbT5ono2qPwns3wTgtFmAWVfNfWVdcNYx34iKtcD1MNFQ0KDWI42e3pf/oIC4rOBUyxJsVLo8K2iwvqJFBbCDwGcefIOm5uq9vz3iNjTfeKtEI8+X278T77oQwky8uP020aU3uI1mnAfVVF/bdPUVufwQ/28qTMDN3/ITPi46CD0nSb7LWSmbDLqUpAAdjqdGv1lmX5440FRNLhUdD73merzk5zKMUXyuFj4z5xrDMqitfaxUtd14jQFe2667+NZ6fEEvOwRLV6mlx23YZ0EDI2vvbrNpoZQg7LTdi6 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0b0196e7-80f1-46c4-eb66-08db627ebed5 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:11.2078 (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: 2TxsvSMkJNS/URJ612TQbTDdPtGQDIl1QRwDpoVkv9cdjeMdYk7ZejEe6TcZCigHKYVpyRyq+DGQu0bfGtiPxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 Precedence: bulk List-ID: X-Mailing-List: linux-trace-kernel@vger.kernel.org Adding eventfs_create_file(), eventfs_create_dir() to create file, dir at runtime as and when requires. 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 | 125 +++++++++++++++++++++++++++++++++++++++ fs/tracefs/inode.c | 47 +++++++++++++++ include/linux/tracefs.h | 6 ++ 3 files changed, 178 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 874ef88bd..0ac1913cf 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -83,6 +83,131 @@ static void eventfs_up_write(struct rw_semaphore *eventfs_rwsem) up_write(eventfs_rwsem); } +/** + * eventfs_create_file - create a file in the tracefs filesystem + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have. + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is NULL, then the + * file will be created in the root of the tracefs filesystem. + * @data: a pointer to 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: a pointer to a struct file_operations that should be used for + * this file. + * + * This is the basic "create a file" function for tracefs. It allows for a + * wide range of flexibility in creating a file. + * + * This function will return a pointer to a dentry if it succeeds. This + * pointer must be passed to the tracefs_remove() function when the file is + * to be removed (no automatic cleanup happens if your module is unloaded, + * you are responsible here.) If an error occurs, %NULL will be returned. + * + * If tracefs is not enabled in the kernel, the value -%ENODEV will be + * returned. + */ +static struct dentry *eventfs_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 (security_locked_down(LOCKDOWN_TRACEFS)) + return NULL; + + 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); +} + +/** + * eventfs_create_dir - create a dir in the tracefs filesystem + * @name: a pointer to a string containing the name of the file to create. + * @mode: the permission that the file should have. + * @parent: a pointer to the parent dentry for this file. This should be a + * directory dentry if set. If this parameter is NULL, then the + * file will be created in the root of the tracefs filesystem. + * @data: a pointer to 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: a pointer to a struct file_operations that should be used for + * this dir. + * @iop: a pointer to a 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. + */ +static struct dentry *eventfs_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; + + if (security_locked_down(LOCKDOWN_TRACEFS)) + return NULL; + + 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 7df1752e8..66c4df734 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -452,6 +452,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 ea10ccc87..57bfd1322 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -38,6 +38,12 @@ struct eventfs_file { bool created; }; +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, struct rw_semaphore *eventfs_rwsem); From patchwork Thu Jun 1 09:00:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263202 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 44C79C7EE2A for ; Thu, 1 Jun 2023 09:02:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232550AbjFAJCI (ORCPT ); Thu, 1 Jun 2023 05:02:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232517AbjFAJBp (ORCPT ); Thu, 1 Jun 2023 05:01:45 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013010.outbound.protection.outlook.com [52.101.64.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2B071B1; Thu, 1 Jun 2023 02:01:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CywL3W1MzQD1XuUEq/01P99dh0+4rjdsr4Tej9OQcpUWj1mPv9700z1ENIe1lp1gr1feROxFAaLW+5PM7drNGtnjYMaDGmLyymate1AebzdSLGR4XjIhtO62ZyPzYrmrtQtZ7MXhir4oNeuztm1nSQt1UeqbUSjHuwFKy9Ql+BJyumRqLpZjMaVCpF3e4f9Eq5uObx0KBY1r3LYWfECo/5tewdHtfbH5Xhz9uWHcSsWc04acTlWaRBQySMYIDRvNHS89VMB9uMXDC4LswB7kwK2kSCWZDso6cc93tEYEYxM80KYWkryuzM70zLSyv4phzZJY8rlXJWafGO9mhYKuLQ== 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=E78sHVMuJgL/uvkdKsj0OxCePCjMkWbxoP7TeuJQJos=; b=MbQLxrLCoMXS0oDNyCzACWXmhHDYqoO1yW2/l6Kbhz3PBwVzg8Wfm7Z8I1U6BhODsVSeq0ODZmL+hjNI+iXFRYHdDWVyEi7vR11VLGfuoUO8RwvCkB3FYlUB1JgpQE7ngK5XJCYr1mAQU8L/d5oAh03zg89tNnypp/VmoLGx9dYUKqZ2wJJypgfyhg5i/air2CEo8MtcyNXFjB8F5LLO9e0sdlsu6zUILR5NKJYoCRGU0jjvwfHz9hCT7++OQPfPFmHEGsb32w8kYl7OJjegFeOjKiFTonriACHvTUU946X9hBZKZxyfY/hz1ryJzJIhRMaweyLrTqckhNXAld70Jw== 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=E78sHVMuJgL/uvkdKsj0OxCePCjMkWbxoP7TeuJQJos=; b=R3+L+73GJy0hE/AqArU1SdMu/6E/o1w3B1xwMRk+pkiyitj5r/oSMeOC7BSaOhTi6keEdCxiIrIO6xdg/BzIaXkte7VDvN8xLbTV8Vq+qAybcW2OyrgD9h2xkUMs1gum8dRSkxoW8lBcmxKBnrqR8w+BuAeQqeWKBwVXFDEazFQ= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:12 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:12 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 07/10] eventfs: adding eventfs lookup, read, open functions Date: Thu, 1 Jun 2023 14:30:10 +0530 Message-Id: <1685610013-33478-8-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: ed553601-7d7b-47ca-65cd-08db627ebf7a 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: XIW7/wLL4e+L62533626wvFkWQJ3WizpR4rVZooKAMi3b3RZ2X78JhrFbhpT6NR6jRIowuvb4VLtOr6/WFqeAnNO3iuliwkib4FucGYHNZHfn1jRwVnLC+d3k+LFFSyp9KWWwM9vdrF0DfzKGT1+Iu3PlZziJiixKWzeAEYt4xbtpAWP7ur6co7ut5tzy3Ujh4WonelFe1qavJjEAVcbtNl5ii3NM9FiTmEKDBN6nlOIaiU82+Aw1W81xsToMfb3+VKEJuNSRWSSGHjjA8FmZTHtEW7VjdrghBN3yWemlURIXGA5tgSWr42tJjVpiV/Hf3C9WfOo4w/on2ScjrpQ0eMWBGBVhMwxAhjo1GhiBDcpwaSF6bnGcN5pFs9leurgLpxSOECj3EOUn6QkQkT7pElCkGpO6pS0ABB1g2zqBtQ7Fk0G+AHLG6ZpWnBpRZ++DsvNl4MIfpQ4u+smHIXO7RWY4QkkpaQ42yjfhCS+QqGuf/a5DqzL3jRWnx6jmL0p9usAokPhAgW7/utTcylC94FUKMOVCXOcf5SLhmnA2BmpZZqJYf+YMagcjEZ/ArSa3AAeeiVRMhf4p4LnDl4NVZ84vs/w5C1pCJXmWmXiOAjNZmGAbR1miJu8wBzWSkVy X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kITzowLn0c02PREQt1SjMxgzdn+W2gGmyZ+JKpinpiehdcWPCBdM4JDHhTh0sId8TcTVD8/FLkcmyZgh6p5kWpHBxWqTRijBUCQDU6HHeQxRrlLQv6wM58wLozCiWlggu87xFOt9CVqECVn0Y3oY9q0buj5Kh4pOZKaMGDUfCIYomX0EyGF1bch4Z8asReBxPLLAUhD2IBD8HIPo479p0PUwhpvr5a6xaAWtbZYkhbEz5RYv3ClRtcylAR/+q6lAWrDhBYYxwqQkuleJTMinpF0QIqGxTbK0c2YfcAQL/QQsDDcDTYFncrBdfqYS/yy+E+q9PLB1nXRPx7Bd6ft5mS7py44DzJEDY6MjAZ8EKzP4w3beGItP13/S2fJ53/5iDC5dZhNQRlQmT6dDo2fDulowKHdYtc+dwEnuP+O+JY9Kd4alPE31sVMD/GUMpdaD8JUsCaVQUy98pE5gQ4QsZX3N5cnv2voL2T+6a3yAiYu9FxulKOuOLoW65bDJWA8XGUfJouVDI1J6C5WGx44GE24BM0T8QVBy2H0omwvbfie3wGGO+GFR6ZxFsCdc6+WbQfzuFQHN4zR5SmACBSuNZPKArJWVfXT4mo5HANgwqNuf8H/10DrDOQzZ9/0Z+xz8D+wkkygZMu1icfPAFicrUN4Cp6r4KiHpIHdvBHQvWX5q0149wDKKPMzIL2twMyNGOVty130cNKDS2nf+z9ycTigHSFa+Dm3E7u2kXt3PmkbMI00CK644ZoP8NhoDAYWLDTZAC7jr8w14s4D0lPWo9osXoU/FmQEIJUA+UeuMvf+9PIeWwbP2mAYJj/k73aBAKcbPGq2YC09wSai4idwkPWYLqmraysvZrJvviURB3ZTr7Ic3GJX9pOreUgKjdOwIdd/PcmOtqH3iml3hQI1sqib5wG2JwgjCLBNsxFY1CUr+57nO6XwUqazbC59bcS+WaO4ccKYtpFJIw0UZhMCcOiS2tqLA78sFp99LTzj+CcaRVrO7gR5REZrR+yoNEoxzmYYIs49roHOOXEL4HjfXntLSNCGK9Y0uuBB9vPmKlaEpLJuwGu8x5cts1vdIISdsVQwrVZ+UZAOBqJscKldANi+Bo0kvMU1zp0lJjPR5NTXvZowLcdpqggyPAParUjMJe/etJhhn847g3sFlxV/Lra46zOojgzAdjpdrh9T+wfGlSTeJfyE6TEkwdQMyiAsoa199wQ2vdpRpWdnThjGJ5P7/Dthj11sYLnIOB8BnbwYFyPNYCNm8QZc0Jor/MiFT//ZXWZadCsV9QZ3Uewmyn9+Si2HOGqnCLF1i3s+uq/Z970ndiCxAohvCOdWiEuvToUG1+jIFnYasnanh0zaovjAs+ueavIw+VtSl5hIIt7yE6dlNpNT5OLPL9mR1OjZVfaDvpKdAhy8fRO8BNXkglZ5HXlKjZPDa4avX3Iur1YCQTdc1shfvNmjaokz7LBJGRGGkEzsdkZeUDJJ2sny0r2xaZIhEoYMxjo98Sk2VcCDOSgRmWo00V0SXNY05RLRKOmGteyenAZB7m4TwGys/3gNJqVgSo3aWqNv8GyIS/HvFWYkheJNrBL+qiFrRIsGs X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed553601-7d7b-47ca-65cd-08db627ebf7a X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:12.2518 (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: tNliiiRiOuMh5HKdvy+DlVfqT6iJBDghu9r333YExM+itv6qCkizV1CbGZsttjB8P27ewQS4fft4C+tyUKVTiQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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 | 188 +++++++++++++++++++++++++++++++++++++++ include/linux/tracefs.h | 2 + 2 files changed, 190 insertions(+) diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c index 0ac1913cf..d98ded15d 100644 --- a/fs/tracefs/event_inode.c +++ b/fs/tracefs/event_inode.c @@ -208,10 +208,198 @@ static struct dentry *eventfs_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; + + eventfs_down_read((struct rw_semaphore *) ef->data); + /* fill parent-child relation */ + list_for_each_entry(ef_child, &ef->ei->e_top_files, list) { + ef_child->d_parent = ef->dentry; + } + eventfs_up_read((struct rw_semaphore *) ef->data); + + 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; + struct rw_semaphore *eventfs_rwsem; + + ti = get_tracefs(dir); + if (!(ti->flags & TRACEFS_EVENT_INODE)) + return NULL; + + ei = ti->private; + eventfs_rwsem = (struct rw_semaphore *) dir->i_private; + eventfs_down_read(eventfs_rwsem); + list_for_each_entry(ef, &ei->e_top_files, list) { + if (strcmp(ef->name, dentry->d_name.name)) + continue; + ret = simple_lookup(dir, dentry, flags); + if (ef->created) + continue; + ef->created = true; + if (ef->ei) + ef->dentry = eventfs_create_dir(ef->name, ef->mode, ef->d_parent, + ef->data, ef->fop, ef->iop); + else + ef->dentry = eventfs_create_file(ef->name, ef->mode, ef->d_parent, + ef->data, ef->fop); + + if (IS_ERR_OR_NULL(ef->dentry)) { + ef->created = false; + } else { + if (ef->ei) + eventfs_post_create_dir(ef); + ef->dentry->d_fsdata = ef; + dput(ef->dentry); + } + break; + } + eventfs_up_read(eventfs_rwsem); + return ret; +} + +/** + * eventfs_release - called to release eventfs file/dir + * @inode: inode to be released + * @file: file to be released (not used) + */ +static int eventfs_release(struct inode *inode, struct file *file) +{ + struct tracefs_inode *ti; + struct eventfs_inode *ei; + struct eventfs_file *ef; + struct dentry *dentry = file_dentry(file); + struct rw_semaphore *eventfs_rwsem; + + ti = get_tracefs(inode); + if (!(ti->flags & TRACEFS_EVENT_INODE)) + return -EINVAL; + + ei = ti->private; + eventfs_rwsem = eventfs_dentry_to_rwsem(dentry); + eventfs_down_read(eventfs_rwsem); + list_for_each_entry(ef, &ei->e_top_files, list) { + if (ef->created) + dput(ef->dentry); + } + eventfs_up_read(eventfs_rwsem); + 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 inode *f_inode = file_inode(file); + struct dentry *dentry = file_dentry(file); + struct rw_semaphore *eventfs_rwsem; + + ti = get_tracefs(f_inode); + if (!(ti->flags & TRACEFS_EVENT_INODE)) + return -EINVAL; + + ei = ti->private; + eventfs_rwsem = eventfs_dentry_to_rwsem(dentry); + eventfs_down_read(eventfs_rwsem); + list_for_each_entry(ef, &ei->e_top_files, list) { + if (ef->created) { + dget(ef->dentry); + continue; + } + + ef->created = true; + + inode_lock(dentry->d_inode); + if (ef->ei) + ef->dentry = eventfs_create_dir(ef->name, ef->mode, dentry, + ef->data, ef->fop, ef->iop); + else + ef->dentry = eventfs_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; + } + } + eventfs_up_read(eventfs_rwsem); + 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 57bfd1322..268450d60 100644 --- a/include/linux/tracefs.h +++ b/include/linux/tracefs.h @@ -68,6 +68,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 Jun 1 09:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263201 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 8A3DAC7EE23 for ; Thu, 1 Jun 2023 09:02:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232578AbjFAJCF (ORCPT ); Thu, 1 Jun 2023 05:02:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232519AbjFAJBo (ORCPT ); Thu, 1 Jun 2023 05:01:44 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013013.outbound.protection.outlook.com [52.101.64.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A69591BB; Thu, 1 Jun 2023 02:01:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bNtnqzgu3WztXdm09NW9akRh+O9iDwXFJCQwXrhFxLP6KBzLqQrnSsj6L2HQtLuNF380RcxjJ1w7+TBR8Edc3LYD7DoXsfRHwpnpTRHhT307vshStvAQeuGOJ0+FoKWKDVd0LR+TFJ8sMxKXoVXIBNgrAol8MsZhbSjgLc5xrEErCYV0YEzEifoVuZhfMT90+IOErToyGApHO0O/u0Fa6Jr5dpJ42y1L0Li50M4m+a4NbO2RCjhsQCHvs8gU7bKW19fImgpm+A56dLPxljhndDfj0bacjTRzqTCkXRQG4RkSSjJyHF4HNuvqXJuk/J0aYkAOtnBXHzCaxU/fCjHeyw== 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=KKcBE/cygiHxi/0/RQWaU+BoIShwEEohRRcN1Oc7Y0s=; b=XqeYetn9ocWGskDZLduMBIrKugYK8FQmG2V0lGMsLl4uhajlB3OJylVwtYSQl3ybM9quENM98G7jZIF6S0diOAVb2fNuqx4wfK2lmsCs1cH5CrdDrdx6v2VgC1sMPqmFk8T3E+GfI8+beAJtVoUFfsTjKOcT2pSZOOZgQXuSL4a2Dl0KdpKmmQwbLEMt4CH+ElRARW4ZPriGIM2D3j67OsyORfSl8NzKSwzagR//M2z+5w3ZJTRwtPXpyzC9pEkZ2bnQHnyh9N5tpu7QW5gW42K9MD9BcwSErMvU8qjluyV49Bjbsz6JGOvknsSWU8/x6L8uUM/xeyuJczeJQz4oDw== 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=KKcBE/cygiHxi/0/RQWaU+BoIShwEEohRRcN1Oc7Y0s=; b=t1bpzWaMIJvig6yN/PkTa6WkjSuKtMAsaubI3Rz1eFLkNhuIVInGGqd+qj4i6YisBXZ3eazKy2VN7dsJlKfe1Rh9B9n6isSaZ59dGvAePJE2FcG4CP4FNSQAN/yNipUbaEC/zt1gJSp7WrOg4BTxTROxelzWg6n3GdbH2fXdC8I= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:13 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:13 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 08/10] eventfs: creating tracefs_inode_cache Date: Thu, 1 Jun 2023 14:30:11 +0530 Message-Id: <1685610013-33478-9-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: c32eaa0f-46b1-439d-92ce-08db627ec010 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: YakZ2LURSnyoKba0mTJUc+3Io+a0RH9MROIaIxpa2HrDetpVhD24/2xMP0LIK+fI3Huys9HwVeX/OtG6o8xOgg3SmTIaHKsvzLZvbW+uDb/0QjdVTEA4lzhXtrD0IEgtSTZcUnlodZg3IDeUBHdFntXPg3/1q0t/251G/Ihzf2AQ6oeQ7XO6zbhFoJmE528ZbR561Mo5neMOn+fWirbzHw7MR/uG1dgmB8jtufdKeTmooJXQG3WEDwkmDmHDIVAxDTUZus/uHoq48c2+Qbz10E5PxCazxWwrvBcWfhd+Fp5h/6TSsPU1dtZvxCr3SzXpY8lCf6FpLoLfO8ZueaukYleX+rOiItn0HNsGPrXT2PM/WuAbmuhClDDxO7WN7PzeekuM7EgP1eWcHyAlxSMGxETmmlRNU9/jS0cySD2vLwdRTgcvUEm9WPEltn6rDNOq4BnSKU5EX+n9tjQvevMMCTTc5/A6TGkE2xcU22it0tWvAAPaEz7ByeG0tA/z3ZGQQlRkRgimKNBqvKC7gE9cgFZG69FekkLosxY71N8il5AHfx5VblKmvSIu4azLxSiEDi2KuIFF5f9t+Pr4TLwsAGJ4x9hhFn/Tn1yJx6I2QwYk5bBsBGCLS2A4bfsFlL0J X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9swLPnYLmckwlLGPd464+QyDXHiqZ0Woz89N6n8nNJ48AH7Ntmh02zs0oTHGr7qBi+8ErxdgaLGiwPryB1DIdbpd6F80T1Y0njHev2U7+oZmpa4H8h+6buwJpvabGh0/lenEzZReLrWQn1OZNdZoEMk0/SZJGVUF7Fm6eauZZ0YzbmH9o02LL2qteIqL2u0YX1gE5AVG52X0fFRjytcqQVKDz4OMkYPfrGZSLBsaxF7OlkZlxY7skVE86Uf4QnmrtbuY+547DxVt8z2N1NV5I1GW76ZXZH6oKKbwiZ6WH2jkSQ66N89jUqjwd+oyh3yjekTpCT1v45ACx1wVuWS1lJVlhwc692cmBQpdIrHTt2qjO/V5f/GFFS/U54rnIILeSbaEu6AQbbrP6YL91wclMCrE88Rr3ICTcesO3PaIICbuOxP+OXrY5TuthpVwSI8f/a886HG9rYH2zANcjJ2lqoHgtb2SZ4vnUHOd7jInjcTE8lIzxlL6+eGa76wgeNsde/qiCBvroo2ocbparnbTJjUE/8o2CF/kZYw8iy7+zcovEcHsyAFLn7NdO7KsAf9FiaWeLUwxxhETNXqBJTAMx6zb5BpmUJr9keiJJJczWpEegGmuxZXO4knsI4RH4mt8LHjaTqd8DbDyrXRKKJ0i7Q/WQjfo9DmJ2Omhznz/naSStDg2yfDnWeHiyI+dDhipFmZwrJs6lW0GlVZqJ3t+Xo+LbW5/podq73qvBh3kA5CNwPolTrTiEqx4iS78gDia7ItFosHLDmKJnynYjMbpdbi7CaQULV4rsy2SfiRt7IMmQb/eQEtra0e0fTEoRoiOlndxSuxd8n8EG/4np4bQabB7KCbBP6c0zzbub6CfRR8Fl9uYButqz384NY0l9//xXVz+w5jdR0gImn0ZoytS2ZXNDCkXEvBuqOLgt5iHLam60DyEzm5BmQfnRkK+QLoOZDFO+sy3ejWJgpln52eg2lLhlbQzB6ECoghf58rQKYS4KwywrI3uXNKH8hss1Ugvj/eiRrZq1wGX93aA8UIqG6d6+q396av2E3q3ZWo1b3LQ/2dJ106qQg1SWk7aPCjuWCdjgHhAR1kVAom6TeH1ZTLo4osdeGDqMKOwR7pbCCemdzfUwJYZY6sNJpLycxCnDcFnueENo+1iLuexYYIJjyVHSAF+pyGIAYKgfcfz2RQOMfOSOzV73F1OKtE+PuH1FvrGOBPJrAAE98vHAb+WwCYtdCBCA/rdPT/9r5voHQEYRZAJYK2Zy2CJzeJiLphSTHDh6bv9ro4BV3WekwiwCaO7f1AISp1b1f3Ng0LPWAe31QDGl3hRToqf9Vm+nPeRUPIiA5m/D3TzuEKaAeUctCqS2L96v8bFaDOz4U13Sqzf6DVqiXlqUD8e1njso8KvyH1Sr94aaPmigJQL6+CpD5m7ZRZ6pbBMEaOPb0wErffoV45K27VOUWR5CcL2xMUWOuKo7BhrBWhXfGmhLitVxGYN5Ut9wCD82QprSE1XP/o/kyKYX4J0tILQzVshPMu78nX2QBdDnc+OzMbNOqZqNnkoM16hfpk8t059RJIwUvn2CsWA1tm3jV69SOQ/HwGb X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: c32eaa0f-46b1-439d-92ce-08db627ec010 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:13.2165 (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: USMoihawouqkpeblLsjobu/le3T4AKOXso5mKDAe/vMfayRrAnYJ3ZOYfI+hvd3V9DV0MMOtrSmHXgjxnQaePA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c index 66c4df734..76820d3e9 100644 --- a/fs/tracefs/inode.c +++ b/fs/tracefs/inode.c @@ -24,11 +24,30 @@ #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) { @@ -347,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, @@ -676,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 Jun 1 09:00:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263203 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 44AD0C77B7E for ; Thu, 1 Jun 2023 09:02:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232528AbjFAJCc (ORCPT ); Thu, 1 Jun 2023 05:02:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbjFAJCQ (ORCPT ); Thu, 1 Jun 2023 05:02:16 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013013.outbound.protection.outlook.com [52.101.64.13]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5824E10CB; Thu, 1 Jun 2023 02:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ebe22mjj3nUxZ3NGmqze897OHzv8HyYBVlCIYLcsfZv4lmq3s4qE3pSKVnh9bao7Auag7aNZeHo09qLggzuBXoz0B7sTJAEuRv3g5OX1m6eMk7XkSW8ajsr1VtlfpLv6NVPEQwkB3vDeohdasixjpxruN7sZvEXCyd84Oc5Kqd6FqMyRa1LP0D0pbVklgXG8TWm/m8MsXUthhuORTAPl0kXQxGj5yED6YlJcuZdi4pdkF7CAD4R7BjnjlW+4fUpmTBdfqr/GERMWahvTgr7ngfVZ2WUjRS0K1ZybAWiaE0Szaa++9sB2ZitlxJN3T9QrLCbswORyP8Rfqx2pWbQIFw== 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=vfeFNhpRQruvCiJ19V7ar/8DL4+EfHjmUsxLaI9S1jc=; b=E9M/vdYqNISSGynIuZJ6uZ0M3TXd3w9e98e0T902uQgYw91FPbnFFKMhDtyJDTdxBnZCSnkhUN+FivkVFuAwZRhzTrk1qOAUtx9L0dciJwbhKUOJaQK3wr72vqJQ7DCQGsfRvdoami4Bnul61F0R+pPevUfT/FE56n7Jv/dR3jqoWf7orltHpgSSkeX5YmdESrg2zhcHQAbCyQAeds1dZWUvYiqvpVYd+W8kzi4vyEneQTyF4vEEG/cokcMGnalLun+hGwEC5q6QRO+J6KSYFhz8YMr2vAU23SXKBZIWfZc5KEYEmjbbBCYvsLRo60SChXeYB/gsu9GX2bG2qNRTWA== 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=vfeFNhpRQruvCiJ19V7ar/8DL4+EfHjmUsxLaI9S1jc=; b=FyPXZNcgQyNIhx6PQy87FcwpJGPVPmAcb6CjR2ZYICdcC6pnEqBEDOxiiIEo5B7g7X3380s5GhJpIquRWfzsxkNyXqwG+mJwwcBwNO523b4zmXMxEM+VUgzupyZUiUKlvlKvIzKZ6yJFH5DB2MokQU/buZ29M5CfzZ+hfwz4erk= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:14 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:14 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 09/10] eventfs: moving tracing/events to eventfs Date: Thu, 1 Jun 2023 14:30:12 +0530 Message-Id: <1685610013-33478-10-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: 0bddf763-7c08-49b2-5d6c-08db627ec0a4 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: cVfLVatDAq3X24lBHsBmBteb++YaRqmLVcGyuXVgD3tiOnZWWKm5539S18ou0aGAmv0wFAZv5l1qSFRInv4ld1fbnPVSCKa1dN13f2H7a+M5/zzy14Rk/8rQYgkFtkwFBLb+oTqB9pDMsRLnsODO/Vp7fC1kJYFsTkcnv0GFzXhykdZ8yBFdIfeKHiI5bFg8niyPCktNZtfoftxK3luiSPXZ1AkE41OMA3BLPG9j56C+OgLCQscrs5vkGWZvEfnc1SWTgA3qC6qGb4a5/5z6Jf8Oeg1WefXrfWYgl3Xn67NgU2cj+eRBEsXocqcNnNilnIDBhL46WZ+5X7k3p6Lq6IzUgSPX8MuZ8PpflLvWH+olnpW0iSdKSe1hc/uSuVTLOU0++JMRspCY7E7kTRT1Sa5lGltoiI0M2eDPnjlImOd+ESd1LzaxU6zcdcSygLfdmkWkas/DItlrEPka5pQRhiL92JaYoKhW1KAknlYuJoI5XciSazrc9zpBWUMLorPk0tDybtD+SSy+6x1uoZPaTDGaVjdQIFGrj9dMAYhtHK8aeMMZbZXQmG8I0r9L7wbm78NRcZYj4zpTFbiKGEjvfoj0vhxNFDT4twIYgLgDm5O14jAJ5ERGTrAEsaEcia87 X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3HGu23MqcM4+92DSyAL//hUqbrepE8evatn/wG8fLhqPKmU/uK/+wL66atGNoUeUdElRzfNkkyHX4uDEgF4Z86JLl9obirG/zqZFuIJ9QfPHo+X86tuv9p+/2iFT9aXhZqYSv+5Vm7ByYXcblkv7ZevxqkAs743Hv6a3YFjGcgcIbJwJOkUQb5VqTYTRqH4dk2/2VeqLa4WvVxzZ/nyUrjQrmCd6uyhG99QQuw0NUJkIiSQvlKzo8skMe582/9xBe9JCZxTfWF4ICRVvE1bDDIKyD/H/26RDamhKmrvWvcwWWklq/QcMEbElMjt1FdK2pZvq+DcLztPE36UfxnXfImveBYHvoKscUOBJH/gE7WtUHlBsdQ1c85Ot+p45mAQxl7bUL/hCRFTIdi+cC6VEp/ENwhAVfzFx3UaN6omYbYNa2DTvMssxbZJQkIJx60Nh+Y5iVllhYlFZ5SCmtMK3X5z5Q6ZoLTvArdXrw2f9c82ck7b33PazISCJQuIBntUvmuMjOdRk2AmRq5ythW5YRXUxY80guHzW4o+AB3OHGOjzyPn+YUvsaXGWFUdoWHHgOvI0t08rGFngISGDQZI64rp7Oh7mmAP40eAnYiQNqyJ8tNNmwC2ZBAHQNugtyEJD3Wdh2QVO2wJ8wXCdpVg5RTknfT56jx/P+9yMHe5kCUBdDMuE/xPy0wuW1VB69b8vhW7shsFzuteY/DiRopFJoWA8pmQsoVPAdXsanLpZVLee5vM/xIaDJV+jI99Ee1g4WNX5guKgngn4CQA8/O5hbnFBk6D3pB6uuK/l9oz0mBhOhqSBmntFlSyruXfJGwotAGOwhUjKzpIYw7UFTE+t6qUaDbAFKftfgTFhb3IkCHUz7xpevpCxqF8EWG8Z5X/owtKyXw34Bp8EIj1hBfXCIu+TAcj4AhdOof1ak5R/aAWMbyDZW1umX7L2rAbSmb2Sq7DW5KU3APOcBeOx6FTNEYqF38mBjI2+OdY+9dJ7g9KsjncIToaoRGfP/2xbF0nK93Yy8ALCOVGzu+plV07gPx6Xze/rT/jgI77nFIHaoathy0XGp5Hp4vJOxwYgQhdEmxn+W/HOGivYuz3ahXTSfqpLyXibNiOzGO5Vwihs1lBk2I4baSh4B8VWHFJ6lW6n02VOosmES3toHtMzs11JUH+NEu5UX1eNLZsqCxAANA2pSbEIX2dZCbQNFThUIPiLLi4tomv5ueMZyNCXAzE1MCGiLqxka/7KpVCPNwf1i30zoJ//fNGIzLN6gUyWAjBN+Ab8MjlGAzXXquRWLHPS6y7zyjvxE48HN0+eouJ3jlby4xy4ByIeZRwnVkzzsn92RJIP3PXoTjas4p4NUqBr6psNHehUo5t9+neykF3WEPZCTdVu0tC3Ff21mMzbpihMpSRVmuSMjdty49ZpFkWdytY1Rs11TU7RjfJt4XmladzGu+oVlHCXLG8an2DZcNnw3jV010fvD+fKvfUZqLETt9/CeGV7sShSNhib3VU0eXCIRLyoePpVaCR8NEhogP1mXjMZmgBQe3iU/5ZeWRIPFNkLNSJykTHRW/6xJKA/xCoYK/uSh33y1tEwAeQ3D0L0 X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0bddf763-7c08-49b2-5d6c-08db627ec0a4 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:14.2121 (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: teyeobMJuEm8LdnlsXlooLqlb50IxHFKj4kK8lFOERZwThaE4UPFB2qcUAM3mMuNOQWskL625BWKeMKNbFEJ2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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 76820d3e9..a098d7153 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 0e373222a..696843d46 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 b895c3346..b265ae2df 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1310,7 +1310,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 16bc5ba45..94aa6f9c9 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -988,7 +988,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); } @@ -1009,7 +1010,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); @@ -2295,13 +2297,13 @@ create_new_subsystem(const char *name) return NULL; } -static struct dentry * +static struct eventfs_file * event_subsystem_dir(struct trace_array *tr, const char *name, struct trace_event_file *file, struct dentry *parent) { struct event_subsystem *system, *iter; struct trace_subsystem_dir *dir; - struct dentry *entry; + int res; /* First see if we did not already create this dir */ list_for_each_entry(dir, &tr->systems, list) { @@ -2309,7 +2311,7 @@ event_subsystem_dir(struct trace_array *tr, const char *name, if (strcmp(system->name, name) == 0) { dir->nr_events++; file->system = dir; - return dir->entry; + return dir->ef; } } @@ -2333,8 +2335,8 @@ event_subsystem_dir(struct trace_array *tr, const char *name, } else __get_system(system); - dir->entry = tracefs_create_dir(name, parent); - if (!dir->entry) { + dir->ef = eventfs_add_subsystem_dir(name, parent, &tr->eventfs_rwsem); + if (IS_ERR(dir->ef)) { pr_warn("Failed to create system directory %s\n", name); __put_system(system); goto out_free; @@ -2349,22 +2351,22 @@ event_subsystem_dir(struct trace_array *tr, const char *name, /* the ftrace system is special, do not create enable or filter files */ if (strcmp(name, "ftrace") != 0) { - entry = tracefs_create_file("filter", TRACE_MODE_WRITE, - dir->entry, dir, + res = eventfs_add_file("filter", TRACE_MODE_WRITE, + dir->ef, dir, &ftrace_subsystem_filter_fops); - if (!entry) { + if (res) { kfree(system->filter); system->filter = NULL; pr_warn("Could not create tracefs '%s/filter' entry\n", name); } - trace_create_file("enable", TRACE_MODE_WRITE, dir->entry, dir, + eventfs_add_file("enable", TRACE_MODE_WRITE, dir->ef, dir, &ftrace_system_enable_fops); } list_add(&dir->list, &tr->systems); - return dir->entry; + return dir->ef; out_free: kfree(dir); @@ -2418,7 +2420,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; @@ -2430,24 +2432,24 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) if (WARN_ON_ONCE(strcmp(call->class->system, TRACE_SYSTEM) == 0)) return -ENODEV; - d_events = event_subsystem_dir(tr, call->class->system, file, parent); - if (!d_events) + ef_subsystem = event_subsystem_dir(tr, call->class->system, file, parent); + if (!ef_subsystem) return -ENOMEM; name = trace_event_name(call); - file->dir = tracefs_create_dir(name, d_events); - if (!file->dir) { + file->ef = eventfs_add_dir(name, ef_subsystem, &tr->eventfs_rwsem); + 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 @@ -2463,27 +2465,27 @@ event_create_dir(struct dentry *parent, struct trace_event_file *file) * triggers or filters. */ if (!(call->flags & TRACE_EVENT_FL_IGNORE_ENABLE)) { - trace_create_file("filter", TRACE_MODE_WRITE, file->dir, + eventfs_add_file("filter", TRACE_MODE_WRITE, file->ef, file, &ftrace_event_filter_fops); - trace_create_file("trigger", TRACE_MODE_WRITE, file->dir, + eventfs_add_file("trigger", TRACE_MODE_WRITE, file->ef, file, &event_trigger_fops); } #ifdef CONFIG_HIST_TRIGGERS - trace_create_file("hist", TRACE_MODE_READ, file->dir, file, + eventfs_add_file("hist", TRACE_MODE_READ, file->ef, file, &event_hist_fops); #endif #ifdef CONFIG_HIST_TRIGGERS_DEBUG - trace_create_file("hist_debug", TRACE_MODE_READ, file->dir, file, + eventfs_add_file("hist_debug", TRACE_MODE_READ, file->ef, file, &event_hist_debug_fops); #endif - trace_create_file("format", TRACE_MODE_READ, file->dir, call, + eventfs_add_file("format", TRACE_MODE_READ, file->ef, call, &ftrace_event_format_fops); #ifdef CONFIG_TRACE_EVENT_INJECT if (call->event.type && call->class->reg) - trace_create_file("inject", 0200, file->dir, file, + eventfs_add_file("inject", 0200, file->ef, file, &event_inject_fops); #endif @@ -3636,21 +3638,22 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) { struct dentry *d_events; struct dentry *entry; + int error = 0; entry = trace_create_file("set_event", TRACE_MODE_WRITE, parent, tr, &ftrace_set_event_fops); if (!entry) return -ENOMEM; - d_events = tracefs_create_dir("events", parent); - if (!d_events) { + d_events = eventfs_create_events_dir("events", parent, &tr->eventfs_rwsem); + 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 */ @@ -3663,11 +3666,11 @@ create_event_toplevel_files(struct dentry *parent, struct trace_array *tr) &ftrace_set_event_notrace_pid_fops); /* ring buffer internal formats */ - trace_create_file("header_page", TRACE_MODE_READ, d_events, + eventfs_add_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); @@ -3755,7 +3758,7 @@ int event_trace_del_tracer(struct trace_array *tr) down_write(&trace_event_sem); __trace_remove_event_dirs(tr); - tracefs_remove(tr->event_dir); + eventfs_remove_events_dir(tr->event_dir); up_write(&trace_event_sem); tr->event_dir = NULL; From patchwork Thu Jun 1 09:00:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajay Kaher X-Patchwork-Id: 13263204 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 5BBD6C7EE23 for ; Thu, 1 Jun 2023 09:02:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232556AbjFAJCd (ORCPT ); Thu, 1 Jun 2023 05:02:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232540AbjFAJCR (ORCPT ); Thu, 1 Jun 2023 05:02:17 -0400 Received: from DM4PR02CU002.outbound.protection.outlook.com (mail-centralusazon11013010.outbound.protection.outlook.com [52.101.64.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A69BF192; Thu, 1 Jun 2023 02:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BW9rSuoVZzQ56h1txT6VWGrd6OW89vz4ypTBxmWqA7c48jSZBKKJSYo5ExOYEMnqQgLQw5YXN69gdrnVmKYIQLRGRS7UIiI6GeQZWsmBcVS+kGlrefgz39CS1/jdwJIrVGh3ZQPt1MociHszbLS2QhrcG1fR5O+EL5t9R2fUQS1jwxfpbsh2XsbPuBqSSl4dch8TM/sxjSoYyNv+91Z+/XZsXWm7lh3zoiRyARvxN1rp99dCfFobpC+gGT/bKDj0gwfp3FkUGkU1rKvOaaKm9Anzw0iCsY5iyR1MoW1EPxxz0dk2liHpZhnk9GVGcp3qfNIRuk1mo7LIe9Kl014vdg== 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=H9bnRNg1BLztg/RndOvyjdrwv2dOtmc68BkZNs0p/m8=; b=FQgYYjhmT1a5zXp8Vk+pxe/JXwWshZAj9rCLMTDLCd97Vkn2xdDRqlSILXUCEcJ8pDhfQeothu08zyeu470NKSbJFBS3LJXISfNb0z+SPTsQ1d4lUXN/eNU+9VxNTRv1R3s61SbrC6uoCRp+uAqz49WnJVAlAmUNX/uw847heo8WIkC727UMpsdo432qbInaAs5WxTCuPzEYEZ6vhGs3DRapLfXnX5jxQkcA5/6nWBQj8h++ia3osU5+2yOVz+K+t0C96VTPAu7pfozcucYQVkt2atBYnQ90dWuwXnmO4wPeqocJ1okwMEMInEGsm1ZHLGPyjHEYbxEvkaHXt4oQCQ== 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=H9bnRNg1BLztg/RndOvyjdrwv2dOtmc68BkZNs0p/m8=; b=ivdUw5iNXO8DxA6oOuPXrCb6TjF1qXqNSM+I79/dEAH/0yB/+QspgRuU1Q3lLJShDMPOM38D2HBCtKSYZUGwkQWZQj2u/bx16keqxtAyJV0dHxHgTB8iC1YHNRxYgpjusotsOhCpQyeEwMe9SJlDHlkE/AIOEfRNfyXOhPu7Hsg= 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 MW4PR05MB8617.namprd05.prod.outlook.com (2603:10b6:303:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22; Thu, 1 Jun 2023 09:01:15 +0000 Received: from PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66]) by PH0PR05MB8703.namprd05.prod.outlook.com ([fe80::5631:475a:58d4:cf66%6]) with mapi id 15.20.6455.020; Thu, 1 Jun 2023 09:01:15 +0000 From: Ajay Kaher To: rostedt@goodmis.org, mhiramat@kernel.org, shuah@kernel.org Cc: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, chinglinyu@google.com, namit@vmware.com, srivatsa@csail.mit.edu, amakhalov@vmware.com, vsirnapalli@vmware.com, tkundu@vmware.com, er.ajay.kaher@gmail.com, Ajay Kaher Subject: [PATCH v3 10/10] test: ftrace: fix kprobe test for eventfs Date: Thu, 1 Jun 2023 14:30:13 +0530 Message-Id: <1685610013-33478-11-git-send-email-akaher@vmware.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1685610013-33478-1-git-send-email-akaher@vmware.com> References: <1685610013-33478-1-git-send-email-akaher@vmware.com> X-ClientProxiedBy: SJ0PR03CA0181.namprd03.prod.outlook.com (2603:10b6:a03:2ef::6) To PH0PR05MB8703.namprd05.prod.outlook.com (2603:10b6:510:bd::5) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR05MB8703:EE_|MW4PR05MB8617:EE_ X-MS-Office365-Filtering-Correlation-Id: ffb13d27-3ef1-46b9-b132-08db627ec141 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: r7EsGjq3XoPnkYQxI5OpWWVVTCUGxXVXPdauEY10ptvfMm0C66ypqIUA9c4aCGNN+vAeNTkaLx311PEH5xL8lEZG4eLWPmKwruyT3NOWsnXjilfIJLe1YsTfxruWJKbqEF6hVkJ7aj1y67jR9/ug8DjoCGwoCG6qSqXbKd6d2TWOLN5QFaj3AWP81aFlqicwtkhA9T9vT7/Jr58qn/aWsgUci1ZEIr+UbnPKbb6OmhSfHniOnxiDIjnxy43fXp85uvgT6cVs7T+ySNFWisrdHcXZtWqvWRvtIy6qkCSLoVHIZYb3X45wnFoki1ofv1+5dPbwcCFVBuq1NKEAPJJnBWimHa5mqjh4FM45CXl37GHpmPackBigvRj5bM/KTCz3K60muufMQqbFXjIdLNgkS8hQIzPVC1qy8hV6YQ57S/cOurx0F5bg/GP1fvYv2nYX4SBceuztbYfOJJ3CsqinmJKN0NZMgUYs19uhDyyEQDXFqMRR0/8KVkW6QbeHOJnGe7FmZvDPFrooNR2Jn9jwSzeywMIXNM17spCb0nR0CvuT+Q+0fJub4S1Bwdq7X+SpdGrfMJHhrxLtlq7Zzr2qd8RV/zhaYk33zvAAsb7+cR3QWiCUKalF7YLCqhIIiWLo X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR05MB8703.namprd05.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(39860400002)(346002)(136003)(376002)(366004)(451199021)(52116002)(6486002)(186003)(5660300002)(41300700001)(107886003)(36756003)(8676002)(38100700002)(8936002)(26005)(6506007)(38350700002)(83380400001)(4326008)(66946007)(2906002)(66556008)(478600001)(66476007)(2616005)(6512007)(86362001)(316002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /t9ccRGjdmE27Jrlrw7K0DkVhVg+KFMZgiplvlxVX6jw63sQPxeHsaChyitmsrMiiZK8yrFB+Lnb9OmpB5UDB4PP4ASIPEc658g+HsYGXIw3GRBOJbN51nQzZb5BiqM5xUzHP1Pwj5gp1c5wcaPGsqeHcKiOyRyVYITVyRDvvIv/UVdeTwDAH2k9EaPennUK4kaxE4gYlFgIzZcB1EkzBwY1LYT/g8vDFEAGvRCQHGc1roBPI2VvjXmePxnT4rZVgl97vsKbLoEVEVJI+MLlnKF+v517vEMbMsLo+pYPzS7k4MbttEqN2sCZ2xERGM/TZOj5mjAdznm6z4sX8ZcMihZN9NnoyRd1KCkRKsHi0oqTX562jqWbY33AmGV/r5pbIS8wEvt6v3/fMZV5+ld8lfQ7QQ2JC5SX9x7vIdtI3vVrd2B//KdpOSyx55in5K21jf71O+KWoe/cucqE5vBKtiZNt8L73wGCq77bLJ+9tI09K13WiKMYR7fXaQHqcwT4IBQ4G/PCLOg+OmKLln5rJyHQf/u3OIb3lIwgFVIX20MAc8IoTArOmkeNpXMqFhPLI4siP9sT25K13GEy1G6fajAI3pFVGKUpHucZUxZ0mU8yfIAxmZjbAbBE7Mb0xUNQJeU4IaiG2q2wO7qWSTtnG5Ej2ZpCyMBORAFnV2n5VHup4qHncntn+tNPhKZyNWtbwBOWcIESxu30iUK6yLsExoqXQuP2zfrNJcxeIrLzBvnFgDRNa7B7crvk8hmu+gYzbGHDye8ug6pdG/PNJO98uj7dpxl/3mDyJOffevlTSMxaJA0z2HzHO5yUg1quPKoLHff+f06Z9ZqAkDWZ4JXynu93QdSsvRJ+zsqIrd8C6IADpMGRau6u6nEEJdl6b1pCTkBTOd9EgpmeAis5tetM7i+aKMsPuS/dOhy3JmmRUV2DxK+K/pASn8u6dFRVAKCtrqqjHCip+b/Y0NgKhxagdcG0vXpdZ/EOZW2RK8BeVmeZ7h9wR6eoXWvT1X3Zjqzf117KN7AGo4BdOulVzvEXr3vRw3BheL22/Wbb/EDa8ZuEpg8koAQ5o1/4xS17O+BSMHkF7X8L5Bx26d5zfsB2/VWiik73UqGFtz1m2x8BW1TZxnPOeFx75spPYDXaQf4hen7fbpXBh+Au3u7mgJMEeiI4RnjugvxpAtdfjS6IHEI+CNAYC1WHRQ2iReIROCRnO5N8wsQE4FrMoAuUBRqO7dnB5PEVrkXSEMTzhwdWO1OVJyLauGB/WvTUbLRGYjBOBpPm2goY1qqheeFl9GZDzc6aR8JHdwy+C5uaSH5kgLdCKH6IyQyZVKpX9ckAgRHwW6XN/LI1hMPkspvg0RdZz+X0edhOiT7G0X51idxos9HUwAE0BDXScniR4sk9Ws9sv3ka0d4MhP+zGGBSrjKsz3WfXG3nW7jSVW56HjrvvBZniPiyl1v370Athm6N33DY3dO3vUs4ordMQMBPSlDguPhdZLoNuAKB5BkUD5IvrzMQ0hz7AZzmLs/No4mTuLj0QkZRGjxQ57lA/lTuWaGum1dWowde0/8T+AbCC7kI4HUHrqbJJLiMpb90o6agqgyK X-OriginatorOrg: vmware.com X-MS-Exchange-CrossTenant-Network-Message-Id: ffb13d27-3ef1-46b9-b132-08db627ec141 X-MS-Exchange-CrossTenant-AuthSource: PH0PR05MB8703.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2023 09:01:15.2284 (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: vSaCirSIiqjd5eMB5T+b+dkaluRY2BMpjRFRQUAIGemE8LPMzC3rPu4rEQZFJsJJNZebdRcqiwmOOId1bGEGSQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR05MB8617 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 285b4770e..523cfb645 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 a4f8e7c53..b9f8c3f8b 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