Received: by 10.223.164.202 with SMTP id h10csp1627400wrb; Sat, 18 Nov 2017 02:59:29 -0800 (PST) X-Google-Smtp-Source: AGs4zMZfVJ8DGU4nKmqZbI0PRfKXW0Cb+Pc1LzYtpMkTM8+8hU+9HRQQCC1cSQiZlkv4qKiL9Fmt X-Received: by 10.159.250.142 with SMTP id k14mr8174048pls.282.1511002769600; Sat, 18 Nov 2017 02:59:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511002769; cv=none; d=google.com; s=arc-20160816; b=mh23OFt3NcqM13WIqZw2NbvgXq+cLd7B5pj9832jMUtxLf/zqRcVLXHJ3AoRFUNEFy atPXgocYHaQFRMA67vtfrJdy3ZLF5wQUm1sIDEF2cTiULR1Xsq8Ug8d510Xhej+UMjEl 0AZS8BaPsW8aRKqQVmOLQdMxjwWrQ/sxYxUwlbDBcLaw9vwJKh9azPhyRwKQiFmw5ppr 1yYwgXQxWsqvEnqv5Xq3rbQ2kuk4QGm3au73AWhIcVXdfXv9zqyUT00uWVjGWs6Uh4FW N/iDsDS4iHh4wdfneAayJbly/cPEbshKfkOakIz5Mi5jAt4ysvmm4poZNRJmPfVrh9Mp zxfA== 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=NFGmQW08vZfGzeoAD0Nunu2AzNYIAOG4ISIQ+9QNihg=; b=G9o0nNA4UXtq6SjA9ebn/IGb481qORtapTH5yPl7HbpSGJK78YAMcNn0j1YbOLSkTb 2AC4f85XOP8GIf/+s9gQDgqSG5VR4yrD6CYeBT+1SH5dSykJXQP5CVO0WowaVj3/QkqL tcDqkcJyP+SSP7k0KZ+AxnvPOgFRWg3Nz191YLWZKZfTJmX9Y4HqIF4rryOsFVgPDu5n 8pqHcO25tOmBz8vCxvlkrfRrdk0rfPu6nY1e9Yy+jUQXWiUufEh84TLhEjhAseujAAJf dngrPkuFU0fa0cu9iTsBwWh62CYbkkSBE/wLo05k2nc7IHWpc9nqyGpXB6rn9Nx1IGNK YECg== 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 ay5si4302061plb.457.2017.11.18.02.59.16; Sat, 18 Nov 2017 02:59:29 -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 S1761277AbdKQUnj (ORCPT + 93 others); Fri, 17 Nov 2017 15:43:39 -0500 Received: from mga01.intel.com ([192.55.52.88]:42609 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935805AbdKQUeR (ORCPT ); Fri, 17 Nov 2017 15:34:17 -0500 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 12:34:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,411,1505804400"; d="scan'208";a="1245396422" Received: from mjglynn-mobl.ger.corp.intel.com (HELO localhost) ([10.254.124.112]) by fmsmga002.fm.intel.com with ESMTP; 17 Nov 2017 12:34:12 -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 10/37] tracing: Break out hist trigger assignment parsing Date: Fri, 17 Nov 2017 14:32:49 -0600 Message-Id: <41a42570c3037371b3cd70293b2ba01d16fdcafe.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 This will make it easier to add variables, and makes the parsing code cleaner regardless. Signed-off-by: Tom Zanussi Signed-off-by: Rajvi Jingar --- kernel/trace/trace_events_hist.c | 72 ++++++++++++++++++++++++++++------------ 1 file changed, 51 insertions(+), 21 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index 37f5ace..e4368bb 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -251,6 +251,51 @@ static void destroy_hist_trigger_attrs(struct hist_trigger_attrs *attrs) kfree(attrs); } +static int parse_assignment(char *str, struct hist_trigger_attrs *attrs) +{ + int ret = 0; + + if ((strncmp(str, "key=", strlen("key=")) == 0) || + (strncmp(str, "keys=", strlen("keys=")) == 0)) { + attrs->keys_str = kstrdup(str, GFP_KERNEL); + if (!attrs->keys_str) { + ret = -ENOMEM; + goto out; + } + } else if ((strncmp(str, "val=", strlen("val=")) == 0) || + (strncmp(str, "vals=", strlen("vals=")) == 0) || + (strncmp(str, "values=", strlen("values=")) == 0)) { + attrs->vals_str = kstrdup(str, GFP_KERNEL); + if (!attrs->vals_str) { + ret = -ENOMEM; + goto out; + } + } else if (strncmp(str, "sort=", strlen("sort=")) == 0) { + attrs->sort_key_str = kstrdup(str, GFP_KERNEL); + if (!attrs->sort_key_str) { + ret = -ENOMEM; + goto out; + } + } else if (strncmp(str, "name=", strlen("name=")) == 0) { + attrs->name = kstrdup(str, GFP_KERNEL); + if (!attrs->name) { + ret = -ENOMEM; + goto out; + } + } else if (strncmp(str, "size=", strlen("size=")) == 0) { + int map_bits = parse_map_size(str); + + if (map_bits < 0) { + ret = map_bits; + goto out; + } + attrs->map_bits = map_bits; + } else + ret = -EINVAL; + out: + return ret; +} + static struct hist_trigger_attrs *parse_hist_trigger_attrs(char *trigger_str) { struct hist_trigger_attrs *attrs; @@ -263,33 +308,18 @@ static struct hist_trigger_attrs *parse_hist_trigger_attrs(char *trigger_str) while (trigger_str) { char *str = strsep(&trigger_str, ":"); - if ((strncmp(str, "key=", strlen("key=")) == 0) || - (strncmp(str, "keys=", strlen("keys=")) == 0)) - attrs->keys_str = kstrdup(str, GFP_KERNEL); - else if ((strncmp(str, "val=", strlen("val=")) == 0) || - (strncmp(str, "vals=", strlen("vals=")) == 0) || - (strncmp(str, "values=", strlen("values=")) == 0)) - attrs->vals_str = kstrdup(str, GFP_KERNEL); - else if (strncmp(str, "sort=", strlen("sort=")) == 0) - attrs->sort_key_str = kstrdup(str, GFP_KERNEL); - else if (strncmp(str, "name=", strlen("name=")) == 0) - attrs->name = kstrdup(str, GFP_KERNEL); - else if (strcmp(str, "pause") == 0) + if (strchr(str, '=')) { + ret = parse_assignment(str, attrs); + if (ret) + goto free; + } else if (strcmp(str, "pause") == 0) attrs->pause = true; else if ((strcmp(str, "cont") == 0) || (strcmp(str, "continue") == 0)) attrs->cont = true; else if (strcmp(str, "clear") == 0) attrs->clear = true; - else if (strncmp(str, "size=", strlen("size=")) == 0) { - int map_bits = parse_map_size(str); - - if (map_bits < 0) { - ret = map_bits; - goto free; - } - attrs->map_bits = map_bits; - } else { + else { ret = -EINVAL; goto free; } -- 1.9.3 From 1584732522315937265@xxx Wed Nov 22 02:45:04 +0000 2017 X-GM-THRID: 1584732522315937265 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread