[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 8 Aug 2017 12:37:41 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: 石祤 <linxiulei@...il.com>
Cc: yang_oliver@...mail.com, mingo@...hat.com, acme@...nel.org,
alexander.shishkin@...ux.intel.com, linux-kernel@...r.kernel.org,
tglx@...utronix.de, eranian@...il.com,
torvalds@...ux-foundation.org, jolsa@...hat.com,
"leilei.lin" <leilei.lin@...baba-inc.com>
Subject: Re: [PATCH v2] perf/core: Avoid context switch overheads
On Tue, Aug 08, 2017 at 06:00:45PM +0800, 石祤 wrote:
> diff --git a/kernel/events/core.c b/kernel/events/core.c
> index 426c2ff..3d86695 100644
> --- a/kernel/events/core.c
> +++ b/kernel/events/core.c
> @@ -3180,6 +3180,13 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
> return;
>
> perf_ctx_lock(cpuctx, ctx);
> + /*
> + * We must check ctx->nr_events while holding ctx->lock, such
> + * that we serialize against perf_install_in_context().
> + */
> + if (!cpuctx->task_ctx && !ctx->nr_events)
> + goto unlock;
Do we really need the cpuctx->task_ctx test? I think that task_ctx is
'tight' these days. We never have it set unless there are events
scheduled for that context.
I even think the cpuctx->task_ctx == ctx test right above here is
superfluous these days. That could only happen when the
perf_install_in_context() IPI came before perf_event_task_sched_in(),
but we removed the arch option to do context switches with IRQs enabled.
> +
> perf_pmu_disable(ctx->pmu);
> /*
> * We want to keep the following priority order:
> @@ -3193,6 +3200,8 @@ static void perf_event_context_sched_in(struct perf_event_context *ctx,
> cpu_ctx_sched_out(cpuctx, EVENT_FLEXIBLE);
> perf_event_sched_in(cpuctx, ctx, task);
> perf_pmu_enable(ctx->pmu);
> +
> +unlock:
> perf_ctx_unlock(cpuctx, ctx);
> }
>
> --
> 2.8.4.31.g9ed660f
>
Powered by blists - more mailing lists