From: Peter Zijlstra <peterz@infradead.org>
To: Song Liu <songliubraving@fb.com>
Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com,
Arnaldo Carvalho de Melo <acme@redhat.com>,
Jiri Olsa <jolsa@kernel.org>,
Alexey Budankov <alexey.budankov@linux.intel.com>,
Namhyung Kim <namhyung@kernel.org>, Tejun Heo <tj@kernel.org>
Subject: Re: [PATCH v8] perf: Sharing PMU counters across compatible events
Date: Thu, 12 Dec 2019 16:39:47 +0100 [thread overview]
Message-ID: <20191212153947.GY2844@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20191207002447.2976319-1-songliubraving@fb.com>
On Fri, Dec 06, 2019 at 04:24:47PM -0800, Song Liu wrote:
> @@ -2174,6 +2410,14 @@ __perf_remove_from_context(struct perf_event *event,
> update_cgrp_time_from_cpuctx(cpuctx);
> }
>
> + if (event->dup_master == event) {
> + if (ctx->is_active)
> + ctx_resched(cpuctx, cpuctx->task_ctx,
> + get_event_type(event), NULL, event);
> + else
> + perf_event_remove_dup(event, ctx);
> + }
> +
> event_sched_out(event, cpuctx, ctx);
> if (flags & DETACH_GROUP)
> perf_group_detach(event);
> @@ -2241,6 +2485,14 @@ static void __perf_event_disable(struct perf_event *event,
> update_cgrp_time_from_event(event);
> }
>
> + if (event->dup_master == event) {
> + if (ctx->is_active)
> + ctx_resched(cpuctx, cpuctx->task_ctx,
> + get_event_type(event), NULL, event);
> + else
> + perf_event_remove_dup(event, ctx);
> + }
> +
> if (event == event->group_leader)
> group_sched_out(event, cpuctx, ctx);
> else
> @@ -2544,7 +2793,9 @@ static void perf_event_sched_in(struct perf_cpu_context *cpuctx,
> */
> static void ctx_resched(struct perf_cpu_context *cpuctx,
> struct perf_event_context *task_ctx,
> - enum event_type_t event_type)
> + enum event_type_t event_type,
> + struct perf_event *event_add_dup,
> + struct perf_event *event_del_dup)
> {
> enum event_type_t ctx_event_type;
> bool cpu_event = !!(event_type & EVENT_CPU);
> @@ -2574,6 +2825,18 @@ static void ctx_resched(struct perf_cpu_context *cpuctx,
> else if (ctx_event_type & EVENT_PINNED)
> cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
>
> + if (event_add_dup) {
> + if (event_add_dup->ctx->is_active)
> + ctx_sched_out(event_add_dup->ctx, cpuctx, EVENT_ALL);
> + perf_event_setup_dup(event_add_dup, event_add_dup->ctx);
> + }
> +
> + if (event_del_dup) {
> + if (event_del_dup->ctx->is_active)
> + ctx_sched_out(event_del_dup->ctx, cpuctx, EVENT_ALL);
> + perf_event_remove_dup(event_del_dup, event_del_dup->ctx);
> + }
> +
> perf_event_sched_in(cpuctx, task_ctx, current);
> perf_pmu_enable(cpuctx->ctx.pmu);
> }
Yuck!
Why do you do a full reschedule when you take out a master?
next prev parent reply other threads:[~2019-12-12 15:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-07 0:24 [PATCH v8] perf: Sharing PMU counters across compatible events Song Liu
2019-12-11 18:50 ` Song Liu
2019-12-12 13:42 ` Peter Zijlstra
2019-12-12 15:18 ` Song Liu
2019-12-12 13:49 ` Peter Zijlstra
2019-12-12 15:37 ` Song Liu
2019-12-12 15:44 ` Peter Zijlstra
2019-12-12 15:47 ` Song Liu
2019-12-12 15:39 ` Peter Zijlstra [this message]
2019-12-12 15:45 ` Song Liu
2019-12-12 16:00 ` Song Liu
2019-12-12 18:01 ` Song Liu
2019-12-12 18:52 ` Peter Zijlstra
2019-12-12 23:49 ` Song Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191212153947.GY2844@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=acme@redhat.com \
--cc=alexey.budankov@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=kernel-team@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@kernel.org \
--cc=songliubraving@fb.com \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.