perf: Small fixes for the kernel counters
Alexander Shishkin
reviewercover 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
Alexander Shishkin
reviewerPATCH 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
@@ -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
[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.
--- kernel/events/core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
kernel/events/core.c +3 -4
@@ -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);
Alexander Shishkin
reviewerPATCH 2/2 perf: Disallow aux_output for kernel events
In reply to Alexander ShishkinCommit
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
@@ -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
Alexander Shishkin
reviewerRe: [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
@@ -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
[tip: perf/urgent] perf/aux: Disallow aux_output for kernel events
In reply to Alexander ShishkinThe 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.
--- kernel/events/core.c | 7 +++++++ 1 file changed, 7 insertions(+)
kernel/events/core.c +7 -0
@@ -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)) {