better names

This commit is contained in:
rusefi 2017-05-21 10:25:35 -04:00
parent a3919be9bd
commit 67a28c081f
5 changed files with 46 additions and 29 deletions

View File

@ -155,16 +155,19 @@ char *getWarning(void) {
} }
uint32_t lastLockTime; uint32_t lastLockTime;
uint32_t maxLockTime = 0; /**
* Maximum time before requesting lock and releasing lock at the end of critical section
*/
uint32_t maxLockedDuration = 0;
void onLockHook(void) { void onLockHook(void) {
lastLockTime = GET_TIMESTAMP(); lastLockTime = GET_TIMESTAMP();
} }
void onUnlockHook(void) { void onUnlockHook(void) {
uint32_t t = GET_TIMESTAMP() - lastLockTime; uint32_t lockedDuration = GET_TIMESTAMP() - lastLockTime;
if (t > maxLockTime) { if (lockedDuration > maxLockedDuration) {
maxLockTime = t; maxLockedDuration = lockedDuration;
} }
// if (t > 2800) { // if (t > 2800) {
// // un-comment this if you want a nice stop for a breakpoint // // un-comment this if you want a nice stop for a breakpoint

View File

@ -35,8 +35,7 @@ extern schfunc_t globalTimerCallback;
*/ */
static efitime_t nextEventTimeNt = 0; static efitime_t nextEventTimeNt = 0;
uint32_t beforeHwSetTimer; uint32_t hwSetTimerDuration;
uint32_t hwSetTimerTime;
uint32_t lastExecutionCount; uint32_t lastExecutionCount;
static void executorCallback(void *arg) { static void executorCallback(void *arg) {
@ -136,9 +135,9 @@ void Executor::scheduleTimerCallback() {
if (nextEventTimeNt == EMPTY_QUEUE) if (nextEventTimeNt == EMPTY_QUEUE)
return; // no pending events in the queue return; // no pending events in the queue
int32_t hwAlarmTime = NT2US((int32_t)nextEventTimeNt - (int32_t)nowNt); int32_t hwAlarmTime = NT2US((int32_t)nextEventTimeNt - (int32_t)nowNt);
beforeHwSetTimer = GET_TIMESTAMP(); uint32_t beforeHwSetTimer = GET_TIMESTAMP();
setHardwareUsTimer(hwAlarmTime == 0 ? 1 : hwAlarmTime); setHardwareUsTimer(hwAlarmTime == 0 ? 1 : hwAlarmTime);
hwSetTimerTime = GET_TIMESTAMP() - beforeHwSetTimer; hwSetTimerDuration = GET_TIMESTAMP() - beforeHwSetTimer;
} }
/** /**

View File

@ -106,8 +106,11 @@ efitime_t EventQueue::getNextEventTime(efitime_t nowX) {
} }
static scheduling_s * longScheduling; static scheduling_s * longScheduling;
uint32_t maxEventQueueTime = 0; /**
uint32_t lastEventQueueTime; * See also maxPrecisionCallbackDuration for total hw callback time
*/
uint32_t maxEventCallbackDuration = 0;
static uint32_t lastEventCallbackDuration;
/** /**
* Invoke all pending actions prior to specified timestamp * Invoke all pending actions prior to specified timestamp
@ -169,12 +172,12 @@ int EventQueue::executeAll(efitime_t now) {
#endif #endif
current->callback(current->param); current->callback(current->param);
// even with overflow it's safe to subtract here // even with overflow it's safe to subtract here
lastEventQueueTime = GET_TIMESTAMP() - before; lastEventCallbackDuration = GET_TIMESTAMP() - before;
if (lastEventQueueTime > maxEventQueueTime) if (lastEventCallbackDuration > maxEventCallbackDuration)
maxEventQueueTime = lastEventQueueTime; maxEventCallbackDuration = lastEventCallbackDuration;
if (lastEventQueueTime > 2000) { if (lastEventCallbackDuration > 2000) {
longScheduling = current; longScheduling = current;
lastEventQueueTime++; // what is this line about? lastEventCallbackDuration++;
} }
} }
return executionCounter; return executionCounter;

View File

@ -386,11 +386,15 @@ void printAllTriggers() {
extern PwmConfig triggerSignal; extern PwmConfig triggerSignal;
#endif /* #if EFI_PROD_CODE */ #endif /* #if EFI_PROD_CODE */
extern uint32_t maxLockTime;
extern uint32_t maxEventQueueTime;
extern uint32_t hipLastExecutionCount; extern uint32_t hipLastExecutionCount;
extern uint32_t hwSetTimerTime; extern uint32_t hwSetTimerDuration;
extern uint32_t maxPrecisionTCallbackDuration;
extern uint32_t maxLockedDuration;
extern uint32_t maxEventCallbackDuration;
#if (EFI_PROD_CODE) || defined(__DOXYGEN__)
extern uint32_t maxPrecisionCallbackDuration;
#endif /* EFI_PROD_CODE */
extern int maxHowFarOff; extern int maxHowFarOff;
extern uint32_t *cyccnt; extern uint32_t *cyccnt;
@ -400,9 +404,13 @@ extern int vvtEventFallCounter;
void resetMaxValues() { void resetMaxValues() {
#if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__) #if (EFI_PROD_CODE || EFI_SIMULATOR) || defined(__DOXYGEN__)
maxEventQueueTime = triggerMaxDuration = 0; maxEventCallbackDuration = triggerMaxDuration = 0;
maxPrecisionTCallbackDuration = 0;
#endif /* EFI_PROD_CODE || EFI_SIMULATOR */ #endif /* EFI_PROD_CODE || EFI_SIMULATOR */
maxLockedDuration = 0;
#if (EFI_PROD_CODE) || defined(__DOXYGEN__)
maxPrecisionCallbackDuration = 0;
#endif /* EFI_PROD_CODE */
} }
void triggerInfo(void) { void triggerInfo(void) {
@ -495,15 +503,14 @@ void triggerInfo(void) {
engine->m.rpmCbTime, engine->m.rpmCbTime,
engine->m.mainTriggerCallbackTime); engine->m.mainTriggerCallbackTime);
scheduleMsg(logger, "maxLockTime=%d / maxTriggerReentraint=%d", maxLockTime, maxTriggerReentraint); scheduleMsg(logger, "maxLockedDuration=%d / maxTriggerReentraint=%d", maxLockedDuration, maxTriggerReentraint);
maxLockTime = 0; scheduleMsg(logger, "maxEventCallbackDuration=%d", maxEventCallbackDuration);
scheduleMsg(logger, "maxEventQueueTime=%d", maxEventQueueTime);
scheduleMsg(logger, "hipLastExecutionCount=%d", hipLastExecutionCount); scheduleMsg(logger, "hipLastExecutionCount=%d", hipLastExecutionCount);
scheduleMsg(logger, "hwSetTimerTime %d", hwSetTimerTime); scheduleMsg(logger, "hwSetTimerDuration=%d", hwSetTimerDuration);
scheduleMsg(logger, "totalTriggerHandlerMaxTime=%d", triggerMaxDuration); scheduleMsg(logger, "totalTriggerHandlerMaxTime=%d", triggerMaxDuration);
scheduleMsg(logger, "maxPrecisionTCallbackDuration=%d", maxPrecisionTCallbackDuration); scheduleMsg(logger, "maxPrecisionCallbackDuration=%d", maxPrecisionCallbackDuration);
resetMaxValues(); resetMaxValues();
#endif /* EFI_PROD_CODE */ #endif /* EFI_PROD_CODE */

View File

@ -21,8 +21,13 @@
#if (EFI_PROD_CODE && HAL_USE_GPT) || defined(__DOXYGEN__) #if (EFI_PROD_CODE && HAL_USE_GPT) || defined(__DOXYGEN__)
#include "efilib2.h" #include "efilib2.h"
uint32_t maxPrecisionTCallbackDuration = 0; /**
* Maximum duration of complete timer callback, all pending events together
* See also 'maxEventCallbackDuration' for maximum duration of one event
*/
uint32_t maxPrecisionCallbackDuration = 0;
// must be one of 32 bit times
#define GPTDEVICE GPTD5 #define GPTDEVICE GPTD5
static volatile efitick_t lastSetTimerTimeNt; static volatile efitick_t lastSetTimerTimeNt;
@ -99,8 +104,8 @@ static void callback(GPTDriver *gptp) {
uint32_t before = GET_TIMESTAMP(); uint32_t before = GET_TIMESTAMP();
globalTimerCallback(NULL); globalTimerCallback(NULL);
uint32_t precisionCallbackDuration = GET_TIMESTAMP() - before; uint32_t precisionCallbackDuration = GET_TIMESTAMP() - before;
if (precisionCallbackDuration > maxPrecisionTCallbackDuration) { if (precisionCallbackDuration > maxPrecisionCallbackDuration) {
maxPrecisionTCallbackDuration = precisionCallbackDuration; maxPrecisionCallbackDuration = precisionCallbackDuration;
} }
} }