From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbeAPRDQ (ORCPT + 1 other); Tue, 16 Jan 2018 12:03:16 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:36564 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124AbeAPRCy (ORCPT ); Tue, 16 Jan 2018 12:02:54 -0500 X-Google-Smtp-Source: ACJfBot7Rv94bBqizCF1iJAoFiUosrDJbhNOWE5k2f1R6SuimgESs3b7ePMWxg3MD0SwQcO7weckWQ== Date: Wed, 17 Jan 2018 00:55:38 +0800 From: Wang YanQing To: Jiri Olsa Cc: acme@redhat.com, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] perf:util:dso: Using O_CLOEXEC in do_open Message-ID: <20180116165538.GB4118@udknight> Mail-Followup-To: Wang YanQing , Jiri Olsa , acme@redhat.com, peterz@infradead.org, mingo@redhat.com, alexander.shishkin@linux.intel.com, linux-kernel@vger.kernel.org References: <20180115050448.GA20759@udknight> <20180115094506.GA14646@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180115094506.GA14646@krava> User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Mon, Jan 15, 2018 at 10:45:06AM +0100, Jiri Olsa wrote: > On Mon, Jan 15, 2018 at 01:04:48PM +0800, Wang YanQing wrote: > > I meet strange behavior with below commands on my gentoo box: > > 1:perf kmem record > > 2:CTRL-C to stop 1 > > 3:perf report > > 4:"Enter", "Enter", "Run scripts for all samples", > > "event_analyzing_sample". > > > > Then perf report: > > " > > No kallsyms or vmlinux with build-id xxxx was found > > /lib/modules/4.10.0+/build/vmlinux with build id xxxx not found, > > continuing without symbols > > ". > > > > It is strange because I am sure /lib/modules/4.10.0+/build/vmlinux > > is right for perf.data. > > > > After digging, I find out the reason is "perf report" generates many > > open fds, then "script_browse" uses popen to run "perf script" which > > run out of open files. The gentoo box has a small default value for > > "max open files", 1024. Yes, "ulimit -n " with a bigger number could > > fix it, but I think that using O_CLOEXEC in do_open is a better way. > > that seems right.. so why does kmem record open those > files before calling cmd_record? should that be fixed? The problem is "perf report", isn't "perf kmem record", see the above reproduction steps again. The problem is "perf report" generates may open fds with dso:do_open for symbol analysis, and "perf report" uses popen to run another command "perf script", then the cmd "perf script" will run out of "max open files". Thanks. > > thanks, > jirka > > > > > Signed-off-by: Wang YanQing > > --- > > tools/perf/util/dso.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c > > index d5b6f7f..36ef45b 100644 > > --- a/tools/perf/util/dso.c > > +++ b/tools/perf/util/dso.c > > @@ -446,7 +446,7 @@ static int do_open(char *name) > > char sbuf[STRERR_BUFSIZE]; > > > > do { > > - fd = open(name, O_RDONLY); > > + fd = open(name, O_RDONLY|O_CLOEXEC); > > if (fd >= 0) > > return fd; > > > > -- > > 1.8.5.6.2.g3d8a54e.dirty