Re: [PATCHv2 1/2] perf tools: Collect tracing event data files directly

Steven Rostedt
2011-09-26T13:36:35Z

On Mon, 2011-09-26 at 11:11 +0200, Jiri Olsa wrote:
> Changing the way the event files are searched by quering specified
> event files directly, instead of walking the events directory.
>
> Hopefully this way is more straightforward and faster.

Have you looked at my code I posted earlier that uses the libparsevents?

It uses globs such that you could do -e sched:sched* and it will enable
all sched events.

-- Steve

> + * and one safety byte ;)
> + */
> + file = malloc_or_die(strlen(path) + strlen(sys) +
> + strlen(name) + strlen("format") + 5);
>
> - free(format);
> - }
> - closedir(dir);
> + sprintf(file, "%s/%s/%s/format", path, sys, name);
> + return file;
> }
>
> -static void read_ftrace_files(struct tracepoint_path *tps)
> +static void put_format_file(char *file)
> {
> - char *path;
> -
> - path = get_tracing_file("events/ftrace");
> -
> - copy_event_system(path, tps);
> -
> - put_tracing_file(path);
> + free(file);
> }
>
> -static bool system_in_tp_list(char *sys, struct tracepoint_path *tps)
> +/*
> + * Walk tracepoint event objects and store them.
> + * Only those matching the sys parameter are stored
> + * and marked as done.
> + */
> +static void read_event_files_system(struct tracepoint_path *tps,
> + const char *sys)
> {
> + off_t count_pos;
> + u32 count = 0;
> +
> + /* Place for number of events under single system. */
> + count_pos = lseek(output_fd, 0, SEEK_CUR);
> + write_or_die(&count, 4);
> +
> while (tps) {
> - if (!strcmp(sys, tps->system))
> - return true;
> + if ((!tps->done) &&
> + (!strcmp(sys, tps->system))) {
> + char *file;
> +
> + file = get_format_file(tps->system, tps->name);
> + if (file) {
> + record_file(file, 8);
> + count++;
> + }
> +
> + put_format_file(file);
> + tps->done = 1;
> + }
> +
> tps = tps->next;