diff options
author | Gui Jianfeng <guijianfeng@cn.fujitsu.com> | 2010-06-24 03:04:02 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-07-16 13:16:47 -0400 |
commit | 74534341c1214ac5993904680616afe698dde3b6 (patch) | |
tree | 6126c003df7ab245b5a90f677b5206930e074cf7 | |
parent | 58c3439083f8fde61de842c93d1407f0f881cd92 (diff) |
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: <4C230362.5080704@cn.fujitsu.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Gui Jianfeng <guijianfeng@cn.fujitsu.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/symbol.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c index b63e5713849f..5b276833e2bf 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, | |||
1443 | { | 1443 | { |
1444 | struct dirent *dent; | 1444 | struct dirent *dent; |
1445 | DIR *dir = opendir(dir_name); | 1445 | DIR *dir = opendir(dir_name); |
1446 | int ret = 0; | ||
1446 | 1447 | ||
1447 | if (!dir) { | 1448 | if (!dir) { |
1448 | pr_debug("%s: cannot open %s dir\n", __func__, dir_name); | 1449 | 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, | |||
1465 | 1466 | ||
1466 | snprintf(path, sizeof(path), "%s/%s", | 1467 | snprintf(path, sizeof(path), "%s/%s", |
1467 | dir_name, dent->d_name); | 1468 | dir_name, dent->d_name); |
1468 | if (map_groups__set_modules_path_dir(self, path) < 0) | 1469 | ret = map_groups__set_modules_path_dir(self, path); |
1469 | goto failure; | 1470 | if (ret < 0) |
1471 | goto out; | ||
1470 | } else { | 1472 | } else { |
1471 | char *dot = strrchr(dent->d_name, '.'), | 1473 | char *dot = strrchr(dent->d_name, '.'), |
1472 | dso_name[PATH_MAX]; | 1474 | dso_name[PATH_MAX]; |
@@ -1487,17 +1489,18 @@ static int map_groups__set_modules_path_dir(struct map_groups *self, | |||
1487 | dir_name, dent->d_name); | 1489 | dir_name, dent->d_name); |
1488 | 1490 | ||
1489 | long_name = strdup(path); | 1491 | long_name = strdup(path); |
1490 | if (long_name == NULL) | 1492 | if (long_name == NULL) { |
1491 | goto failure; | 1493 | ret = -1; |
1494 | goto out; | ||
1495 | } | ||
1492 | dso__set_long_name(map->dso, long_name); | 1496 | dso__set_long_name(map->dso, long_name); |
1493 | dso__kernel_module_get_build_id(map->dso, ""); | 1497 | dso__kernel_module_get_build_id(map->dso, ""); |
1494 | } | 1498 | } |
1495 | } | 1499 | } |
1496 | 1500 | ||
1497 | return 0; | 1501 | out: |
1498 | failure: | ||
1499 | closedir(dir); | 1502 | closedir(dir); |
1500 | return -1; | 1503 | return ret; |
1501 | } | 1504 | } |
1502 | 1505 | ||
1503 | static char *get_kernel_version(const char *root_dir) | 1506 | static char *get_kernel_version(const char *root_dir) |