From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a706o-0003I4-2q for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a706i-0003nW-BB for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:06 -0500 Received: from e06smtp06.uk.ibm.com ([195.75.94.102]:43583) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a706i-0003n8-1R for qemu-devel@nongnu.org; Thu, 10 Dec 2015 07:14:00 -0500 Received: from localhost by e06smtp06.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 10 Dec 2015 12:13:59 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 9ADFE1B08076 for ; Thu, 10 Dec 2015 12:14:25 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBACDtRg9699822 for ; Thu, 10 Dec 2015 12:13:55 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBACDsro025207 for ; Thu, 10 Dec 2015 05:13:55 -0700 From: Janosch Frank Date: Thu, 10 Dec 2015 13:12:44 +0100 Message-Id: <1449749584-23214-15-git-send-email-frankja@linux.vnet.ibm.com> In-Reply-To: <1449749584-23214-1-git-send-email-frankja@linux.vnet.ibm.com> References: <1449749584-23214-1-git-send-email-frankja@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 14/34] scripts/kvm/kvm_stat: Set sensible no. files rlimit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: cornelia.huck@de.ibm.com, frankja@linux.vnet.ibm.com As num cpus * 1000 is NOT a sensible rlimit, we need to calculate a more accurate rlimit. The number of open files is directly dependent on the cpu count and on the number of trace points per cpu. A additional constant works as a buffer for files that are needed by python or do get opened when the script runs. Hence we have: cpus * traces + constant Reviewed-by: Jason J. Herne --- scripts/kvm/kvm_stat | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/scripts/kvm/kvm_stat b/scripts/kvm/kvm_stat index 62ca853..b8c2a8f 100755 --- a/scripts/kvm/kvm_stat +++ b/scripts/kvm/kvm_stat @@ -395,8 +395,15 @@ class TracepointProvider(object): def _setup(self, _fields): self._fields = _fields cpus = self._online_cpus() - nfiles = len(cpus) * 1000 - resource.setrlimit(resource.RLIMIT_NOFILE, (nfiles, nfiles)) + + # The constant is needed as a buffer for python libs, std + # streams and other files that the script opens. + rlimit = len(cpus) * len(_fields) + 50 + try: + resource.setrlimit(resource.RLIMIT_NOFILE, (rlimit, rlimit)) + except ValueError: + sys.exit("NOFILE rlimit could not be raised to {0}".format(rlimit)) + events = [] self.group_leaders = [] for cpu in cpus: -- 2.3.0