Skip to contentSkip to conversation

perf: Small fixes for the kernel counters

PATCH Applied Alexander Shishkin 2 participants 6 messages Oct 30, 2019 – Nov 13, 2019 perf events

lore
Share & tools
lore

Alexander Shishkin

author reviewer
#0 lore raw

cover perf: Small fixes for the kernel counters

Hi,

As a result of [1] it seems a reasonable thing to do to refuse to create kernel events with attr.aux_output (2/2). The other one is a comment fix.

[1] https://marc.info/?l=linux-kernel&m=157242901628761&w=2

Alexander Shishkin (2):
perf: Reattach a misplaced comment
perf: Disallow aux_output for kernel events

 kernel/events/core.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
Signature · 1 line
2.23.0
author reviewer
#1 lore raw

PATCH 1/2 perf: Reattach a misplaced comment

A comment is in a wrong place in perf_event_create_kernel_counter(). Fix that.

---
 kernel/events/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/events/core.c +3 -4
index cfd89b4a02d8..d2f16546a2ab 100644
@@ -11415,10 +11415,6 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 	struct perf_event *event;
 	int err;
 
-	/*
-	 * Get the target context (task or percpu):
-	 */
-
 	event = perf_event_alloc(attr, cpu, task, NULL, NULL,
 				 overflow_handler, context, -1);
 	if (IS_ERR(event)) {
@@ -11429,6 +11425,9 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 	/* Mark owner so we could distinguish it from user events. */
 	event->owner = TASK_TOMBSTONE;
 
+	/*
+	 * Get the target context (task or percpu):
+	 */
 	ctx = find_get_context(event->pmu, task, event);
 	if (IS_ERR(ctx)) {
 		err = PTR_ERR(ctx);
Signature · 1 line
2.23.0
#2 lore raw

[tip: perf/urgent] perf/core: Reattach a misplaced comment

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:     f25d8ba9e1b204b90fbf55970ea6e68955006068
Gitweb:        https://git.kernel.org/tip/f25d8ba9e1b204b90fbf55970ea6e68955006068
Author:        Alexander Shishkin <[email protected]>
AuthorDate:    Wed, 30 Oct 2019 15:47:30 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 13 Nov 2019 08:16:41 +01:00

perf/core: Reattach a misplaced comment

A comment is in a wrong place in perf_event_create_kernel_counter(). Fix that.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc David Ahern <[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 | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/events/core.c +3 -4
index b752bd3..e18d8d3 100644
@@ -11331,10 +11331,6 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 	struct perf_event *event;
 	int err;
 
-	/*
-	 * Get the target context (task or percpu):
-	 */
-
 	event = perf_event_alloc(attr, cpu, task, NULL, NULL,
 				 overflow_handler, context, -1);
 	if (IS_ERR(event)) {
@@ -11345,6 +11341,9 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 	/* Mark owner so we could distinguish it from user events. */
 	event->owner = TASK_TOMBSTONE;
 
+	/*
+	 * Get the target context (task or percpu):
+	 */
 	ctx = find_get_context(event->pmu, task, event);
 	if (IS_ERR(ctx)) {
 		err = PTR_ERR(ctx);
author reviewer
#3 lore raw

PATCH 2/2 perf: Disallow aux_output for kernel events

In reply to Alexander Shishkin

Commit

ab43762ef0109 ("perf: Allow normal events to output AUX data")

added 'aux_output' bit to the attribute structure, which relies on AUX events and grouping, neither of which is supported for the kernel events. This notwithstanding, attempts have been made to use it in the kernel code, suggesting the necessity of an explicit hard -EINVAL.

Fix this by rejecting attributes with aux_output set for kernel events.

---
 kernel/events/core.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/events/core.c +7 -0
index d2f16546a2ab..d31cf601c710 100644
@@ -11415,6 +11415,13 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 	struct perf_event *event;
 	int err;
 
+	/*
+	 * Grouping is not supported for kernel events, neither is 'AUX',
+	 * make sure the caller's intentions are adjusted.
+	 */
+	if (attr->aux_output)
+		return -EINVAL;
+
 	event = perf_event_alloc(attr, cpu, task, NULL, NULL,
 				 overflow_handler, context, -1);
 	if (IS_ERR(event)) {
Signature · 1 line
2.23.0
author reviewer
#4 lore raw

Re: [PATCH 2/2] perf: Disallow aux_output for kernel events

Review

Quoted 6 lines · Alexander Shishkin
(quoted diff) +6 -0
+	/*
+	 * Grouping is not supported for kernel events, neither is 'AUX',
+	 * make sure the caller's intentions are adjusted.
+	 */
+	if (attr->aux_output)
+		return -EINVAL;

Should have been ERR_PTR(-EINVAL).

From 72e1839403cb10da589873e1e529778e1f087b96 Mon Sep 17 00:00:00 2001
From: Alexander Shishkin <[email protected]>
Date: Wed, 30 Oct 2019 15:27:35 +0200
Subject: [PATCH] perf: Disallow aux_output for kernel events

Commit

ab43762ef0109 ("perf: Allow normal events to output AUX data")

added 'aux_output' bit to the attribute structure, which relies on AUX events and grouping, neither of which is supported for the kernel events. This notwithstanding, attempts have been made to use it in the kernel code, suggesting the necessity of an explicit hard -EINVAL.

Fix this by rejecting attributes with aux_output set for kernel events.

---
 kernel/events/core.c | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/events/core.c +7 -0
index 6d0d4b14f11c..b1aa5237052b 100644
@@ -11555,6 +11555,13 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 	struct perf_event *event;
 	int err;
 
+	/*
+	 * Grouping is not supported for kernel events, neither is 'AUX',
+	 * make sure the caller's intentions are adjusted.
+	 */
+	if (attr->aux_output)
+		return ERR_PTR(-EINVAL);
+
 	event = perf_event_alloc(attr, cpu, task, NULL, NULL,
 				 overflow_handler, context, -1);
 	if (IS_ERR(event)) {
Signature · 1 line
2.24.0.rc1
#5 lore raw

[tip: perf/urgent] perf/aux: Disallow aux_output for kernel events

In reply to Alexander Shishkin
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:     dce5affb94eb54edfff17727a6240a6a5d998666
Gitweb:        https://git.kernel.org/tip/dce5affb94eb54edfff17727a6240a6a5d998666
Author:        Alexander Shishkin <[email protected]>
AuthorDate:    Wed, 30 Oct 2019 15:47:31 +02:00
Committer:     Ingo Molnar <[email protected]>
CommitterDate: Wed, 13 Nov 2019 08:16:42 +01:00

perf/aux: Disallow aux_output for kernel events

Commit

ab43762ef0109 ("perf: Allow normal events to output AUX data")

added 'aux_output' bit to the attribute structure, which relies on AUX events and grouping, neither of which is supported for the kernel events. This notwithstanding, attempts have been made to use it in the kernel code, suggesting the necessity of an explicit hard -EINVAL.

Fix this by rejecting attributes with aux_output set for kernel events.

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc David Ahern <[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 | 7 +++++++
 1 file changed, 7 insertions(+)
kernel/events/core.c +7 -0
index e18d8d3..7655441 100644
@@ -11331,6 +11331,13 @@ perf_event_create_kernel_counter(struct perf_event_attr *attr, int cpu,
 	struct perf_event *event;
 	int err;
 
+	/*
+	 * Grouping is not supported for kernel events, neither is 'AUX',
+	 * make sure the caller's intentions are adjusted.
+	 */
+	if (attr->aux_output)
+		return ERR_PTR(-EINVAL);
+
 	event = perf_event_alloc(attr, cpu, task, NULL, NULL,
 				 overflow_handler, context, -1);
 	if (IS_ERR(event)) {