Received: by 10.223.164.202 with SMTP id h10csp422675wrb; Fri, 10 Nov 2017 08:27:20 -0800 (PST) X-Google-Smtp-Source: AGs4zMZe+JuV5O1+yryPGncMNt1mRXMeQ5hRgSF6qEW2Lt7NIH3KBHuzvOEdXDqnQGqyT0O3eJBJ X-Received: by 10.98.141.65 with SMTP id z62mr946318pfd.186.1510331240360; Fri, 10 Nov 2017 08:27:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510331240; cv=none; d=google.com; s=arc-20160816; b=Pyj5K23l6xsJuDOwn4Mg/664GBdqu161FqYBiM5fKr24TAjoJ2swXfJQJLgqrGkAxx 5vWS1iZGnBtFIZnT1VsjTpPQjZobKBE5YRNB9bpnFPVD0LLd8Sfo9Qyv/SZmP1ahApCm byNEBC6vNjuPPDc85Z8S94Vq+aWCp++o13IboHLLmF1OVUa6tWaRXgW1NGrkp09zyNJ+ UqPUzg/kO5FjqtICnq59WHOZkNDZHOziDkg/vxdZyMNUAUA3vcJWUk1ll8U8lNZeinpy tJ8uVyI1Qzzm2fhSbk4fVIO+toZgDEPrXhQtvDn7LInPOOFra1vmDtDBQETtQSiin54P KaXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=gD7dyg+9BU/stnaF1ENbys/cnTNsrUJCjmsnhnkqa6I=; b=y8AmUsTK2jVOEQ6TL5cPdFw5Aehp1Og3LD0RybJAYdRzCLF2i2ONRvznGHDKnT+e5Y sJot06attXVTbTyGqhxTVaxi4ZORHKiMAA7YdFsbZDXCH99Jc7gY2ZS3BTVC2GcnhI8O G77IOxjD3QMBEkrHDvibLwuHJ7m5SH52l2H7BPeAwQwyDcL+/Wm73k6GbYoIacTAmKzz gvSczra8TwZecezIn3/W15uvNXd7RzEiCI8Mz0eJEgWM7xnN70IXzV3H4Jkt2Te3e2Py onozcLDBsltDVQu3s8JualovpcMWoNuQq4SiPmQGXATWQMiSxkwJfsm6GAyuP64fASeY q5eA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t19si8781191plo.127.2017.11.10.08.27.07; Fri, 10 Nov 2017 08:27:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753256AbdKJQ03 (ORCPT + 82 others); Fri, 10 Nov 2017 11:26:29 -0500 Received: from mga02.intel.com ([134.134.136.20]:26178 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752559AbdKJQ01 (ORCPT ); Fri, 10 Nov 2017 11:26:27 -0500 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Nov 2017 08:26:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,375,1505804400"; d="scan'208";a="127663" Received: from dkusalov-mobl4.amr.corp.intel.com (HELO [10.254.117.34]) ([10.254.117.34]) by fmsmga004.fm.intel.com with ESMTP; 10 Nov 2017 08:26:24 -0800 Message-ID: <1510331184.9878.5.camel@tzanussi-mobl.amr.corp.intel.com> Subject: Re: [PATCH v5 15/37] tracing: Add variable support to hist triggers From: Tom Zanussi To: Namhyung Kim Cc: rostedt@goodmis.org, tglx@linutronix.de, mhiramat@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel.opensrc@gmail.com, joelaf@google.com, mathieu.desnoyers@efficios.com, baohong.liu@intel.com, rajvi.jingar@intel.com, julia@ni.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, kernel-team@lge.com Date: Fri, 10 Nov 2017 10:26:24 -0600 In-Reply-To: <20171110072841.GB1544@danjae.aot.lge.com> References: <20171110072841.GB1544@danjae.aot.lge.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Namhyung, On Fri, 2017-11-10 at 16:28 +0900, Namhyung Kim wrote: > Hi Tom, > > On Thu, Nov 09, 2017 at 02:33:46PM -0600, Tom Zanussi wrote: > > Add support for saving the value of a current event's event field by > > assigning it to a variable that can be read by a subsequent event. > > > > The basic syntax for saving a variable is to simply prefix a unique > > variable name not corresponding to any keyword along with an '=' sign > > to any event field. > > > > Both keys and values can be saved and retrieved in this way: > > > > # echo 'hist:keys=next_pid:vals=$ts0:ts0=$common_timestamp ... > > # echo 'hist:timer_pid=common_pid:key=$timer_pid ...' > > > > If a variable isn't a key variable or prefixed with 'vals=', the > > associated event field will be saved in a variable but won't be summed > > as a value: > > > > # echo 'hist:keys=next_pid:ts1=$common_timestamp:... > > > > Multiple variables can be assigned at the same time: > > > > # echo 'hist:keys=pid:vals=$ts0,$b,field2:ts0=$common_timestamp,b=field1 ... > > > > Multiple (or single) variables can also be assigned at the same time > > using separate assignments: > > > > # echo 'hist:keys=pid:vals=$ts0:ts0=$common_timestamp:b=field1:c=field2 ... > > > > Variables set as above can be used by being referenced from another > > event, as described in a subsequent patch. > > > > Signed-off-by: Tom Zanussi > > Signed-off-by: Baohong Liu > > --- > > [SNIP] > > +static int parse_var_defs(struct hist_trigger_data *hist_data) > > +{ > > + char *s, *str, *var_name, *field_str; > > + unsigned int i, j, n_vars = 0; > > + int ret = 0; > > + > > + for (i = 0; i < hist_data->attrs->n_assignments; i++) { > > + str = hist_data->attrs->assignment_str[i]; > > + for (j = 0; j < TRACING_MAP_VARS_MAX; j++) { > > + field_str = strsep(&str, ","); > > + if (!field_str) > > + break; > > + > > + var_name = strsep(&field_str, "="); > > + if (!var_name || !field_str) { > > + ret = -EINVAL; > > + goto free; > > + } > > + > > + s = kstrdup(var_name, GFP_KERNEL); > > + if (!s) { > > + ret = -ENOMEM; > > + goto free; > > + } > > + hist_data->attrs->var_defs.name[n_vars] = s; > > + > > + s = kstrdup(field_str, GFP_KERNEL); > > + if (!s) { > > + kfree(hist_data->attrs->var_defs.name[n_vars]); > > + ret = -ENOMEM; > > + goto free; > > + } > > + hist_data->attrs->var_defs.expr[n_vars++] = s; > > + > > + hist_data->attrs->var_defs.n_vars = n_vars; > > + > > + if (n_vars == TRACING_MAP_VARS_MAX) > > + goto free; > > This will silently discard all variables. Why not returning an error? > Also I think it should be moved to the beginning of this block.. > Yes, thanks for pointing this out. This should fix it, will merge into the appropriate patches in the next version... Tom From: Tom Zanussi Date: Fri, 10 Nov 2017 09:01:21 -0600 Subject: [PATCH] tracing: Fix parse_var_defs max case Fix the VARS_MAX case and add an error condition for it. Merge into variable support and 'last err' patches. Signed-off-by: Tom Zanussi --- kernel/trace/trace_events_hist.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 4d1b636..1ea9304 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -4050,6 +4050,12 @@ static int parse_var_defs(struct hist_trigger_data *hist_data) goto free; } + if (n_vars == TRACING_MAP_VARS_MAX) { + hist_err("Too many variables defined: ", var_name); + ret = -EINVAL; + goto free; + } + s = kstrdup(var_name, GFP_KERNEL); if (!s) { ret = -ENOMEM; @@ -4066,9 +4072,6 @@ static int parse_var_defs(struct hist_trigger_data *hist_data) hist_data->attrs->var_defs.expr[n_vars++] = s; hist_data->attrs->var_defs.n_vars = n_vars; - - if (n_vars == TRACING_MAP_VARS_MAX) - goto free; } } -- 2.7.4 From 1583685665838112254@xxx Fri Nov 10 13:25:44 +0000 2017 X-GM-THRID: 1583622557264979126 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread