Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## Development Build: equuleus-rc1+dev67
- 'Fix #452, rtems sysmom overflow buffer'
- See: <https://github.com/nasa/psp/pull/453>


## Development Build: equuleus-rc1:dev61
- update PCS_malloc stub PoolSize overflow
- Add rtems_sysmon unit test
Expand Down
2 changes: 1 addition & 1 deletion fsw/mcp750-vxworks/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 61
#define CFE_PSP_IMPL_BUILD_NUMBER 67
#define CFE_PSP_IMPL_BUILD_BASELINE "equuleus-rc1"
#define CFE_PSP_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
#define CFE_PSP_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */
Expand Down
42 changes: 17 additions & 25 deletions fsw/modules/rtems_sysmon/rtems_sysmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ void rtems_sysmon_Init(uint32_t local_module_id)
bool rtems_cpu_usage_visitor(Thread_Control *the_thread, void *arg)
{
rtems_sysmon_cpuload_state_t *state = (rtems_sysmon_cpuload_state_t *)arg;
rtems_sysmon_cpuload_core_t* core_p = &state->per_core[state->num_cpus];
rtems_sysmon_cpuload_core_t* core_p;

Timestamp_Control uptime_at_last_calc = core_p->last_run_time;
Timestamp_Control idle_uptime_at_last_calc = core_p->idle_last_uptime;
Timestamp_Control uptime_at_last_calc;
Timestamp_Control idle_uptime_at_last_calc;
Timestamp_Control current_uptime;
Timestamp_Control idle_task_uptime;
Timestamp_Control idle_uptime_elapsed;
Expand All @@ -82,8 +82,19 @@ bool rtems_cpu_usage_visitor(Thread_Control *the_thread, void *arg)
uint32_t fval;
bool status = false;

if(state->poll_core_no >= RTEMS_SYSMON_MAX_CPUS)
{
/* Set true to stop iterating. All idle task has been found. */
status = true;
state->poll_core_no = 0;
}

core_p = &state->per_core[state->poll_core_no];
uptime_at_last_calc = core_p->last_run_time;
idle_uptime_at_last_calc = core_p->idle_last_uptime;

_Thread_Get_name(the_thread, name, sizeof(name));
if(strncmp("IDLE", name, 4) == 0)
if(strncmp("IDLE", name, 4) == 0 && status == false)
{
#if __RTEMS_MAJOR__ == 5
_Thread_Get_CPU_time_used( the_thread, &idle_task_uptime );
Expand Down Expand Up @@ -122,26 +133,7 @@ bool rtems_cpu_usage_visitor(Thread_Control *the_thread, void *arg)
core_p->avg_load |= (core_p->avg_load << 12);
}

#ifdef DEBUG_BUILD
rtems_cpu_usage_report();

uint32_t microsec = _Timestamp_Get_nanoseconds( &idle_uptime_elapsed ) / TOD_NANOSECONDS_PER_MICROSECOND;
uint32_t sec = _Timestamp_Get_seconds( &idle_uptime_elapsed );
RTEMS_SYSMON_DEBUG("\nCFE_PSP(rtems_sysmon): IDLE cpu time elapsed = %7u.%06u, IDLE percentages =%4u.%03u\n",
sec, microsec, ival, fval);

microsec = _Timestamp_Get_nanoseconds( &total_elapsed ) / TOD_NANOSECONDS_PER_MICROSECOND;
sec = _Timestamp_Get_seconds( &total_elapsed );
RTEMS_SYSMON_DEBUG("CFE_PSP(rtems_sysmon): Total elapsed CPU time = %7u.%06u, CPU Load =%08X\n",
sec, microsec, core_p->avg_load);
#endif

state->num_cpus++;
if(state->num_cpus >= RTEMS_SYSMON_MAX_CPUS)
{
/* stop checking when all idle tasks has been found */
status = true;
}
state->poll_core_no++;
}

/* return true to exit iterating tasks */
Expand All @@ -150,7 +142,7 @@ bool rtems_cpu_usage_visitor(Thread_Control *the_thread, void *arg)

void rtems_sysmon_update_stat(rtems_sysmon_cpuload_state_t *state)
{
state->num_cpus = 0;
state->poll_core_no = 0;
rtems_task_iterate( rtems_cpu_usage_visitor, state);
}

Expand Down
2 changes: 1 addition & 1 deletion fsw/modules/rtems_sysmon/rtems_sysmon.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef struct rtems_sysmon_cpuload_state
rtems_id task_id;
rtems_name task_name;

uint8_t num_cpus;
uint8_t poll_core_no;
rtems_sysmon_cpuload_core_t per_core[RTEMS_SYSMON_MAX_CPUS];

} rtems_sysmon_cpuload_state_t;
Expand Down
2 changes: 1 addition & 1 deletion fsw/pc-linux/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 61
#define CFE_PSP_IMPL_BUILD_NUMBER 67
#define CFE_PSP_IMPL_BUILD_BASELINE "equuleus-rc1"
#define CFE_PSP_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
#define CFE_PSP_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */
Expand Down
2 changes: 1 addition & 1 deletion fsw/pc-rtems/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 61
#define CFE_PSP_IMPL_BUILD_NUMBER 67
#define CFE_PSP_IMPL_BUILD_BASELINE "equuleus-rc1"
#define CFE_PSP_BUILD_DEV_CYCLE "equuleus-rc2" /**< @brief Development: Release name for current development cycle */
#define CFE_PSP_BUILD_CODENAME "Equuleus" /**< @brief: Development: Code name for the current build */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ void Test_Cpu_Visitor_Nominal(void)
UT_TimeDivideData.IntValue = 100;
UT_TimeDivideData.FraValue = 0;

UtAssert_BOOL_TRUE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_BOOL_FALSE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_True(Arg.per_core[0].avg_load == 0xFFFFFF, "Nominal Case: 100 percents cpu utilization");

/* Nominal Case Idle Task */
Expand All @@ -317,7 +317,7 @@ void Test_Cpu_Visitor_Nominal(void)
UT_TimeDivideData.TotalElapsed = 10;
UT_TimeDivideData.IdleUptimeElapsed = 5;

UtAssert_BOOL_TRUE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_BOOL_FALSE(rtems_cpu_usage_visitor(&Thread, &Arg));

AverageLoadCalc = 0x1000 * UT_TimeDivideData.IntValue / 100;
AverageLoadCalc |= (AverageLoadCalc << 12);
Expand All @@ -337,7 +337,7 @@ void Test_Cpu_Visitor_Nominal(void)
UT_TimeDivideData.TotalElapsed = 10; /* placeholder */
UT_TimeDivideData.IdleUptimeElapsed = 5; /* placeholder*/

UtAssert_BOOL_TRUE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_BOOL_FALSE(rtems_cpu_usage_visitor(&Thread, &Arg));

/* convert int and fra part of percentages into integer.
** Then convert into an percentages and normalizes out of 0x1000
Expand All @@ -361,18 +361,18 @@ void Test_Cpu_Visitor_Nominal(void)
UT_TimeDivideData.TotalElapsed = 0;
UT_TimeDivideData.IdleUptimeElapsed = 0;

UtAssert_BOOL_TRUE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_BOOL_FALSE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_True(Arg.per_core[0].avg_load == 0, "Nominal Case: 0 percents cpu utilization");

/* Nominal Case: Max Cpu not reach */
/* Nominal Case: polling cpu reaches RTEMS_SYSMON_MAX_CPUS */
memset(UT_ThreadGetNameData.Name, 0, sizeof(UT_ThreadGetNameData.Name));
memset(&Arg, 0, sizeof(Arg));
memset(&UT_TimeDivideData, 0, sizeof(UT_TimeDivideData));

strncpy(UT_ThreadGetNameData.Name, "IDLE", 4);
Arg.num_cpus = -1;
UtAssert_BOOL_FALSE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_True(Arg.num_cpus == 0, "Nominal Case: CPU Number increment");
Arg.poll_core_no = RTEMS_SYSMON_MAX_CPUS;
UtAssert_BOOL_TRUE(rtems_cpu_usage_visitor(&Thread, &Arg));
UtAssert_True(Arg.poll_core_no == 0, "Nominal Case: cpu number reseted");

}

Expand Down
Loading