Commit f3069249 authored by Jiri Olsa's avatar Jiri Olsa Committed by Arnaldo Carvalho de Melo

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: default avatarJiri Olsa <jolsa@kernel.org>
Tested-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: default avatarNilay 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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 3be28870
...@@ -251,6 +251,9 @@ int test__dso_data_cache(int subtest __maybe_unused) ...@@ -251,6 +251,9 @@ int test__dso_data_cache(int subtest __maybe_unused)
long nr_end, nr = open_files_cnt(); long nr_end, nr = open_files_cnt();
int dso_cnt, limit, i, fd; int dso_cnt, limit, i, fd;
/* Rest the internal dso open counter limit. */
reset_fd_limit();
memset(&machine, 0, sizeof(machine)); memset(&machine, 0, sizeof(machine));
/* set as system limit */ /* set as system limit */
...@@ -312,6 +315,9 @@ int test__dso_data_reopen(int subtest __maybe_unused) ...@@ -312,6 +315,9 @@ int test__dso_data_reopen(int subtest __maybe_unused)
#define dso_1 (dsos[1]) #define dso_1 (dsos[1])
#define dso_2 (dsos[2]) #define dso_2 (dsos[2])
/* Rest the internal dso open counter limit. */
reset_fd_limit();
memset(&machine, 0, sizeof(machine)); memset(&machine, 0, sizeof(machine));
/* /*
......
...@@ -442,17 +442,27 @@ static rlim_t get_fd_limit(void) ...@@ -442,17 +442,27 @@ static rlim_t get_fd_limit(void)
return limit; return limit;
} }
static bool may_cache_fd(void) static rlim_t fd_limit;
/*
* Used only by tests/dso-data.c to reset the environment
* for tests. I dont expect we should change this during
* standard runtime.
*/
void reset_fd_limit(void)
{ {
static rlim_t limit; fd_limit = 0;
}
if (!limit) static bool may_cache_fd(void)
limit = get_fd_limit(); {
if (!fd_limit)
fd_limit = get_fd_limit();
if (limit == RLIM_INFINITY) if (fd_limit == RLIM_INFINITY)
return true; return true;
return limit > (rlim_t) dso__data_open_cnt; return fd_limit > (rlim_t) dso__data_open_cnt;
} }
/* /*
......
...@@ -360,4 +360,6 @@ enum dso_type dso__type(struct dso *dso, struct machine *machine); ...@@ -360,4 +360,6 @@ enum dso_type dso__type(struct dso *dso, struct machine *machine);
int dso__strerror_load(struct dso *dso, char *buf, size_t buflen); int dso__strerror_load(struct dso *dso, char *buf, size_t buflen);
void reset_fd_limit(void);
#endif /* __PERF_DSO */ #endif /* __PERF_DSO */
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