more CPU stats code
This commit is contained in:
parent
91c1533abe
commit
a549009c99
|
@ -35,10 +35,28 @@
|
||||||
#define CHPRINTF_USE_FLOAT TRUE
|
#define CHPRINTF_USE_FLOAT TRUE
|
||||||
|
|
||||||
#if !defined(EFI_CLOCK_LOCKS) || defined(__DOXYGEN__)
|
#if !defined(EFI_CLOCK_LOCKS) || defined(__DOXYGEN__)
|
||||||
|
// looks like this value could not be defined in efifeatures.h - please define either externally or just change the value here
|
||||||
#define EFI_CLOCK_LOCKS FALSE
|
#define EFI_CLOCK_LOCKS FALSE
|
||||||
#endif /* EFI_CLOCK_LOCKS */
|
#endif /* EFI_CLOCK_LOCKS */
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
#ifndef __ASSEMBLER__
|
||||||
|
#if EFI_CLOCK_LOCKS
|
||||||
|
void irqEnterHook(void);
|
||||||
|
void irqExitHook(void);
|
||||||
|
#else /* EFI_CLOCK_LOCKS */
|
||||||
|
#define irqEnterHook() {}
|
||||||
|
#define irqExitHook() {}
|
||||||
|
#endif /*EFI_CLOCK_LOCKS */
|
||||||
|
#endif /* __ASSEMBLER__ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
#if EFI_CLOCK_LOCKS
|
#if EFI_CLOCK_LOCKS
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
|
@ -511,6 +529,7 @@ extern "C"
|
||||||
*/
|
*/
|
||||||
#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
|
#define CH_CFG_IRQ_PROLOGUE_HOOK() { \
|
||||||
/* IRQ prologue code here.*/ \
|
/* IRQ prologue code here.*/ \
|
||||||
|
irqEnterHook(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -518,6 +537,7 @@ extern "C"
|
||||||
*/
|
*/
|
||||||
#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
|
#define CH_CFG_IRQ_EPILOGUE_HOOK() { \
|
||||||
/* IRQ epilogue code here.*/ \
|
/* IRQ epilogue code here.*/ \
|
||||||
|
irqExitHook(); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -246,6 +246,43 @@ static void resetAccel(void) {
|
||||||
engine->wallFuel.reset();
|
engine->wallFuel.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#if EFI_CLOCK_LOCKS
|
||||||
|
static int previousSecond;
|
||||||
|
|
||||||
|
typedef FLStack<int, 16> irq_enter_timestamps_t;
|
||||||
|
|
||||||
|
static irq_enter_timestamps_t irqEnterTimestamps;
|
||||||
|
|
||||||
|
void irqEnterHook(void) {
|
||||||
|
irqEnterTimestamps.push(GET_TIMESTAMP());
|
||||||
|
}
|
||||||
|
|
||||||
|
static int currentIrqDurationAccumulator = 0;
|
||||||
|
static int currentIrqCounter = 0;
|
||||||
|
/**
|
||||||
|
* See also maxLockedDuration
|
||||||
|
*/
|
||||||
|
int perSecondIrqDuration = 0;
|
||||||
|
int perSecondIrqCounter = 0;
|
||||||
|
void irqExitHook(void) {
|
||||||
|
int enterTime = irqEnterTimestamps.pop();
|
||||||
|
currentIrqDurationAccumulator += (GET_TIMESTAMP() - enterTime);
|
||||||
|
currentIrqCounter++;
|
||||||
|
}
|
||||||
|
#endif /* EFI_CLOCK_LOCKS */
|
||||||
|
|
||||||
|
static void invokePerSecond(void) {
|
||||||
|
#if EFI_CLOCK_LOCKS
|
||||||
|
// this data transfer is not atomic but should be totally good enough
|
||||||
|
perSecondIrqDuration = currentIrqDurationAccumulator;
|
||||||
|
perSecondIrqCounter = currentIrqCounter;
|
||||||
|
currentIrqDurationAccumulator = currentIrqCounter = 0;
|
||||||
|
#endif /* EFI_CLOCK_LOCKS */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void periodicSlowCallback(Engine *engine) {
|
static void periodicSlowCallback(Engine *engine) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6661, getRemainingStack(chThdGetSelfX()) > 64, "lowStckOnEv");
|
efiAssertVoid(CUSTOM_ERR_6661, getRemainingStack(chThdGetSelfX()) > 64, "lowStckOnEv");
|
||||||
#if EFI_PROD_CODE
|
#if EFI_PROD_CODE
|
||||||
|
@ -253,11 +290,16 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
* We need to push current value into the 64 bit counter often enough so that we do not miss an overflow
|
* We need to push current value into the 64 bit counter often enough so that we do not miss an overflow
|
||||||
*/
|
*/
|
||||||
bool alreadyLocked = lockAnyContext();
|
bool alreadyLocked = lockAnyContext();
|
||||||
updateAndSet(&halTime.state, port_rt_get_counter_value());
|
updateAndSet(&halTime.state, GET_TIMESTAMP());
|
||||||
if (!alreadyLocked) {
|
if (!alreadyLocked) {
|
||||||
unlockAnyContext();
|
unlockAnyContext();
|
||||||
}
|
}
|
||||||
#endif
|
int timeSeconds = getTimeNowSeconds();
|
||||||
|
if (previousSecond != timeSeconds) {
|
||||||
|
previousSecond = timeSeconds;
|
||||||
|
invokePerSecond();
|
||||||
|
}
|
||||||
|
#endif /* EFI_PROD_CODE */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update engine RPM state if needed (check timeouts).
|
* Update engine RPM state if needed (check timeouts).
|
||||||
|
@ -265,9 +307,9 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
engine->rpmCalculator.checkIfSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
engine->rpmCalculator.checkIfSpinning(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
|
||||||
if (engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
if (engine->rpmCalculator.isStopped(PASS_ENGINE_PARAMETER_SIGNATURE)) {
|
||||||
#if (EFI_PROD_CODE && EFI_ENGINE_CONTROL && EFI_INTERNAL_FLASH) || defined(__DOXYGEN__)
|
#if EFI_INTERNAL_FLASH || defined(__DOXYGEN__)
|
||||||
writeToFlashIfPending();
|
writeToFlashIfPending();
|
||||||
#endif
|
#endif /* EFI_INTERNAL_FLASH */
|
||||||
resetAccel();
|
resetAccel();
|
||||||
} else {
|
} else {
|
||||||
updatePrimeInjectionPulseState(PASS_ENGINE_PARAMETER_SIGNATURE);
|
updatePrimeInjectionPulseState(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
|
@ -282,7 +324,7 @@ static void periodicSlowCallback(Engine *engine) {
|
||||||
engine->updateSlowSensors();
|
engine->updateSlowSensors();
|
||||||
engine->checkShutdown();
|
engine->checkShutdown();
|
||||||
|
|
||||||
#if (EFI_PROD_CODE && EFI_FSIO) || defined(__DOXYGEN__)
|
#if EFI_FSIO || defined(__DOXYGEN__)
|
||||||
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
runFsio(PASS_ENGINE_PARAMETER_SIGNATURE);
|
||||||
#endif /* EFI_PROD_CODE && EFI_FSIO */
|
#endif /* EFI_PROD_CODE && EFI_FSIO */
|
||||||
|
|
||||||
|
@ -736,5 +778,5 @@ int getRusEfiVersion(void) {
|
||||||
if (initBootloader() != 0)
|
if (initBootloader() != 0)
|
||||||
return 123;
|
return 123;
|
||||||
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
#endif /* EFI_BOOTLOADER_INCLUDE_CODE */
|
||||||
return 20181209;
|
return 20181223;
|
||||||
}
|
}
|
||||||
|
|
|
@ -505,6 +505,9 @@ extern uint32_t hwSetTimerDuration;
|
||||||
extern uint32_t maxLockedDuration;
|
extern uint32_t maxLockedDuration;
|
||||||
extern uint32_t maxEventCallbackDuration;
|
extern uint32_t maxEventCallbackDuration;
|
||||||
|
|
||||||
|
extern int perSecondIrqDuration;
|
||||||
|
extern int perSecondIrqCounter;
|
||||||
|
|
||||||
#if (EFI_PROD_CODE) || defined(__DOXYGEN__)
|
#if (EFI_PROD_CODE) || defined(__DOXYGEN__)
|
||||||
extern uint32_t maxPrecisionCallbackDuration;
|
extern uint32_t maxPrecisionCallbackDuration;
|
||||||
#endif /* EFI_PROD_CODE */
|
#endif /* EFI_PROD_CODE */
|
||||||
|
@ -622,6 +625,10 @@ void triggerInfo(void) {
|
||||||
|
|
||||||
#if EFI_CLOCK_LOCKS || defined(__DOXYGEN__)
|
#if EFI_CLOCK_LOCKS || defined(__DOXYGEN__)
|
||||||
scheduleMsg(logger, "maxLockedDuration=%d / maxTriggerReentraint=%d", maxLockedDuration, maxTriggerReentraint);
|
scheduleMsg(logger, "maxLockedDuration=%d / maxTriggerReentraint=%d", maxLockedDuration, maxTriggerReentraint);
|
||||||
|
|
||||||
|
scheduleMsg(logger, "perSecondIrqDuration=%d ticks / perSecondIrqCounter=%d", perSecondIrqDuration, perSecondIrqCounter);
|
||||||
|
scheduleMsg(logger, "IRQ CPU utilization %f%%", perSecondIrqDuration / 168000000.0 * 100);
|
||||||
|
|
||||||
#endif /* EFI_CLOCK_LOCKS */
|
#endif /* EFI_CLOCK_LOCKS */
|
||||||
|
|
||||||
scheduleMsg(logger, "maxEventCallbackDuration=%d", maxEventCallbackDuration);
|
scheduleMsg(logger, "maxEventCallbackDuration=%d", maxEventCallbackDuration);
|
||||||
|
|
Loading…
Reference in New Issue