@@ -355,18 +355,17 @@ void intel_pmu_lbr_restore(void *ctx)
355
355
wrmsrl (MSR_LBR_SELECT , task_ctx -> lbr_sel );
356
356
}
357
357
358
- static __always_inline bool
359
- lbr_is_reset_in_cstate (struct x86_perf_task_context * task_ctx )
358
+ static __always_inline bool lbr_is_reset_in_cstate (void * ctx )
360
359
{
361
- return !rdlbr_from (task_ctx -> tos );
360
+ return !rdlbr_from ((( struct x86_perf_task_context * ) ctx ) -> tos );
362
361
}
363
362
364
- static void __intel_pmu_lbr_restore (struct x86_perf_task_context * task_ctx )
363
+ static void __intel_pmu_lbr_restore (void * ctx )
365
364
{
366
365
struct cpu_hw_events * cpuc = this_cpu_ptr (& cpu_hw_events );
367
366
368
- if (task_ctx -> opt . lbr_callstack_users == 0 ||
369
- task_ctx -> opt . lbr_stack_state == LBR_NONE ) {
367
+ if (task_context_opt ( ctx ) -> lbr_callstack_users == 0 ||
368
+ task_context_opt ( ctx ) -> lbr_stack_state == LBR_NONE ) {
370
369
intel_pmu_lbr_reset ();
371
370
return ;
372
371
}
@@ -376,16 +375,16 @@ static void __intel_pmu_lbr_restore(struct x86_perf_task_context *task_ctx)
376
375
* - No one else touched them, and
377
376
* - Was not cleared in Cstate
378
377
*/
379
- if ((task_ctx == cpuc -> last_task_ctx ) &&
380
- (task_ctx -> opt . log_id == cpuc -> last_log_id ) &&
381
- !lbr_is_reset_in_cstate (task_ctx )) {
382
- task_ctx -> opt . lbr_stack_state = LBR_NONE ;
378
+ if ((ctx == cpuc -> last_task_ctx ) &&
379
+ (task_context_opt ( ctx ) -> log_id == cpuc -> last_log_id ) &&
380
+ !lbr_is_reset_in_cstate (ctx )) {
381
+ task_context_opt ( ctx ) -> lbr_stack_state = LBR_NONE ;
383
382
return ;
384
383
}
385
384
386
- x86_pmu .lbr_restore (task_ctx );
385
+ x86_pmu .lbr_restore (ctx );
387
386
388
- task_ctx -> opt . lbr_stack_state = LBR_NONE ;
387
+ task_context_opt ( ctx ) -> lbr_stack_state = LBR_NONE ;
389
388
}
390
389
391
390
void intel_pmu_lbr_save (void * ctx )
@@ -415,27 +414,27 @@ void intel_pmu_lbr_save(void *ctx)
415
414
rdmsrl (MSR_LBR_SELECT , task_ctx -> lbr_sel );
416
415
}
417
416
418
- static void __intel_pmu_lbr_save (struct x86_perf_task_context * task_ctx )
417
+ static void __intel_pmu_lbr_save (void * ctx )
419
418
{
420
419
struct cpu_hw_events * cpuc = this_cpu_ptr (& cpu_hw_events );
421
420
422
- if (task_ctx -> opt . lbr_callstack_users == 0 ) {
423
- task_ctx -> opt . lbr_stack_state = LBR_NONE ;
421
+ if (task_context_opt ( ctx ) -> lbr_callstack_users == 0 ) {
422
+ task_context_opt ( ctx ) -> lbr_stack_state = LBR_NONE ;
424
423
return ;
425
424
}
426
425
427
- x86_pmu .lbr_save (task_ctx );
426
+ x86_pmu .lbr_save (ctx );
428
427
429
- task_ctx -> opt . lbr_stack_state = LBR_VALID ;
428
+ task_context_opt ( ctx ) -> lbr_stack_state = LBR_VALID ;
430
429
431
- cpuc -> last_task_ctx = task_ctx ;
432
- cpuc -> last_log_id = ++ task_ctx -> opt . log_id ;
430
+ cpuc -> last_task_ctx = ctx ;
431
+ cpuc -> last_log_id = ++ task_context_opt ( ctx ) -> log_id ;
433
432
}
434
433
435
434
void intel_pmu_lbr_swap_task_ctx (struct perf_event_context * prev ,
436
435
struct perf_event_context * next )
437
436
{
438
- struct x86_perf_task_context * prev_ctx_data , * next_ctx_data ;
437
+ void * prev_ctx_data , * next_ctx_data ;
439
438
440
439
swap (prev -> task_ctx_data , next -> task_ctx_data );
441
440
@@ -451,14 +450,14 @@ void intel_pmu_lbr_swap_task_ctx(struct perf_event_context *prev,
451
450
if (!prev_ctx_data || !next_ctx_data )
452
451
return ;
453
452
454
- swap (prev_ctx_data -> opt . lbr_callstack_users ,
455
- next_ctx_data -> opt . lbr_callstack_users );
453
+ swap (task_context_opt ( prev_ctx_data ) -> lbr_callstack_users ,
454
+ task_context_opt ( next_ctx_data ) -> lbr_callstack_users );
456
455
}
457
456
458
457
void intel_pmu_lbr_sched_task (struct perf_event_context * ctx , bool sched_in )
459
458
{
460
459
struct cpu_hw_events * cpuc = this_cpu_ptr (& cpu_hw_events );
461
- struct x86_perf_task_context * task_ctx ;
460
+ void * task_ctx ;
462
461
463
462
if (!cpuc -> lbr_users )
464
463
return ;
@@ -495,7 +494,6 @@ static inline bool branch_user_callstack(unsigned br_sel)
495
494
void intel_pmu_lbr_add (struct perf_event * event )
496
495
{
497
496
struct cpu_hw_events * cpuc = this_cpu_ptr (& cpu_hw_events );
498
- struct x86_perf_task_context * task_ctx ;
499
497
500
498
if (!x86_pmu .lbr_nr )
501
499
return ;
@@ -505,10 +503,8 @@ void intel_pmu_lbr_add(struct perf_event *event)
505
503
506
504
cpuc -> br_sel = event -> hw .branch_reg .reg ;
507
505
508
- if (branch_user_callstack (cpuc -> br_sel ) && event -> ctx -> task_ctx_data ) {
509
- task_ctx = event -> ctx -> task_ctx_data ;
510
- task_ctx -> opt .lbr_callstack_users ++ ;
511
- }
506
+ if (branch_user_callstack (cpuc -> br_sel ) && event -> ctx -> task_ctx_data )
507
+ task_context_opt (event -> ctx -> task_ctx_data )-> lbr_callstack_users ++ ;
512
508
513
509
/*
514
510
* Request pmu::sched_task() callback, which will fire inside the
@@ -539,16 +535,13 @@ void intel_pmu_lbr_add(struct perf_event *event)
539
535
void intel_pmu_lbr_del (struct perf_event * event )
540
536
{
541
537
struct cpu_hw_events * cpuc = this_cpu_ptr (& cpu_hw_events );
542
- struct x86_perf_task_context * task_ctx ;
543
538
544
539
if (!x86_pmu .lbr_nr )
545
540
return ;
546
541
547
542
if (branch_user_callstack (cpuc -> br_sel ) &&
548
- event -> ctx -> task_ctx_data ) {
549
- task_ctx = event -> ctx -> task_ctx_data ;
550
- task_ctx -> opt .lbr_callstack_users -- ;
551
- }
543
+ event -> ctx -> task_ctx_data )
544
+ task_context_opt (event -> ctx -> task_ctx_data )-> lbr_callstack_users -- ;
552
545
553
546
if (event -> hw .flags & PERF_X86_EVENT_LBR_SELECT )
554
547
cpuc -> lbr_select = 0 ;
0 commit comments