1 // SPDX-License-Identifier: GPL-2.0
3 * trace_events_trigger - trace event triggers
5 * Copyright (C) 2013 Tom Zanussi <tom.zanussi@linux.intel.com>
8 #include <linux/security.h>
9 #include <linux/module.h>
10 #include <linux/ctype.h>
11 #include <linux/mutex.h>
12 #include <linux/slab.h>
13 #include <linux/rculist.h>
17 static LIST_HEAD(trigger_commands);
18 static DEFINE_MUTEX(trigger_cmd_mutex);
20 void trigger_data_free(struct event_trigger_data *data)
22 if (data->cmd_ops->set_filter)
23 data->cmd_ops->set_filter(NULL, data, NULL);
25 /* make sure current triggers exit before free */
26 tracepoint_synchronize_unregister();
32 * event_triggers_call - Call triggers associated with a trace event
33 * @file: The trace_event_file associated with the event
34 * @rec: The trace entry for the event, NULL for unconditional invocation
36 * For each trigger associated with an event, invoke the trigger
37 * function registered with the associated trigger command. If rec is
38 * non-NULL, it means that the trigger requires further processing and
39 * shouldn't be unconditionally invoked. If rec is non-NULL and the
40 * trigger has a filter associated with it, rec will checked against
41 * the filter and if the record matches the trigger will be invoked.
42 * If the trigger is a 'post_trigger', meaning it shouldn't be invoked
43 * in any case until the current event is written, the trigger
44 * function isn't invoked but the bit associated with the deferred
45 * trigger is set in the return value.
47 * Returns an enum event_trigger_type value containing a set bit for
48 * any trigger that should be deferred, ETT_NONE if nothing to defer.
50 * Called from tracepoint handlers (with rcu_read_lock_sched() held).
52 * Return: an enum event_trigger_type value containing a set bit for
53 * any trigger that should be deferred, ETT_NONE if nothing to defer.
55 enum event_trigger_type
56 event_triggers_call(struct trace_event_file *file,
57 struct trace_buffer *buffer, void *rec,
58 struct ring_buffer_event *event)
60 struct event_trigger_data *data;
61 enum event_trigger_type tt = ETT_NONE;
62 struct event_filter *filter;
64 if (list_empty(&file->triggers))
67 list_for_each_entry_rcu(data, &file->triggers, list) {
71 data->ops->trigger(data, buffer, rec, event);
74 filter = rcu_dereference_sched(data->filter);
75 if (filter && !filter_match_preds(filter, rec))
77 if (event_command_post_trigger(data->cmd_ops)) {
78 tt |= data->cmd_ops->trigger_type;
81 data->ops->trigger(data, buffer, rec, event);
85 EXPORT_SYMBOL_GPL(event_triggers_call);
87 bool __trace_trigger_soft_disabled(struct trace_event_file *file)
89 unsigned long eflags = file->flags;
91 if (eflags & EVENT_FILE_FL_TRIGGER_MODE)
92 event_triggers_call(file, NULL, NULL, NULL);
93 if (eflags & EVENT_FILE_FL_SOFT_DISABLED)
95 if (eflags & EVENT_FILE_FL_PID_FILTER)
96 return trace_event_ignore_this_pid(file);
99 EXPORT_SYMBOL_GPL(__trace_trigger_soft_disabled);
102 * event_triggers_post_call - Call 'post_triggers' for a trace event
103 * @file: The trace_event_file associated with the event
104 * @tt: enum event_trigger_type containing a set bit for each trigger to invoke
106 * For each trigger associated with an event, invoke the trigger
107 * function registered with the associated trigger command, if the
108 * corresponding bit is set in the tt enum passed into this function.
109 * See @event_triggers_call for details on how those bits are set.
111 * Called from tracepoint handlers (with rcu_read_lock_sched() held).
114 event_triggers_post_call(struct trace_event_file *file,
115 enum event_trigger_type tt)
117 struct event_trigger_data *data;
119 list_for_each_entry_rcu(data, &file->triggers, list) {
122 if (data->cmd_ops->trigger_type & tt)
123 data->ops->trigger(data, NULL, NULL, NULL);
126 EXPORT_SYMBOL_GPL(event_triggers_post_call);
128 #define SHOW_AVAILABLE_TRIGGERS (void *)(1UL)
130 static void *trigger_next(struct seq_file *m, void *t, loff_t *pos)
132 struct trace_event_file *event_file = event_file_data(m->private);
134 if (t == SHOW_AVAILABLE_TRIGGERS) {
138 return seq_list_next(t, &event_file->triggers, pos);
141 static bool check_user_trigger(struct trace_event_file *file)
143 struct event_trigger_data *data;
145 list_for_each_entry_rcu(data, &file->triggers, list) {
146 if (data->flags & EVENT_TRIGGER_FL_PROBE)
153 static void *trigger_start(struct seq_file *m, loff_t *pos)
155 struct trace_event_file *event_file;
157 /* ->stop() is called even if ->start() fails */
158 mutex_lock(&event_mutex);
159 event_file = event_file_data(m->private);
160 if (unlikely(!event_file))
161 return ERR_PTR(-ENODEV);
163 if (list_empty(&event_file->triggers) || !check_user_trigger(event_file))
164 return *pos == 0 ? SHOW_AVAILABLE_TRIGGERS : NULL;
166 return seq_list_start(&event_file->triggers, *pos);
169 static void trigger_stop(struct seq_file *m, void *t)
171 mutex_unlock(&event_mutex);
174 static int trigger_show(struct seq_file *m, void *v)
176 struct event_trigger_data *data;
177 struct event_command *p;
179 if (v == SHOW_AVAILABLE_TRIGGERS) {
180 seq_puts(m, "# Available triggers:\n");
182 mutex_lock(&trigger_cmd_mutex);
183 list_for_each_entry_reverse(p, &trigger_commands, list)
184 seq_printf(m, " %s", p->name);
186 mutex_unlock(&trigger_cmd_mutex);
190 data = list_entry(v, struct event_trigger_data, list);
191 data->ops->print(m, data);
196 static const struct seq_operations event_triggers_seq_ops = {
197 .start = trigger_start,
198 .next = trigger_next,
199 .stop = trigger_stop,
200 .show = trigger_show,
203 static int event_trigger_regex_open(struct inode *inode, struct file *file)
207 ret = security_locked_down(LOCKDOWN_TRACEFS);
211 mutex_lock(&event_mutex);
213 if (unlikely(!event_file_data(file))) {
214 mutex_unlock(&event_mutex);
218 if ((file->f_mode & FMODE_WRITE) &&
219 (file->f_flags & O_TRUNC)) {
220 struct trace_event_file *event_file;
221 struct event_command *p;
223 event_file = event_file_data(file);
225 list_for_each_entry(p, &trigger_commands, list) {
227 p->unreg_all(event_file);
231 if (file->f_mode & FMODE_READ) {
232 ret = seq_open(file, &event_triggers_seq_ops);
234 struct seq_file *m = file->private_data;
239 mutex_unlock(&event_mutex);
244 int trigger_process_regex(struct trace_event_file *file, char *buff)
246 char *command, *next;
247 struct event_command *p;
250 next = buff = skip_spaces(buff);
251 command = strsep(&next, ": \t");
253 next = skip_spaces(next);
257 command = (command[0] != '!') ? command : command + 1;
259 mutex_lock(&trigger_cmd_mutex);
260 list_for_each_entry(p, &trigger_commands, list) {
261 if (strcmp(p->name, command) == 0) {
262 ret = p->parse(p, file, buff, command, next);
267 mutex_unlock(&trigger_cmd_mutex);
272 static ssize_t event_trigger_regex_write(struct file *file,
273 const char __user *ubuf,
274 size_t cnt, loff_t *ppos)
276 struct trace_event_file *event_file;
283 if (cnt >= PAGE_SIZE)
286 buf = memdup_user_nul(ubuf, cnt);
292 mutex_lock(&event_mutex);
293 event_file = event_file_data(file);
294 if (unlikely(!event_file)) {
295 mutex_unlock(&event_mutex);
299 ret = trigger_process_regex(event_file, buf);
300 mutex_unlock(&event_mutex);
312 static int event_trigger_regex_release(struct inode *inode, struct file *file)
314 mutex_lock(&event_mutex);
316 if (file->f_mode & FMODE_READ)
317 seq_release(inode, file);
319 mutex_unlock(&event_mutex);
325 event_trigger_write(struct file *filp, const char __user *ubuf,
326 size_t cnt, loff_t *ppos)
328 return event_trigger_regex_write(filp, ubuf, cnt, ppos);
332 event_trigger_open(struct inode *inode, struct file *filp)
334 /* Checks for tracefs lockdown */
335 return event_trigger_regex_open(inode, filp);
339 event_trigger_release(struct inode *inode, struct file *file)
341 return event_trigger_regex_release(inode, file);
344 const struct file_operations event_trigger_fops = {
345 .open = event_trigger_open,
347 .write = event_trigger_write,
348 .llseek = tracing_lseek,
349 .release = event_trigger_release,
353 * Currently we only register event commands from __init, so mark this
356 __init int register_event_command(struct event_command *cmd)
358 struct event_command *p;
361 mutex_lock(&trigger_cmd_mutex);
362 list_for_each_entry(p, &trigger_commands, list) {
363 if (strcmp(cmd->name, p->name) == 0) {
368 list_add(&cmd->list, &trigger_commands);
370 mutex_unlock(&trigger_cmd_mutex);
376 * Currently we only unregister event commands from __init, so mark
379 __init int unregister_event_command(struct event_command *cmd)
381 struct event_command *p, *n;
384 mutex_lock(&trigger_cmd_mutex);
385 list_for_each_entry_safe(p, n, &trigger_commands, list) {
386 if (strcmp(cmd->name, p->name) == 0) {
388 list_del_init(&p->list);
393 mutex_unlock(&trigger_cmd_mutex);
399 * event_trigger_print - Generic event_trigger_ops @print implementation
400 * @name: The name of the event trigger
401 * @m: The seq_file being printed to
402 * @data: Trigger-specific data
403 * @filter_str: filter_str to print, if present
405 * Common implementation for event triggers to print themselves.
407 * Usually wrapped by a function that simply sets the @name of the
408 * trigger command and then invokes this.
410 * Return: 0 on success, errno otherwise
413 event_trigger_print(const char *name, struct seq_file *m,
414 void *data, char *filter_str)
416 long count = (long)data;
421 seq_puts(m, ":unlimited");
423 seq_printf(m, ":count=%ld", count);
426 seq_printf(m, " if %s\n", filter_str);
434 * event_trigger_init - Generic event_trigger_ops @init implementation
435 * @data: Trigger-specific data
437 * Common implementation of event trigger initialization.
439 * Usually used directly as the @init method in event trigger
442 * Return: 0 on success, errno otherwise
444 int event_trigger_init(struct event_trigger_data *data)
451 * event_trigger_free - Generic event_trigger_ops @free implementation
452 * @data: Trigger-specific data
454 * Common implementation of event trigger de-initialization.
456 * Usually used directly as the @free method in event trigger
460 event_trigger_free(struct event_trigger_data *data)
462 if (WARN_ON_ONCE(data->ref <= 0))
467 trigger_data_free(data);
470 int trace_event_trigger_enable_disable(struct trace_event_file *file,
475 if (trigger_enable) {
476 if (atomic_inc_return(&file->tm_ref) > 1)
478 set_bit(EVENT_FILE_FL_TRIGGER_MODE_BIT, &file->flags);
479 ret = trace_event_enable_disable(file, 1, 1);
481 if (atomic_dec_return(&file->tm_ref) > 0)
483 clear_bit(EVENT_FILE_FL_TRIGGER_MODE_BIT, &file->flags);
484 ret = trace_event_enable_disable(file, 0, 1);
491 * clear_event_triggers - Clear all triggers associated with a trace array
492 * @tr: The trace array to clear
494 * For each trigger, the triggering event has its tm_ref decremented
495 * via trace_event_trigger_enable_disable(), and any associated event
496 * (in the case of enable/disable_event triggers) will have its sm_ref
497 * decremented via free()->trace_event_enable_disable(). That
498 * combination effectively reverses the soft-mode/trigger state added
499 * by trigger registration.
501 * Must be called with event_mutex held.
504 clear_event_triggers(struct trace_array *tr)
506 struct trace_event_file *file;
508 list_for_each_entry(file, &tr->events, list) {
509 struct event_trigger_data *data, *n;
510 list_for_each_entry_safe(data, n, &file->triggers, list) {
511 trace_event_trigger_enable_disable(file, 0);
512 list_del_rcu(&data->list);
514 data->ops->free(data);
520 * update_cond_flag - Set or reset the TRIGGER_COND bit
521 * @file: The trace_event_file associated with the event
523 * If an event has triggers and any of those triggers has a filter or
524 * a post_trigger, trigger invocation needs to be deferred until after
525 * the current event has logged its data, and the event should have
526 * its TRIGGER_COND bit set, otherwise the TRIGGER_COND bit should be
529 void update_cond_flag(struct trace_event_file *file)
531 struct event_trigger_data *data;
532 bool set_cond = false;
534 lockdep_assert_held(&event_mutex);
536 list_for_each_entry(data, &file->triggers, list) {
537 if (data->filter || event_command_post_trigger(data->cmd_ops) ||
538 event_command_needs_rec(data->cmd_ops)) {
545 set_bit(EVENT_FILE_FL_TRIGGER_COND_BIT, &file->flags);
547 clear_bit(EVENT_FILE_FL_TRIGGER_COND_BIT, &file->flags);
551 * register_trigger - Generic event_command @reg implementation
552 * @glob: The raw string used to register the trigger
553 * @data: Trigger-specific data to associate with the trigger
554 * @file: The trace_event_file associated with the event
556 * Common implementation for event trigger registration.
558 * Usually used directly as the @reg method in event command
561 * Return: 0 on success, errno otherwise
563 static int register_trigger(char *glob,
564 struct event_trigger_data *data,
565 struct trace_event_file *file)
567 struct event_trigger_data *test;
570 lockdep_assert_held(&event_mutex);
572 list_for_each_entry(test, &file->triggers, list) {
573 if (test->cmd_ops->trigger_type == data->cmd_ops->trigger_type) {
579 if (data->ops->init) {
580 ret = data->ops->init(data);
585 list_add_rcu(&data->list, &file->triggers);
587 update_cond_flag(file);
588 ret = trace_event_trigger_enable_disable(file, 1);
590 list_del_rcu(&data->list);
591 update_cond_flag(file);
598 * unregister_trigger - Generic event_command @unreg implementation
599 * @glob: The raw string used to register the trigger
600 * @test: Trigger-specific data used to find the trigger to remove
601 * @file: The trace_event_file associated with the event
603 * Common implementation for event trigger unregistration.
605 * Usually used directly as the @unreg method in event command
608 static void unregister_trigger(char *glob,
609 struct event_trigger_data *test,
610 struct trace_event_file *file)
612 struct event_trigger_data *data = NULL, *iter;
614 lockdep_assert_held(&event_mutex);
616 list_for_each_entry(iter, &file->triggers, list) {
617 if (iter->cmd_ops->trigger_type == test->cmd_ops->trigger_type) {
619 list_del_rcu(&data->list);
620 trace_event_trigger_enable_disable(file, 0);
621 update_cond_flag(file);
626 if (data && data->ops->free)
627 data->ops->free(data);
631 * Event trigger parsing helper functions.
633 * These functions help make it easier to write an event trigger
634 * parsing function i.e. the struct event_command.parse() callback
635 * function responsible for parsing and registering a trigger command
636 * written to the 'trigger' file.
638 * A trigger command (or just 'trigger' for short) takes the form:
639 * [trigger] [if filter]
641 * The struct event_command.parse() callback (and other struct
642 * event_command functions) refer to several components of a trigger
643 * command. Those same components are referenced by the event trigger
644 * parsing helper functions defined below. These components are:
646 * cmd - the trigger command name
647 * glob - the trigger command name optionally prefaced with '!'
648 * param_and_filter - text following cmd and ':'
649 * param - text following cmd and ':' and stripped of filter
650 * filter - the optional filter text following (and including) 'if'
652 * To illustrate the use of these componenents, here are some concrete
653 * examples. For the following triggers:
655 * echo 'traceon:5 if pid == 0' > trigger
656 * - 'traceon' is both cmd and glob
657 * - '5 if pid == 0' is the param_and_filter
659 * - 'if pid == 0' is the filter
661 * echo 'enable_event:sys:event:n' > trigger
662 * - 'enable_event' is both cmd and glob
663 * - 'sys:event:n' is the param_and_filter
664 * - 'sys:event:n' is the param
665 * - there is no filter
667 * echo 'hist:keys=pid if prio > 50' > trigger
668 * - 'hist' is both cmd and glob
669 * - 'keys=pid if prio > 50' is the param_and_filter
670 * - 'keys=pid' is the param
671 * - 'if prio > 50' is the filter
673 * echo '!enable_event:sys:event:n' > trigger
674 * - 'enable_event' the cmd
675 * - '!enable_event' is the glob
676 * - 'sys:event:n' is the param_and_filter
677 * - 'sys:event:n' is the param
678 * - there is no filter
680 * echo 'traceoff' > trigger
681 * - 'traceoff' is both cmd and glob
682 * - there is no param_and_filter
683 * - there is no param
684 * - there is no filter
686 * There are a few different categories of event trigger covered by
689 * - triggers that don't require a parameter e.g. traceon
690 * - triggers that do require a parameter e.g. enable_event and hist
691 * - triggers that though they may not require a param may support an
692 * optional 'n' param (n = number of times the trigger should fire)
693 * e.g.: traceon:5 or enable_event:sys:event:n
694 * - triggers that do not support an 'n' param e.g. hist
696 * These functions can be used or ignored as necessary - it all
697 * depends on the complexity of the trigger, and the granularity of
698 * the functions supported reflects the fact that some implementations
699 * may need to customize certain aspects of their implementations and
700 * won't need certain functions. For instance, the hist trigger
701 * implementation doesn't use event_trigger_separate_filter() because
702 * it has special requirements for handling the filter.
706 * event_trigger_check_remove - check whether an event trigger specifies remove
707 * @glob: The trigger command string, with optional remove(!) operator
709 * The event trigger callback implementations pass in 'glob' as a
710 * parameter. This is the command name either with or without a
711 * remove(!) operator. This function simply parses the glob and
712 * determines whether the command corresponds to a trigger removal or
713 * a trigger addition.
715 * Return: true if this is a remove command, false otherwise
717 bool event_trigger_check_remove(const char *glob)
719 return (glob && glob[0] == '!') ? true : false;
723 * event_trigger_empty_param - check whether the param is empty
724 * @param: The trigger param string
726 * The event trigger callback implementations pass in 'param' as a
727 * parameter. This corresponds to the string following the command
728 * name minus the command name. This function can be called by a
729 * callback implementation for any command that requires a param; a
730 * callback that doesn't require a param can ignore it.
732 * Return: true if this is an empty param, false otherwise
734 bool event_trigger_empty_param(const char *param)
740 * event_trigger_separate_filter - separate an event trigger from a filter
741 * @param_and_filter: String containing trigger and possibly filter
742 * @param: outparam, will be filled with a pointer to the trigger
743 * @filter: outparam, will be filled with a pointer to the filter
744 * @param_required: Specifies whether or not the param string is required
746 * Given a param string of the form '[trigger] [if filter]', this
747 * function separates the filter from the trigger and returns the
748 * trigger in @param and the filter in @filter. Either the @param
749 * or the @filter may be set to NULL by this function - if not set to
750 * NULL, they will contain strings corresponding to the trigger and
753 * There are two cases that need to be handled with respect to the
754 * passed-in param: either the param is required, or it is not
755 * required. If @param_required is set, and there's no param, it will
756 * return -EINVAL. If @param_required is not set and there's a param
757 * that starts with a number, that corresponds to the case of a
758 * trigger with :n (n = number of times the trigger should fire) and
759 * the parsing continues normally; otherwise the function just returns
760 * and assumes param just contains a filter and there's nothing else
763 * Return: 0 on success, errno otherwise
765 int event_trigger_separate_filter(char *param_and_filter, char **param,
766 char **filter, bool param_required)
770 *param = *filter = NULL;
772 if (!param_and_filter) {
779 * Here we check for an optional param. The only legal
780 * optional param is :n, and if that's the case, continue
781 * below. Otherwise we assume what's left is a filter and
782 * return it as the filter string for the caller to deal with.
784 if (!param_required && param_and_filter && !isdigit(param_and_filter[0])) {
785 *filter = param_and_filter;
790 * Separate the param from the filter (param [if filter]).
791 * Here we have either an optional :n param or a required
792 * param and an optional filter.
794 *param = strsep(¶m_and_filter, " \t");
797 * Here we have a filter, though it may be empty.
799 if (param_and_filter) {
800 *filter = skip_spaces(param_and_filter);
809 * event_trigger_alloc - allocate and init event_trigger_data for a trigger
810 * @cmd_ops: The event_command operations for the trigger
811 * @cmd: The cmd string
812 * @param: The param string
813 * @private_data: User data to associate with the event trigger
815 * Allocate an event_trigger_data instance and initialize it. The
816 * @cmd_ops are used along with the @cmd and @param to get the
817 * trigger_ops to assign to the event_trigger_data. @private_data can
818 * also be passed in and associated with the event_trigger_data.
820 * Use event_trigger_free() to free an event_trigger_data object.
822 * Return: The trigger_data object success, NULL otherwise
824 struct event_trigger_data *event_trigger_alloc(struct event_command *cmd_ops,
829 struct event_trigger_data *trigger_data;
830 struct event_trigger_ops *trigger_ops;
832 trigger_ops = cmd_ops->get_trigger_ops(cmd, param);
834 trigger_data = kzalloc(sizeof(*trigger_data), GFP_KERNEL);
838 trigger_data->count = -1;
839 trigger_data->ops = trigger_ops;
840 trigger_data->cmd_ops = cmd_ops;
841 trigger_data->private_data = private_data;
843 INIT_LIST_HEAD(&trigger_data->list);
844 INIT_LIST_HEAD(&trigger_data->named_list);
845 RCU_INIT_POINTER(trigger_data->filter, NULL);
851 * event_trigger_parse_num - parse and return the number param for a trigger
852 * @param: The param string
853 * @trigger_data: The trigger_data for the trigger
855 * Parse the :n (n = number of times the trigger should fire) param
856 * and set the count variable in the trigger_data to the parsed count.
858 * Return: 0 on success, errno otherwise
860 int event_trigger_parse_num(char *param,
861 struct event_trigger_data *trigger_data)
867 number = strsep(¶m, ":");
873 * We use the callback data field (which is a pointer)
876 ret = kstrtoul(number, 0, &trigger_data->count);
883 * event_trigger_set_filter - set an event trigger's filter
884 * @cmd_ops: The event_command operations for the trigger
885 * @file: The event file for the trigger's event
886 * @param: The string containing the filter
887 * @trigger_data: The trigger_data for the trigger
889 * Set the filter for the trigger. If the filter is NULL, just return
892 * Return: 0 on success, errno otherwise
894 int event_trigger_set_filter(struct event_command *cmd_ops,
895 struct trace_event_file *file,
897 struct event_trigger_data *trigger_data)
899 if (param && cmd_ops->set_filter)
900 return cmd_ops->set_filter(param, trigger_data, file);
906 * event_trigger_reset_filter - reset an event trigger's filter
907 * @cmd_ops: The event_command operations for the trigger
908 * @trigger_data: The trigger_data for the trigger
910 * Reset the filter for the trigger to no filter.
912 void event_trigger_reset_filter(struct event_command *cmd_ops,
913 struct event_trigger_data *trigger_data)
915 if (cmd_ops->set_filter)
916 cmd_ops->set_filter(NULL, trigger_data, NULL);
920 * event_trigger_register - register an event trigger
921 * @cmd_ops: The event_command operations for the trigger
922 * @file: The event file for the trigger's event
923 * @glob: The trigger command string, with optional remove(!) operator
924 * @trigger_data: The trigger_data for the trigger
926 * Register an event trigger. The @cmd_ops are used to call the
927 * cmd_ops->reg() function which actually does the registration.
929 * Return: 0 on success, errno otherwise
931 int event_trigger_register(struct event_command *cmd_ops,
932 struct trace_event_file *file,
934 struct event_trigger_data *trigger_data)
936 return cmd_ops->reg(glob, trigger_data, file);
940 * event_trigger_unregister - unregister an event trigger
941 * @cmd_ops: The event_command operations for the trigger
942 * @file: The event file for the trigger's event
943 * @glob: The trigger command string, with optional remove(!) operator
944 * @trigger_data: The trigger_data for the trigger
946 * Unregister an event trigger. The @cmd_ops are used to call the
947 * cmd_ops->unreg() function which actually does the unregistration.
949 void event_trigger_unregister(struct event_command *cmd_ops,
950 struct trace_event_file *file,
952 struct event_trigger_data *trigger_data)
954 cmd_ops->unreg(glob, trigger_data, file);
958 * End event trigger parsing helper functions.
962 * event_trigger_parse - Generic event_command @parse implementation
963 * @cmd_ops: The command ops, used for trigger registration
964 * @file: The trace_event_file associated with the event
965 * @glob: The raw string used to register the trigger
966 * @cmd: The cmd portion of the string used to register the trigger
967 * @param_and_filter: The param and filter portion of the string used to register the trigger
969 * Common implementation for event command parsing and trigger
972 * Usually used directly as the @parse method in event command
975 * Return: 0 on success, errno otherwise
978 event_trigger_parse(struct event_command *cmd_ops,
979 struct trace_event_file *file,
980 char *glob, char *cmd, char *param_and_filter)
982 struct event_trigger_data *trigger_data;
983 char *param, *filter;
987 remove = event_trigger_check_remove(glob);
989 ret = event_trigger_separate_filter(param_and_filter, ¶m, &filter, false);
994 trigger_data = event_trigger_alloc(cmd_ops, cmd, param, file);
999 event_trigger_unregister(cmd_ops, file, glob+1, trigger_data);
1000 kfree(trigger_data);
1005 ret = event_trigger_parse_num(param, trigger_data);
1009 ret = event_trigger_set_filter(cmd_ops, file, filter, trigger_data);
1013 /* Up the trigger_data count to make sure reg doesn't free it on failure */
1014 event_trigger_init(trigger_data);
1016 ret = event_trigger_register(cmd_ops, file, glob, trigger_data);
1020 /* Down the counter of trigger_data or free it if not used anymore */
1021 event_trigger_free(trigger_data);
1026 event_trigger_reset_filter(cmd_ops, trigger_data);
1027 kfree(trigger_data);
1032 * set_trigger_filter - Generic event_command @set_filter implementation
1033 * @filter_str: The filter string for the trigger, NULL to remove filter
1034 * @trigger_data: Trigger-specific data
1035 * @file: The trace_event_file associated with the event
1037 * Common implementation for event command filter parsing and filter
1040 * Usually used directly as the @set_filter method in event command
1043 * Also used to remove a filter (if filter_str = NULL).
1045 * Return: 0 on success, errno otherwise
1047 int set_trigger_filter(char *filter_str,
1048 struct event_trigger_data *trigger_data,
1049 struct trace_event_file *file)
1051 struct event_trigger_data *data = trigger_data;
1052 struct event_filter *filter = NULL, *tmp;
1056 if (!filter_str) /* clear the current filter */
1059 s = strsep(&filter_str, " \t");
1061 if (!strlen(s) || strcmp(s, "if") != 0)
1067 /* The filter is for the 'trigger' event, not the triggered event */
1068 ret = create_event_filter(file->tr, file->event_call,
1069 filter_str, false, &filter);
1071 * If create_event_filter() fails, filter still needs to be freed.
1072 * Which the calling code will do with data->filter.
1075 tmp = rcu_access_pointer(data->filter);
1077 rcu_assign_pointer(data->filter, filter);
1080 /* Make sure the call is done with the filter */
1081 tracepoint_synchronize_unregister();
1082 free_event_filter(tmp);
1085 kfree(data->filter_str);
1086 data->filter_str = NULL;
1089 data->filter_str = kstrdup(filter_str, GFP_KERNEL);
1090 if (!data->filter_str) {
1091 free_event_filter(rcu_access_pointer(data->filter));
1092 data->filter = NULL;
1100 static LIST_HEAD(named_triggers);
1103 * find_named_trigger - Find the common named trigger associated with @name
1104 * @name: The name of the set of named triggers to find the common data for
1106 * Named triggers are sets of triggers that share a common set of
1107 * trigger data. The first named trigger registered with a given name
1108 * owns the common trigger data that the others subsequently
1109 * registered with the same name will reference. This function
1110 * returns the common trigger data associated with that first
1111 * registered instance.
1113 * Return: the common trigger data for the given named trigger on
1114 * success, NULL otherwise.
1116 struct event_trigger_data *find_named_trigger(const char *name)
1118 struct event_trigger_data *data;
1123 list_for_each_entry(data, &named_triggers, named_list) {
1124 if (data->named_data)
1126 if (strcmp(data->name, name) == 0)
1134 * is_named_trigger - determine if a given trigger is a named trigger
1135 * @test: The trigger data to test
1137 * Return: true if 'test' is a named trigger, false otherwise.
1139 bool is_named_trigger(struct event_trigger_data *test)
1141 struct event_trigger_data *data;
1143 list_for_each_entry(data, &named_triggers, named_list) {
1152 * save_named_trigger - save the trigger in the named trigger list
1153 * @name: The name of the named trigger set
1154 * @data: The trigger data to save
1156 * Return: 0 if successful, negative error otherwise.
1158 int save_named_trigger(const char *name, struct event_trigger_data *data)
1160 data->name = kstrdup(name, GFP_KERNEL);
1164 list_add(&data->named_list, &named_triggers);
1170 * del_named_trigger - delete a trigger from the named trigger list
1171 * @data: The trigger data to delete
1173 void del_named_trigger(struct event_trigger_data *data)
1178 list_del(&data->named_list);
1181 static void __pause_named_trigger(struct event_trigger_data *data, bool pause)
1183 struct event_trigger_data *test;
1185 list_for_each_entry(test, &named_triggers, named_list) {
1186 if (strcmp(test->name, data->name) == 0) {
1188 test->paused_tmp = test->paused;
1189 test->paused = true;
1191 test->paused = test->paused_tmp;
1198 * pause_named_trigger - Pause all named triggers with the same name
1199 * @data: The trigger data of a named trigger to pause
1201 * Pauses a named trigger along with all other triggers having the
1202 * same name. Because named triggers share a common set of data,
1203 * pausing only one is meaningless, so pausing one named trigger needs
1204 * to pause all triggers with the same name.
1206 void pause_named_trigger(struct event_trigger_data *data)
1208 __pause_named_trigger(data, true);
1212 * unpause_named_trigger - Un-pause all named triggers with the same name
1213 * @data: The trigger data of a named trigger to unpause
1215 * Un-pauses a named trigger along with all other triggers having the
1216 * same name. Because named triggers share a common set of data,
1217 * unpausing only one is meaningless, so unpausing one named trigger
1218 * needs to unpause all triggers with the same name.
1220 void unpause_named_trigger(struct event_trigger_data *data)
1222 __pause_named_trigger(data, false);
1226 * set_named_trigger_data - Associate common named trigger data
1227 * @data: The trigger data to associate
1228 * @named_data: The common named trigger to be associated
1230 * Named triggers are sets of triggers that share a common set of
1231 * trigger data. The first named trigger registered with a given name
1232 * owns the common trigger data that the others subsequently
1233 * registered with the same name will reference. This function
1234 * associates the common trigger data from the first trigger with the
1237 void set_named_trigger_data(struct event_trigger_data *data,
1238 struct event_trigger_data *named_data)
1240 data->named_data = named_data;
1243 struct event_trigger_data *
1244 get_named_trigger_data(struct event_trigger_data *data)
1246 return data->named_data;
1250 traceon_trigger(struct event_trigger_data *data,
1251 struct trace_buffer *buffer, void *rec,
1252 struct ring_buffer_event *event)
1254 struct trace_event_file *file = data->private_data;
1257 if (tracer_tracing_is_on(file->tr))
1260 tracer_tracing_on(file->tr);
1264 if (tracing_is_on())
1271 traceon_count_trigger(struct event_trigger_data *data,
1272 struct trace_buffer *buffer, void *rec,
1273 struct ring_buffer_event *event)
1275 struct trace_event_file *file = data->private_data;
1278 if (tracer_tracing_is_on(file->tr))
1281 if (tracing_is_on())
1288 if (data->count != -1)
1292 tracer_tracing_on(file->tr);
1298 traceoff_trigger(struct event_trigger_data *data,
1299 struct trace_buffer *buffer, void *rec,
1300 struct ring_buffer_event *event)
1302 struct trace_event_file *file = data->private_data;
1305 if (!tracer_tracing_is_on(file->tr))
1308 tracer_tracing_off(file->tr);
1312 if (!tracing_is_on())
1319 traceoff_count_trigger(struct event_trigger_data *data,
1320 struct trace_buffer *buffer, void *rec,
1321 struct ring_buffer_event *event)
1323 struct trace_event_file *file = data->private_data;
1326 if (!tracer_tracing_is_on(file->tr))
1329 if (!tracing_is_on())
1336 if (data->count != -1)
1340 tracer_tracing_off(file->tr);
1346 traceon_trigger_print(struct seq_file *m, struct event_trigger_data *data)
1348 return event_trigger_print("traceon", m, (void *)data->count,
1353 traceoff_trigger_print(struct seq_file *m, struct event_trigger_data *data)
1355 return event_trigger_print("traceoff", m, (void *)data->count,
1359 static struct event_trigger_ops traceon_trigger_ops = {
1360 .trigger = traceon_trigger,
1361 .print = traceon_trigger_print,
1362 .init = event_trigger_init,
1363 .free = event_trigger_free,
1366 static struct event_trigger_ops traceon_count_trigger_ops = {
1367 .trigger = traceon_count_trigger,
1368 .print = traceon_trigger_print,
1369 .init = event_trigger_init,
1370 .free = event_trigger_free,
1373 static struct event_trigger_ops traceoff_trigger_ops = {
1374 .trigger = traceoff_trigger,
1375 .print = traceoff_trigger_print,
1376 .init = event_trigger_init,
1377 .free = event_trigger_free,
1380 static struct event_trigger_ops traceoff_count_trigger_ops = {
1381 .trigger = traceoff_count_trigger,
1382 .print = traceoff_trigger_print,
1383 .init = event_trigger_init,
1384 .free = event_trigger_free,
1387 static struct event_trigger_ops *
1388 onoff_get_trigger_ops(char *cmd, char *param)
1390 struct event_trigger_ops *ops;
1392 /* we register both traceon and traceoff to this callback */
1393 if (strcmp(cmd, "traceon") == 0)
1394 ops = param ? &traceon_count_trigger_ops :
1395 &traceon_trigger_ops;
1397 ops = param ? &traceoff_count_trigger_ops :
1398 &traceoff_trigger_ops;
1403 static struct event_command trigger_traceon_cmd = {
1405 .trigger_type = ETT_TRACE_ONOFF,
1406 .parse = event_trigger_parse,
1407 .reg = register_trigger,
1408 .unreg = unregister_trigger,
1409 .get_trigger_ops = onoff_get_trigger_ops,
1410 .set_filter = set_trigger_filter,
1413 static struct event_command trigger_traceoff_cmd = {
1415 .trigger_type = ETT_TRACE_ONOFF,
1416 .flags = EVENT_CMD_FL_POST_TRIGGER,
1417 .parse = event_trigger_parse,
1418 .reg = register_trigger,
1419 .unreg = unregister_trigger,
1420 .get_trigger_ops = onoff_get_trigger_ops,
1421 .set_filter = set_trigger_filter,
1424 #ifdef CONFIG_TRACER_SNAPSHOT
1426 snapshot_trigger(struct event_trigger_data *data,
1427 struct trace_buffer *buffer, void *rec,
1428 struct ring_buffer_event *event)
1430 struct trace_event_file *file = data->private_data;
1433 tracing_snapshot_instance(file->tr);
1439 snapshot_count_trigger(struct event_trigger_data *data,
1440 struct trace_buffer *buffer, void *rec,
1441 struct ring_buffer_event *event)
1446 if (data->count != -1)
1449 snapshot_trigger(data, buffer, rec, event);
1453 register_snapshot_trigger(char *glob,
1454 struct event_trigger_data *data,
1455 struct trace_event_file *file)
1457 if (tracing_alloc_snapshot_instance(file->tr) != 0)
1460 return register_trigger(glob, data, file);
1464 snapshot_trigger_print(struct seq_file *m, struct event_trigger_data *data)
1466 return event_trigger_print("snapshot", m, (void *)data->count,
1470 static struct event_trigger_ops snapshot_trigger_ops = {
1471 .trigger = snapshot_trigger,
1472 .print = snapshot_trigger_print,
1473 .init = event_trigger_init,
1474 .free = event_trigger_free,
1477 static struct event_trigger_ops snapshot_count_trigger_ops = {
1478 .trigger = snapshot_count_trigger,
1479 .print = snapshot_trigger_print,
1480 .init = event_trigger_init,
1481 .free = event_trigger_free,
1484 static struct event_trigger_ops *
1485 snapshot_get_trigger_ops(char *cmd, char *param)
1487 return param ? &snapshot_count_trigger_ops : &snapshot_trigger_ops;
1490 static struct event_command trigger_snapshot_cmd = {
1492 .trigger_type = ETT_SNAPSHOT,
1493 .parse = event_trigger_parse,
1494 .reg = register_snapshot_trigger,
1495 .unreg = unregister_trigger,
1496 .get_trigger_ops = snapshot_get_trigger_ops,
1497 .set_filter = set_trigger_filter,
1500 static __init int register_trigger_snapshot_cmd(void)
1504 ret = register_event_command(&trigger_snapshot_cmd);
1510 static __init int register_trigger_snapshot_cmd(void) { return 0; }
1511 #endif /* CONFIG_TRACER_SNAPSHOT */
1513 #ifdef CONFIG_STACKTRACE
1514 #ifdef CONFIG_UNWINDER_ORC
1516 * event_triggers_post_call()
1517 * trace_event_raw_event_xxx()
1519 # define STACK_SKIP 2
1523 * stacktrace_trigger()
1524 * event_triggers_post_call()
1525 * trace_event_buffer_commit()
1526 * trace_event_raw_event_xxx()
1528 #define STACK_SKIP 4
1532 stacktrace_trigger(struct event_trigger_data *data,
1533 struct trace_buffer *buffer, void *rec,
1534 struct ring_buffer_event *event)
1536 struct trace_event_file *file = data->private_data;
1539 __trace_stack(file->tr, tracing_gen_ctx(), STACK_SKIP);
1541 trace_dump_stack(STACK_SKIP);
1545 stacktrace_count_trigger(struct event_trigger_data *data,
1546 struct trace_buffer *buffer, void *rec,
1547 struct ring_buffer_event *event)
1552 if (data->count != -1)
1555 stacktrace_trigger(data, buffer, rec, event);
1559 stacktrace_trigger_print(struct seq_file *m, struct event_trigger_data *data)
1561 return event_trigger_print("stacktrace", m, (void *)data->count,
1565 static struct event_trigger_ops stacktrace_trigger_ops = {
1566 .trigger = stacktrace_trigger,
1567 .print = stacktrace_trigger_print,
1568 .init = event_trigger_init,
1569 .free = event_trigger_free,
1572 static struct event_trigger_ops stacktrace_count_trigger_ops = {
1573 .trigger = stacktrace_count_trigger,
1574 .print = stacktrace_trigger_print,
1575 .init = event_trigger_init,
1576 .free = event_trigger_free,
1579 static struct event_trigger_ops *
1580 stacktrace_get_trigger_ops(char *cmd, char *param)
1582 return param ? &stacktrace_count_trigger_ops : &stacktrace_trigger_ops;
1585 static struct event_command trigger_stacktrace_cmd = {
1586 .name = "stacktrace",
1587 .trigger_type = ETT_STACKTRACE,
1588 .flags = EVENT_CMD_FL_POST_TRIGGER,
1589 .parse = event_trigger_parse,
1590 .reg = register_trigger,
1591 .unreg = unregister_trigger,
1592 .get_trigger_ops = stacktrace_get_trigger_ops,
1593 .set_filter = set_trigger_filter,
1596 static __init int register_trigger_stacktrace_cmd(void)
1600 ret = register_event_command(&trigger_stacktrace_cmd);
1606 static __init int register_trigger_stacktrace_cmd(void) { return 0; }
1607 #endif /* CONFIG_STACKTRACE */
1609 static __init void unregister_trigger_traceon_traceoff_cmds(void)
1611 unregister_event_command(&trigger_traceon_cmd);
1612 unregister_event_command(&trigger_traceoff_cmd);
1616 event_enable_trigger(struct event_trigger_data *data,
1617 struct trace_buffer *buffer, void *rec,
1618 struct ring_buffer_event *event)
1620 struct enable_trigger_data *enable_data = data->private_data;
1622 if (enable_data->enable)
1623 clear_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &enable_data->file->flags);
1625 set_bit(EVENT_FILE_FL_SOFT_DISABLED_BIT, &enable_data->file->flags);
1629 event_enable_count_trigger(struct event_trigger_data *data,
1630 struct trace_buffer *buffer, void *rec,
1631 struct ring_buffer_event *event)
1633 struct enable_trigger_data *enable_data = data->private_data;
1638 /* Skip if the event is in a state we want to switch to */
1639 if (enable_data->enable == !(enable_data->file->flags & EVENT_FILE_FL_SOFT_DISABLED))
1642 if (data->count != -1)
1645 event_enable_trigger(data, buffer, rec, event);
1648 int event_enable_trigger_print(struct seq_file *m,
1649 struct event_trigger_data *data)
1651 struct enable_trigger_data *enable_data = data->private_data;
1653 seq_printf(m, "%s:%s:%s",
1655 (enable_data->enable ? ENABLE_HIST_STR : DISABLE_HIST_STR) :
1656 (enable_data->enable ? ENABLE_EVENT_STR : DISABLE_EVENT_STR),
1657 enable_data->file->event_call->class->system,
1658 trace_event_name(enable_data->file->event_call));
1660 if (data->count == -1)
1661 seq_puts(m, ":unlimited");
1663 seq_printf(m, ":count=%ld", data->count);
1665 if (data->filter_str)
1666 seq_printf(m, " if %s\n", data->filter_str);
1673 void event_enable_trigger_free(struct event_trigger_data *data)
1675 struct enable_trigger_data *enable_data = data->private_data;
1677 if (WARN_ON_ONCE(data->ref <= 0))
1682 /* Remove the SOFT_MODE flag */
1683 trace_event_enable_disable(enable_data->file, 0, 1);
1684 trace_event_put_ref(enable_data->file->event_call);
1685 trigger_data_free(data);
1690 static struct event_trigger_ops event_enable_trigger_ops = {
1691 .trigger = event_enable_trigger,
1692 .print = event_enable_trigger_print,
1693 .init = event_trigger_init,
1694 .free = event_enable_trigger_free,
1697 static struct event_trigger_ops event_enable_count_trigger_ops = {
1698 .trigger = event_enable_count_trigger,
1699 .print = event_enable_trigger_print,
1700 .init = event_trigger_init,
1701 .free = event_enable_trigger_free,
1704 static struct event_trigger_ops event_disable_trigger_ops = {
1705 .trigger = event_enable_trigger,
1706 .print = event_enable_trigger_print,
1707 .init = event_trigger_init,
1708 .free = event_enable_trigger_free,
1711 static struct event_trigger_ops event_disable_count_trigger_ops = {
1712 .trigger = event_enable_count_trigger,
1713 .print = event_enable_trigger_print,
1714 .init = event_trigger_init,
1715 .free = event_enable_trigger_free,
1718 int event_enable_trigger_parse(struct event_command *cmd_ops,
1719 struct trace_event_file *file,
1720 char *glob, char *cmd, char *param_and_filter)
1722 struct trace_event_file *event_enable_file;
1723 struct enable_trigger_data *enable_data;
1724 struct event_trigger_data *trigger_data;
1725 struct trace_array *tr = file->tr;
1726 char *param, *filter;
1727 bool enable, remove;
1733 remove = event_trigger_check_remove(glob);
1735 if (event_trigger_empty_param(param_and_filter))
1738 ret = event_trigger_separate_filter(param_and_filter, ¶m, &filter, true);
1742 system = strsep(¶m, ":");
1746 event = strsep(¶m, ":");
1749 event_enable_file = find_event_file(tr, system, event);
1750 if (!event_enable_file)
1753 #ifdef CONFIG_HIST_TRIGGERS
1754 hist = ((strcmp(cmd, ENABLE_HIST_STR) == 0) ||
1755 (strcmp(cmd, DISABLE_HIST_STR) == 0));
1757 enable = ((strcmp(cmd, ENABLE_EVENT_STR) == 0) ||
1758 (strcmp(cmd, ENABLE_HIST_STR) == 0));
1760 enable = strcmp(cmd, ENABLE_EVENT_STR) == 0;
1764 enable_data = kzalloc(sizeof(*enable_data), GFP_KERNEL);
1768 enable_data->hist = hist;
1769 enable_data->enable = enable;
1770 enable_data->file = event_enable_file;
1772 trigger_data = event_trigger_alloc(cmd_ops, cmd, param, enable_data);
1773 if (!trigger_data) {
1779 event_trigger_unregister(cmd_ops, file, glob+1, trigger_data);
1780 kfree(trigger_data);
1786 /* Up the trigger_data count to make sure nothing frees it on failure */
1787 event_trigger_init(trigger_data);
1789 ret = event_trigger_parse_num(param, trigger_data);
1793 ret = event_trigger_set_filter(cmd_ops, file, filter, trigger_data);
1797 /* Don't let event modules unload while probe registered */
1798 ret = trace_event_try_get_ref(event_enable_file->event_call);
1804 ret = trace_event_enable_disable(event_enable_file, 1, 1);
1808 ret = event_trigger_register(cmd_ops, file, glob, trigger_data);
1812 event_trigger_free(trigger_data);
1816 trace_event_enable_disable(event_enable_file, 0, 1);
1818 trace_event_put_ref(event_enable_file->event_call);
1820 event_trigger_reset_filter(cmd_ops, trigger_data);
1821 event_trigger_free(trigger_data);
1827 int event_enable_register_trigger(char *glob,
1828 struct event_trigger_data *data,
1829 struct trace_event_file *file)
1831 struct enable_trigger_data *enable_data = data->private_data;
1832 struct enable_trigger_data *test_enable_data;
1833 struct event_trigger_data *test;
1836 lockdep_assert_held(&event_mutex);
1838 list_for_each_entry(test, &file->triggers, list) {
1839 test_enable_data = test->private_data;
1840 if (test_enable_data &&
1841 (test->cmd_ops->trigger_type ==
1842 data->cmd_ops->trigger_type) &&
1843 (test_enable_data->file == enable_data->file)) {
1849 if (data->ops->init) {
1850 ret = data->ops->init(data);
1855 list_add_rcu(&data->list, &file->triggers);
1857 update_cond_flag(file);
1858 ret = trace_event_trigger_enable_disable(file, 1);
1860 list_del_rcu(&data->list);
1861 update_cond_flag(file);
1867 void event_enable_unregister_trigger(char *glob,
1868 struct event_trigger_data *test,
1869 struct trace_event_file *file)
1871 struct enable_trigger_data *test_enable_data = test->private_data;
1872 struct event_trigger_data *data = NULL, *iter;
1873 struct enable_trigger_data *enable_data;
1875 lockdep_assert_held(&event_mutex);
1877 list_for_each_entry(iter, &file->triggers, list) {
1878 enable_data = iter->private_data;
1880 (iter->cmd_ops->trigger_type ==
1881 test->cmd_ops->trigger_type) &&
1882 (enable_data->file == test_enable_data->file)) {
1884 list_del_rcu(&data->list);
1885 trace_event_trigger_enable_disable(file, 0);
1886 update_cond_flag(file);
1891 if (data && data->ops->free)
1892 data->ops->free(data);
1895 static struct event_trigger_ops *
1896 event_enable_get_trigger_ops(char *cmd, char *param)
1898 struct event_trigger_ops *ops;
1901 #ifdef CONFIG_HIST_TRIGGERS
1902 enable = ((strcmp(cmd, ENABLE_EVENT_STR) == 0) ||
1903 (strcmp(cmd, ENABLE_HIST_STR) == 0));
1905 enable = strcmp(cmd, ENABLE_EVENT_STR) == 0;
1908 ops = param ? &event_enable_count_trigger_ops :
1909 &event_enable_trigger_ops;
1911 ops = param ? &event_disable_count_trigger_ops :
1912 &event_disable_trigger_ops;
1917 static struct event_command trigger_enable_cmd = {
1918 .name = ENABLE_EVENT_STR,
1919 .trigger_type = ETT_EVENT_ENABLE,
1920 .parse = event_enable_trigger_parse,
1921 .reg = event_enable_register_trigger,
1922 .unreg = event_enable_unregister_trigger,
1923 .get_trigger_ops = event_enable_get_trigger_ops,
1924 .set_filter = set_trigger_filter,
1927 static struct event_command trigger_disable_cmd = {
1928 .name = DISABLE_EVENT_STR,
1929 .trigger_type = ETT_EVENT_ENABLE,
1930 .parse = event_enable_trigger_parse,
1931 .reg = event_enable_register_trigger,
1932 .unreg = event_enable_unregister_trigger,
1933 .get_trigger_ops = event_enable_get_trigger_ops,
1934 .set_filter = set_trigger_filter,
1937 static __init void unregister_trigger_enable_disable_cmds(void)
1939 unregister_event_command(&trigger_enable_cmd);
1940 unregister_event_command(&trigger_disable_cmd);
1943 static __init int register_trigger_enable_disable_cmds(void)
1947 ret = register_event_command(&trigger_enable_cmd);
1948 if (WARN_ON(ret < 0))
1950 ret = register_event_command(&trigger_disable_cmd);
1951 if (WARN_ON(ret < 0))
1952 unregister_trigger_enable_disable_cmds();
1957 static __init int register_trigger_traceon_traceoff_cmds(void)
1961 ret = register_event_command(&trigger_traceon_cmd);
1962 if (WARN_ON(ret < 0))
1964 ret = register_event_command(&trigger_traceoff_cmd);
1965 if (WARN_ON(ret < 0))
1966 unregister_trigger_traceon_traceoff_cmds();
1971 __init int register_trigger_cmds(void)
1973 register_trigger_traceon_traceoff_cmds();
1974 register_trigger_snapshot_cmd();
1975 register_trigger_stacktrace_cmd();
1976 register_trigger_enable_disable_cmds();
1977 register_trigger_hist_enable_disable_cmds();
1978 register_trigger_hist_cmd();