From patchwork Wed Aug 29 12:17:10 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: 10580255 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 408AD174A for ; Wed, 29 Aug 2018 12:43:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FDC3288C4 for ; Wed, 29 Aug 2018 12:43:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2400629C49; Wed, 29 Aug 2018 12:43:46 +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 8FA11288C4 for ; Wed, 29 Aug 2018 12:43:45 +0000 (UTC) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id D31FED59; Wed, 29 Aug 2018 12:36:54 +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 6EBB4DB6 for ; Wed, 29 Aug 2018 12:36:50 +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 54D811DD12 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 CAB553A32B2 for ; Wed, 29 Aug 2018 21:18:03 +0900 (JST) Received: from mr04.melco.co.jp (unknown [127.0.0.1]) by mr04.imss (Postfix) with ESMTP id 420l575pWWzRk8j for ; Wed, 29 Aug 2018 21:18:03 +0900 (JST) Received: from mf04_second.melco.co.jp (unknown [192.168.20.184]) by mr04.melco.co.jp (Postfix) with ESMTP id 420l575VrMzRjwX for ; Wed, 29 Aug 2018 21:18:03 +0900 (JST) Received: from mf04.melco.co.jp (unknown [133.141.98.184]) by mf04_second.melco.co.jp (Postfix) with ESMTP id 420l575TmZzRkD2 for ; Wed, 29 Aug 2018 21:18:03 +0900 (JST) Received: from JPN01-TY1-obe.outbound.protection.outlook.com (unknown [23.103.139.183]) by mf04.melco.co.jp (Postfix) with ESMTP id 420l575KD6zRkCw for ; Wed, 29 Aug 2018 21:18:03 +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=DNBP82dcsJndd8d6cTFiRXFZpG5nR4IQmCsAYBhAwcg=; b=UFwOtmvxF0ll8wIhoPGeQlwiNZoRlZN+9n2BYLQ5gui0NZzNLxm9B+ajQL4dDfA7gYTVn/J8zCRcS7nBD38kQQx5Xgs+ezSHfuwXjCyoPrcL6GW8G2TmetVFjV2NHt9XByqIVszv6b9druVvuozPd1lM8d707tbqFfA52yZtkcA= Received: from TY1PR01MB1692.jpnprd01.prod.outlook.com (52.133.160.145) by TY1PR01MB0762.jpnprd01.prod.outlook.com (10.167.158.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:18:03 +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:03 +0000 From: "Motai.Hirotaka@aj.MitsubishiElectric.co.jp" To: "ltsi-dev@lists.linuxfoundation.org" Thread-Topic: [LTSI-dev] [PATCH 35/54] tracing: Add cpu field for hist triggers Thread-Index: AdQ/jJJoRfe8OLy5RFi8Q50XJyvcwA== Date: Wed, 29 Aug 2018 12:17:10 +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; TY1PR01MB0762; 6:kV9DtHq+5u8AtwRn8lKgQPeyRrrOrl5O8zgrq6DoWsAqhaRYUZm7UC/YTYeS0FQnJf2KBKii1l5OeBmNI1IICYQOo+gj/XBfj/8GqxrxDmnWbvCS1KR3nIBfxnpknP5gLDKMwXNbreoDrpEhAdhH/p+TKQD3084bLk1ot0MqC7hE7pGJbEhNF9Ar34glnXKRilcqcHkbivh97uBMyYefFOWtA4vZQHE0ITqcllFnkKV4eVi+MJ/wCIK7cxsNgE58sYaGlyTnqRxpm6KWNrlbp8vP/fUv6A1yNo1J4I4Rzced9wgs9i8bmGXPwxd/H87E6UQPZimbkmeIOMCvQSvpOWLeIy19/b2XtjVvZtGN8mMk7WL8FN1VAn2DGtKbDef337hzz38XT01DJrQ1+uc0FkurK+F5FpTDmNSE96581f9ResD5+vnHb1SsyfsJY/7BCVOVsb02rWKgQ4TMQxduQQ==; 5:swYm1/7fuWk7wGN5iqyFrbi25pZJZoQk4Add71kwQ7mIZPkueHeuBtoRPAm3acesfe9bEyR+NHHG77W78Ly6Z4xCE2RN+sELnIqC00ph/jnagzIe8UzOUcBJHRYfd9vz9U7g4e5vlFEHlLHW6LG72DEqaVUUhDfGFhVo64tWIvM=; 7:zuDUjfuGWwKdjess19MbX7GGpp41cPF2I9HZ0V9pFCbng8aCVAUhBaUscbX84hy8LegnPB6DF/wgramVfA4d1FvkzmcnzzJBEp4SQTqSkjH9TlnnbnFzQcf000mvBoj+QCMfujvcIcjVTbelDdp4IjO17VRwoxf7BIhgRRgXE+gJfMQt2nYPhQfFU3VS7KOi/vRKIL3aks8YkR12EOQhVMRaYTFNk8u4bRkhiwSS68KnfJES47YAs5OSEkXeWJOq x-ms-office365-filtering-correlation-id: f3c9e38f-db43-4280-ef83-08d60da977de x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:TY1PR01MB0762; x-ms-traffictypediagnostic: TY1PR01MB0762: 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)(3231311)(944501410)(52105095)(93006095)(93001095)(3002001)(10201501046)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699016); SRVR:TY1PR01MB0762; BCL:0; PCL:0; RULEID:; SRVR:TY1PR01MB0762; x-forefront-prvs: 077929D941 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(396003)(346002)(376002)(136003)(366004)(199004)(189003)(7696005)(186003)(72206003)(6116002)(478600001)(3846002)(1857600001)(256004)(74482002)(5250100002)(5660300001)(14444005)(966005)(2501003)(99286004)(2900100001)(8936002)(53936002)(68736007)(33656002)(9686003)(2906002)(97736004)(6306002)(26005)(476003)(7736002)(305945005)(74316002)(6666003)(316002)(14454004)(486006)(55016002)(81166006)(5640700003)(66066001)(8676002)(86362001)(6436002)(2351001)(6506007)(106356001)(25786009)(6916009)(105586002)(102836004)(575784001)(81156014); DIR:OUT; SFP:1102; SCL:1; SRVR:TY1PR01MB0762; 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: zEpqX81e59jKQVbpzhDMF08V/8183N6pvbK6oQkxcLWdCDpD/GDrmFF5k1cociKs8Bivhe53qDwau037RRCSDeBdikLdc86jzFMvtWB7c2Zj5O0q0fMB2Bv68kSgqb1T8Er/DlRt4tE6OD3bWiaGnj8Rc0HlRMJkUFpP4JRhMOABFyHT4ZpEcifqdG5EAg+piKSArNS3iPpR0zYbkPqm+LRtm5OzGVuvAAxxRktrZxmw6i5Xf65rUbXjeW2zdF++lF1Bx/lbnDqTo9vUvOXK3tC6oX64RR70w0Qj8fhmv4k+o2FL1iloKS7tebjsLkkP1QL8mCgbYM5qPpdJEXMFnpFCHD5GrkZqDWALW8WeloU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: aj.MitsubishiElectric.co.jp X-MS-Exchange-CrossTenant-Network-Message-Id: f3c9e38f-db43-4280-ef83-08d60da977de X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Aug 2018 12:17:22.6427 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: c5a75b62-4bff-4c96-a720-6621ce9978e5 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY1PR01MB0762 Subject: [LTSI-dev] [PATCH 35/54] tracing: Add cpu field for hist triggers 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 A common key to use in a histogram is the cpuid - add a new cpu 'synthetic' field named 'cpu' for that purpose. Link: http://lkml.kernel.org/r/89537645bfc957e0d76e2cacf5f0ada88691a6cc.1516069914.git.tom.zanussi@linux.intel.com Signed-off-by: Tom Zanussi Signed-off-by: Steven Rostedt (VMware) (cherry picked from commit 8b7622bf94a44b3f912e6492bf500e86171300b8) Signed-off-by: Hirotaka MOTAI --- Documentation/trace/histogram.txt | 15 +++++++++++++++ kernel/trace/trace_events_hist.c | 28 +++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Documentation/trace/histogram.txt b/Documentation/trace/histogram.txt index 25c94730..be612ca7 100644 --- a/Documentation/trace/histogram.txt +++ b/Documentation/trace/histogram.txt @@ -167,16 +167,31 @@ The above sets up an initially paused hist trigger which is unpaused and starts aggregating events when a given program is executed, and which stops aggregating when the process exits and the hist trigger is paused again. The examples below provide a more concrete illustration of the concepts and typical usage patterns discussed above. + 'special' event fields + ------------------------ + + There are a number of 'special event fields' available for use as + keys or values in a hist trigger. These look like and behave as if + they were actual event fields, but aren't really part of the event's + field definition or format file. They are however available for any + event, and can be used anywhere an actual event field could be. + They are: + + common_timestamp u64 - timestamp (from ring buffer) associated + with the event, in nanoseconds. May be + modified by .usecs to have timestamps + interpreted as microseconds. + cpu int - the cpu on which the event occurred. 6.2 'hist' trigger examples --------------------------- The first set of examples creates aggregations using the kmalloc event. The fields that can be used for the hist trigger are listed in the kmalloc event's format file: diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 7e88daae..98be6ad8 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -222,16 +222,17 @@ enum hist_field_flags { HIST_FIELD_FL_SYSCALL = 1 << 7, HIST_FIELD_FL_STACKTRACE = 1 << 8, HIST_FIELD_FL_LOG2 = 1 << 9, HIST_FIELD_FL_TIMESTAMP = 1 << 10, HIST_FIELD_FL_TIMESTAMP_USECS = 1 << 11, HIST_FIELD_FL_VAR = 1 << 12, HIST_FIELD_FL_EXPR = 1 << 13, HIST_FIELD_FL_VAR_REF = 1 << 14, + HIST_FIELD_FL_CPU = 1 << 15, }; struct var_defs { unsigned int n_vars; char *name[TRACING_MAP_VARS_MAX]; char *expr[TRACING_MAP_VARS_MAX]; }; @@ -1159,16 +1160,26 @@ static u64 hist_field_timestamp(struct hist_field *hist_field, u64 ts = ring_buffer_event_time_stamp(rbe); if (hist_data->attrs->ts_in_usecs && trace_clock_in_ns(tr)) ts = ns2usecs(ts); return ts; } +static u64 hist_field_cpu(struct hist_field *hist_field, + struct tracing_map_elt *elt, + struct ring_buffer_event *rbe, + void *event) +{ + int cpu = smp_processor_id(); + + return cpu; +} + static struct hist_field * check_field_for_var_ref(struct hist_field *hist_field, struct hist_trigger_data *var_data, unsigned int var_idx) { struct hist_field *found = NULL; if (hist_field && hist_field->flags & HIST_FIELD_FL_VAR_REF) { @@ -1597,16 +1608,18 @@ static const char *hist_field_name(struct hist_field *field, return field_name; if (field->field) field_name = field->field->name; else if (field->flags & HIST_FIELD_FL_LOG2) field_name = hist_field_name(field->operands[0], ++level); else if (field->flags & HIST_FIELD_FL_TIMESTAMP) field_name = "common_timestamp"; + else if (field->flags & HIST_FIELD_FL_CPU) + field_name = "cpu"; else if (field->flags & HIST_FIELD_FL_EXPR || field->flags & HIST_FIELD_FL_VAR_REF) { if (field->system) { static char full_name[MAX_FILTER_STR_VAL]; strcat(full_name, field->system); strcat(full_name, "."); strcat(full_name, field->event_name); @@ -2104,16 +2117,25 @@ static struct hist_field *create_hist_field(struct hist_trigger_data *hist_data, 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 (flags & HIST_FIELD_FL_CPU) { + hist_field->fn = hist_field_cpu; + hist_field->size = sizeof(int); + hist_field->type = kstrdup("unsigned int", 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); @@ -2340,17 +2362,19 @@ parse_field(struct hist_trigger_data *hist_data, struct trace_event_file *file, } } if (strcmp(field_name, "common_timestamp") == 0) { *flags |= HIST_FIELD_FL_TIMESTAMP; hist_data->enable_timestamps = true; if (*flags & HIST_FIELD_FL_TIMESTAMP_USECS) hist_data->attrs->ts_in_usecs = true; - } else { + } else if (strcmp(field_name, "cpu") == 0) + *flags |= HIST_FIELD_FL_CPU; + else { field = trace_find_event_field(file->event_call, field_name); if (!field || !field->size) { field = ERR_PTR(-EINVAL); goto out; } } out: kfree(str); @@ -4614,16 +4638,18 @@ static void hist_field_print(struct seq_file *m, struct hist_field *hist_field) { const char *field_name = hist_field_name(hist_field, 0); if (hist_field->var.name) seq_printf(m, "%s=", hist_field->var.name); if (hist_field->flags & HIST_FIELD_FL_TIMESTAMP) seq_puts(m, "common_timestamp"); + else if (hist_field->flags & HIST_FIELD_FL_CPU) + seq_puts(m, "cpu"); else if (field_name) { if (hist_field->flags & HIST_FIELD_FL_VAR_REF) seq_putc(m, '$'); seq_printf(m, "%s", field_name); } if (hist_field->flags) { const char *flags_str = get_hist_field_flags(hist_field);