summaryrefslogtreecommitdiffstats
path: root/tools/perf/util/data.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:35:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 17:39:31 +0000
commit85c675d0d09a45a135bddd15d7b385f8758c32fb (patch)
tree76267dbc9b9a130337be3640948fe397b04ac629 /tools/perf/util/data.c
parentAdding upstream version 6.6.15. (diff)
downloadlinux-85c675d0d09a45a135bddd15d7b385f8758c32fb.tar.xz
linux-85c675d0d09a45a135bddd15d7b385f8758c32fb.zip
Adding upstream version 6.7.7.upstream/6.7.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tools/perf/util/data.c')
-rw-r--r--tools/perf/util/data.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index fc16299c9..c29d8a382 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -17,6 +17,7 @@
#include "util.h" // rm_rf_perf_data()
#include "debug.h"
#include "header.h"
+#include "rlimit.h"
#include <internal/lib.h>
static void close_dir(struct perf_data_file *files, int nr)
@@ -35,6 +36,7 @@ void perf_data__close_dir(struct perf_data *data)
int perf_data__create_dir(struct perf_data *data, int nr)
{
+ enum rlimit_action set_rlimit = NO_CHANGE;
struct perf_data_file *files = NULL;
int i, ret;
@@ -54,11 +56,21 @@ int perf_data__create_dir(struct perf_data *data, int nr)
goto out_err;
}
+retry_open:
ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR);
if (ret < 0) {
+ /*
+ * If using parallel threads to collect data,
+ * perf record needs at least 6 fds per CPU.
+ * When we run out of them try to increase the limits.
+ */
+ if (errno == EMFILE && rlimit__increase_nofile(&set_rlimit))
+ goto retry_open;
+
ret = -errno;
goto out_err;
}
+ set_rlimit = NO_CHANGE;
file->fd = ret;
}