Changeset 89c0313 in rtems


Ignore:
Timestamp:
Dec 21, 2017, 1:31:55 PM (3 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
5, master
Children:
3a4e044
Parents:
0c5d22f
git-author:
Sebastian Huber <sebastian.huber@…> (12/21/17 13:31:55)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/02/18 14:01:20)
Message:

score: Optimize watchdog tickle

Avoid unnecessary lock acquire/release operations. Get realtime via
timecounter only if necessary.

Update #3264.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • cpukit/include/rtems/score/watchdogimpl.h

    r0c5d22f r89c0313  
    9797}
    9898
     99RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Header_first(
     100  const Watchdog_Header *header
     101)
     102{
     103  return (Watchdog_Control *) header->first;
     104}
     105
    99106RTEMS_INLINE_ROUTINE void _Watchdog_Header_destroy(
    100107  Watchdog_Header *header
     
    188195void _Watchdog_Do_tickle(
    189196  Watchdog_Header  *header,
     197  Watchdog_Control *first,
    190198  uint64_t          now,
    191199#if defined(RTEMS_SMP)
     
    196204
    197205#if defined(RTEMS_SMP)
    198   #define _Watchdog_Tickle( header, now, lock, lock_context ) \
    199     _Watchdog_Do_tickle( header, now, lock, lock_context )
     206  #define _Watchdog_Tickle( header, first, now, lock, lock_context ) \
     207    _Watchdog_Do_tickle( header, first, now, lock, lock_context )
    200208#else
    201   #define _Watchdog_Tickle( header, now, lock, lock_context ) \
    202     _Watchdog_Do_tickle( header, now, lock_context )
     209  #define _Watchdog_Tickle( header, first, now, lock, lock_context ) \
     210    _Watchdog_Do_tickle( header, first, now, lock_context )
    203211#endif
    204212
     
    549557}
    550558
    551 RTEMS_INLINE_ROUTINE void _Watchdog_Per_CPU_tickle_realtime(
    552   Per_CPU_Control *cpu,
    553   uint64_t         now
    554 )
    555 {
    556   ISR_lock_Context lock_context;
    557 
    558   _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context );
    559   _Watchdog_Tickle(
    560     &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ],
    561     now,
    562     &cpu->Watchdog.Lock,
    563     &lock_context
    564   );
    565 }
    566 
    567559/** @} */
    568560
  • cpukit/score/src/coretodset.c

    r0c5d22f r89c0313  
    4242
    4343  for ( cpu_index = 0 ; cpu_index < cpu_count ; ++cpu_index ) {
    44     Per_CPU_Control *cpu = _Per_CPU_Get_by_index( cpu_index );
     44    Per_CPU_Control  *cpu;
     45    Watchdog_Header  *header;
     46    ISR_lock_Context  lock_context;
     47    Watchdog_Control *first;
    4548
    46     _Watchdog_Per_CPU_tickle_realtime( cpu, tod_as_ticks );
     49    cpu = _Per_CPU_Get_by_index( cpu_index );
     50    header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ];
     51
     52    _ISR_lock_ISR_disable_and_acquire( &cpu->Watchdog.Lock, &lock_context );
     53
     54    first = _Watchdog_Header_first( header );
     55
     56    if ( first != NULL ) {
     57      _Watchdog_Tickle(
     58        header,
     59        first,
     60        tod_as_ticks,
     61        &cpu->Watchdog.Lock,
     62        &lock_context
     63      );
     64    }
     65
     66    _ISR_lock_Release_and_ISR_enable( &cpu->Watchdog.Lock, &lock_context );
    4767  }
    4868
  • cpukit/score/src/watchdogtick.c

    r0c5d22f r89c0313  
    2424void _Watchdog_Do_tickle(
    2525  Watchdog_Header  *header,
     26  Watchdog_Control *first,
    2627  uint64_t          now,
    2728#ifdef RTEMS_SMP
     
    3132)
    3233{
    33   while ( true ) {
    34     Watchdog_Control *the_watchdog;
    35 
    36     the_watchdog = (Watchdog_Control *) header->first;
    37 
    38     if ( the_watchdog == NULL ) {
    39       break;
    40     }
    41 
    42     if ( the_watchdog->expire <= now ) {
     34  do {
     35    if ( first->expire <= now ) {
    4336      Watchdog_Service_routine_entry routine;
    4437
    45       _Watchdog_Next_first( header, the_watchdog );
    46       _RBTree_Extract( &header->Watchdogs, &the_watchdog->Node.RBTree );
    47       _Watchdog_Set_state( the_watchdog, WATCHDOG_INACTIVE );
    48       routine = the_watchdog->routine;
     38      _Watchdog_Next_first( header, first );
     39      _RBTree_Extract( &header->Watchdogs, &first->Node.RBTree );
     40      _Watchdog_Set_state( first, WATCHDOG_INACTIVE );
     41      routine = first->routine;
    4942
    5043      _ISR_lock_Release_and_ISR_enable( lock, lock_context );
    51       ( *routine )( the_watchdog );
     44      ( *routine )( first );
    5245      _ISR_lock_ISR_disable_and_acquire( lock, lock_context );
    5346    } else {
    5447      break;
    5548    }
    56   }
    5749
    58   _ISR_lock_Release_and_ISR_enable( lock, lock_context );
     50    first = _Watchdog_Header_first( header );
     51  } while ( first != NULL );
    5952}
    6053
    6154void _Watchdog_Tick( Per_CPU_Control *cpu )
    6255{
    63   ISR_lock_Context lock_context;
    64   uint64_t         ticks;
    65   struct timespec  now;
     56  ISR_lock_Context  lock_context;
     57  Watchdog_Header  *header;
     58  Watchdog_Control *first;
     59  uint64_t          ticks;
     60  struct timespec   now;
    6661
    6762  if ( _Per_CPU_Is_boot_processor( cpu ) ) {
     
    7671  cpu->Watchdog.ticks = ticks;
    7772
    78   _Watchdog_Tickle(
    79     &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ],
    80     ticks,
    81     &cpu->Watchdog.Lock,
    82     &lock_context
    83   );
     73  header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_MONOTONIC ];
     74  first = _Watchdog_Header_first( header );
    8475
    85   _Timecounter_Getnanotime( &now );
    86   _Watchdog_Per_CPU_tickle_realtime(
    87     cpu,
    88     _Watchdog_Realtime_from_timespec( &now )
    89   );
     76  if ( first != NULL ) {
     77    _Watchdog_Tickle(
     78      header,
     79      first,
     80      ticks,
     81      &cpu->Watchdog.Lock,
     82      &lock_context
     83    );
     84  }
     85
     86  header = &cpu->Watchdog.Header[ PER_CPU_WATCHDOG_REALTIME ];
     87  first = _Watchdog_Header_first( header );
     88
     89  if ( first != NULL ) {
     90    _Timecounter_Getnanotime( &now );
     91    _Watchdog_Tickle(
     92      header,
     93      first,
     94      _Watchdog_Realtime_from_timespec( &now ),
     95      &cpu->Watchdog.Lock,
     96      &lock_context
     97    );
     98  }
     99
     100  _ISR_lock_Release_and_ISR_enable( &cpu->Watchdog.Lock, &lock_context );
    90101
    91102  _Scheduler_Tick( cpu );
  • testsuites/sptests/spwatchdog/init.c

    r0c5d22f r89c0313  
    8383  ISR_LOCK_DEFINE( , lock, "Test" )
    8484  ISR_lock_Context lock_context;
     85  Watchdog_Control *first;
    8586
    8687  _ISR_lock_ISR_disable_and_acquire( &lock, &lock_context );
     88
    8789  ++now;
    88   _Watchdog_Tickle( header, now, &lock, &lock_context );
     90  first = _Watchdog_Header_first( header );
     91
     92  if ( first != NULL ) {
     93    _Watchdog_Tickle( header, first, now, &lock, &lock_context );
     94  }
     95
     96  _ISR_lock_Release_and_ISR_enable( &lock, &lock_context );
    8997  _ISR_lock_Destroy( &lock );
    9098
Note: See TracChangeset for help on using the changeset viewer.