@@ -475,69 +475,31 @@ static bool tmigr_check_lonely(struct tmigr_group *group)
475
475
return bitmap_weight (& active , BIT_CNT ) <= 1 ;
476
476
}
477
477
478
- typedef bool (* up_f )(struct tmigr_group * , struct tmigr_group * , void * );
479
-
480
- static void __walk_groups (up_f up , void * data ,
481
- struct tmigr_cpu * tmc )
482
- {
483
- struct tmigr_group * child = NULL , * group = tmc -> tmgroup ;
484
-
485
- do {
486
- WARN_ON_ONCE (group -> level >= tmigr_hierarchy_levels );
487
-
488
- if (up (group , child , data ))
489
- break ;
490
-
491
- child = group ;
492
- group = group -> parent ;
493
- } while (group );
494
- }
495
-
496
- static void walk_groups (up_f up , void * data , struct tmigr_cpu * tmc )
497
- {
498
- lockdep_assert_held (& tmc -> lock );
499
-
500
- __walk_groups (up , data , tmc );
501
- }
502
-
503
478
/**
504
479
* struct tmigr_walk - data required for walking the hierarchy
505
480
* @nextexp: Next CPU event expiry information which is handed into
506
481
* the timer migration code by the timer code
507
482
* (get_next_timer_interrupt())
508
- * @firstexp: Contains the first event expiry information when last
509
- * active CPU of hierarchy is on the way to idle to make
510
- * sure CPU will be back in time. It is updated in top
511
- * level group only. Be aware, there could occur a new top
512
- * level of the hierarchy between the 'top level call' in
513
- * tmigr_update_events() and the check for the parent group
514
- * in walk_groups(). Then @firstexp might contain a value
515
- * != KTIME_MAX even if it was not the final top
516
- * level. This is not a problem, as the worst outcome is a
517
- * CPU which might wake up a little early.
483
+ * @firstexp: Contains the first event expiry information when
484
+ * hierarchy is completely idle. When CPU itself was the
485
+ * last going idle, information makes sure, that CPU will
486
+ * be back in time. When using this value in the remote
487
+ * expiry case, firstexp is stored in the per CPU tmigr_cpu
488
+ * struct of CPU which expires remote timers. It is updated
489
+ * in top level group only. Be aware, there could occur a
490
+ * new top level of the hierarchy between the 'top level
491
+ * call' in tmigr_update_events() and the check for the
492
+ * parent group in walk_groups(). Then @firstexp might
493
+ * contain a value != KTIME_MAX even if it was not the
494
+ * final top level. This is not a problem, as the worst
495
+ * outcome is a CPU which might wake up a little early.
518
496
* @evt: Pointer to tmigr_event which needs to be queued (of idle
519
497
* child group)
520
498
* @childmask: childmask of child group
521
499
* @remote: Is set, when the new timer path is executed in
522
500
* tmigr_handle_remote_cpu()
523
- */
524
- struct tmigr_walk {
525
- u64 nextexp ;
526
- u64 firstexp ;
527
- struct tmigr_event * evt ;
528
- u8 childmask ;
529
- bool remote ;
530
- };
531
-
532
- /**
533
- * struct tmigr_remote_data - data required for remote expiry hierarchy walk
534
501
* @basej: timer base in jiffies
535
502
* @now: timer base monotonic
536
- * @firstexp: returns expiry of the first timer in the idle timer
537
- * migration hierarchy to make sure the timer is handled in
538
- * time; it is stored in the per CPU tmigr_cpu struct of
539
- * CPU which expires remote timers
540
- * @childmask: childmask of child group
541
503
* @check: is set if there is the need to handle remote timers;
542
504
* required in tmigr_requires_handle_remote() only
543
505
* @tmc_active: this flag indicates, whether the CPU which triggers
@@ -546,15 +508,43 @@ struct tmigr_walk {
546
508
* idle, only the first event of the top level has to be
547
509
* considered.
548
510
*/
549
- struct tmigr_remote_data {
550
- unsigned long basej ;
551
- u64 now ;
552
- u64 firstexp ;
553
- u8 childmask ;
554
- bool check ;
555
- bool tmc_active ;
511
+ struct tmigr_walk {
512
+ u64 nextexp ;
513
+ u64 firstexp ;
514
+ struct tmigr_event * evt ;
515
+ u8 childmask ;
516
+ bool remote ;
517
+ unsigned long basej ;
518
+ u64 now ;
519
+ bool check ;
520
+ bool tmc_active ;
556
521
};
557
522
523
+ typedef bool (* up_f )(struct tmigr_group * , struct tmigr_group * , struct tmigr_walk * );
524
+
525
+ static void __walk_groups (up_f up , struct tmigr_walk * data ,
526
+ struct tmigr_cpu * tmc )
527
+ {
528
+ struct tmigr_group * child = NULL , * group = tmc -> tmgroup ;
529
+
530
+ do {
531
+ WARN_ON_ONCE (group -> level >= tmigr_hierarchy_levels );
532
+
533
+ if (up (group , child , data ))
534
+ break ;
535
+
536
+ child = group ;
537
+ group = group -> parent ;
538
+ } while (group );
539
+ }
540
+
541
+ static void walk_groups (up_f up , struct tmigr_walk * data , struct tmigr_cpu * tmc )
542
+ {
543
+ lockdep_assert_held (& tmc -> lock );
544
+
545
+ __walk_groups (up , data , tmc );
546
+ }
547
+
558
548
/*
559
549
* Returns the next event of the timerqueue @group->events
560
550
*
@@ -625,10 +615,9 @@ static u64 tmigr_next_groupevt_expires(struct tmigr_group *group)
625
615
626
616
static bool tmigr_active_up (struct tmigr_group * group ,
627
617
struct tmigr_group * child ,
628
- void * ptr )
618
+ struct tmigr_walk * data )
629
619
{
630
620
union tmigr_state curstate , newstate ;
631
- struct tmigr_walk * data = ptr ;
632
621
bool walk_done ;
633
622
u8 childmask ;
634
623
@@ -867,10 +856,8 @@ bool tmigr_update_events(struct tmigr_group *group, struct tmigr_group *child,
867
856
868
857
static bool tmigr_new_timer_up (struct tmigr_group * group ,
869
858
struct tmigr_group * child ,
870
- void * ptr )
859
+ struct tmigr_walk * data )
871
860
{
872
- struct tmigr_walk * data = ptr ;
873
-
874
861
return tmigr_update_events (group , child , data );
875
862
}
876
863
@@ -1002,9 +989,8 @@ static void tmigr_handle_remote_cpu(unsigned int cpu, u64 now,
1002
989
1003
990
static bool tmigr_handle_remote_up (struct tmigr_group * group ,
1004
991
struct tmigr_group * child ,
1005
- void * ptr )
992
+ struct tmigr_walk * data )
1006
993
{
1007
- struct tmigr_remote_data * data = ptr ;
1008
994
struct tmigr_event * evt ;
1009
995
unsigned long jif ;
1010
996
u8 childmask ;
@@ -1062,7 +1048,7 @@ static bool tmigr_handle_remote_up(struct tmigr_group *group,
1062
1048
void tmigr_handle_remote (void )
1063
1049
{
1064
1050
struct tmigr_cpu * tmc = this_cpu_ptr (& tmigr_cpu );
1065
- struct tmigr_remote_data data ;
1051
+ struct tmigr_walk data ;
1066
1052
1067
1053
if (tmigr_is_not_available (tmc ))
1068
1054
return ;
@@ -1104,9 +1090,8 @@ void tmigr_handle_remote(void)
1104
1090
1105
1091
static bool tmigr_requires_handle_remote_up (struct tmigr_group * group ,
1106
1092
struct tmigr_group * child ,
1107
- void * ptr )
1093
+ struct tmigr_walk * data )
1108
1094
{
1109
- struct tmigr_remote_data * data = ptr ;
1110
1095
u8 childmask ;
1111
1096
1112
1097
childmask = data -> childmask ;
@@ -1164,7 +1149,7 @@ static bool tmigr_requires_handle_remote_up(struct tmigr_group *group,
1164
1149
bool tmigr_requires_handle_remote (void )
1165
1150
{
1166
1151
struct tmigr_cpu * tmc = this_cpu_ptr (& tmigr_cpu );
1167
- struct tmigr_remote_data data ;
1152
+ struct tmigr_walk data ;
1168
1153
unsigned long jif ;
1169
1154
bool ret = false;
1170
1155
@@ -1252,10 +1237,9 @@ u64 tmigr_cpu_new_timer(u64 nextexp)
1252
1237
1253
1238
static bool tmigr_inactive_up (struct tmigr_group * group ,
1254
1239
struct tmigr_group * child ,
1255
- void * ptr )
1240
+ struct tmigr_walk * data )
1256
1241
{
1257
1242
union tmigr_state curstate , newstate , childstate ;
1258
- struct tmigr_walk * data = ptr ;
1259
1243
bool walk_done ;
1260
1244
u8 childmask ;
1261
1245
0 commit comments