Received: by 10.223.164.202 with SMTP id h10csp684049wrb; Thu, 9 Nov 2017 12:39:39 -0800 (PST) X-Google-Smtp-Source: ABhQp+R2vSHO0XW/jJR4pEGE0c9Tg9ZxPyx9VMlnnvEZFw0gp9EbktUNb7k+JzMCHFM54645fJcA X-Received: by 10.159.216.140 with SMTP id s12mr1647591plp.318.1510259979061; Thu, 09 Nov 2017 12:39:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510259979; cv=none; d=google.com; s=arc-20160816; b=v7GfWvy5e3fisAnGA9XoaUc5EhPdbrIRJfXlvjhJSqtOCQ2y1pTSy0ldELU+b1G6FH GbM0iKhhJHOp7ydAOoYGRfUMGdU7A7P5aB3187Dn4F/ecD4LsOebUGclgyicOaFZJZfO ShU5KK+ST/QzM5hZ+QgvIOxEA2w5l9Jwn/W1B3d+q5k+47X1j4F0huew3CkwewEHQKOC AtXzj5sRboUOGv/rZ1pA1ru/EKbHOIks751eapOcLEgYkwpRGPKdbg292HcgVcN80PPC yh4Q0MSf2RBys92252pzlSYvKXIM+mXU9bcq9FcF5uLcQB40rFdPSZfpCoxeH2ee6UaK nlKw== 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=7+4s2s/FBjUpNFWZuENwu50mVZFDRdBnpqRhvFDrMvU=; b=UTc258+L1XpelQK9evsxcVjT+xIutXRxcPG/x9gXrL43Q3DBSW5/nl/FmCF+9o8Nvn 1qPQcmsIjCRh/dKVqj+rjNwCDwk1uM1CuHYBnLz88RPmsd0L1cVN1xUWMt5a6+FhBDB3 PqiOyZnTT41uAVJZF7K9zyTcSAz1OphBluUhcWFpFknC81cshJjuPwwK0VE6p72d0+wV PchaM69Ge4Bm4oTiAK+8yvRSUibd4GjjeHnsC648lNNq79x9WmuXhW32YAOOUhk13LE4 wItwhLHc5mdLJmKkVwiHcdwpMraIrU2TpX+riLwl3xD71o5K4ty63uFsbaxl7k0VQfSF VBUg== 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 bg3si7274524plb.668.2017.11.09.12.39.27; Thu, 09 Nov 2017 12:39:39 -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 S1755290AbdKIUiQ (ORCPT + 83 others); Thu, 9 Nov 2017 15:38:16 -0500 Received: from mga07.intel.com ([134.134.136.100]:46789 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755146AbdKIUfp (ORCPT ); Thu, 9 Nov 2017 15:35:45 -0500 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP; 09 Nov 2017 12:35:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,370,1505804400"; d="scan'208";a="174024760" Received: from dkusalov-mobl4.amr.corp.intel.com (HELO localhost) ([10.254.117.34]) by fmsmga005.fm.intel.com with ESMTP; 09 Nov 2017 12:35:43 -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, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH v5 28/37] tracing: Allow whitespace to surround hist trigger filter Date: Thu, 9 Nov 2017 14:33:59 -0600 Message-Id: <371a287d6ac3672e5e99d075dc9c8f5e65777411.1510252666.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 8838847..e6ff38f 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -5150,7 +5150,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) @@ -5159,10 +5159,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 1583668412850500663@xxx Fri Nov 10 08:51:31 +0000 2017 X-GM-THRID: 1583557427897285626 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread