Remove use ticks for statistics configure option.

This was obsolete and broken based upon recent time keeping changes.

Thie build option was previously enabled by adding
USE_TICKS_FOR_STATISTICS=1 to the configure command line.

This propagated into the code as preprocessor conditionals
using the __RTEMS_USE_TICKS_FOR_STATISTICS__ conditional.
This commit is contained in:
Joel Sherrill
2015-05-27 10:13:58 -05:00
parent 80fca28198
commit e6b31b27fb
19 changed files with 167 additions and 434 deletions

View File

@@ -240,11 +240,6 @@ RTEMS_CPUOPT([RTEMS_VERSION],
["]_RTEMS_VERSION["],
[RTEMS version string])
RTEMS_CPUOPT([__RTEMS_USE_TICKS_FOR_STATISTICS__],
[test x"${USE_TICKS_FOR_STATISTICS}" = x"1"],
[1],
[disable nanosecond granularity for statistics])
## Header file differences that need to be known in .h after install
RTEMS_CPUOPT([__RTEMS_HAVE_SYS_CPUSET_H__],
[test x"${ac_cv_header_sys_cpuset_h}" = x"yes"],

View File

@@ -31,9 +31,7 @@
#include <errno.h>
#include <rtems/seterr.h>
#include <rtems/score/todimpl.h>
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#include <rtems/score/timestamp.h>
#endif
#include <rtems/score/timestamp.h>
#include <rtems/score/threadimpl.h>
/**
@@ -63,8 +61,6 @@ clock_t _times(
* of ticks since boot and the number of ticks executed by this
* this thread.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
{
Timestamp_Control per_tick;
uint32_t ticks_of_executing;
@@ -94,10 +90,6 @@ clock_t _times(
_Thread_Dispatch_enable( cpu_self );
ptms->tms_utime = ticks_of_executing * us_per_tick;
}
#else
executing = _Thread_Get_executing();
ptms->tms_utime = executing->cpu_time_used * us_per_tick;
#endif
ptms->tms_stime = ticks * us_per_tick;
ptms->tms_cutime = 0;
ptms->tms_cstime = 0;

View File

@@ -22,8 +22,4 @@
#include <rtems/cpuuse.h>
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
Timestamp_Control CPU_usage_Uptime_at_last_reset;
#else
uint32_t CPU_usage_Ticks_at_last_reset;
#endif
Timestamp_Control CPU_usage_Uptime_at_last_reset;

View File

@@ -44,12 +44,8 @@ void rtems_cpu_usage_report_with_plugin(
Objects_Information *information;
char name[13];
uint32_t ival, fval;
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
Timestamp_Control uptime, total, ran, uptime_at_last_reset;
uint32_t seconds, nanoseconds;
#else
uint32_t total_units = 0;
#endif
if ( !print )
return;
@@ -59,38 +55,15 @@ void rtems_cpu_usage_report_with_plugin(
* the number of "ticks" we gave credit for to give the user a rough
* guideline as to what each number means proportionally.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_Timestamp_Set_to_zero( &total );
uptime_at_last_reset = CPU_usage_Uptime_at_last_reset;
#else
for ( api_index = 1 ; api_index <= OBJECTS_APIS_LAST ; api_index++ ) {
#if !defined(RTEMS_POSIX_API) || defined(RTEMS_DEBUG)
if ( !_Objects_Information_table[ api_index ] )
continue;
#endif
information = _Objects_Information_table[ api_index ][ 1 ];
if ( information ) {
for ( i=1 ; i <= information->maximum ; i++ ) {
the_thread = (Thread_Control *)information->local_table[ i ];
if ( the_thread )
total_units += the_thread->cpu_time_used;
}
}
}
#endif
(*print)(
context,
"-------------------------------------------------------------------------------\n"
" CPU USAGE BY THREAD\n"
"------------+----------------------------------------+---------------+---------\n"
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
" ID | NAME | SECONDS | PERCENT\n"
#else
" ID | NAME | TICKS | PERCENT\n"
#endif
"------------+----------------------------------------+---------------+---------\n"
);
@@ -117,7 +90,6 @@ void rtems_cpu_usage_report_with_plugin(
name
);
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
{
Timestamp_Control last;
@@ -150,31 +122,10 @@ void rtems_cpu_usage_report_with_plugin(
ival, fval
);
}
#else
if (total_units) {
uint64_t ival_64;
ival_64 = the_thread->cpu_time_used;
ival_64 *= 100000;
ival = ival_64 / total_units;
} else {
ival = 0;
}
fval = ival % 1000;
ival /= 1000;
(*print)( context,
"%14" PRIu32 " |%4" PRIu32 ".%03" PRIu32 "\n",
the_thread->cpu_time_used,
ival,
fval
);
#endif
}
}
}
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
seconds = _Timestamp_Get_seconds( &total );
nanoseconds = _Timestamp_Get_nanoseconds( &total ) /
TOD_NANOSECONDS_PER_MICROSECOND;
@@ -185,17 +136,6 @@ void rtems_cpu_usage_report_with_plugin(
"-------------------------------------------------------------------------------\n",
seconds, nanoseconds
);
#else
(*print)(
context,
"------------+----------------------------------------+---------------+---------\n"
" TICKS SINCE LAST SYSTEM RESET: %14" PRIu32 "\n"
" TOTAL UNITS: %14" PRIu32 "\n"
"-------------------------------------------------------------------------------\n",
_Watchdog_Ticks_since_boot - CPU_usage_Ticks_at_last_reset,
total_units
);
#endif
}
void rtems_cpu_usage_report( void )

View File

@@ -27,11 +27,7 @@ static void CPU_usage_Per_thread_handler(
Thread_Control *the_thread
)
{
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_Timestamp_Set_to_zero( &the_thread->cpu_time_used );
#else
the_thread->cpu_time_used = 0;
#endif
}
/*
@@ -39,7 +35,6 @@ static void CPU_usage_Per_thread_handler(
*/
void rtems_cpu_usage_reset( void )
{
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
uint32_t cpu_count;
uint32_t cpu_index;
@@ -51,9 +46,6 @@ void rtems_cpu_usage_reset( void )
cpu->time_of_last_context_switch = CPU_usage_Uptime_at_last_reset;
}
#else
CPU_usage_Ticks_at_last_reset = _Watchdog_Ticks_since_boot;
#endif
rtems_iterate_over_all_threads(CPU_usage_Per_thread_handler);
}

View File

@@ -144,31 +144,14 @@ static inline bool less_than_uint32_t( uint32_t * lhs, uint32_t * rhs )
return false;
}
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#define CPU_usage_Equal_to( _lhs, _rhs ) \
#define CPU_usage_Equal_to( _lhs, _rhs ) \
_Timestamp_Equal_to( _lhs, _rhs )
#else
#define CPU_usage_Equal_to( _lhs, _rhs ) \
equal_to_uint32_t( _lhs, _rhs )
#endif
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#define CPU_usage_Set_to_zero( _time ) \
#define CPU_usage_Set_to_zero( _time ) \
_Timestamp_Set_to_zero( _time )
#else
#define CPU_usage_Set_to_zero( _time ) \
do { \
*_time = 0; \
} while (0)
#endif
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#define CPU_usage_Less_than( _lhs, _rhs ) \
#define CPU_usage_Less_than( _lhs, _rhs ) \
_Timestamp_Less_than( _lhs, _rhs )
#else
#define CPU_usage_Less_than( _lhs, _rhs ) \
less_than_uint32_t( _lhs, _rhs )
#endif
static void
print_memsize(rtems_cpu_usage_data* data, const uint32_t size, const char* label)
@@ -581,11 +564,6 @@ void rtems_cpu_usage_top_with_plugin(
rtems_printk_plugin_t print
)
{
#ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
if ( !print )
return;
(*print)(context, "error: tick kernels not supported\n");
#else
rtems_status_code sc;
rtems_task_priority priority;
rtems_name name;
@@ -714,7 +692,6 @@ void rtems_cpu_usage_top_with_plugin(
rtems_event_send(id, RTEMS_EVENT_1);
}
}
#endif
}
void rtems_cpu_usage_top( void )

View File

@@ -25,9 +25,7 @@
#include <rtems.h>
#include <rtems/bspIo.h>
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#include <rtems/score/timestamp.h>
#endif
#include <rtems/score/timestamp.h>
/**
* @defgroup libmisc_cpuuse CPU Usage
@@ -39,11 +37,7 @@
extern "C" {
#endif
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
#else
extern uint32_t CPU_usage_Ticks_at_last_reset;
#endif
extern Timestamp_Control CPU_usage_Uptime_at_last_reset;
/*
* rtems_cpu_usage_report_with_handler

View File

@@ -62,25 +62,17 @@ extern "C" {
* This is the public type used for the rate monotonic timing
* statistics.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#include <rtems/score/timespec.h>
#include <rtems/score/timespec.h>
typedef struct timespec rtems_rate_monotonic_period_time_t;
#else
typedef uint32_t rtems_rate_monotonic_period_time_t;
#endif
typedef struct timespec rtems_rate_monotonic_period_time_t;
/**
* This is the internal type used for the rate monotonic timing
* statistics.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#include <rtems/score/timestamp.h>
#include <rtems/score/timestamp.h>
typedef Timestamp_Control Rate_monotonic_Period_time_t;
#else
typedef uint32_t Rate_monotonic_Period_time_t;
#endif
typedef Timestamp_Control Rate_monotonic_Period_time_t;
/**
* The following enumerated type defines the states in which a

View File

@@ -201,8 +201,7 @@ void _Rate_monotonic_Initiate_statistics(
*
* This method resets the statistics information for a period instance.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
#define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
do { \
/* set the minimums to a large value */ \
_Timestamp_Set( \
@@ -211,21 +210,13 @@ void _Rate_monotonic_Initiate_statistics(
0x7fffffff \
); \
} while (0)
#else
#define _Rate_monotonic_Reset_wall_time_statistics( _the_period ) \
do { \
/* set the minimum to a large value */ \
(_the_period)->Statistics.min_wall_time = 0xffffffff; \
} while (0)
#endif
/**
* @brief Rate_monotonic_Reset_cpu_use_statistics
*
* This helper method resets the period CPU usage statistics structure.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
do { \
/* set the minimums to a large value */ \
_Timestamp_Set( \
@@ -234,13 +225,6 @@ void _Rate_monotonic_Initiate_statistics(
0x7fffffff \
); \
} while (0)
#else
#define _Rate_monotonic_Reset_cpu_use_statistics( _the_period ) \
do { \
/* set the minimum to a large value */ \
(_the_period)->Statistics.min_cpu_time = 0xffffffff; \
} while (0)
#endif
/**
* @brief Rate_monotonic_Reset_statistics

View File

@@ -124,11 +124,7 @@ typedef Watchdog_Interval rtems_interval;
* When using nanoseconds granularity timing, RTEMS may internally use a
* variety of representations.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
typedef struct timespec rtems_thread_cpu_usage_t;
#else
typedef uint32_t rtems_thread_cpu_usage_t;
#endif
typedef struct timespec rtems_thread_cpu_usage_t;
/**
* @brief Data structure to manage and manipulate calendar

View File

@@ -46,21 +46,12 @@ rtems_status_code rtems_rate_monotonic_get_statistics(
src = &the_period->Statistics;
dst->count = src->count;
dst->missed_count = src->missed_count;
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_Timestamp_To_timespec( &src->min_cpu_time, &dst->min_cpu_time );
_Timestamp_To_timespec( &src->max_cpu_time, &dst->max_cpu_time );
_Timestamp_To_timespec( &src->total_cpu_time, &dst->total_cpu_time );
_Timestamp_To_timespec( &src->min_wall_time, &dst->min_wall_time );
_Timestamp_To_timespec( &src->max_wall_time, &dst->max_wall_time );
_Timestamp_To_timespec( &src->total_wall_time, &dst->total_wall_time );
#else
dst->min_cpu_time = src->min_cpu_time;
dst->max_cpu_time = src->max_cpu_time;
dst->total_cpu_time = src->total_cpu_time;
dst->min_wall_time = src->min_wall_time;
dst->max_wall_time = src->max_wall_time;
dst->total_wall_time = src->total_wall_time;
#endif
_Objects_Put( &the_period->Object );
return RTEMS_SUCCESSFUL;

View File

@@ -24,10 +24,7 @@
#include <rtems/score/isr.h>
#include <rtems/rtems/ratemonimpl.h>
#include <rtems/score/thread.h>
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#include <rtems/score/timespec.h>
#endif
#include <rtems/score/timespec.h>
rtems_status_code rtems_rate_monotonic_get_status(
rtems_id id,
@@ -54,14 +51,8 @@ rtems_status_code rtems_rate_monotonic_get_status(
* If the period is inactive, there is no information.
*/
if ( status->state == RATE_MONOTONIC_INACTIVE ) {
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_Timespec_Set_to_zero( &status->since_last_period );
_Timespec_Set_to_zero( &status->executed_since_last_period );
#else
status->since_last_period = 0;
status->executed_since_last_period = 0;
#endif
} else {
/*
@@ -76,17 +67,12 @@ rtems_status_code rtems_rate_monotonic_get_status(
return RTEMS_NOT_DEFINED;
}
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_Timestamp_To_timespec(
&since_last_period, &status->since_last_period
);
_Timestamp_To_timespec(
&executed, &status->executed_since_last_period
);
#else
status->since_last_period = since_last_period;
status->executed_since_last_period = executed;
#endif
}
_Objects_Put( &the_period->Object );

View File

@@ -30,31 +30,23 @@ bool _Rate_monotonic_Get_status(
Thread_CPU_usage_t *cpu_since_last_period
)
{
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
Timestamp_Control uptime;
#endif
Thread_Control *owning_thread = the_period->owner;
Thread_CPU_usage_t used;
/*
* Determine elapsed wall time since period initiated.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_TOD_Get_uptime( &uptime );
_Timestamp_Subtract(
&the_period->time_period_initiated, &uptime, wall_since_last_period
);
#else
*wall_since_last_period =
_Watchdog_Ticks_since_boot - the_period->time_period_initiated;
#endif
/*
* Determine cpu usage since period initiated.
*/
used = owning_thread->cpu_time_used;
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
if (owning_thread == _Thread_Executing) {
Thread_CPU_usage_t ran;
@@ -81,16 +73,7 @@ bool _Rate_monotonic_Get_status(
cpu_since_last_period
);
}
#else
/*
* The cpu usage info was reset while executing. Can't
* determine a status.
*/
if (used < the_period->cpu_usage_period_initiated)
return false;
*cpu_since_last_period = used - the_period->cpu_usage_period_initiated;
#endif
return true;
}

