Skip to contentSkip to conversation

perf: close the opened directories.

PATCH Superseded Gui Jianfeng 4 participants 10 messages Jun 19, 2010 – Jul 17, 2010 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: close the opened directories.

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.

---
 tools/perf/util/symbol.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +11 -7
index 7fd6b15..a00dcad 100644
@@ -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)
Signature · 1 line
1.6.5.2
#1 lore raw
Quoted 8 lines · Gui Jianfeng

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.

Quoted 55 lines
---
 tools/perf/util/symbol.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +11 -7
index 7fd6b15..a00dcad 100644
@@ -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)
#2 lore raw
In reply to Gui Jianfeng
Quoted 8 lines · Gui Jianfeng

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!

Quoted 19 lines
---
 tools/perf/util/symbol.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +1 -0
index 7fd6b15..a00dcad 100644
@@ -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);

tools/perf/util/symbol.c static int map_groups__set_modules_path_dir(struct map_groups *self, · line 1472

Quoted 9 lines
tools/perf/util/symbol.c +4 -2
@@ -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;
Quoted 27 lines
tools/perf/util/symbol.c +6 -5
 		} 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)
#3 lore raw
Quoted 39 lines · Yanmin
Quoted 8 lines · Gui Jianfeng

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!

Quoted 18 lines
---
 tools/perf/util/symbol.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +1 -0
index 7fd6b15..a00dcad 100644
@@ -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);

tools/perf/util/symbol.c static int map_groups__set_modules_path_dir(struct map_groups *self, · line 1472

Quoted 9 lines
tools/perf/util/symbol.c +4 -2
@@ -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:

Quoted 3 lines
			ret = map_groups__set_modules_path_dir(self, path);
			if (ret < 0)
				goto out;

Sure, will change.

Thanks,
Gui

Quoted 34 lines
Quoted 30 lines
tools/perf/util/symbol.c +6 -5
 		} 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)
#4 lore raw

PATCH v2 1/1 perf: close the opened directories.

In reply to Zhang, Yanmin

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.

---
 tools/perf/util/symbol.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +10 -7
index 7fd6b15..3609a20 100644
@@ -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,9 @@ 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;
+			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 +1489,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)
Signature · 1 line
1.6.5.2
maintainer
#5 lore raw
Quoted 10 lines · Gui Jianfeng

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.

Looks good to me, Arnaldo, will you pick this up?

#6 lore raw
In reply to Gui Jianfeng

Em Thu, Jun 24, 2010 at 03:04:02PM +0800, Gui Jianfeng escreveu:

Quoted 10 lines

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.

Thanks, will apply.

- Arnaldo

#7 lore raw
Quoted 5 lines · Arnaldo Carvalho de Melo

Em Thu, Jun 24, 2010 at 03:04:02PM +0800, Gui Jianfeng escreveu:

Quoted 4 lines

When I ran "perf kvm ... top", I encountered the following error output.

Error: perfcounter syscall returned with -1 (Too many open files)

Quoted 8 lines
Quoted 6 lines

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.

Thanks, will apply.

Hi Arnaldo,

Would you pick up this fix?

Thanks,
Gui

Quoted 4 lines

- Arnaldo

#8 lore raw

Em Fri, Jul 16, 2010 at 03:37:07PM +0800, Gui Jianfeng escreveu:

Quoted 11 lines
Quoted 10 lines · Arnaldo Carvalho de Melo

Em Thu, Jun 24, 2010 at 03:04:02PM +0800, Gui Jianfeng escreveu:

Quoted 9 lines

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.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Thanks, will apply.

Hi Arnaldo,

Would you pick up this fix?

It was already, no? Nope, I thought about that other one about . and .., will apply.

- Arnaldo

#9 lore raw

[tip:perf/urgent] perf symbols: Fix directory descriptor leaking

In reply to Gui Jianfeng
Commit-ID:  74534341c1214ac5993904680616afe698dde3b6
Gitweb:     http://git.kernel.org/tip/74534341c1214ac5993904680616afe698dde3b6
Author:     Gui Jianfeng <[email protected]>
AuthorDate: Thu, 24 Jun 2010 15:04:02 +0800
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 16 Jul 2010 14:16:47 -0300

perf symbols: Fix directory descriptor leaking

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 directories at initialization time, but forgets to close them. Here is the fix.

LKML-Reference: <[email protected]>

---
 tools/perf/util/symbol.c |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)
tools/perf/util/symbol.c +10 -7
index b63e571..5b27683 100644
@@ -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,9 @@ 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;
+			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 +1489,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)