Skip to contentSkip to conversation

perf: Consistently fail fork on allocation failures

PATCH Applied Alexander Shishkin 2 participants 2 messages Nov 5, 2019 – Nov 13, 2019 perf events

lore
Share & tools
lore

Alexander Shishkin

author reviewer
#0 lore raw

PATCH 1/1 perf: Consistently fail fork on allocation failures

Commit

313ccb9615948 ("perf: Allocate context task_ctx_data for child event")

makes the inherit path skip over the current event in case of task_ctx_data allocation failure. This, however, is inconsistent with allocation failures in perf_event_alloc(), which would abort the fork.

Correct this by returning an error code on task_ctx_data allocation failure and failing the fork in that case.

---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
index 8ff1218e91b1..c8203f1b2d20 100644
@@ -12026,7 +12026,7 @@ inherit_event(struct perf_event *parent_event,
 						   GFP_KERNEL);
 		if (!child_ctx->task_ctx_data) {
 			free_event(child_event);
-			return NULL;
+			return ERR_PTR(-ENOMEM);
 		}
 	}
 
Signature · 1 line
2.24.0.rc1
#1 lore raw

[tip: perf/urgent] perf/core: Consistently fail fork on allocation failures

The following commit has been merged into the perf/urgent branch of tip:

The following commit has been merged into the perf/urgent branch of tip:

Commit-ID:     697d877849d4b34ab58d7078d6930bad0ef6fc66
Gitweb:        https://git.kernel.org/tip/697d877849d4b34ab58d7078d6930bad0ef6fc66
Author:        Alexander Shishkin <[email protected]>
AuthorDate:    Tue, 05 Nov 2019 09:57:02 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 13 Nov 2019 08:16:43 +01:00

perf/core: Consistently fail fork on allocation failures

Commit:

313ccb9615948 ("perf: Allocate context task_ctx_data for child event")

makes the inherit path skip over the current event in case of task_ctx_data allocation failure. This, however, is inconsistent with allocation failures in perf_event_alloc(), which would abort the fork.

Correct this by returning an error code on task_ctx_data allocation failure and failing the fork in that case.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc David Ahern <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Jiri Olsa <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Mark Rutland <[email protected]>
Cc Namhyung Kim <[email protected]>
Cc Stephane Eranian <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Vince Weaver <[email protected]>
---
 kernel/events/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/events/core.c +1 -1
index 7655441..466e333 100644
@@ -11802,7 +11802,7 @@ inherit_event(struct perf_event *parent_event,
 						   GFP_KERNEL);
 		if (!child_ctx->task_ctx_data) {
 			free_event(child_event);
-			return NULL;
+			return ERR_PTR(-ENOMEM);
 		}
 	}