Received: by 10.223.164.202 with SMTP id h10csp686138wrb; Thu, 9 Nov 2017 12:41:48 -0800 (PST) X-Google-Smtp-Source: ABhQp+SkPPeudBhs0sX95b0pUStwq8dEOGEyFGuzlq0EkZwvQbEqiro+ms6LXLUqJGZw/R+8WSc5 X-Received: by 10.159.234.73 with SMTP id c9mr1587239plr.89.1510260108176; Thu, 09 Nov 2017 12:41:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510260108; cv=none; d=google.com; s=arc-20160816; b=EwQf8euVOWz8mDJ1Eq9aYU4WnGVxCd+u9XUgLeTUQJ5RMKyb60Ax3tUeQQFwr85LFE cx/dPyCW+sC4rObytmKuVhEh9ErrkFl8uOP5YydWcHlOsnMDY5GGxjbWsvYjJF/BVv99 t6ggne/LAXzImPUopZSkALroMUmu+WuOoYg065yfH0+vCCBd9fEslYuRPGRXDmqjWcBy tGPvHwIf5W2f/mofiHwkluErquO1quS/HJa8+2+L/u9Gk7qps33jWygooWPAXUpwKxx/ 4hiupWP+plj0xT5MP+lJ1coTdoHO0hHhIxnT9wax8vABjAK+yCnwbp8Eh9/yrJLuRWyP WkWg== 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=Pi/lc6V7H1uQp3je+DWRZ1RDBRKPZShHlYsYB5F8wxM=; b=FPZzVA0UVQZZyPXQAAEDOAQHEPqz5nbtc+yIBxrBVrjZ4KLceji7O/IW9i9bUCAj3T Mtb+PF0SqHNOYPumSoXEtcz5Z3OyYnSO3UG90fWo3XmAfLJuU4J88AH3VkAQ1ADCx1DX 9sc311Hv9TleJGg9KS7Wj9/1SCEYI2bGxlx7wTQSbvAJe04KyZuCHHLTJyTOYAHOPWiS KnR2ogISrM/pOWbQFNh6bsQtXZwbBjQqzZ5hx+vxAnNpDbOctsbHSHKiDCI+HmrdfT4U lz/QCwwGDuE0uxht7AA9PSkS3dqiMkrEsaOKB9qeImzAKMEYmITK2iskN+0juMnGjTHc yMJA== 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 s13si7266727plq.584.2017.11.09.12.41.30; Thu, 09 Nov 2017 12:41:48 -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 S1755254AbdKIUkQ (ORCPT + 83 others); Thu, 9 Nov 2017 15:40:16 -0500 Received: from mga06.intel.com ([134.134.136.31]:41962 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754867AbdKIUfP (ORCPT ); Thu, 9 Nov 2017 15:35:15 -0500 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga104.jf.intel.com with ESMTP; 09 Nov 2017 12:35:14 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.44,370,1505804400"; d="scan'208";a="5892131" Received: from dkusalov-mobl4.amr.corp.intel.com (HELO localhost) ([10.254.117.34]) by orsmga002.jf.intel.com with ESMTP; 09 Nov 2017 12:35: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, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH v5 19/37] tracing: Generalize per-element hist trigger data Date: Thu, 9 Nov 2017 14:33:50 -0600 Message-Id: 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 0eec597..4055187 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -247,6 +247,10 @@ static u64 hist_field_timestamp(struct hist_field *hist_field, void *event, return ts; } +struct hist_elt_data { + char *comm; +}; + static const char *hist_field_name(struct hist_field *field, unsigned int level) { @@ -461,45 +465,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) @@ -1507,21 +1527,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, @@ -1547,8 +1552,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); @@ -1736,7 +1740,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 1583586874470112979@xxx Thu Nov 09 11:15:29 +0000 2017 X-GM-THRID: 1582773873031494647 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread