All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] perf: Small fixes for the kernel counters
@ 2019-10-30 13:47 Alexander Shishkin
  2019-10-30 13:47 ` [PATCH 1/2] perf: Reattach a misplaced comment Alexander Shishkin
  2019-10-30 13:47 ` [PATCH 2/2] perf: Disallow aux_output for kernel events Alexander Shishkin
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Shishkin @ 2019-10-30 13:47 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel, Alexander Shishkin

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(-)

-- 
2.23.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] perf: Reattach a misplaced comment
  2019-10-30 13:47 [PATCH 0/2] perf: Small fixes for the kernel counters Alexander Shishkin
@ 2019-10-30 13:47 ` Alexander Shishkin
  2019-11-13 10:06   ` [tip: perf/urgent] perf/core: " tip-bot2 for Alexander Shishkin
  2019-10-30 13:47 ` [PATCH 2/2] perf: Disallow aux_output for kernel events Alexander Shishkin
  1 sibling, 1 reply; 6+ messages in thread
From: Alexander Shishkin @ 2019-10-30 13:47 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel, Alexander Shishkin

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

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 kernel/events/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index cfd89b4a02d8..d2f16546a2ab 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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);
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] perf: Disallow aux_output for kernel events
  2019-10-30 13:47 [PATCH 0/2] perf: Small fixes for the kernel counters Alexander Shishkin
  2019-10-30 13:47 ` [PATCH 1/2] perf: Reattach a misplaced comment Alexander Shishkin
@ 2019-10-30 13:47 ` Alexander Shishkin
  2019-10-31  6:31   ` Alexander Shishkin
  2019-11-13 10:06   ` [tip: perf/urgent] perf/aux: " tip-bot2 for Alexander Shishkin
  1 sibling, 2 replies; 6+ messages in thread
From: Alexander Shishkin @ 2019-10-30 13:47 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel, 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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 kernel/events/core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index d2f16546a2ab..d31cf601c710 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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)) {
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] perf: Disallow aux_output for kernel events
  2019-10-30 13:47 ` [PATCH 2/2] perf: Disallow aux_output for kernel events Alexander Shishkin
@ 2019-10-31  6:31   ` Alexander Shishkin
  2019-11-13 10:06   ` [tip: perf/urgent] perf/aux: " tip-bot2 for Alexander Shishkin
  1 sibling, 0 replies; 6+ messages in thread
From: Alexander Shishkin @ 2019-10-31  6:31 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: Arnaldo Carvalho de Melo, Ingo Molnar, linux-kernel, alexander.shishkin

Alexander Shishkin <alexander.shishkin@linux.intel.com> writes:

> +	/*
> +	 * 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 <alexander.shishkin@linux.intel.com>
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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
---
 kernel/events/core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index 6d0d4b14f11c..b1aa5237052b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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)) {
-- 
2.24.0.rc1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip: perf/urgent] perf/core: Reattach a misplaced comment
  2019-10-30 13:47 ` [PATCH 1/2] perf: Reattach a misplaced comment Alexander Shishkin
@ 2019-11-13 10:06   ` tip-bot2 for Alexander Shishkin
  0 siblings, 0 replies; 6+ messages in thread
From: tip-bot2 for Alexander Shishkin @ 2019-11-13 10:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Alexander Shishkin, Peter Zijlstra (Intel),
	Arnaldo Carvalho de Melo, David Ahern, Jiri Olsa, Linus Torvalds,
	Mark Rutland, Namhyung Kim, Stephane Eranian, Thomas Gleixner,
	Vince Weaver, Ingo Molnar, Borislav Petkov, linux-kernel

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 <alexander.shishkin@linux.intel.com>
AuthorDate:    Wed, 30 Oct 2019 15:47:30 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: https://lkml.kernel.org/r/20191030134731.5437-2-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/events/core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index b752bd3..e18d8d3 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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);

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [tip: perf/urgent] perf/aux: Disallow aux_output for kernel events
  2019-10-30 13:47 ` [PATCH 2/2] perf: Disallow aux_output for kernel events Alexander Shishkin
  2019-10-31  6:31   ` Alexander Shishkin
@ 2019-11-13 10:06   ` tip-bot2 for Alexander Shishkin
  1 sibling, 0 replies; 6+ messages in thread
From: tip-bot2 for Alexander Shishkin @ 2019-11-13 10:06 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Alexander Shishkin, Peter Zijlstra (Intel),
	Arnaldo Carvalho de Melo, David Ahern, Jiri Olsa, Linus Torvalds,
	Mark Rutland, Namhyung Kim, Stephane Eranian, Thomas Gleixner,
	Vince Weaver, Ingo Molnar, Borislav Petkov, linux-kernel

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 <alexander.shishkin@linux.intel.com>
AuthorDate:    Wed, 30 Oct 2019 15:47:31 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Link: https://lkml.kernel.org/r/20191030134731.5437-3-alexander.shishkin@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/events/core.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kernel/events/core.c b/kernel/events/core.c
index e18d8d3..7655441 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -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)) {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-11-13 10:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 13:47 [PATCH 0/2] perf: Small fixes for the kernel counters Alexander Shishkin
2019-10-30 13:47 ` [PATCH 1/2] perf: Reattach a misplaced comment Alexander Shishkin
2019-11-13 10:06   ` [tip: perf/urgent] perf/core: " tip-bot2 for Alexander Shishkin
2019-10-30 13:47 ` [PATCH 2/2] perf: Disallow aux_output for kernel events Alexander Shishkin
2019-10-31  6:31   ` Alexander Shishkin
2019-11-13 10:06   ` [tip: perf/urgent] perf/aux: " tip-bot2 for Alexander Shishkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.