* [PATCH] perf/core: make sure group events are for the same cpu
@ 2017-06-17 7:42 Zhou Chengming
2017-06-20 13:08 ` Alexander Shishkin
0 siblings, 1 reply; 3+ messages in thread
From: Zhou Chengming @ 2017-06-17 7:42 UTC (permalink / raw)
To: mingo, peterz
Cc: linux-kernel, acme, alexander.shishkin, guohanjun, zhouchengming1
The else branch are broken for taskctx: two events can on the same
taskctx, but on different cpu. This patch fix it, we don't need to
check move_group. We first make sure we're on the same task, or both
per-cpu events, and then make sure we're events for the same cpu.
Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com>
---
kernel/events/core.c | 31 +++++++++++--------------------
1 file changed, 11 insertions(+), 20 deletions(-)
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 6c4e523..59270bd 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -10010,28 +10010,19 @@ static int perf_event_set_clock(struct perf_event *event, clockid_t clk_id)
goto err_context;
/*
- * Do not allow to attach to a group in a different
- * task or CPU context:
+ * Make sure we're both on the same task, or both
+ * per-cpu events.
*/
- if (move_group) {
- /*
- * Make sure we're both on the same task, or both
- * per-cpu events.
- */
- if (group_leader->ctx->task != ctx->task)
- goto err_context;
+ if (group_leader->ctx->task != ctx->task)
+ goto err_context;
- /*
- * Make sure we're both events for the same CPU;
- * grouping events for different CPUs is broken; since
- * you can never concurrently schedule them anyhow.
- */
- if (group_leader->cpu != event->cpu)
- goto err_context;
- } else {
- if (group_leader->ctx != ctx)
- goto err_context;
- }
+ /*
+ * Make sure we're both events for the same CPU;
+ * grouping events for different CPUs is broken; since
+ * you can never concurrently schedule them anyhow.
+ */
+ if (group_leader->cpu != event->cpu)
+ goto err_context;
/*
* Only a group leader can be exclusive or pinned
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/core: make sure group events are for the same cpu
2017-06-17 7:42 [PATCH] perf/core: make sure group events are for the same cpu Zhou Chengming
@ 2017-06-20 13:08 ` Alexander Shishkin
2017-06-21 6:55 ` zhouchengming
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Shishkin @ 2017-06-20 13:08 UTC (permalink / raw)
To: Zhou Chengming, mingo, peterz
Cc: linux-kernel, acme, guohanjun, zhouchengming1
Zhou Chengming <zhouchengming1@huawei.com> writes:
> The else branch are broken for taskctx:
This is not a good way to open a commit message.
> two events can on the same taskctx, but on different cpu.
How?
Regards,
--
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] perf/core: make sure group events are for the same cpu
2017-06-20 13:08 ` Alexander Shishkin
@ 2017-06-21 6:55 ` zhouchengming
0 siblings, 0 replies; 3+ messages in thread
From: zhouchengming @ 2017-06-21 6:55 UTC (permalink / raw)
To: Alexander Shishkin; +Cc: mingo, peterz, linux-kernel, acme, guohanjun
On 2017/6/20 21:08, Alexander Shishkin wrote:
> Zhou Chengming<zhouchengming1@huawei.com> writes:
>
>> The else branch are broken for taskctx:
> This is not a good way to open a commit message.
>
>> two events can on the same taskctx, but on different cpu.
> How?
fd1 = perf_open_event(attr, pid, 0, -1, flags);
fd2 = perf_open_event(attr, pid, 1, fd1, flags);
fd1 will be the leader event, fd2 will be the sibling event in the group.
And they are for the same task, so they will be put on the same taskctx successfully
if !move_group.
Obviously it's wrong, we can't concurrently schedule them as a group, since they are
on different cpu.
Thanks.
>
> Regards,
> --
> Alex
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-21 6:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-17 7:42 [PATCH] perf/core: make sure group events are for the same cpu Zhou Chengming
2017-06-20 13:08 ` Alexander Shishkin
2017-06-21 6:55 ` zhouchengming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox