Re: [PATCH V5 09/16] perf, x86: Save/resotre LBR stack during context switch

From: Peter Zijlstra
Date: Wed Sep 24 2014 - 09:33:29 EST


On Wed, Sep 10, 2014 at 10:09:06AM -0400, kan.liang@xxxxxxxxx wrote:
> void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in)
> {
> struct cpu_hw_events *cpuc = &__get_cpu_var(cpu_hw_events);
> + struct x86_perf_task_context *task_ctx;
>
> if (!x86_pmu.lbr_nr)
> return;
> /*
> + * If LBR callstack feature is enabled and the stack was saved when
> + * the task was scheduled out, restore the stack. Otherwise flush
> + * the LBR stack.
> + */
> + task_ctx = ctx ? ctx->task_ctx_data : NULL;
> + if (task_ctx) {
> + if (sched_in) {
> + __intel_pmu_lbr_restore(task_ctx);
> + cpuc->lbr_context = ctx;
> + } else {
> + __intel_pmu_lbr_save(task_ctx);
> + }
> + }
> +
> + /*
> * When sampling the branck stack in system-wide, it may be
> * necessary to flush the stack on context switch. This happens
> * when the branch stack does not tag its entries with the pid

Why would we still need to reset if we did a save/restore on the branch
stack?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/