Received: by 10.223.164.202 with SMTP id h10csp1627340wrb; Sat, 18 Nov 2017 02:59:25 -0800 (PST) X-Google-Smtp-Source: AGs4zMakOUZmlVwyeo9bMbGyABz08mszMTibqTXiaQS1PJdrIsLMKae7lqUZG3ot4zzJwBzWASvX X-Received: by 10.84.171.195 with SMTP id l61mr7890872plb.27.1511002765423; Sat, 18 Nov 2017 02:59:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511002765; cv=none; d=google.com; s=arc-20160816; b=aeuu0FFxycrMH712I8+MqoN2ma+HhSbK3gi+YRaSMhyWgOfHrQCCMCuaFSpIxYrNdV 4RFVUxm8T7E+xob+I8aG75XGvzsdJa3lm0ZTb/Jd6/hC6ZBUNg0Yghxkj1Eb447Pc1PX lNFOiML95PcM1sF1CPxWsm8Vdx2NCDmlH5V3G99iIN3Xenf8IzoH7fHs+bCyQoXnIBmj kCpCW8Q8MESj4h7a4fdU868ZDygmQ2ejVmB+yWDJY4qfyVZ9xxl4Feu9sTvqm61Pk3Ke MjdNO0c7F+ff+EAoTKi4xmAKiTPyAS2HRnq3VhVQgU7hb2G+fme1bX8gNuIn9JZzyOrC WMxQ== 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=HtSV1834q40PCTpaUh/bV5Bd4vPBHKEKSWzJHT/5AOs=; b=g6NVFQbzeliGy5dnS+Q1fHLni+64C3eWGrbBOwT9YlepVoO0pOgruxlUiR4tXKCYqL KXecV4btfDmPJla64jQXuzogqOgx5ftxGYUZ+bjAEQqWh3CJa9lWZ5o/fIjxNC/C8Vex QdMZEsWuRCvrwOye9He/yEhr9x8ZgIG0H1isVninpNPvCT4W4f6LPANYAhvMLouKFVQE snE2bt0UqmNitiVkS3t28SH+NU/OG93c3d4QJR9RF88ZBeDYgHsSQdyvCyFMuYezCXf2 uqJSZU1yySrquUeoemImSoJHlmHrugYpU4ivp6oN329Cx1i4yfJ4Feq3iV1PNEyyTShi eLnw== 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 z76si4373013pgz.199.2017.11.18.02.59.12; Sat, 18 Nov 2017 02:59:25 -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 S966503AbdKQUl2 (ORCPT + 93 others); Fri, 17 Nov 2017 15:41:28 -0500 Received: from mga11.intel.com ([192.55.52.93]:64125 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935925AbdKQUes (ORCPT ); Fri, 17 Nov 2017 15:34:48 -0500 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Nov 2017 12:34:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,411,1505804400"; d="scan'208";a="177010435" Received: from mjglynn-mobl.ger.corp.intel.com (HELO localhost) ([10.254.124.112]) by fmsmga005.fm.intel.com with ESMTP; 17 Nov 2017 12:34:45 -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 19/37] tracing: Generalize per-element hist trigger data Date: Fri, 17 Nov 2017 14:32:58 -0600 Message-Id: <1118ebcf18dea2690acee4dba72fd85efc2ca77e.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 Up until now, hist triggers only needed per-element support for saving 'comm' data, which was saved directly as a private data pointer. In anticipation of the need to save other data besides 'comm', add a new hist_elt_data struct for the purpose, and switch the current 'comm'-related code over to that. Signed-off-by: Tom Zanussi --- kernel/trace/trace_events_hist.c | 76 +++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index f6c59a5..d9f24b7 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -289,6 +289,10 @@ static struct hist_field *find_var(struct hist_trigger_data *hist_data, return NULL; } +struct hist_elt_data { + char *comm; +}; + static const char *hist_field_name(struct hist_field *field, unsigned int level) { @@ -503,45 +507,61 @@ static inline void save_comm(char *comm, struct task_struct *task) memcpy(comm, task->comm, TASK_COMM_LEN); } -static void hist_trigger_elt_comm_free(struct tracing_map_elt *elt) +static void hist_elt_data_free(struct hist_elt_data *elt_data) +{ + kfree(elt_data->comm); + kfree(elt_data); +} + +static void hist_trigger_elt_data_free(struct tracing_map_elt *elt) { - kfree((char *)elt->private_data); + struct hist_elt_data *elt_data = elt->private_data; + + hist_elt_data_free(elt_data); } -static int hist_trigger_elt_comm_alloc(struct tracing_map_elt *elt) +static int hist_trigger_elt_data_alloc(struct tracing_map_elt *elt) { struct hist_trigger_data *hist_data = elt->map->private_data; + unsigned int size = TASK_COMM_LEN + 1; + struct hist_elt_data *elt_data; struct hist_field *key_field; unsigned int i; + elt_data = kzalloc(sizeof(*elt_data), GFP_KERNEL); + if (!elt_data) + return -ENOMEM; + for_each_hist_key_field(i, hist_data) { key_field = hist_data->fields[i]; if (key_field->flags & HIST_FIELD_FL_EXECNAME) { - unsigned int size = TASK_COMM_LEN + 1; - - elt->private_data = kzalloc(size, GFP_KERNEL); - if (!elt->private_data) + elt_data->comm = kzalloc(size, GFP_KERNEL); + if (!elt_data->comm) { + kfree(elt_data); return -ENOMEM; + } break; } } + elt->private_data = elt_data; + return 0; } -static void hist_trigger_elt_comm_init(struct tracing_map_elt *elt) +static void hist_trigger_elt_data_init(struct tracing_map_elt *elt) { - char *comm = elt->private_data; + struct hist_elt_data *elt_data = elt->private_data; - if (comm) - save_comm(comm, current); + if (elt_data->comm) + save_comm(elt_data->comm, current); } -static const struct tracing_map_ops hist_trigger_elt_comm_ops = { - .elt_alloc = hist_trigger_elt_comm_alloc, - .elt_free = hist_trigger_elt_comm_free, - .elt_init = hist_trigger_elt_comm_init, +static const struct tracing_map_ops hist_trigger_elt_data_ops = { + .elt_alloc = hist_trigger_elt_data_alloc, + .elt_free = hist_trigger_elt_data_free, + .elt_init = hist_trigger_elt_data_init, }; static const char *get_hist_field_flags(struct hist_field *hist_field) @@ -1512,21 +1532,6 @@ static int create_tracing_map_fields(struct hist_trigger_data *hist_data) return 0; } -static bool need_tracing_map_ops(struct hist_trigger_data *hist_data) -{ - struct hist_field *key_field; - unsigned int i; - - for_each_hist_key_field(i, hist_data) { - key_field = hist_data->fields[i]; - - if (key_field->flags & HIST_FIELD_FL_EXECNAME) - return true; - } - - return false; -} - static struct hist_trigger_data * create_hist_data(unsigned int map_bits, struct hist_trigger_attrs *attrs, @@ -1552,8 +1557,7 @@ static bool need_tracing_map_ops(struct hist_trigger_data *hist_data) if (ret) goto free; - if (need_tracing_map_ops(hist_data)) - map_ops = &hist_trigger_elt_comm_ops; + map_ops = &hist_trigger_elt_data_ops; hist_data->map = tracing_map_create(map_bits, hist_data->key_size, map_ops, hist_data); @@ -1741,7 +1745,13 @@ static void hist_trigger_stacktrace_print(struct seq_file *m, seq_printf(m, "%s: [%llx] %-55s", field_name, uval, str); } else if (key_field->flags & HIST_FIELD_FL_EXECNAME) { - char *comm = elt->private_data; + struct hist_elt_data *elt_data = elt->private_data; + char *comm; + + if (WARN_ON_ONCE(!elt_data)) + return; + + comm = elt_data->comm; uval = *(u64 *)(key + key_field->offset); seq_printf(m, "%s: %-16s[%10llu]", field_name, -- 1.9.3 From 1584590418201357236@xxx Mon Nov 20 13:06:23 +0000 2017 X-GM-THRID: 1583945945590122535 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread