From patchwork Wed Aug 29 12:17:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" X-Patchwork-Id: 10580165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB638174A for ; Wed, 29 Aug 2018 12:38:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9BC5E2AFBC for ; Wed, 29 Aug 2018 12:38:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8FDDB2AFC2; Wed, 29 Aug 2018 12:38:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 557C22AFBC for ; Wed, 29 Aug 2018 12:38:12 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 301D9CE7; Wed, 29 Aug 2018 12:36:40 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 69AACCDE for ; Wed, 29 Aug 2018 12:36:37 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx04.melco.co.jp (mx04.melco.co.jp [192.218.140.144]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 23AD377E for ; Wed, 29 Aug 2018 12:36:34 +0000 (UTC) Received: from mr04.melco.co.jp (mr04 [133.141.98.166]) by mx04.melco.co.jp (Postfix) with ESMTP id BD15C3A32BF for ; Wed, 29 Aug 2018 21:18:10 +0900 (JST) Received: from mr04.melco.co.jp (unknown [127.0.0.1]) by mr04.imss (Postfix) with ESMTP id 420l5G5QWxzRk8j for ; Wed, 29 Aug 2018 21:18:10 +0900 (JST) Received: from mf04_second.melco.co.jp (unknown [192.168.20.184]) by mr04.melco.co.jp (Postfix) with ESMTP id 420l5G56ngzRjwX for ; Wed, 29 Aug 2018 21:18:10 +0900 (JST) Received: from mf04.melco.co.jp (unknown [133.141.98.184]) by mf04_second.melco.co.jp (Postfix) with ESMTP id 420l5G51W4zRkCw for ; Wed, 29 Aug 2018 21:18:10 +0900 (JST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (unknown [23.103.139.147]) by mf04.melco.co.jp (Postfix) with ESMTP id 420l5G4ZRfzRkCn for ; Wed, 29 Aug 2018 21:18:10 +0900 (JST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mitsubishielectricgroup.onmicrosoft.com; s=selector1-mitsubishielectricgroup-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RFSf5E+7mI0rut5ln71yXKjGRk5yUioEq4plUJtGDgE=; b=Is+8F2zzx7fAiNIjNpuPf+Iwu3cpWmZlO3ksmI3/bKzigu9RsazYwChD9GudpYa5ycHdmHxXvlptamew5l4dSKWuY10Knp0tQU6orMpJFxpUW3qVXNJ/fP+0tb4yP0YO+K7YpmXFGtYCPwKMrWhbEjE3vz3I/UqRMPpwmP8k5oo= Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com (52.133.160.145) by TY1PR01MB1456.jpnprd01.prod.outlook.com (10.174.228.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.17; Wed, 29 Aug 2018 12:18:10 +0000 Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com ([fe80::d04e:e6f6:c782:22fa]) by TY1PR01MB1692.jpnprd01.prod.outlook.com ([fe80::d04e:e6f6:c782:22fa%2]) with mapi id 15.20.1080.015; Wed, 29 Aug 2018 12:18:10 +0000 From: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" To: "ltsi-dev@lists.linuxfoundation.org" Thread-Topic: [LTSI-dev] [PATCH 52/54] tracing: Add __find_event_file() to find event files without restrictions Thread-Index: AdQ/jTvZ+dNtze11Teizz3UyiiELRA== Date: Wed, 29 Aug 2018 12:17:13 +0000 Deferred-Delivery: Wed, 29 Aug 2018 12:15:00 +0000 Message-ID: Accept-Language: ja-JP, en-US Content-Language: ja-JP X-MS-Has-Attach: X-MS-TNEF-Correlator: x-melpop: 1 authentication-results: spf=none (sender IP is ) smtp.mailfrom=Motai.Hirotaka@aj.MitsubishiElectric.co.jp; x-originating-ip: [153.231.200.201] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; TY1PR01MB1456; 6:XOuIzicxs6Bd280nVXbSOFGEq+F6agWldMvOPlYGR/wLFeVjBwx7BWhjC8BajaU/rB8K/jwOKqUrC8LeGNne//KUdAvajC88JSiujmODDaQKe3q7rWwUILkr1mPeCr908+qKDWciMu/Jz2xK+yfCOgUe2YbwZUXYtGyKMlrmXNUpNVQK0eUCY5isFp7a6/LmI6BQOft+lmv0Q4y9SIhf9PyScHY4t/BKzKsIlZ8laZUP19+MX++wAPCkWMHHWweUyAC90R+REJopf64/fghdUKHEeBg5177zB/bjYu4/A6qvaNF9d2WYgG2hXznKy9iQGtNQZrWaLRmWWkUhOeTl0Grxy+9S0fIEG/z0ARaqn1leNPWRBpASVFICErn3axOmgZ1SlgIOg5Z+5pMbLxsonJJewARZLARy5CYVsg5jjNRjmRv6exs7IVTORqjdOYsH7T/XzJFGBBPNwkxyUdHnRA==; 5:0zmzSlEF3pbY4oLVYBIZnLXdmtjEtOCM6JIdev87jagG8khFoBDyKjhlXSQSim6BKb1fPn98Dxg6giMB2xZFR+Pp03sErMMwhOLZE6jEt0qwBW0WaXpFGvj1J75tXTpselRLQU2/Iz/CYvZ0jAwlUF/WyUotAzA0iPTBJqz3aKA=; 7:6eG46qKr5s3iU6dxsuB3aN5pEfp2O7iazanXhGLkpUsnRv3NnAwwX22j1th6WaZWqPVugehvEkumgL0fZK/P2CNFT1hd37YcZJfzvi8SycfsZmEIAZ89T10hUBW18topC/f2i+Hsx1U4xzdGlyezCw9FGyVMVMgSrO4olk1/PLuCiZbyIdEuQwn+2x8ABRFP1OAZ546NlnKgOY6xZAq0yJrTNYus3h5avEZj8pIfZTaHB34avymnM9oU1MiH8WtW x-ms-office365-filtering-correlation-id: 6dbbf4d8-f70c-4060-c0a7-08d60da97c05 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(5600074)(711020)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020); SRVR:TY1PR01MB1456; x-ms-traffictypediagnostic: TY1PR01MB1456: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(201708071742011)(7699016); SRVR:TY1PR01MB1456; BCL:0; PCL:0; RULEID:; SRVR:TY1PR01MB1456; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(366004)(136003)(346002)(376002)(39860400002)(199004)(189003)(26005)(6116002)(3846002)(6506007)(5660300001)(6916009)(74316002)(99286004)(486006)(8676002)(476003)(106356001)(1857600001)(2351001)(105586002)(33656002)(68736007)(81166006)(7696005)(2900100001)(9686003)(186003)(81156014)(97736004)(102836004)(66066001)(7736002)(5640700003)(6436002)(55016002)(53936002)(2501003)(478600001)(5250100002)(14454004)(72206003)(25786009)(316002)(86362001)(2906002)(8936002)(305945005)(74482002)(256004)(14444005)(37363001); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR01MB1456; H:TY1PR01MB1692.jpnprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:0; MX:1; received-spf: None (protection.outlook.com: aj.MitsubishiElectric.co.jp does not designate permitted sender hosts) x-microsoft-antispam-message-info: O9AwNzJkZ8jWOaxQUugBhNOtvXDT5bTgrlYM2G+DT0EXxf3t1G1opjwJp581bFWqNGLL2MVVB4GuI0ztbcel9chHj+qarf0QFcHME+9JFCQW5GNB/UsLtSBjBza+OpfIvHZHAnRIQvqia6I9xp5N2PMyclMoJ0yAznbh7xpcCYUJocd3GF21wZqWUSNVwewYLKrQ4Q5TjWfnyKpG7zdYYWXUr/3mitZlmoHf/YgSBbo+heaSUKql5b8uvcXX7sU5+J9PhjZfr1OMiko7j5hPCc2SW7R87+rg6u+dNeHBJV8TcjppjBsAaNBoRnGemYA0Pyta26+0i++NvsFtjMM1A+9mG1lZ9VL7bniz7S+9VrY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aj.MitsubishiElectric.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 6dbbf4d8-f70c-4060-c0a7-08d60da97c05 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 12:17:22.6517 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c5a75b62-4bff-4c96-a720-6621ce9978e5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR01MB1456 Subject: [LTSI-dev] [PATCH 52/54] tracing: Add __find_event_file() to find event files without restrictions X-BeenThere: ltsi-dev@lists.linuxfoundation.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: "A list to discuss patches, development, and other things related to the LTSI project" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ltsi-dev-bounces@lists.linuxfoundation.org Errors-To: ltsi-dev-bounces@lists.linuxfoundation.org X-Virus-Scanned: ClamAV using ClamSMTP By adding the function __find_event_file() that can search for files without restrictions, such as if the event associated with the file has a reg function, or if it has the "ignore" flag set, the files that are associated to ftrace internal events (like trace_marker and function events) can be found and used. find_event_file() still returns a "filtered" file, as most callers need a valid trace event file. One created by the trace_events.h macros and not one created for parsing ftrace specific events. Reviewed-by: Namhyung Kim Signed-off-by: Steven Rostedt (VMware) (cherry picked from commit 3c96529c0739959e2aa235d44e47f5c68c1e40de) Signed-off-by: Hirotaka MOTAI --- kernel/trace/trace.h | 3 +++ kernel/trace/trace_events.c | 22 +++++++++++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h index 0b8af849..267ffa24 100644 --- a/kernel/trace/trace.h +++ b/kernel/trace/trace.h @@ -1456,16 +1456,19 @@ struct ftrace_event_field * trace_find_event_field(struct trace_event_call *call, char *name); extern void trace_event_enable_cmd_record(bool enable); extern void trace_event_enable_tgid_record(bool enable); extern int event_trace_add_tracer(struct dentry *parent, struct trace_array *tr); extern int event_trace_del_tracer(struct trace_array *tr); +extern struct trace_event_file *__find_event_file(struct trace_array *tr, + const char *system, + const char *event); extern struct trace_event_file *find_event_file(struct trace_array *tr, const char *system, const char *event); static inline void *event_file_data(struct file *filp) { return ACCESS_ONCE(file_inode(filp)->i_private); } diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index d53268a4..4076f143 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2470,41 +2470,53 @@ __trace_add_event_dirs(struct trace_array *tr) list_for_each_entry(call, &ftrace_events, list) { ret = __trace_add_new_event(call, tr); if (ret < 0) pr_warn("Could not create directory for event %s\n", trace_event_name(call)); } } +/* Returns any file that matches the system and event */ struct trace_event_file * -find_event_file(struct trace_array *tr, const char *system, const char *event) +__find_event_file(struct trace_array *tr, const char *system, const char *event) { struct trace_event_file *file; struct trace_event_call *call; const char *name; list_for_each_entry(file, &tr->events, list) { call = file->event_call; name = trace_event_name(call); - if (!name || !call->class || !call->class->reg) - continue; - - if (call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) + if (!name || !call->class) continue; if (strcmp(event, name) == 0 && strcmp(system, call->class->system) == 0) return file; } return NULL; } +/* Returns valid trace event files that match system and event */ +struct trace_event_file * +find_event_file(struct trace_array *tr, const char *system, const char *event) +{ + struct trace_event_file *file; + + file = __find_event_file(tr, system, event); + if (!file || !file->event_call->class->reg || + file->event_call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) + return NULL; + + return file; +} + #ifdef CONFIG_DYNAMIC_FTRACE /* Avoid typos */ #define ENABLE_EVENT_STR "enable_event" #define DISABLE_EVENT_STR "disable_event" struct event_probe_data { struct trace_event_file *file;