View File

@@ -23,12 +23,10 @@
#include <inttypes.h>
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
/* We print to 1/10's of milliseconds */
#define NANOSECONDS_DIVIDER 1000
#define PERCENT_FMT "%04" PRId32
#define NANOSECONDS_FMT "%06" PRId32
#endif
/* We print to 1/10's of milliseconds */
#define NANOSECONDS_DIVIDER 1000
#define PERCENT_FMT "%04" PRId32
#define NANOSECONDS_FMT "%06" PRId32
void rtems_rate_monotonic_report_statistics_with_plugin(
void *context,
@@ -45,10 +43,8 @@ void rtems_rate_monotonic_report_statistics_with_plugin(
return;
(*print)( context, "Period information by period\n" );
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
(*print)( context, "--- CPU times are in seconds ---\n" );
(*print)( context, "--- Wall times are in seconds ---\n" );
#endif
/*
Layout by columns -- in memory of Hollerith :)
@@ -62,25 +58,11 @@ ididididid NNNN ccccc mmmmmm X
1234567890123456789012345678901234567890123456789012345678901234567890123456789\
\n");
*/
(*print)( context, " ID OWNER COUNT MISSED "
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
(*print)( context,
" ID OWNER COUNT MISSED "
" CPU TIME WALL TIME\n"
" "
#endif
"CPU TIME "
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
" "
#endif
" WALL TIME\n"
);
(*print)( context, " "
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
" "
#endif
"MIN/MAX/AVG "
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
" "
#endif
" MIN/MAX/AVG\n"
" MIN/MAX/AVG MIN/MAX/AVG\n"
);
/*
@@ -126,7 +108,6 @@ ididididid NNNN ccccc mmmmmm X
* print CPU Usage part of statistics
*/
{
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
struct timespec cpu_average;
struct timespec *min_cpu = &the_stats.min_cpu_time;
struct timespec *max_cpu = &the_stats.max_cpu_time;
@@ -144,25 +125,12 @@ ididididid NNNN ccccc mmmmmm X
_Timespec_Get_seconds( &cpu_average ),
_Timespec_Get_nanoseconds( &cpu_average ) / NANOSECONDS_DIVIDER
);
#else
uint32_t ival_cpu, fval_cpu;
ival_cpu = the_stats.total_cpu_time * 100 / the_stats.count;
fval_cpu = ival_cpu % 100;
ival_cpu /= 100;
(*print)( context,
"%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 " ",
the_stats.min_cpu_time, the_stats.max_cpu_time, ival_cpu, fval_cpu
);
#endif
}
/*
* print wall time part of statistics
*/
{
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
struct timespec wall_average;
struct timespec *min_wall = &the_stats.min_wall_time;
struct timespec *max_wall = &the_stats.max_wall_time;
@@ -180,17 +148,6 @@ ididididid NNNN ccccc mmmmmm X
_Timespec_Get_seconds( &wall_average ),
_Timespec_Get_nanoseconds( &wall_average ) / NANOSECONDS_DIVIDER
);
#else
uint32_t ival_wall, fval_wall;
ival_wall = the_stats.total_wall_time * 100 / the_stats.count;
fval_wall = ival_wall % 100;
ival_wall /= 100;
(*print)( context,
"%3" PRId32 "/%4" PRId32 "/%3" PRId32 ".%02" PRId32 "\n",
the_stats.min_wall_time, the_stats.max_wall_time, ival_wall, fval_wall
);
#endif
}
}
}

