[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140924112318.GX6758@twins.programming.kicks-ass.net>
Date: Wed, 24 Sep 2014 13:23:18 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: kan.liang@...el.com
Cc: eranian@...gle.com, linux-kernel@...r.kernel.org, mingo@...hat.com,
paulus@...ba.org, acme@...nel.org, ak@...ux.intel.com,
"Yan, Zheng" <zheng.z.yan@...el.com>
Subject: Re: [PATCH V5 02/16] perf, core: introduce pmu context switch
callback
On Wed, Sep 10, 2014 at 10:08:59AM -0400, kan.liang@...el.com wrote:
> From: Kan Liang <kan.liang@...el.com>
>
> The callback is invoked when process is scheduled in or out.
> It provides mechanism for later patches to save/store the LBR
> stack. For the schedule in case, the callback is invoked at
> the same place that flush branch stack callback is invoked.
> So it also can replace the flush branch stack callback. To
> avoid unnecessary overhead, the callback is enabled only when
> there are events use the LBR stack.
>
> Signed-off-by: Yan, Zheng <zheng.z.yan@...el.com>
Same broken attribution and SoB chain.
> +void perf_sched_cb_disable(struct pmu *pmu)
> +{
> + this_cpu_dec(perf_sched_cb_usages);
> +}
> +
> +void perf_sched_cb_enable(struct pmu *pmu)
> +{
> + this_cpu_inc(perf_sched_cb_usages);
> +}
lkml.kernel.org/r/20140715113957.GD9918@...ns.programming.kicks-ass.net
> +/*
> + * This function provides the context switch callback to the lower code
> + * layer. It is invoked ONLY when the context switch callback is enabled.
> + */
> +static void perf_pmu_sched_task(struct task_struct *prev,
> + struct task_struct *next,
> + bool sched_in)
> +{
> + struct perf_cpu_context *cpuctx;
> + struct pmu *pmu;
> + unsigned long flags;
> +
> + if (prev == next)
> + return;
> +
> + local_irq_save(flags);
> +
> + rcu_read_lock();
> +
> + list_for_each_entry_rcu(pmu, &pmus, entry) {
> + if (pmu->sched_task) {
> + cpuctx = this_cpu_ptr(pmu->pmu_cpu_context);
> +
> + perf_ctx_lock(cpuctx, cpuctx->task_ctx);
> +
> + perf_pmu_disable(pmu);
> +
> + pmu->sched_task(cpuctx->task_ctx, sched_in);
> +
> + perf_pmu_enable(pmu);
> +
> + perf_ctx_unlock(cpuctx, cpuctx->task_ctx);
> + /* only CPU PMU has context switch callback */
> + break;
> + }
> + }
> +
> + rcu_read_unlock();
> +
> + local_irq_restore(flags);
> +}
lkml.kernel.org/r/20140702084833.GT6758@...ns.programming.kicks-ass.net
Maybe you should have read back the previous postings before taking over
this series :-)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists