cpuc->last_log_id = ++task_ctx->log_id;
 }
 
+void intel_pmu_lbr_swap_task_ctx(struct perf_event_context *prev,
+                                struct perf_event_context *next)
+{
+       struct x86_perf_task_context *prev_ctx_data, *next_ctx_data;
+
+       swap(prev->task_ctx_data, next->task_ctx_data);
+
+       /*
+        * Architecture specific synchronization makes sense in
+        * case both prev->task_ctx_data and next->task_ctx_data
+        * pointers are allocated.
+        */
+
+       prev_ctx_data = next->task_ctx_data;
+       next_ctx_data = prev->task_ctx_data;
+
+       if (!prev_ctx_data || !next_ctx_data)
+               return;
+
+       swap(prev_ctx_data->lbr_callstack_users,
+            next_ctx_data->lbr_callstack_users);
+}
+
 void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in)
 {
        struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
 
 
 void intel_ds_init(void);
 
+void intel_pmu_lbr_swap_task_ctx(struct perf_event_context *prev,
+                                struct perf_event_context *next);
+
 void intel_pmu_lbr_sched_task(struct perf_event_context *ctx, bool sched_in);
 
 u64 lbr_from_signext_quirk_wr(u64 val);