KernelBenchmarksTrackUtilisation: refactor reset

Change benchmark_track_reset_utilisation to take a tcb object parameter
so that the function is more widely applicable.

Signed-off-by: Kent McLeod <Kent.Mcleod@data61.csiro.au>
This commit is contained in:
Kent McLeod 2020-07-14 14:05:19 +10:00
parent 4eccea54e5
commit 8e358332bf
3 changed files with 18 additions and 19 deletions

View file

@ -17,7 +17,7 @@ extern timestamp_t ksEnter;
void benchmark_track_utilisation_dump(void);
void benchmark_track_reset_utilisation(void);
void benchmark_track_reset_utilisation(tcb_t *tcb);
/* Calculate and add the utilisation time from when the heir started to run i.e. scheduled
* and until it's being kicked off
*/

View file

@ -209,7 +209,7 @@ exception_t handleUnknownSyscall(word_t w)
#endif /* CONFIG_BENCHMARK_USE_KERNEL_LOG_BUFFER */
#ifdef CONFIG_BENCHMARK_TRACK_UTILISATION
NODE_STATE(benchmark_log_utilisation_enabled) = true;
NODE_STATE(ksIdleThread)->benchmark.utilisation = 0;
benchmark_track_reset_utilisation(NODE_STATE(ksIdleThread));
NODE_STATE(ksCurThread)->benchmark.schedule_start_time = ksEnter;
NODE_STATE(benchmark_start_time) = ksEnter;
benchmark_arch_utilisation_reset();
@ -244,7 +244,21 @@ exception_t handleUnknownSyscall(word_t w)
benchmark_track_utilisation_dump();
return EXCEPTION_NONE;
} else if (w == SysBenchmarkResetThreadUtilisation) {
benchmark_track_reset_utilisation();
word_t tcb_cptr = getRegister(NODE_STATE(ksCurThread), capRegister);
lookupCap_ret_t lu_ret;
word_t cap_type;
lu_ret = lookupCap(NODE_STATE(ksCurThread), tcb_cptr);
/* ensure we got a TCB cap */
cap_type = cap_get_capType(lu_ret.cap);
if (cap_type != cap_thread_cap) {
userError("SysBenchmarkResetThreadUtilisation: cap is not a TCB, halting");
return EXCEPTION_NONE;
}
tcb_t *tcb = TCB_PTR(cap_thread_cap_get_capTCBPtr(lu_ret.cap));
benchmark_track_reset_utilisation(tcb);
return EXCEPTION_NONE;
}
#endif /* CONFIG_BENCHMARK_TRACK_UTILISATION */

View file

@ -48,23 +48,8 @@ void benchmark_track_utilisation_dump(void)
}
void benchmark_track_reset_utilisation(void)
void benchmark_track_reset_utilisation(tcb_t *tcb)
{
tcb_t *tcb = NULL;
word_t tcb_cptr = getRegister(NODE_STATE(ksCurThread), capRegister);
lookupCap_ret_t lu_ret;
word_t cap_type;
lu_ret = lookupCap(NODE_STATE(ksCurThread), tcb_cptr);
/* ensure we got a TCB cap */
cap_type = cap_get_capType(lu_ret.cap);
if (cap_type != cap_thread_cap) {
userError("SysBenchmarkResetThreadUtilisation: cap is not a TCB, halting");
return;
}
tcb = TCB_PTR(cap_thread_cap_get_capTCBPtr(lu_ret.cap));
tcb->benchmark.utilisation = 0;
tcb->benchmark.schedule_start_time = 0;
}