Received: by 10.223.164.202 with SMTP id h10csp1693884wrb; Sat, 18 Nov 2017 04:22:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMYaWA3OgdDvWqy1yLMcLhTx2cECU1R5tFpLOU/90wySU5PEgJXupA5cKVN9CMYkhtSZauE4 X-Received: by 10.84.130.33 with SMTP id 30mr8412565plc.379.1511007753007; Sat, 18 Nov 2017 04:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511007752; cv=none; d=google.com; s=arc-20160816; b=SqAJvCBJLL7PnERfLLtrHAq/V19o3JF4YemFJBKprnxT9ffvh0X5xkTi0D+6dJcxIO OV4EUd8J8U8Asb63wGi7V4yA/XwllQzEC24HolMaV+7GkVZ7fQ0eC+kC9pbhx0TmLcqp 8u9hCGXZs07ckBzK8cO8iqd30YnSAl4QMtG8hw0a7iB529URxVw9p45bxRnoSea4cHeP x0RQFdB48GphGWwsgTlTFA0FrHvAlscj/a4P51dDWl1zzLhD1OotSR23a4un5bju3VQS CmBsLVOI2dEM50+KwU4Nf0ruxvV51DFiLUoU0+F7Y1fK1PNXUqt1bB0LrWNHe8eTGBkQ 6WoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=0x5R//QETOGUQZfmmWPI2aBPpzYNpbuabXDhhJhwFic=; b=WloEpquyb1RzmxwxgG5UwLXnUblI35mWIn0YAhKkBHefncnegWNmGb6PIq70pAcVQ8 QS9Opaq1sGHNKbz9uzvtRetZc6AeHOlOtFRxqZvpvtpqiclfYcIeXOJCFmEyHG7zNaU7 kOxFZ23Lc4S33vNQEmA90tAAz+h4iyIkOvGktrJLA/PVtV7ZSZlag2anIKBws3BxgbB3 y93VUwElDJqM/aN0qwXSWdAT9QNCaKLs0ZrJd5Kz4rsgJ0SmAiRc/cu+VD64BlXAEYwq ZQvH1bwkaf2t5ShsZL9RLtjEU1RO5wZVCz8Akf4K+BuULv4/LUw/1VnKHaEG2fLNvQW4 Wn1A== 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 g1si4458748pgo.705.2017.11.18.04.21.43; Sat, 18 Nov 2017 04:22:32 -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 S966450AbdKQUiZ (ORCPT + 93 others); Fri, 17 Nov 2017 15:38:25 -0500 Received: from mga05.intel.com ([192.55.52.43]:3967 "EHLO mga05.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936041AbdKQUfg (ORCPT ); Fri, 17 Nov 2017 15:35:36 -0500 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 12:35:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,411,1505804400"; d="scan'208";a="6249159" Received: from mjglynn-mobl.ger.corp.intel.com (HELO localhost) ([10.254.124.112]) by orsmga001.jf.intel.com with ESMTP; 17 Nov 2017 12:35:33 -0800 From: Tom Zanussi To: rostedt@goodmis.org Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@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, fengguang.wu@intel.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH v6 28/37] tracing: Allow whitespace to surround hist trigger filter Date: Fri, 17 Nov 2017 14:33:07 -0600 Message-Id: <7c2299377db3d14f8b3fa3e3060674e637fec9db.1510948725.git.tom.zanussi@linux.intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The existing code only allows for one space before and after the 'if' specifying the filter for a hist trigger. Add code to make that more permissive as far as whitespace goes. Specifically, we want to allow spaces in the trigger itself now that we have additional syntax (onmatch/onmax) where spaces are more natural e.g. spaces after commas in param lists. Signed-off-by: Tom Zanussi --- kernel/trace/trace_events_hist.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 7d24c37..121f7ef 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -5155,7 +5155,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops, struct synth_event *se; const char *se_name; bool remove = false; - char *trigger; + char *trigger, *p; int ret = 0; if (!param) @@ -5164,10 +5164,37 @@ static int event_hist_trigger_func(struct event_command *cmd_ops, if (glob[0] == '!') remove = true; - /* separate the trigger from the filter (k:v [if filter]) */ - trigger = strsep(¶m, " \t"); - if (!trigger) - return -EINVAL; + /* + * separate the trigger from the filter (k:v [if filter]) + * allowing for whitespace in the trigger + */ + p = trigger = param; + do { + p = strstr(p, "if"); + if (!p) + break; + if (p == param) + return -EINVAL; + if (*(p - 1) != ' ' && *(p - 1) != '\t') { + p++; + continue; + } + if (p >= param + strlen(param) - strlen("if") - 1) + return -EINVAL; + if (*(p + strlen("if")) != ' ' && *(p + strlen("if")) != '\t') { + p++; + continue; + } + break; + } while (p); + + if (!p) + param = NULL; + else { + *(p - 1) = '\0'; + param = strstrip(p); + trigger = strstrip(trigger); + } attrs = parse_hist_trigger_attrs(trigger); if (IS_ERR(attrs)) -- 1.9.3 From 1584415680046931552@xxx Sat Nov 18 14:49:00 +0000 2017 X-GM-THRID: 1584415680046931552 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread