From patchwork Wed Aug 29 12:17:04 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: 10580239 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 58A88175A for ; Wed, 29 Aug 2018 12:43:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48BF528A44 for ; Wed, 29 Aug 2018 12:43:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C76028A78; Wed, 29 Aug 2018 12:43:12 +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 9DD1A28A44 for ; Wed, 29 Aug 2018 12:43:11 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 74432DA5; Wed, 29 Aug 2018 12:36:53 +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 8F230D8E for ; Wed, 29 Aug 2018 12:36:47 +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 smtp2.linuxfoundation.org (Postfix) with ESMTPS id BC1B51DD19 for ; Wed, 29 Aug 2018 12:36:41 +0000 (UTC) Received: from mr04.melco.co.jp (mr04 [133.141.98.166]) by mx04.melco.co.jp (Postfix) with ESMTP id 4158C3A2734 for ; Wed, 29 Aug 2018 21:17:24 +0900 (JST) Received: from mr04.melco.co.jp (unknown [127.0.0.1]) by mr04.imss (Postfix) with ESMTP id 420l4N1mVjzRkF8 for ; Wed, 29 Aug 2018 21:17:24 +0900 (JST) Received: from mf04_second.melco.co.jp (unknown [192.168.20.184]) by mr04.melco.co.jp (Postfix) with ESMTP id 420l4N1SjZzRjwX for ; Wed, 29 Aug 2018 21:17:24 +0900 (JST) Received: from mf04.melco.co.jp (unknown [133.141.98.184]) by mf04_second.melco.co.jp (Postfix) with ESMTP id 420l4N1RW6zRkD2 for ; Wed, 29 Aug 2018 21:17:24 +0900 (JST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (unknown [23.103.139.145]) by mf04.melco.co.jp (Postfix) with ESMTP id 420l4N0ssCzRkCw for ; Wed, 29 Aug 2018 21:17:24 +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=rendhbFOHqm2MT9cQSAL7XLngIud0QMhqaBX1Ntmao8=; b=JtIZ0fIurWzGpBp7CZGvnfYGZ013Q7liPwYnXgmRtPq/o8iztA1ja9vFxI+fAPof+LFW2eflUMoy8jwo/ARBEgMZpLhCl55QQqK77nAf/mbqr16N3+OHBamo03i9W5BOKvQaUhuh+2pfKKS4GMuB1x8n9VuSap02iZmptlwfL14= Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com (52.133.160.145) by TY1PR01MB1231.jpnprd01.prod.outlook.com (10.174.226.23) 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:17:23 +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:23 +0000 From: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" To: "ltsi-dev@lists.linuxfoundation.org" Thread-Topic: [LTSI-dev] [PATCH 03/54] tracing: Add hist_field_name() accessor Thread-Index: AdQ/iNtQ2d13TzHrQCuTPVYfwlRlEQ== Date: Wed, 29 Aug 2018 12:17:04 +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; TY1PR01MB1231; 6:SOYw3UOlBnqnjBqH+S5TFxWfnBshndp+XSpP11eEyXLw5IVhjRm4s3bj3GcanusGXhVBN3MG/MTDpVnWY+YHSsw83sXIDpDwmTzyUucJ9RJfWJM37ck0w3vkzSwZ831n0pm/6f8kx3dPUmpFNLmysfc+l0JN4Z3Fja5TvTrfcPLiYiKV2MHlXJJtDk4h91KIVvJp3+QOmaB4Mic5icMs3W49f2hNiNqXzGvKMsK6FrvoqFs0IlA37qEC4GZU6i1AuNS2fKKAXQStRBHjhPm9TKy5xCG7S7vhm1UON1OEyqYQTX22B7zjS1mQ8dZJ4QtP4IQy4LJjxGnJS/SqX3fLdiBmYaEJGyOcQbrGWXFGpQDiEgXUZ5NrGEjY256TmPrbjS040P2yp2lz1OT7O/IyfW85Xl3NDyQXDSadOCCHklt52EnSqjj6WJR7SUHS/3iygDdtfEU3u1dtU4AwmKtB3g==; 5:HmOSMrhc3q3hvCkroCxW306zxL4Q9pBBklTYEN9rDIJhKgUIxSyozDIeeV2K/PbGvgJyiKshqEKeyXXxxyvnBOFsquaq12NUVz/WkEaK7QYZIwaoS7bXY7xlr8F0eR8JFciuK5dmW8zp2FNcjiGCD+A3PhlG1tHRvTaODBQGWJU=; 7:aj0R0+urD+qEOBCTL5bxBXSNhIccvGRMXTPxaUn+8wJ/qYOXaEv/VlVP9unXX+dq4lsw6/aJ6Z216MwDWM5vHqs0N0A98PtYEXyzc+fFsQsoUzOtCJ64xkPH/2WQAvSowpvNokM/zcVoANGFpXGh+xCDobwDERxmRerLaMhs0UcY6i9egLAcxK/+TE/jLjWhYB19WUpt+nS1aKCoSzF4JvptUVqfHRBWUYl4MkJ0U3iXqp73LLG8gCYVRg0OGFkp x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: e5b5904c-5d00-4b06-1fdc-08d60da96042 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:TY1PR01MB1231; x-ms-traffictypediagnostic: TY1PR01MB1231: 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)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(201708071742011)(7699016); SRVR:TY1PR01MB1231; BCL:0; PCL:0; RULEID:; SRVR:TY1PR01MB1231; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(396003)(366004)(376002)(346002)(39860400002)(189003)(199004)(478600001)(105586002)(2906002)(14454004)(33656002)(66066001)(966005)(72206003)(6116002)(3846002)(97736004)(2900100001)(2501003)(5250100002)(74482002)(25786009)(7736002)(9686003)(5660300001)(6506007)(26005)(6666003)(6916009)(2351001)(81156014)(106356001)(86362001)(6436002)(6306002)(5640700003)(74316002)(8676002)(1857600001)(81166006)(102836004)(53936002)(7696005)(68736007)(55016002)(305945005)(256004)(14444005)(316002)(186003)(8936002)(486006)(99286004)(476003); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR01MB1231; 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: H58tGLh4wxwNmWXBrAWZNcXGlh7SssN2Zhnx6E/tHyxc2UFlDqgFbYvR84knURFNqHSXtcFke85DzUBLbFd6s/H8MLOZHMc7gx3JDpYSWmA3ALmiJf//F+vCDhQwONA+7HJtWy//uKdSYsJ6WOU09SO9i5b/pvu/hPhA0WbIWJmYf7IEFegTyUejkXJKdEcglW5Uqs31TxlZ+bHos1nhkJcNMdRRJlZ+rpv0QsHwJj2UQCJPYz5l0C5gzCxzL+LmgzsM2rhOG9pD/4xCdqychFnv1uSDhbGSqVoaBs0CbFe+0WfjMZ79bRiM+UM2faB7T5pvYlpAE7utRWafNoOH9yDXYGiVhwt9XM2ByP/45IA= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aj.MitsubishiElectric.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: e5b5904c-5d00-4b06-1fdc-08d60da96042 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 12:17:22.6247 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c5a75b62-4bff-4c96-a720-6621ce9978e5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR01MB1231 Subject: [LTSI-dev] [PATCH 03/54] tracing: Add hist_field_name() accessor 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 In preparation for hist_fields that won't be strictly based on trace_event_fields, add a new hist_field_name() accessor to allow that flexibility and update associated users. Link: http://lkml.kernel.org/r/5b5a2d36dde067cbbe2434b10f06daac27b7dbd5.1506105045.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi Signed-off-by: Steven Rostedt (VMware) (cherry picked from commit 85013256cf01629f72a327674c5d007b4a4b40da) Signed-off-by: Hirotaka MOTAI --- kernel/trace/trace_events_hist.c | 67 +++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 0c7ec304..34edf5fd 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -141,16 +141,33 @@ struct hist_trigger_data { unsigned int key_size; struct tracing_map_sort_key sort_keys[TRACING_MAP_SORT_KEYS_MAX]; unsigned int n_sort_keys; struct trace_event_file *event_file; struct hist_trigger_attrs *attrs; struct tracing_map *map; }; +static const char *hist_field_name(struct hist_field *field, + unsigned int level) +{ + const char *field_name = ""; + + if (level > 1) + return field_name; + + if (field->field) + field_name = field->field->name; + + if (field_name == NULL) + field_name = ""; + + return field_name; +} + static hist_field_fn_t select_value_fn(int field_size, int field_is_signed) { hist_field_fn_t fn = NULL; switch (field_size) { case 8: if (field_is_signed) fn = hist_field_s64; @@ -648,34 +665,35 @@ static int is_descending(const char *str) return 0; return -EINVAL; } static int create_sort_keys(struct hist_trigger_data *hist_data) { char *fields_str = hist_data->attrs->sort_key_str; - struct ftrace_event_field *field = NULL; struct tracing_map_sort_key *sort_key; int descending, ret = 0; unsigned int i, j; hist_data->n_sort_keys = 1; /* we always have at least one, hitcount */ if (!fields_str) goto out; strsep(&fields_str, "="); if (!fields_str) { ret = -EINVAL; goto out; } for (i = 0; i < TRACING_MAP_SORT_KEYS_MAX; i++) { + struct hist_field *hist_field; char *field_str, *field_name; + const char *test_name; sort_key = &hist_data->sort_keys[i]; field_str = strsep(&fields_str, ","); if (!field_str) { if (i == 0) ret = -EINVAL; break; @@ -698,18 +716,20 @@ static int create_sort_keys(struct hist_trigger_data *hist_data) ret = descending; break; } sort_key->descending = descending; continue; } for (j = 1; j < hist_data->n_fields; j++) { - field = hist_data->fields[j]->field; - if (field && (strcmp(field_name, field->name) == 0)) { + hist_field = hist_data->fields[j]; + test_name = hist_field_name(hist_field, 0); + + if (strcmp(field_name, test_name) == 0) { sort_key->field_idx = j; descending = is_descending(field_str); if (descending < 0) { ret = descending; goto out; } sort_key->descending = descending; break; @@ -947,92 +967,93 @@ static void hist_trigger_stacktrace_print(struct seq_file *m, static void hist_trigger_entry_print(struct seq_file *m, struct hist_trigger_data *hist_data, void *key, struct tracing_map_elt *elt) { struct hist_field *key_field; char str[KSYM_SYMBOL_LEN]; bool multiline = false; + const char *field_name; unsigned int i; u64 uval; seq_puts(m, "{ "); for_each_hist_key_field(i, hist_data) { key_field = hist_data->fields[i]; if (i > hist_data->n_vals) seq_puts(m, ", "); + field_name = hist_field_name(key_field, 0); + if (key_field->flags & HIST_FIELD_FL_HEX) { uval = *(u64 *)(key + key_field->offset); - seq_printf(m, "%s: %llx", - key_field->field->name, uval); + seq_printf(m, "%s: %llx", field_name, uval); } else if (key_field->flags & HIST_FIELD_FL_SYM) { uval = *(u64 *)(key + key_field->offset); sprint_symbol_no_offset(str, uval); - seq_printf(m, "%s: [%llx] %-45s", - key_field->field->name, uval, str); + 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", - key_field->field->name, uval, str); + seq_printf(m, "%s: [%llx] %-55s", field_name, + uval, str); } else if (key_field->flags & HIST_FIELD_FL_EXECNAME) { char *comm = elt->private_data; uval = *(u64 *)(key + key_field->offset); - seq_printf(m, "%s: %-16s[%10llu]", - key_field->field->name, comm, uval); + 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); syscall_name = get_syscall_name(uval); if (!syscall_name) syscall_name = "unknown_syscall"; - seq_printf(m, "%s: %-30s[%3llu]", - key_field->field->name, syscall_name, uval); + seq_printf(m, "%s: %-30s[%3llu]", field_name, + syscall_name, uval); } else if (key_field->flags & HIST_FIELD_FL_STACKTRACE) { seq_puts(m, "stacktrace:\n"); hist_trigger_stacktrace_print(m, key + key_field->offset, HIST_STACKTRACE_DEPTH); multiline = true; } else if (key_field->flags & HIST_FIELD_FL_LOG2) { - seq_printf(m, "%s: ~ 2^%-2llu", key_field->field->name, + seq_printf(m, "%s: ~ 2^%-2llu", field_name, *(u64 *)(key + key_field->offset)); } else if (key_field->flags & HIST_FIELD_FL_STRING) { - seq_printf(m, "%s: %-50s", key_field->field->name, + seq_printf(m, "%s: %-50s", field_name, (char *)(key + key_field->offset)); } else { uval = *(u64 *)(key + key_field->offset); - seq_printf(m, "%s: %10llu", key_field->field->name, - uval); + seq_printf(m, "%s: %10llu", field_name, uval); } } if (!multiline) seq_puts(m, " "); seq_puts(m, "}"); seq_printf(m, " hitcount: %10llu", tracing_map_read_sum(elt, HITCOUNT_IDX)); for (i = 1; i < hist_data->n_vals; i++) { + field_name = hist_field_name(hist_data->fields[i], 0); + if (hist_data->fields[i]->flags & HIST_FIELD_FL_HEX) { - seq_printf(m, " %s: %10llx", - hist_data->fields[i]->field->name, + seq_printf(m, " %s: %10llx", field_name, tracing_map_read_sum(elt, i)); } else { - seq_printf(m, " %s: %10llu", - hist_data->fields[i]->field->name, + seq_printf(m, " %s: %10llu", field_name, tracing_map_read_sum(elt, i)); } } seq_puts(m, "\n"); } static int print_entries(struct seq_file *m, @@ -1135,17 +1156,19 @@ static const char *get_hist_field_flags(struct hist_field *hist_field) else if (hist_field->flags & HIST_FIELD_FL_LOG2) flags_str = "log2"; return flags_str; } static void hist_field_print(struct seq_file *m, struct hist_field *hist_field) { - seq_printf(m, "%s", hist_field->field->name); + const char *field_name = hist_field_name(hist_field, 0); + + seq_printf(m, "%s", field_name); if (hist_field->flags) { const char *flags_str = get_hist_field_flags(hist_field); if (flags_str) seq_printf(m, ".%s", flags_str); } }