perf trace: Associate vfs_getname()'ed pathname with fd returned from 'openat'
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 2 Aug 2018 13:30:08 +0000 (10:30 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 2 Aug 2018 13:30:08 +0000 (10:30 -0300)
commit6a648b534d3d4f6532241fd9b97c0dab7b0c3f89
tree85d2a1d6bcb51bee3b7ccebd0a3d2d6cfc39eae8
parentec2cb7a526d49b65576301e183448fb51ee543a6
perf trace: Associate vfs_getname()'ed pathname with fd returned from 'openat'

When the vfs_getname() wannabe tracepoint is in place:

  # perf probe -l
    probe:vfs_getname    (on getname_flags:73@acme/git/linux/fs/namei.c with pathname)
  #

'perf trace' will use it to get the pathname when it is copied from
userspace to the kernel, right after syscalls:sys_enter_open, copied
in the 'probe:vfs_getname', stash it somewhere and then, at
syscalls:sys_exit_open time, if the 'open' return is not -1, i.e. a
successfull open syscall, associate that pathname to this return, i.e.
the fd.

We were not doing this for the 'openat' syscall, which would cause 'perf
trace' to fallback to using /proc to get the fd, change it so that we
use what we got from probe:vfs_getname, reducing the 'openat'
beautification process cost, ditching the syscalls performed to read
procfs state and avoiding some possible races in the process.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-xnp44ao3bkb6ejeczxfnjwsh@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-trace.c