[RTEMS Project] #3902: rate monotonic statistics not resetting correctly

RTEMS trac trac at rtems.org
Fri Mar 6 23:25:48 UTC 2020


#3902: rate monotonic statistics not resetting correctly
---------------------------------+--------------------
  Reporter:  Martin Erik Werner  |      Owner:  (none)
      Type:  defect              |     Status:  new
  Priority:  normal              |  Milestone:
 Component:  rtems               |    Version:  4.11
  Severity:  normal              |   Keywords:
Blocked By:                      |   Blocking:
---------------------------------+--------------------
 When resetting the rate monotonic statistics, the max wall time and total
 wall time values are not being reset.

 This issue affects RTEMS 4.11 but does not affect RTEMS 5.

 In the 4.11 implementation for the reset:
 {{{
 #!c
 // cpukit/rtems/include/rtems/rtems/ratemonimpl.h
 #define _Rate_monotonic_Reset_statistics( _the_period ) \
   do { \
     memset( \
       &(_the_period)->Statistics, \
       0, \
       sizeof( rtems_rate_monotonic_period_statistics ) \
     ); \
     _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \
     _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \
   } while (0)
 }}}

 The zeroing size is calculated based on the
 rtems_rate_monotonic_period_statistics which is the public API struct and
 not the same type as the internal `Statistics` member that it is trying to
 reset, which is instead of type `Rate_monotonic_Statistics`.

 These structures have different sizes and the
 `rtems_rate_monotonic_period_statistics` struct is 48 bytes smaller than
 the `Rate_monotonic_Statistics` struct. This means that the memset zeroes
 too little.

 The subsequent `_Rate_monotonic_Reset*` calls takes care of resetting some
 additional members but the two at the end (max wall and total wall) are
 left without being reset.

 a fix would be:

 {{{
 #!diff
 diff --git a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
 b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
 index b3aa1cf303..a57dd1056a 100644
 --- a/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
 +++ b/cpukit/rtems/include/rtems/rtems/ratemonimpl.h
 @@ -236,7 +236,7 @@ void _Rate_monotonic_Initiate_statistics(
      memset( \
        &(_the_period)->Statistics, \
        0, \
 -      sizeof( rtems_rate_monotonic_period_statistics ) \
 +      sizeof( (_the_period)->Statistics ) \
      ); \
      _Rate_monotonic_Reset_cpu_use_statistics( _the_period ); \
      _Rate_monotonic_Reset_wall_time_statistics( _the_period ); \
 }}}

 In RTEMS 5, the size for the memset is calculated correctly and the
 statistics are reset correctly. (The size has also swapped, such that the
 public API struct is now larger than the internal struct.)

--
Ticket URL: <http://devel.rtems.org/ticket/3902>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list