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: 10580215 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 094FB175A for ; Wed, 29 Aug 2018 12:41:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED15B2B010 for ; Wed, 29 Aug 2018 12:41:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E05A92B014; Wed, 29 Aug 2018 12:41:50 +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 6B3412B010 for ; Wed, 29 Aug 2018 12:41:50 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 528AFD21; Wed, 29 Aug 2018 12:36:49 +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 4E0B5D5A for ; Wed, 29 Aug 2018 12:36:42 +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 smtp1.linuxfoundation.org (Postfix) with ESMTPS id C83954FA for ; Wed, 29 Aug 2018 12:36:39 +0000 (UTC) Received: from mr06.melco.co.jp (mr06 [133.141.98.164]) by mx06.melco.co.jp (Postfix) with ESMTP id 098C13A2F78 for ; Wed, 29 Aug 2018 21:17:31 +0900 (JST) Received: from mr06.melco.co.jp (unknown [127.0.0.1]) by mr06.imss (Postfix) with ESMTP id 420l4V6x2bzRkFm 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 420l4V6dFdzRk5W 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 420l4V6z6WzRkCw for ; Wed, 29 Aug 2018 21:17:30 +0900 (JST) Received: from JPN01-OS2-obe.outbound.protection.outlook.com (unknown [23.103.139.143]) by mf04.melco.co.jp (Postfix) with ESMTP id 420l4V6XjjzRkCn 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=HvsfAWPaJQXLZBBo06/AgvA9FhnKXB6a4MRjT1+pluQ=; b=kgrscL1gFlIZPBnXsVHmPDwuzGbsno557HpgqZUN4kTmMQYIscClehZqO39Mc7fm+guACC0MFPoQWIIQhwuVNkJldSIOLPl+I5w0U5MH4rtHcmbCWUy11Qg3cCTAwY56PfTSU3ed7+PM3+XQT8kIiEzJXfYopCroFWxsDZ0UoZw= 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:30 +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:30 +0000 From: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" To: "ltsi-dev@lists.linuxfoundation.org" Thread-Topic: [LTSI-dev] [PATCH 26/54] tracing: Add hist_field 'type' field Thread-Index: AdQ/i9EU/aO7Fj4nQmWf/rxOvkcBWg== 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:xnZjgZnnRWD7pNtfuYLwHFHPIGgYpQ4W9xduu16Dix3IubwgmKg+KTr6yeIEqItA646opS71qgALiDyooWTJ3imzr4lLHJpH5j8YkpDU5Nl7hVMExBL/SX7osWzDX0ALCBVdJaa9JywrshzyWYG4AazEuoPkiqVuhAtOSfnNctTEKUomlsAnImPazGnrG7+1cgco/rSHueWr+C2+eFjS0yvTHf9PgI21KmTfwfs33HyZrWNCGMSwQFDlaXgTVRGVmL8AX/5hHG03vgc+yxppnaalIdCdeaqO8iOY1qL7BkivK14hziP05UlROPmUVxW8MJHTG8kOtY4AXEoib1LTOjQGO0EYtSD75vDw4VxpPbUpAlcnT4NZE/mz6zYwWhi6dHQXnO4EGCBXWEG/lM6i7Y+iO+NsJrw0dlrMmcqmdijK67Jv8q8X+n0QZJSU5KJ7W0qcxe9dr+ttrUJIy7sYAQ==; 5:pzMxc+YpGnem45aYCgPDOhiiBwf1+LPexwbLfolq2ClvXxa4eH61ryAMJGzUWAzxoNX+GfSfH79K3o/Qw2aKq2QpjRgsRda7LUCD9tU4wj8g2ME6T1C0RPba+qSI8q8LSA6Tphx3Ef6oWdUhII5AtLTennBWtN3OU8klB1Zz2kg=; 7:4x5vqtHbqslSfwe0FlsdHM5YJGpry61LgJa3LULEhH2PgpI+4KC9M+X+60D6SpH53TPCRd821i0a5aVSXVWr69MFZtDXzly5mfnq80Z54TIUG+FjBj7vWwQtGvkkVL2AcLrB6+9Du5P5wdh1rY80ZJULJ0xCbX2sKM+tAdYsmydgLZoPI19BHI9cJi15+IRnnQpv/nQdG6oQ6+fkk516GEVs4kWHkUKRfOziIxIY58YDJcdN4A3zPEJsTDdXfGNz x-ms-office365-filtering-correlation-id: 8455641d-4655-4fb7-a82d-08d60da96452 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)(575784001)(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: FOyGi3wPziSoNwG4Zzz/WsiRUswsXZuiiMkd7wFXJbg1OyZjUyEp1wzG9JYAZFu3oUGGM2zQABdyGWW9HaEnqtqo0YnY0HYgx1xFe2rYSNwjOE1fb2Do228Jt08VRWKpotRaqBZXMLo4Idkk+/mOZSgoRswSS8fly2N9HNtSSbHMbw4tV4EVCwCq/k4yoYcos0IiuwXh3m2+MurrsQ+azdGlI8X/104DggkEu5JecS1fVY+PBi0B45UVQ4soqE9CXajCoEyPFAiLZISTjwqSf/yFy6a4zyatlkQ3qfRm8NTo97gA5MyGgLSRMlmKoIRwv4C4N3+R5P/ji3N3onUci9E7wR23fQ1oRTCzMYjloFE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aj.MitsubishiElectric.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: 8455641d-4655-4fb7-a82d-08d60da96452 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 12:17:22.6377 (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 26/54] tracing: Add hist_field 'type' field 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 Future support for synthetic events requires hist_field 'type' information, so add a field for that. Also, make other hist_field attribute usage consistent (size, is_signed, etc). Link: http://lkml.kernel.org/r/3fd12a2e86316b05151ba0d7c68268e780af2c9d.1516069914.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi Signed-off-by: Steven Rostedt (VMware) (cherry picked from commit 19a9facd0fe33a3e376923383958b2c86cbd3994) Signed-off-by: Hirotaka MOTAI --- kernel/trace/trace_events_hist.c | 33 ++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 7a54ab50..e30bd86b 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -49,16 +49,17 @@ struct hist_var { struct hist_field { struct ftrace_event_field *field; unsigned long flags; hist_field_fn_t fn; unsigned int size; unsigned int offset; unsigned int is_signed; + const char *type; struct hist_field *operands[HIST_FIELD_OPERANDS_MAX]; struct hist_trigger_data *hist_data; struct hist_var var; enum field_op_id operator; char *name; }; static u64 hist_field_none(struct hist_field *field, @@ -712,16 +713,17 @@ static void destroy_hist_field(struct hist_field *hist_field, if (!hist_field) return; for (i = 0; i < HIST_FIELD_OPERANDS_MAX; i++) destroy_hist_field(hist_field->operands[i], level + 1); kfree(hist_field->var.name); kfree(hist_field->name); + kfree(hist_field->type); kfree(hist_field); } static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, struct ftrace_event_field *field, unsigned long flags, char *var_name) @@ -737,51 +739,72 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, hist_field->hist_data = hist_data; if (flags & HIST_FIELD_FL_EXPR) goto out; /* caller will populate */ if (flags & HIST_FIELD_FL_HITCOUNT) { hist_field->fn = hist_field_counter; + hist_field->size = sizeof(u64); + hist_field->type = kstrdup("u64", GFP_KERNEL); + if (!hist_field->type) + goto free; goto out; } if (flags & HIST_FIELD_FL_STACKTRACE) { hist_field->fn = hist_field_none; goto out; } if (flags & HIST_FIELD_FL_LOG2) { unsigned long fl = flags & ~HIST_FIELD_FL_LOG2; hist_field->fn = hist_field_log2; hist_field->operands[0] = create_hist_field(hist_data, field, fl, NULL); hist_field->size = hist_field->operands[0]->size; + hist_field->type = kstrdup(hist_field->operands[0]->type, GFP_KERNEL); + if (!hist_field->type) + goto free; goto out; } if (flags & HIST_FIELD_FL_TIMESTAMP) { hist_field->fn = hist_field_timestamp; hist_field->size = sizeof(u64); + hist_field->type = kstrdup("u64", GFP_KERNEL); + if (!hist_field->type) + goto free; goto out; } if (WARN_ON_ONCE(!field)) goto out; if (is_string_field(field)) { flags |= HIST_FIELD_FL_STRING; + hist_field->size = MAX_FILTER_STR_VAL; + hist_field->type = kstrdup(field->type, GFP_KERNEL); + if (!hist_field->type) + goto free; + if (field->filter_type == FILTER_STATIC_STRING) hist_field->fn = hist_field_string; else if (field->filter_type == FILTER_DYN_STRING) hist_field->fn = hist_field_dynstring; else hist_field->fn = hist_field_pstring; } else { + hist_field->size = field->size; + hist_field->is_signed = field->is_signed; + hist_field->type = kstrdup(field->type, GFP_KERNEL); + if (!hist_field->type) + goto free; + hist_field->fn = select_value_fn(field->size, field->is_signed); if (!hist_field->fn) { destroy_hist_field(hist_field, 0); return NULL; } } out: @@ -944,16 +967,21 @@ static struct hist_field *parse_unary(struct hist_trigger_data *hist_data, } expr->flags |= operand1->flags & (HIST_FIELD_FL_TIMESTAMP | HIST_FIELD_FL_TIMESTAMP_USECS); expr->fn = hist_field_unary_minus; expr->operands[0] = operand1; expr->operator = FIELD_OP_UNARY_MINUS; expr->name = expr_str(expr, 0); + expr->type = kstrdup(operand1->type, GFP_KERNEL); + if (!expr->type) { + ret = -ENOMEM; + goto free; + } return expr; free: destroy_hist_field(expr, 0); return ERR_PTR(ret); } static int check_expr_operands(struct hist_field *operand1, @@ -1037,16 +1065,21 @@ static struct hist_field *parse_expr(struct hist_trigger_data *hist_data, ret = -ENOMEM; goto free; } expr->operands[0] = operand1; expr->operands[1] = operand2; expr->operator = field_op; expr->name = expr_str(expr, 0); + expr->type = kstrdup(operand1->type, GFP_KERNEL); + if (!expr->type) { + ret = -ENOMEM; + goto free; + } switch (field_op) { case FIELD_OP_MINUS: expr->fn = hist_field_minus; break; case FIELD_OP_PLUS: expr->fn = hist_field_plus; break;