From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752697AbcGAGs5 (ORCPT ); Fri, 1 Jul 2016 02:48:57 -0400 Received: from terminus.zytor.com ([198.137.202.10]:59842 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752400AbcGAGsz (ORCPT ); Fri, 1 Jul 2016 02:48:55 -0400 Date: Thu, 30 Jun 2016 23:48:43 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: linux-kernel@vger.kernel.org, jolsa@kernel.org, dsahern@gmail.com, namhyung@kernel.org, tglx@linutronix.de, acme@redhat.com, hpa@zytor.com, mingo@kernel.org, nilayvaish@gmail.com, a.p.zijlstra@chello.nl Reply-To: a.p.zijlstra@chello.nl, tglx@linutronix.de, mingo@kernel.org, nilayvaish@gmail.com, acme@redhat.com, hpa@zytor.com, dsahern@gmail.com, namhyung@kernel.org, jolsa@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <1467113345-12669-2-git-send-email-jolsa@kernel.org> References: <1467113345-12669-2-git-send-email-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Allow to reset open files counter Git-Commit-ID: f3069249e9e6b0ce303c3547dfa2960ee2e95b61 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f3069249e9e6b0ce303c3547dfa2960ee2e95b61 Gitweb: http://git.kernel.org/tip/f3069249e9e6b0ce303c3547dfa2960ee2e95b61 Author: Jiri Olsa AuthorDate: Tue, 28 Jun 2016 13:29:02 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 30 Jun 2016 18:27:44 -0300 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 Tested-by: Arnaldo Carvalho de Melo Tested-by: Nilay Vaish Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/1467113345-12669-2-git-send-email-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/tests/dso-data.c | 6 ++++++ tools/perf/util/dso.c | 22 ++++++++++++++++------ 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 8cf0d9e..13725e0 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) long nr_end, nr = open_files_cnt(); int dso_cnt, limit, i, fd; + /* Rest the internal dso open counter limit. */ + reset_fd_limit(); + memset(&machine, 0, sizeof(machine)); /* set as system limit */ @@ -312,6 +315,9 @@ int test__dso_data_reopen(int subtest __maybe_unused) #define dso_1 (dsos[1]) #define dso_2 (dsos[2]) + /* Rest the internal dso open counter limit. */ + reset_fd_limit(); + memset(&machine, 0, sizeof(machine)); /* diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c index 5d286f5..e1de6cc 100644 --- a/tools/perf/util/dso.c +++ b/tools/perf/util/dso.c @@ -442,17 +442,27 @@ static rlim_t get_fd_limit(void) 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) - limit = get_fd_limit(); +static bool may_cache_fd(void) +{ + if (!fd_limit) + fd_limit = get_fd_limit(); - if (limit == RLIM_INFINITY) + if (fd_limit == RLIM_INFINITY) return true; - return limit > (rlim_t) dso__data_open_cnt; + return fd_limit > (rlim_t) dso__data_open_cnt; } /* diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h index 76d79d0..a571f24 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); int dso__strerror_load(struct dso *dso, char *buf, size_t buflen); +void reset_fd_limit(void); + #endif /* __PERF_DSO */