From patchwork Wed Aug 29 12:17:08 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: 10580257 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 56591174A for ; Wed, 29 Aug 2018 12:43:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45CD5288C4 for ; Wed, 29 Aug 2018 12:43:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39E4B29C49; Wed, 29 Aug 2018 12:43:55 +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 A8966288C4 for ; Wed, 29 Aug 2018 12:43:54 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 2937FDC3; Wed, 29 Aug 2018 12:36:55 +0000 (UTC) X-Original-To: ltsi-dev@lists.linuxfoundation.org Delivered-To: ltsi-dev@mail.linuxfoundation.org Received: from smtp2.linuxfoundation.org (smtp2.linux-foundation.org [172.17.192.36]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 93B49DB9 for ; Wed, 29 Aug 2018 12:36:50 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx06.melco.co.jp (mx06.melco.co.jp [192.218.140.146]) by smtp2.linuxfoundation.org (Postfix) with ESMTPS id CEDD91DDC7 for ; Wed, 29 Aug 2018 12:36:40 +0000 (UTC) Received: from mr06.melco.co.jp (mr06 [133.141.98.164]) by mx06.melco.co.jp (Postfix) with ESMTP id 729163A2F02 for ; Wed, 29 Aug 2018 21:17:30 +0900 (JST) Received: from mr06.melco.co.jp (unknown [127.0.0.1]) by mr06.imss (Postfix) with ESMTP id 420l4V2tDqzRk5W for ; Wed, 29 Aug 2018 21:17:30 +0900 (JST) Received: from mf04_second.melco.co.jp (unknown [192.168.20.184]) by mr06.melco.co.jp (Postfix) with ESMTP id 420l4V2ZZFzRkFm for ; Wed, 29 Aug 2018 21:17:30 +0900 (JST) Received: from mf04.melco.co.jp (unknown [133.141.98.184]) by mf04_second.melco.co.jp (Postfix) with ESMTP id 420l4V2wTczRkCw for ; Wed, 29 Aug 2018 21:17:30 +0900 (JST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (unknown [23.103.139.152]) by mf04.melco.co.jp (Postfix) with ESMTP id 420l4V2b1CzRkCn for ; Wed, 29 Aug 2018 21:17:30 +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=ucgwlgiMgwxSHRpxP+ANaZLn+XJV0HOIcWy8tnAe3Hc=; b=J3EX78pTgVt8mDF/hFK1nxCO7uNHTgoJTmlO3+oZZ/hDjKXwh99kugmvXdApvuVLjoZ+00l4o4RKXdOPiOt/n5mhaxfEFpkX+K67yL4xqkf1c/+c7VgzcRX2gT5aDR7K/d6qMVfKUvhPr+udnpbIgGlg5wXC5VjM+KACwXFLzEY= Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com (52.133.160.145) by TY1PR01MB1708.jpnprd01.prod.outlook.com (52.133.160.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1080.15; Wed, 29 Aug 2018 12:17:29 +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:17:29 +0000 From: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" To: "ltsi-dev@lists.linuxfoundation.org" Thread-Topic: [LTSI-dev] [PATCH 24/54] tracing: Generalize per-element hist trigger data Thread-Index: AdQ/i7rVJoZQHV5jRKCEUoBTjTJ5Pw== Date: Wed, 29 Aug 2018 12:17:08 +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; TY1PR01MB1708; 6:p/wmaplXailQNVAu7/OG95uTEYK8CXKn1xoXN0mdFj9DmVKwMWtl8hLRgDZz35rt3X/Hx7NS5zXJTUJdhknp7aR3sU/muub7ckeQw6jTEkvQyrE5QqiUxUu7d9oEf/3WXNl39xkp/vGRR7NPTuasqEmI1vZGu1fmmZaMRrrGNOJQGgB2WBv4aHcnV84iQIgfQw8XX4Qo6qenhsUWBdG8M3L4gJUEGk6sL2xNQM6A2uoujYgwrSn4LKjU0BquwSkFtihce7feJ102wFbvuUqEOj1devFznvWgHwEFuRb87FXWIycI+1fu5F6AARpKy/U+b4krPzDkmMMVinwUAeWZ5lHFEZJGnw8fL3/YEPFcPeSbSLIKTzoqQuyrOock0QZzF89ZFAzmDIvmbiUZm1d2G1Ux2IkyewYwTe/6yU270LTUtBDXU8KWYj/0idmoGup8XQH+kQx4HmSUBWKixWPmRA==; 5:BC0alHNFwn19rKLfkYaex8pSVVaU1ubptlqfK5jGeBzlRoo7WeomFE6j7k+6G6V5clpy1Y/tcYM6dVAIUmIDZ80qkkRDj4UoXa1gpRDqyI5QJ3u3WMPGbDsxYKe36R0zAbB+1OiTg1AR6RdPlywR+7nrsygNxzeSdvI7lopWIQ0=; 7:+ggGdPyIeD/lquM8sFdeVRhtp6BTB70HN29Uw4JX/AL4rz5lZi6Sl5s+gf1KZ98QfAQ1bC8apvuS/5WsOqxNE3r2jBTQfLEjs0lOY94VVp/zMgfQlZLmf/I5uWepauWbYZYrjEeOJKNeN/VpUFmSsEGQGtFWBrunOydNSn3qBXsLXHJx1LgroEDpkQW1DAYTIvvZEM4k+6cC0k4ZCu9jKbQciaA0SW7VwZ83Z8Dpg97You+D/GyWoPP0qtch3umH x-ms-office365-filtering-correlation-id: 16894771-a566-4a0a-8fb8-08d60da963f8 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:TY1PR01MB1708; x-ms-traffictypediagnostic: TY1PR01MB1708: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(42068640409301)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(201708071742011)(7699016); SRVR:TY1PR01MB1708; BCL:0; PCL:0; RULEID:; SRVR:TY1PR01MB1708; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(366004)(396003)(39860400002)(346002)(376002)(189003)(199004)(966005)(25786009)(74482002)(81156014)(8676002)(106356001)(5660300001)(105586002)(6506007)(14454004)(81166006)(33656002)(26005)(7736002)(74316002)(186003)(72206003)(305945005)(66066001)(68736007)(97736004)(478600001)(476003)(102836004)(2906002)(8936002)(6666003)(6916009)(486006)(6116002)(1857600001)(316002)(7696005)(2900100001)(5640700003)(3846002)(55016002)(99286004)(53936002)(86362001)(256004)(6436002)(6306002)(2501003)(5250100002)(9686003)(2351001); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR01MB1708; H:TY1PR01MB1692.jpnprd01.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:0; received-spf: None (protection.outlook.com: aj.MitsubishiElectric.co.jp does not designate permitted sender hosts) x-microsoft-antispam-message-info: kcT+VMcQt9k+0+Zox2LbMSlem4sLcOV9CVyTWdrRCvfx4ud0Klco9Ux97caoqFLEUp604juX5zbhTo0XPgD8qUR/AHIas3A5a9WqlQR7Kr3P6w3XmYMe7booxaNBCqqF3rHgeLRCbyhXezT/v3N5Y9OOhqN8Zkgg3ZtxuuIzBLgXdj4RgYRWD2TDz1UIxW3a9HhJIvVUKJn9HXpQkf/KsXBLInoSrUUoSE/gkWhZ+Gmsj8my59eh8UHk5zfCxAvGtxcd+jLvAsUH2KTnEFRpgiXJvp2tdLQptCy0j+7VHONslSvBIvzdcrAEGYtQioXcimvBY9Qzw7ZQZRXVVtYqciglfPJN0hOJ7zt89MCIBpE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aj.MitsubishiElectric.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 16894771-a566-4a0a-8fb8-08d60da963f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 12:17:22.6367 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c5a75b62-4bff-4c96-a720-6621ce9978e5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR01MB1708 Subject: [LTSI-dev] [PATCH 24/54] tracing: Generalize per-element hist trigger data 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 Up until now, hist triggers only needed per-element support for saving 'comm' data, which was saved directly as a private data pointer. In anticipation of the need to save other data besides 'comm', add a new hist_elt_data struct for the purpose, and switch the current 'comm'-related code over to that. Link: http://lkml.kernel.org/r/4502c338c965ddf5fc19fb1ec4764391e001ed4b.1516069914.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi Signed-off-by: Steven Rostedt (VMware) (cherry picked from commit af6a29bcaf8ff260222a953536c13c167d5c4649) Signed-off-by: Hirotaka MOTAI --- kernel/trace/trace_events_hist.c | 76 ++++++++++++++++++-------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 4c3c7d78..f072ed31 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -284,16 +284,20 @@ static struct hist_field *find_var(struct hist_trigger_data *hist_data, if (hist_field) return hist_field; } } return NULL; } +struct hist_elt_data { + char *comm; +}; + static const char *hist_field_name(struct hist_field *field, unsigned int level) { const char *field_name = ""; if (level > 1) return field_name; @@ -498,55 +502,71 @@ static inline void save_comm(char *comm, struct task_struct *task) if (WARN_ON_ONCE(task->pid < 0)) { strcpy(comm, ""); return; } memcpy(comm, task->comm, TASK_COMM_LEN); } -static void hist_trigger_elt_comm_free(struct tracing_map_elt *elt) +static void hist_elt_data_free(struct hist_elt_data *elt_data) +{ + kfree(elt_data->comm); + kfree(elt_data); +} + +static void hist_trigger_elt_data_free(struct tracing_map_elt *elt) { - kfree((char *)elt->private_data); + struct hist_elt_data *elt_data = elt->private_data; + + hist_elt_data_free(elt_data); } -static int hist_trigger_elt_comm_alloc(struct tracing_map_elt *elt) +static int hist_trigger_elt_data_alloc(struct tracing_map_elt *elt) { struct hist_trigger_data *hist_data = elt->map->private_data; + unsigned int size = TASK_COMM_LEN; + struct hist_elt_data *elt_data; struct hist_field *key_field; unsigned int i; + elt_data = kzalloc(sizeof(*elt_data), GFP_KERNEL); + if (!elt_data) + return -ENOMEM; + for_each_hist_key_field(i, hist_data) { key_field = hist_data->fields[i]; if (key_field->flags & HIST_FIELD_FL_EXECNAME) { - unsigned int size = TASK_COMM_LEN + 1; - - elt->private_data = kzalloc(size, GFP_KERNEL); - if (!elt->private_data) + elt_data->comm = kzalloc(size, GFP_KERNEL); + if (!elt_data->comm) { + kfree(elt_data); return -ENOMEM; + } break; } } + elt->private_data = elt_data; + return 0; } -static void hist_trigger_elt_comm_init(struct tracing_map_elt *elt) +static void hist_trigger_elt_data_init(struct tracing_map_elt *elt) { - char *comm = elt->private_data; + struct hist_elt_data *elt_data = elt->private_data; - if (comm) - save_comm(comm, current); + if (elt_data->comm) + save_comm(elt_data->comm, current); } -static const struct tracing_map_ops hist_trigger_elt_comm_ops = { - .elt_alloc = hist_trigger_elt_comm_alloc, - .elt_free = hist_trigger_elt_comm_free, - .elt_init = hist_trigger_elt_comm_init, +static const struct tracing_map_ops hist_trigger_elt_data_ops = { + .elt_alloc = hist_trigger_elt_data_alloc, + .elt_free = hist_trigger_elt_data_free, + .elt_init = hist_trigger_elt_data_init, }; static const char *get_hist_field_flags(struct hist_field *hist_field) { const char *flags_str = NULL; if (hist_field->flags & HIST_FIELD_FL_HEX) flags_str = "hex"; @@ -1479,31 +1499,16 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data) hist_field->var.idx = idx; hist_field->var.hist_data = hist_data; } } return 0; } -static bool need_tracing_map_ops(struct hist_trigger_data *hist_data) -{ - struct hist_field *key_field; - unsigned int i; - - for_each_hist_key_field(i, hist_data) { - key_field = hist_data->fields[i]; - - if (key_field->flags & HIST_FIELD_FL_EXECNAME) - return true; - } - - return false; -} - static struct hist_trigger_data * create_hist_data(unsigned int map_bits, struct hist_trigger_attrs *attrs, struct trace_event_file *file, bool remove) { const struct tracing_map_ops *map_ops = NULL; struct hist_trigger_data *hist_data; @@ -1519,18 +1524,17 @@ create_hist_data(unsigned int map_bits, ret = create_hist_fields(hist_data, file); if (ret) goto free; ret = create_sort_keys(hist_data); if (ret) goto free; - if (need_tracing_map_ops(hist_data)) - map_ops = &hist_trigger_elt_comm_ops; + map_ops = &hist_trigger_elt_data_ops; hist_data->map = tracing_map_create(map_bits, hist_data->key_size, map_ops, hist_data); if (IS_ERR(hist_data->map)) { ret = PTR_ERR(hist_data->map); hist_data->map = NULL; goto free; } @@ -1708,17 +1712,23 @@ hist_trigger_entry_print(struct seq_file *m, seq_printf(m, "%s: [%llx] %-45s", field_name, uval, str); } else if (key_field->flags & HIST_FIELD_FL_SYM_OFFSET) { uval = *(u64 *)(key + key_field->offset); sprint_symbol(str, uval); seq_printf(m, "%s: [%llx] %-55s", field_name, uval, str); } else if (key_field->flags & HIST_FIELD_FL_EXECNAME) { - char *comm = elt->private_data; + struct hist_elt_data *elt_data = elt->private_data; + char *comm; + + if (WARN_ON_ONCE(!elt_data)) + return; + + comm = elt_data->comm; uval = *(u64 *)(key + key_field->offset); seq_printf(m, "%s: %-16s[%10llu]", field_name, comm, uval); } else if (key_field->flags & HIST_FIELD_FL_SYSCALL) { const char *syscall_name; uval = *(u64 *)(key + key_field->offset);