Skip to content

Commit fc1adfe

Browse files
Alexey BudankovIngo Molnar
authored andcommitted
perf/core, perf/x86: Introduce swap_task_ctx() method at 'struct pmu'
Declare swap_task_ctx() methods at the generic and x86 specific pmu types to bridge calls to platform specific PMU code on optimized context switch path between equivalent task perf event contexts. Signed-off-by: Alexey Budankov <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Arnaldo Carvalho de Melo <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Song Liu <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vince Weaver <[email protected]> Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]>
1 parent 6513303 commit fc1adfe

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

arch/x86/events/perf_event.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,14 @@ struct x86_pmu {
682682
*/
683683
atomic_t lbr_exclusive[x86_lbr_exclusive_max];
684684

685+
/*
686+
* perf task context (i.e. struct perf_event_context::task_ctx_data)
687+
* switch helper to bridge calls from perf/core to perf/x86.
688+
* See struct pmu::swap_task_ctx() usage for examples;
689+
*/
690+
void (*swap_task_ctx)(struct perf_event_context *prev,
691+
struct perf_event_context *next);
692+
685693
/*
686694
* AMD bits
687695
*/

include/linux/perf_event.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,15 @@ struct pmu {
410410
*/
411411
size_t task_ctx_size;
412412

413+
/*
414+
* PMU specific parts of task perf event context (i.e. ctx->task_ctx_data)
415+
* can be synchronized using this function. See Intel LBR callstack support
416+
* implementation and Perf core context switch handling callbacks for usage
417+
* examples.
418+
*/
419+
void (*swap_task_ctx) (struct perf_event_context *prev,
420+
struct perf_event_context *next);
421+
/* optional */
413422

414423
/*
415424
* Set up pmu-private data structures for an AUX area

0 commit comments

Comments
 (0)