perf tools: Add dso__data_get/put_fd()
Using dso__data_fd() in multi-thread environment is not safe since returned fd can be closed and/or reused anytime. So convert it to the dso__data_get/put_fd() pair to protect the access with lock. The original dso__data_fd() is deprecated and kept only for testing. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/1432137821-10853-3-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:

committed by
Arnaldo Carvalho de Melo

parent
e840238d7c
commit
4bb11d012a
@@ -240,7 +240,8 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
|
||||
|
||||
/*
|
||||
* The dso__data_* external interface provides following functions:
|
||||
* dso__data_fd
|
||||
* dso__data_get_fd
|
||||
* dso__data_put_fd
|
||||
* dso__data_close
|
||||
* dso__data_size
|
||||
* dso__data_read_offset
|
||||
@@ -257,8 +258,11 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
|
||||
* The current usage of the dso__data_* interface is as follows:
|
||||
*
|
||||
* Get DSO's fd:
|
||||
* int fd = dso__data_fd(dso, machine);
|
||||
* USE 'fd' SOMEHOW
|
||||
* int fd = dso__data_get_fd(dso, machine);
|
||||
* if (fd >= 0) {
|
||||
* USE 'fd' SOMEHOW
|
||||
* dso__data_put_fd(dso);
|
||||
* }
|
||||
*
|
||||
* Read DSO's data:
|
||||
* n = dso__data_read_offset(dso_0, &machine, 0, buf, BUFSIZE);
|
||||
@@ -277,7 +281,8 @@ int __kmod_path__parse(struct kmod_path *m, const char *path,
|
||||
*
|
||||
* TODO
|
||||
*/
|
||||
int dso__data_fd(struct dso *dso, struct machine *machine);
|
||||
int dso__data_get_fd(struct dso *dso, struct machine *machine);
|
||||
void dso__data_put_fd(struct dso *dso __maybe_unused);
|
||||
void dso__data_close(struct dso *dso);
|
||||
|
||||
off_t dso__data_size(struct dso *dso, struct machine *machine);
|
||||
|
Reference in New Issue
Block a user