From: Namhyung Kim <namhyung@kernel.org>
To: Tom Zanussi <tom.zanussi@linux.intel.com>
Cc: rostedt@goodmis.org, tglx@linutronix.de, mhiramat@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,
kernel-team@lge.com
Subject: Re: [PATCH v6 26/37] tracing: Add 'onmatch' hist trigger action support
Date: Wed, 22 Nov 2017 18:49:56 +0900 [thread overview]
Message-ID: <20171122094955.GA2221@danjae.aot.lge.com> (raw)
In-Reply-To: <cb8329d8ff410082472191be48bfb99e7aafc6a2.1510948725.git.tom.zanussi@linux.intel.com>
On Fri, Nov 17, 2017 at 02:33:05PM -0600, Tom Zanussi wrote:
> Add an 'onmatch(matching.event).<synthetic_event_name>(param list)'
> hist trigger action which is invoked with the set of variables or
> event fields named in the 'param list'. The result is the generation
> of a synthetic event that consists of the values contained in those
> variables and/or fields at the time the invoking event was hit.
>
> As an example the below defines a simple synthetic event using a
> variable defined on the sched_wakeup_new event, and shows the event
> definition with unresolved fields, since the sched_wakeup_new event
> with the testpid variable hasn't been defined yet:
>
> # echo 'wakeup_new_test pid_t pid; int prio' >> \
> /sys/kernel/debug/tracing/synthetic_events
>
> # cat /sys/kernel/debug/tracing/synthetic_events
> wakeup_new_test pid_t pid; int prio
>
> The following hist trigger both defines a testpid variable and
> specifies an onmatch() trace action that uses that variable along with
> a non-variable field to generate a wakeup_new_test synthetic event
> whenever a sched_wakeup_new event occurs, which because of the 'if
> comm == "cyclictest"' filter only happens when the executable is
> cyclictest:
>
> # echo 'hist:testpid=pid:keys=$testpid:\
> onmatch(sched.sched_wakeup_new).wakeup_new_test($testpid, prio) \
> if comm=="cyclictest"' >> \
> /sys/kernel/debug/tracing/events/sched/sched_wakeup_new/trigger
>
> Creating and displaying a histogram based on those events is now just
> a matter of using the fields and new synthetic event in the
> tracing/events/synthetic directory, as usual:
>
> # echo 'hist:keys=pid,prio:sort=pid,prio' >> \
> /sys/kernel/debug/tracing/events/synthetic/wakeup_new_test/trigger
>
> Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
> Signed-off-by: Rajvi Jingar <rajvi.jingar@intel.com>
> ---
[SNIP]
> +static int onmatch_create(struct hist_trigger_data *hist_data,
> + struct trace_event_file *file,
> + struct action_data *data)
> +{
> + char *event_name, *param, *system = NULL;
> + struct hist_field *hist_field, *var_ref;
> + unsigned int i, var_ref_idx;
> + unsigned int field_pos = 0;
> + struct synth_event *event;
> + int ret = 0;
> +
> + mutex_lock(&synth_event_mutex);
> + event = find_synth_event(data->onmatch.synth_event_name);
> + if (!event) {
> + mutex_unlock(&synth_event_mutex);
> + return -EINVAL;
> + }
> + mutex_unlock(&synth_event_mutex);
> +
> + var_ref_idx = hist_data->n_var_refs;
> +
> + for (i = 0; i < data->n_params; i++) {
> + char *p;
> +
> + p = param = kstrdup(data->params[i], GFP_KERNEL);
> + if (!param) {
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + system = strsep(¶m, ".");
> + if (!param) {
> + param = (char *)system;
> + system = event_name = NULL;
> + } else {
> + event_name = strsep(¶m, ".");
> + if (!param) {
> + kfree(p);
> + ret = -EINVAL;
> + goto out;
> + }
> + }
> +
> + if (param[0] == '$')
What about $common_timestamp ?
> + hist_field = onmatch_find_var(hist_data, data, system,
> + event_name, param);
> + else
> + hist_field = onmatch_create_field_var(hist_data, data,
> + system,
> + event_name,
> + param);
> +
> + if (!hist_field) {
> + kfree(p);
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + if (check_synth_field(event, hist_field, field_pos) == 0) {
> + var_ref = create_var_ref(hist_field, system, event_name);
> + if (!var_ref) {
> + kfree(p);
> + ret = -ENOMEM;
> + goto out;
> + }
> +
> + save_synth_var_ref(hist_data, var_ref);
> + field_pos++;
> + kfree(p);
> + continue;
> + }
> +
> + kfree(p);
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + if (field_pos != event->n_fields) {
> + ret = -EINVAL;
> + goto out;
> + }
> +
> + data->fn = action_trace;
> + data->onmatch.synth_event = event;
> + data->onmatch.var_ref_idx = var_ref_idx;
> + event->ref++;
Is it safe to update the refcount without synth_event_mutex?
Thanks,
Namhyung
> + out:
> + return ret;
> +}
next prev parent reply other threads:[~2017-11-22 9:52 UTC|newest]
Thread overview: 50+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-17 20:32 [PATCH v6 00/37] tracing: Inter-event (e.g. latency) support Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 01/37] tracing: Move hist trigger Documentation to histogram.txt Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 02/37] tracing: Add Documentation for log2 modifier Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 03/37] tracing: Add support to detect and avoid duplicates Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 04/37] tracing: Remove code which merges duplicates Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 05/37] ring-buffer: Add interface for setting absolute time stamps Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 06/37] ring-buffer: Redefine the unimplemented RINGBUF_TYPE_TIME_STAMP Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 07/37] tracing: Add timestamp_mode trace file Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 08/37] tracing: Give event triggers access to ring_buffer_event Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 09/37] tracing: Add ring buffer event param to hist field functions Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 10/37] tracing: Break out hist trigger assignment parsing Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 11/37] tracing: Add hist trigger timestamp support Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 12/37] tracing: Add per-element variable support to tracing_map Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 13/37] tracing: Add hist_data member to hist_field Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 14/37] tracing: Add usecs modifier for hist trigger timestamps Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 15/37] tracing: Add variable support to hist triggers Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 16/37] tracing: Account for variables in named trigger compatibility Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 17/37] tracing: Move get_hist_field_flags() Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 18/37] tracing: Add simple expression support to hist triggers Tom Zanussi
2017-11-20 6:05 ` Namhyung Kim
2017-11-17 20:32 ` [PATCH v6 19/37] tracing: Generalize per-element hist trigger data Tom Zanussi
2017-11-17 20:32 ` [PATCH v6 20/37] tracing: Pass tracing_map_elt to hist_field accessor functions Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 21/37] tracing: Add hist_field 'type' field Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 22/37] tracing: Add variable reference handling to hist triggers Tom Zanussi
2017-11-21 10:53 ` Namhyung Kim
2017-11-17 20:33 ` [PATCH v6 23/37] tracing: Add hist trigger action hook Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 24/37] tracing: Add support for 'synthetic' events Tom Zanussi
2017-11-21 11:32 ` Namhyung Kim
2017-11-17 20:33 ` [PATCH v6 25/37] tracing: Add support for 'field variables' Tom Zanussi
2017-11-21 12:08 ` Namhyung Kim
2017-11-22 6:05 ` Namhyung Kim
2017-11-17 20:33 ` [PATCH v6 26/37] tracing: Add 'onmatch' hist trigger action support Tom Zanussi
2017-11-22 9:49 ` Namhyung Kim [this message]
2017-11-17 20:33 ` [PATCH v6 27/37] tracing: Add 'onmax' " Tom Zanussi
2017-11-23 5:09 ` Namhyung Kim
2017-11-29 20:53 ` Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 28/37] tracing: Allow whitespace to surround hist trigger filter Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 29/37] tracing: Add cpu field for hist triggers Tom Zanussi
2017-11-23 5:25 ` Namhyung Kim
2017-11-29 21:02 ` Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 30/37] tracing: Add hist trigger support for variable reference aliases Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 31/37] tracing: Add 'last error' error facility for hist triggers Tom Zanussi
2017-11-23 6:22 ` Namhyung Kim
2017-11-17 20:33 ` [PATCH v6 32/37] tracing: Add inter-event hist trigger Documentation Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 33/37] tracing: Make tracing_set_clock() non-static Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 34/37] tracing: Add a clock attribute for hist triggers Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 35/37] tracing: Increase trace_recursive_lock() limit for synthetic events Tom Zanussi
2017-11-17 20:33 ` [PATCH v6 36/37] tracing: Add inter-event blurb to HIST_TRIGGERS config option Tom Zanussi
2017-11-23 6:57 ` Namhyung Kim
2017-11-17 20:33 ` [PATCH v6 37/37] selftests: ftrace: Add inter-event hist triggers testcases Tom Zanussi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171122094955.GA2221@danjae.aot.lge.com \
--to=namhyung@kernel.org \
--cc=baohong.liu@intel.com \
--cc=bigeasy@linutronix.de \
--cc=fengguang.wu@intel.com \
--cc=joel.opensrc@gmail.com \
--cc=joelaf@google.com \
--cc=julia@ni.com \
--cc=kernel-team@lge.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=rajvi.jingar@intel.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=tom.zanussi@linux.intel.com \
--cc=vedang.patel@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome