From: Gui Jianfeng on
Gui Jianfeng wrote:
> When I ran "perf kvm ... top", I encountered the following error output.
>
> Error: perfcounter syscall returned with -1 (Too many open files)
>
> Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
>
> Looking into perf, I found perf opens too many direcotries at initialization
> time, but forgets to close them. Here is the fix.

Ping.

>
> Signed-off-by: Gui Jianfeng <guijianfeng(a)cn.fujitsu.com>
> ---
> tools/perf/util/symbol.c | 18 +++++++++++-------
> 1 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 7fd6b15..a00dcad 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1443,6 +1443,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
> {
> struct dirent *dent;
> DIR *dir = opendir(dir_name);
> + int ret = 0;
>
> if (!dir) {
> pr_debug("%s: cannot open %s dir\n", __func__, dir_name);
> @@ -1465,8 +1466,10 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
>
> snprintf(path, sizeof(path), "%s/%s",
> dir_name, dent->d_name);
> - if (map_groups__set_modules_path_dir(self, path) < 0)
> - goto failure;
> + if (map_groups__set_modules_path_dir(self, path) < 0) {
> + ret = -1;
> + goto out;
> + }
> } else {
> char *dot = strrchr(dent->d_name, '.'),
> dso_name[PATH_MAX];
> @@ -1487,17 +1490,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
> dir_name, dent->d_name);
>
> long_name = strdup(path);
> - if (long_name == NULL)
> - goto failure;
> + if (long_name == NULL) {
> + ret = -1;
> + goto out;
> + }
> dso__set_long_name(map->dso, long_name);
> dso__kernel_module_get_build_id(map->dso, "");
> }
> }
>
> - return 0;
> -failure:
> +out:
> closedir(dir);
> - return -1;
> + return ret;
> }
>
> static char *get_kernel_version(const char *root_dir)

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Zhang, Yanmin on
On Sat, 2010-06-19 at 11:54 +0800, Gui Jianfeng wrote:
> When I ran "perf kvm ... top", I encountered the following error output.
>
> Error: perfcounter syscall returned with -1 (Too many open files)
>
> Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
>
> Looking into perf, I found perf opens too many direcotries at initialization
> time, but forgets to close them. Here is the fix.
Good catch!

>
> Signed-off-by: Gui Jianfeng <guijianfeng(a)cn.fujitsu.com>
> ---
> tools/perf/util/symbol.c | 18 +++++++++++-------
> 1 files changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
> index 7fd6b15..a00dcad 100644
> --- a/tools/perf/util/symbol.c
> +++ b/tools/perf/util/symbol.c
> @@ -1443,6 +1443,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
> {
> struct dirent *dent;
> DIR *dir = opendir(dir_name);
> + int ret = 0;
>
> if (!dir) {
> pr_debug("%s: cannot open %s dir\n", __func__, dir_name);
> @@ -1465,8 +1466,10 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
>
> snprintf(path, sizeof(path), "%s/%s",
> dir_name, dent->d_name);
> - if (map_groups__set_modules_path_dir(self, path) < 0)
> - goto failure;
> + if (map_groups__set_modules_path_dir(self, path) < 0) {
> + ret = -1;
> + goto out;
> + }
How about changing above to:
ret = map_groups__set_modules_path_dir(self, path);
if (ret < 0)
goto out;



> } else {
> char *dot = strrchr(dent->d_name, '.'),
> dso_name[PATH_MAX];
> @@ -1487,17 +1490,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
> dir_name, dent->d_name);
>
> long_name = strdup(path);
> - if (long_name == NULL)
> - goto failure;
> + if (long_name == NULL) {
> + ret = -1;
> + goto out;
> + }
> dso__set_long_name(map->dso, long_name);
> dso__kernel_module_get_build_id(map->dso, "");
> }
> }
>
> - return 0;
> -failure:
> +out:
> closedir(dir);
> - return -1;
> + return ret;
> }
>
> static char *get_kernel_version(const char *root_dir)


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Gui Jianfeng on
Zhang, Yanmin wrote:
> On Sat, 2010-06-19 at 11:54 +0800, Gui Jianfeng wrote:
>> When I ran "perf kvm ... top", I encountered the following error output.
>>
>> Error: perfcounter syscall returned with -1 (Too many open files)
>>
>> Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
>>
>> Looking into perf, I found perf opens too many direcotries at initialization
>> time, but forgets to close them. Here is the fix.
> Good catch!
>
>> Signed-off-by: Gui Jianfeng <guijianfeng(a)cn.fujitsu.com>
>> ---
>> tools/perf/util/symbol.c | 18 +++++++++++-------
>> 1 files changed, 11 insertions(+), 7 deletions(-)
>>
>> diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
>> index 7fd6b15..a00dcad 100644
>> --- a/tools/perf/util/symbol.c
>> +++ b/tools/perf/util/symbol.c
>> @@ -1443,6 +1443,7 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
>> {
>> struct dirent *dent;
>> DIR *dir = opendir(dir_name);
>> + int ret = 0;
>>
>> if (!dir) {
>> pr_debug("%s: cannot open %s dir\n", __func__, dir_name);
>> @@ -1465,8 +1466,10 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
>>
>> snprintf(path, sizeof(path), "%s/%s",
>> dir_name, dent->d_name);
>> - if (map_groups__set_modules_path_dir(self, path) < 0)
>> - goto failure;
>> + if (map_groups__set_modules_path_dir(self, path) < 0) {
>> + ret = -1;
>> + goto out;
>> + }
> How about changing above to:
> ret = map_groups__set_modules_path_dir(self, path);
> if (ret < 0)
> goto out;

Sure, will change.

Thanks,
Gui

>
>
>
>> } else {
>> char *dot = strrchr(dent->d_name, '.'),
>> dso_name[PATH_MAX];
>> @@ -1487,17 +1490,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self,
>> dir_name, dent->d_name);
>>
>> long_name = strdup(path);
>> - if (long_name == NULL)
>> - goto failure;
>> + if (long_name == NULL) {
>> + ret = -1;
>> + goto out;
>> + }
>> dso__set_long_name(map->dso, long_name);
>> dso__kernel_module_get_build_id(map->dso, "");
>> }
>> }
>>
>> - return 0;
>> -failure:
>> +out:
>> closedir(dir);
>> - return -1;
>> + return ret;
>> }
>>
>> static char *get_kernel_version(const char *root_dir)
>
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Peter Zijlstra on
On Thu, 2010-06-24 at 15:04 +0800, Gui Jianfeng wrote:
> When I ran "perf kvm ... top", I encountered the following error output.
>
> Error: perfcounter syscall returned with -1 (Too many open files)
>
> Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
>
> Looking into perf, I found perf opens too many direcotries at initialization
> time, but forgets to close them. Here is the fix.
>
> Signef-off-by: Gui Jianfeng <guijianfeng(a)cn.fujitsu.com>

Looks good to me, Arnaldo, will you pick this up?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
From: Arnaldo Carvalho de Melo on
Em Thu, Jun 24, 2010 at 03:04:02PM +0800, Gui Jianfeng escreveu:
> When I ran "perf kvm ... top", I encountered the following error output.
>
> Error: perfcounter syscall returned with -1 (Too many open files)
>
> Fatal: No CONFIG_PERF_EVENTS=y kernel support configured?
>
> Looking into perf, I found perf opens too many direcotries at initialization
> time, but forgets to close them. Here is the fix.
>
> Signef-off-by: Gui Jianfeng <guijianfeng(a)cn.fujitsu.com>

Thanks, will apply.

- Arnaldo
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo(a)vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/