perf trace: Rename thread_thread->paths to thread_trace->files

So that we can add more per file attributes besides the pathname, such
as which ioctl beautifier to use, for cases such as the sound and
usbdeffs ioctls, that both use the 'U' command, so we have to
differentiate at the major number for the device file.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-1895cmhrdz2dkl5prf2cj2yj@git.kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 61f61159
...@@ -957,6 +957,10 @@ static size_t fprintf_duration(unsigned long t, bool calculated, FILE *fp) ...@@ -957,6 +957,10 @@ static size_t fprintf_duration(unsigned long t, bool calculated, FILE *fp)
return printed + fprintf(fp, "): "); return printed + fprintf(fp, "): ");
} }
struct file {
char *pathname;
};
/** /**
* filename.ptr: The filename char pointer that will be vfs_getname'd * filename.ptr: The filename char pointer that will be vfs_getname'd
* filename.entry_str_pos: Where to insert the string translated from * filename.entry_str_pos: Where to insert the string translated from
...@@ -981,8 +985,8 @@ struct thread_trace { ...@@ -981,8 +985,8 @@ struct thread_trace {
} filename; } filename;
struct { struct {
int max; int max;
char **table; struct file *table;
} paths; } files;
struct intlist *syscall_stats; struct intlist *syscall_stats;
}; };
...@@ -992,7 +996,7 @@ static struct thread_trace *thread_trace__new(void) ...@@ -992,7 +996,7 @@ static struct thread_trace *thread_trace__new(void)
struct thread_trace *ttrace = zalloc(sizeof(struct thread_trace)); struct thread_trace *ttrace = zalloc(sizeof(struct thread_trace));
if (ttrace) if (ttrace)
ttrace->paths.max = -1; ttrace->files.max = -1;
ttrace->syscall_stats = intlist__new(NULL); ttrace->syscall_stats = intlist__new(NULL);
...@@ -1040,26 +1044,26 @@ static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pat ...@@ -1040,26 +1044,26 @@ static int trace__set_fd_pathname(struct thread *thread, int fd, const char *pat
{ {
struct thread_trace *ttrace = thread__priv(thread); struct thread_trace *ttrace = thread__priv(thread);
if (fd > ttrace->paths.max) { if (fd > ttrace->files.max) {
char **npath = realloc(ttrace->paths.table, (fd + 1) * sizeof(char *)); struct file *nfiles = realloc(ttrace->files.table, (fd + 1) * sizeof(struct file));
if (npath == NULL) if (nfiles == NULL)
return -1; return -1;
if (ttrace->paths.max != -1) { if (ttrace->files.max != -1) {
memset(npath + ttrace->paths.max + 1, 0, memset(nfiles + ttrace->files.max + 1, 0,
(fd - ttrace->paths.max) * sizeof(char *)); (fd - ttrace->files.max) * sizeof(struct file));
} else { } else {
memset(npath, 0, (fd + 1) * sizeof(char *)); memset(nfiles, 0, (fd + 1) * sizeof(struct file));
} }
ttrace->paths.table = npath; ttrace->files.table = nfiles;
ttrace->paths.max = fd; ttrace->files.max = fd;
} }
ttrace->paths.table[fd] = strdup(pathname); ttrace->files.table[fd].pathname = strdup(pathname);
return ttrace->paths.table[fd] != NULL ? 0 : -1; return ttrace->files.table[fd].pathname != NULL ? 0 : -1;
} }
static int thread__read_fd_path(struct thread *thread, int fd) static int thread__read_fd_path(struct thread *thread, int fd)
...@@ -1099,7 +1103,7 @@ static const char *thread__fd_path(struct thread *thread, int fd, ...@@ -1099,7 +1103,7 @@ static const char *thread__fd_path(struct thread *thread, int fd,
if (fd < 0) if (fd < 0)
return NULL; return NULL;
if ((fd > ttrace->paths.max || ttrace->paths.table[fd] == NULL)) { if ((fd > ttrace->files.max || ttrace->files.table[fd].pathname == NULL)) {
if (!trace->live) if (!trace->live)
return NULL; return NULL;
++trace->stats.proc_getname; ++trace->stats.proc_getname;
...@@ -1107,7 +1111,7 @@ static const char *thread__fd_path(struct thread *thread, int fd, ...@@ -1107,7 +1111,7 @@ static const char *thread__fd_path(struct thread *thread, int fd,
return NULL; return NULL;
} }
return ttrace->paths.table[fd]; return ttrace->files.table[fd].pathname;
} }
size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg) size_t syscall_arg__scnprintf_fd(char *bf, size_t size, struct syscall_arg *arg)
...@@ -1146,8 +1150,8 @@ static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size, ...@@ -1146,8 +1150,8 @@ static size_t syscall_arg__scnprintf_close_fd(char *bf, size_t size,
size_t printed = syscall_arg__scnprintf_fd(bf, size, arg); size_t printed = syscall_arg__scnprintf_fd(bf, size, arg);
struct thread_trace *ttrace = thread__priv(arg->thread); struct thread_trace *ttrace = thread__priv(arg->thread);
if (ttrace && fd >= 0 && fd <= ttrace->paths.max) if (ttrace && fd >= 0 && fd <= ttrace->files.max)
zfree(&ttrace->paths.table[fd]); zfree(&ttrace->files.table[fd].pathname);
return printed; return printed;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment