Lines Matching +full:current +full:- +full:path
1 // SPDX-License-Identifier: GPL-2.0
3 * in kernel monitor support: allows rv to control in-kernel monitors.
28 * __ikm_read_enable - reads monitor's enable status
32 * Returns the current status, or -1 if the monitor does not exist,
37 char path[MAX_PATH];
41 snprintf(path, MAX_PATH, "rv/monitors/%s/enable", monitor_name);
43 retval = tracefs_instance_file_read_number(NULL, path, &enabled);
45 return -1;
51 * __ikm_find_monitor - find the full name of a possibly nested module
55 * Returns 1 if we found the monitor, -1 on error and 0 if it does not exist.
67 return -1;
78 out_name[2 * MAX_DA_NAME_LEN - 1] = '\0';
81 out_name[colon - line] = '/';
98 * ikm_read_enable - reads monitor's enable status
100 * Returns the current status, or -1 on error.
109 return -1;
118 * ikm_write_enable - write to the monitor's enable file
120 * Return the number of bytes written, -1 on error.
124 char path[MAX_PATH];
129 snprintf(path, MAX_PATH, "rv/monitors/%s/enable", monitor_name);
130 retval = tracefs_instance_file_write(NULL, path, enable_disable);
133 return -1;
140 * ikm_enable - enable a monitor
142 * Returns -1 on failure. Success otherwise.
150 * ikm_disable - disable a monitor
152 * Returns -1 on failure. Success otherwise.
160 * ikm_read_desc - read monitors' description
167 char path[MAX_PATH];
170 snprintf(path, MAX_PATH, "rv/monitors/%s/desc", monitor_name);
171 desc = tracefs_instance_file_read(NULL, path, NULL);
183 * ikm_fill_monitor_definition - fill monitor's definition
185 * Returns -1 on error, 1 if the monitor does not belong in the container, 0 otherwise.
204 ikm->nested = 1;
209 ikm->nested = 0;
215 return -1;
221 return -1;
224 strncpy(ikm->name, nested_name, sizeof(ikm->name) - 1);
225 ikm->name[sizeof(ikm->name) - 1] = '\0';
226 ikm->enabled = enabled;
227 strncpy(ikm->desc, desc, sizeof(ikm->desc) - 1);
228 ikm->desc[sizeof(ikm->desc) - 1] = '\0';
235 * ikm_write_reactor - switch the reactor to *reactor
237 * Return the number or characters written, -1 on error.
241 char path[MAX_PATH];
244 snprintf(path, MAX_PATH, "rv/monitors/%s/reactors", monitor_name);
245 retval = tracefs_instance_file_write(NULL, path, reactor);
252 * ikm_read_reactor - read the reactors file
259 char path[MAX_PATH];
262 snprintf(path, MAX_PATH, "rv/monitors/%s/reactors", monitor_name);
263 reactors = tracefs_instance_file_read(NULL, path, NULL);
273 * ikm_get_current_reactor - get the current enabled reactor
278 * Returns a dynamically allocated memory with the current
308 debug_msg("ikm: read current reactor %s\n", curr_reactor);
318 char path[MAX_PATH];
322 snprintf(path, MAX_PATH, "events/rv/event_%s/format", monitor_name);
323 format = tracefs_instance_file_read(NULL, path, NULL);
326 return -1;
329 /* print fmt: "%d: %s x %s -> %s %s", REC->id, ... */
330 has_id = !!strstr(format, "REC->id");
340 * ikm_list_monitors - list all available monitors
342 * Returns 0 on success, -1 otherwise.
355 return -1;
371 printf("%s%-*s %s %s\n", indent ? " - " : "",
372 indent ? MAX_DA_NAME_LEN - 3 : MAX_DA_NAME_LEN,
381 printf("-- No monitor found in container %s --\n", container);
383 printf("-- No monitor found --\n");
393 trace_seq_printf(s, "%16s-%-8s %5s %5s ", "<TASK>", "PID", "[CPU]", "TYPE");
397 trace_seq_printf(s, "%24s x %-24s -> %-24s %s\n",
403 trace_seq_printf(s, "%16s %-8s %5s %5s ", " | ", " | ", " | ", " | ");
408 trace_seq_printf(s, "%24s %-24s %-24s %s\n",
417 * ikm_event_handler - callback to handle event events
444 tep_print_event(trace_event->tep, s, record, "%16s-%-8d [%.3d] ",
448 tep_print_event(trace_event->tep, s, record, "%s ", TEP_PRINT_NAME);
454 /* placeholder if we are dealing with a mixed-type container*/
465 trace_seq_printf(s, "%24s x %-24s -> %-24s %s\n",
478 * ikm_error_handler - callback to handle error events
488 int cpu = record->cpu;
506 tep_print_event(trace_event->tep, s, record, "%s ", TEP_PRINT_NAME);
512 /* placeholder if we are dealing with a mixed-type container*/
535 retval = tracefs_event_enable(inst->inst, "rv", event);
537 return -1;
539 tep_register_event_handler(inst->tep, -1, "rv", event,
543 retval = tracefs_event_enable(inst->inst, "rv", event);
545 return -1;
547 tep_register_event_handler(inst->tep, -1, "rv", event,
553 return -1;
570 return -1;
576 if (ep->d_type != DT_DIR || ep->d_name[0] == '.')
578 retval = ikm_enable_trace_events(ep->d_name, inst);
588 * ikm_setup_trace_instance - set up a tracing instance to collect data
621 tracefs_trace_on(inst->inst);
634 * ikm_destroy_trace_instance - destroy a previously created instance
646 * ikm_usage_print_reactors - print all available reactors, one per line.
673 * ikm_usage - print usage
684 " -h/--help: print this menu and the reactor list",
685 " -r/--reactor 'reactor': enables the 'reactor'",
686 " -s/--self: when tracing (-t), also trace rv command",
687 " -t/--trace: trace monitor's event",
688 " -v/--verbose: print debug messages",
699 fprintf(stderr, "\n usage: rv mon %s [-h] [-q] [-r reactor] [-s] [-v]", monitor_name);
709 * parse_arguments - parse arguments and set config
733 if (c == -1)
744 config_my_pid = -1;
759 "ikm: failed to read current reactor, are reactors enabled?");
774 * ikm_run_monitor - apply configs and run the monitor
777 * monitors were found, or -1 on error.
796 return -1;
801 err_msg("ikm: monitor %s (in-kernel) is already enabled\n", nested_name);
802 return -1;
821 ikm_print_header(inst->seq);
825 retval = tracefs_iterate_raw_events(inst->tep,
826 inst->inst,
852 return -1;