diff options
author | Jiri Olsa <jolsa@kernel.org> | 2016-06-28 07:29:02 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2016-06-30 17:27:44 -0400 |
commit | f3069249e9e6b0ce303c3547dfa2960ee2e95b61 (patch) | |
tree | bfbcc640021817450bdf555d13e27bf1bbf72ce0 /tools/perf | |
parent | 3be28870c05ad09dfff4dbefe71b02aba5dba569 (diff) |
perf tools: Allow to reset open files counter
I hit a bug when running test suite without forking
each test (-F option):
$ perf test -F dso
8: Test dso data read : Ok
9: Test dso data cache : FAILED!
10: Test dso data reopen : FAILED!
The reason the session file limit is set just once for
perf process so we need to reset it for each test,
otherwise wrong limit is taken into account.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Nilay Vaish <nilayvaish@gmail.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1467113345-12669-2-git-send-email-jolsa@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/tests/dso-data.c | 6 | ||||
-rw-r--r-- | tools/perf/util/dso.c | 22 | ||||
-rw-r--r-- | tools/perf/util/dso.h | 2 |
3 files changed, 24 insertions, 6 deletions
diff --git a/tools/perf/tests/dso-data.c b/tools/perf/tests/dso-data.c index 8cf0d9e189a8..13725e09ba22 100644 --- a/tools/perf/tests/dso-data.c +++ b/tools/perf/tests/dso-data.c | |||
@@ -251,6 +251,9 @@ int test__dso_data_cache(int subtest __maybe_unused) | |||
251 | long nr_end, nr = open_files_cnt(); | 251 | long nr_end, nr = open_files_cnt(); |
252 | int dso_cnt, limit, i, fd; | 252 | int dso_cnt, limit, i, fd; |
253 | 253 | ||
254 | /* Rest the internal dso open counter limit. */ | ||
255 | reset_fd_limit(); | ||
256 | |||
254 | memset(&machine, 0, sizeof(machine)); | 257 | memset(&machine, 0, sizeof(machine)); |
255 | 258 | ||
256 | /* set as system limit */ | 259 | /* set as system limit */ |
@@ -312,6 +315,9 @@ int test__dso_data_reopen(int subtest __maybe_unused) | |||
312 | #define dso_1 (dsos[1]) | 315 | #define dso_1 (dsos[1]) |
313 | #define dso_2 (dsos[2]) | 316 | #define dso_2 (dsos[2]) |
314 | 317 | ||
318 | /* Rest the internal dso open counter limit. */ | ||
319 | reset_fd_limit(); | ||
320 | |||
315 | memset(&machine, 0, sizeof(machine)); | 321 | memset(&machine, 0, sizeof(machine)); |
316 | 322 | ||
317 | /* | 323 | /* |
diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 5d286f5d7906..e1de6cc4863e 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c | |||
@@ -442,17 +442,27 @@ static rlim_t get_fd_limit(void) | |||
442 | return limit; | 442 | return limit; |
443 | } | 443 | } |
444 | 444 | ||
445 | static bool may_cache_fd(void) | 445 | static rlim_t fd_limit; |
446 | |||
447 | /* | ||
448 | * Used only by tests/dso-data.c to reset the environment | ||
449 | * for tests. I dont expect we should change this during | ||
450 | * standard runtime. | ||
451 | */ | ||
452 | void reset_fd_limit(void) | ||
446 | { | 453 | { |
447 | static rlim_t limit; | 454 | fd_limit = 0; |
455 | } | ||
448 | 456 | ||
449 | if (!limit) | 457 | static bool may_cache_fd(void) |
450 | limit = get_fd_limit(); | 458 | { |
459 | if (!fd_limit) | ||
460 | fd_limit = get_fd_limit(); | ||
451 | 461 | ||
452 | if (limit == RLIM_INFINITY) | 462 | if (fd_limit == RLIM_INFINITY) |
453 | return true; | 463 | return true; |
454 | 464 | ||
455 | return limit > (rlim_t) dso__data_open_cnt; | 465 | return fd_limit > (rlim_t) dso__data_open_cnt; |
456 | } | 466 | } |
457 | 467 | ||
458 | /* | 468 | /* |
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 76d79d070e21..a571f24895ca 100644 --- a/tools/perf/util/dso.h +++ b/tools/perf/util/dso.h | |||
@@ -360,4 +360,6 @@ enum dso_type dso__type(struct dso *dso, struct machine *machine); | |||
360 | 360 | ||
361 | int dso__strerror_load(struct dso *dso, char *buf, size_t buflen); | 361 | int dso__strerror_load(struct dso *dso, char *buf, size_t buflen); |
362 | 362 | ||
363 | void reset_fd_limit(void); | ||
364 | |||
363 | #endif /* __PERF_DSO */ | 365 | #endif /* __PERF_DSO */ |