mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-01 03:34:32 +02:00
Merge branch 'bugfix/pm_dump_locks_v4.1' into 'release/v4.1'
esp_pm: esp_pm_dump_locks: don't print from a critical section (backport v4.1) See merge request espressif/esp-idf!8353
This commit is contained in:
@@ -173,26 +173,35 @@ esp_err_t esp_pm_dump_locks(FILE* stream)
|
|||||||
|
|
||||||
fprintf(stream, "Lock stats:\n");
|
fprintf(stream, "Lock stats:\n");
|
||||||
esp_pm_lock_t* it;
|
esp_pm_lock_t* it;
|
||||||
|
char line[64];
|
||||||
SLIST_FOREACH(it, &s_list, next) {
|
SLIST_FOREACH(it, &s_list, next) {
|
||||||
|
char *buf = line;
|
||||||
|
size_t len = sizeof(line) - 1;
|
||||||
|
line[len] = 0;
|
||||||
|
size_t cb;
|
||||||
|
|
||||||
portENTER_CRITICAL(&it->spinlock);
|
portENTER_CRITICAL(&it->spinlock);
|
||||||
if (it->name == NULL) {
|
if (it->name == NULL) {
|
||||||
fprintf(stream, "lock@%p ", it);
|
cb = snprintf(buf, len, "lock@%p ", it);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stream, "%-15s ", it->name);
|
cb = snprintf(buf, len, "%-15s ", it->name);
|
||||||
}
|
}
|
||||||
|
buf += cb;
|
||||||
|
len -= cb;
|
||||||
#ifdef WITH_PROFILING
|
#ifdef WITH_PROFILING
|
||||||
pm_time_t time_held = it->time_held;
|
pm_time_t time_held = it->time_held;
|
||||||
if (it->count > 0) {
|
if (it->count > 0) {
|
||||||
time_held += cur_time - it->last_taken;
|
time_held += cur_time - it->last_taken;
|
||||||
}
|
}
|
||||||
fprintf(stream, "%10s %3d %3d %9d %9lld %3lld%%\n",
|
snprintf(buf, len, "%10s %3d %3d %9d %9lld %3lld%%\n",
|
||||||
s_lock_type_names[it->type], it->arg,
|
s_lock_type_names[it->type], it->arg,
|
||||||
it->count, it->times_taken, time_held,
|
it->count, it->times_taken, time_held,
|
||||||
(time_held + cur_time_d100 - 1) / cur_time_d100);
|
(time_held + cur_time_d100 - 1) / cur_time_d100);
|
||||||
#else
|
#else
|
||||||
fprintf(stream, "%10s %3d %3d\n", s_lock_type_names[it->type], it->arg, it->count);
|
snprintf(buf, len, "%10s %3d %3d\n", s_lock_type_names[it->type], it->arg, it->count);
|
||||||
#endif // WITH_PROFILING
|
#endif // WITH_PROFILING
|
||||||
portEXIT_CRITICAL(&it->spinlock);
|
portEXIT_CRITICAL(&it->spinlock);
|
||||||
|
fputs(line, stream);
|
||||||
}
|
}
|
||||||
_lock_release(&s_list_lock);
|
_lock_release(&s_list_lock);
|
||||||
#ifdef WITH_PROFILING
|
#ifdef WITH_PROFILING
|
||||||
|
Reference in New Issue
Block a user