View File

@@ -83,13 +83,9 @@ extern "C" {
* The user can define this at configure time and go back to ticks
* resolution.
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
#include <rtems/score/timestamp.h>
#include <rtems/score/timestamp.h>
typedef Timestamp_Control Thread_CPU_usage_t;
#else
typedef uint32_t Thread_CPU_usage_t;
#endif
typedef Timestamp_Control Thread_CPU_usage_t;
/**
* The following defines the "return type" of a thread.

View File

@@ -31,13 +31,6 @@ void _Scheduler_default_Tick(
{
(void) scheduler;
#ifdef __RTEMS_USE_TICKS_FOR_STATISTICS__
/*
* Increment the number of ticks this thread has been executing
*/
executing->cpu_time_used++;
#endif
/*
* If the thread is not preemptible or is not ready, then
* just return.

View File

@@ -99,17 +99,10 @@ void _Thread_Do_dispatch( Per_CPU_Control *cpu_self, ISR_Level level )
_ISR_Enable( level );
#endif
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_Thread_Update_cpu_time_used(
executing,
&cpu_self->time_of_last_context_switch
);
#else
{
_TOD_Get_uptime( &cpu_self->time_of_last_context_switch );
heir->cpu_time_used++;
}
#endif
#if !defined(__DYNAMIC_REENT__)
/*

View File

@@ -217,11 +217,7 @@ bool _Thread_Initialize(
/*
* Initialize the CPU usage statistics
*/
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
_Timestamp_Set_to_zero( &the_thread->cpu_time_used );
#else
the_thread->cpu_time_used = 0;
#endif
/*
* initialize thread's key vaule node chain

View File

@@ -55,15 +55,10 @@ rtems_task Init(
/* Check status values. */
rtems_test_assert( period_status.owner == rtems_task_self() );
rtems_test_assert( period_status.state == RATE_MONOTONIC_INACTIVE );
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
rtems_test_assert( period_status.since_last_period.tv_sec == 0 );
rtems_test_assert( period_status.since_last_period.tv_nsec == 0 );
rtems_test_assert( period_status.executed_since_last_period.tv_sec == 0 );
rtems_test_assert( period_status.executed_since_last_period.tv_nsec == 0 );
#else
rtems_test_assert( period_status.since_last_period == 0 );
rtems_test_assert( period_status.executed_since_last_period == 0 );
#endif
/*
* Check get_status error cases.
@@ -113,7 +108,6 @@ rtems_task Init(
directive_failed( status, "rate_monotonic_get_status" );
/* Check status values. */
#ifndef __RTEMS_USE_TICKS_FOR_STATISTICS__
/* Note: POSIX mandates struct timespec->tv_nsec to be a "long" */
printf(
"wall time should be ~600000000 is %ld\n",
@@ -133,20 +127,6 @@ rtems_task Init(
rtems_test_assert(
period_status.executed_since_last_period.tv_nsec <= 110000000
);
#else
printf(
"wall time should be ~60 is %" PRId32 "\n",
(int) period_status.since_last_period
);
printf(
"cpu time should be ~10 is %" PRId32 "\n",
(int) period_status.executed_since_last_period
);
rtems_test_assert( period_status.since_last_period >= 60 );
rtems_test_assert( period_status.since_last_period <= 61 );
rtems_test_assert( period_status.executed_since_last_period >= 10 );
rtems_test_assert( period_status.executed_since_last_period <= 12 );
#endif
/* ensure the missed periods are properly accounted for */
puts( "rtems_rate_monotonic_cancel - OK" );