Collect debug information about thread queues

This commit is contained in:
Mark
2020-01-05 02:41:31 +02:00
parent 30078e18e6
commit a83f7ddb45
2 changed files with 23 additions and 0 deletions
+19
View File
@@ -365,6 +365,25 @@ static uint64_t debug_last_tick = 0;
static void debug_stats(void) {
kdebug("--- STATS ---\n");
kdebug("syscalls/s: %lu\n", syscall_count);
kdebug("CPU queues:\n");
for (size_t i = 0; i < sched_ncpus; ++i) {
debugf(DEBUG_DEFAULT, " cpu%d [ ", i);
for (struct thread *it = sched_queue_heads[i]; it; it = it->next) {
if (it->flags & THREAD_KERNEL) {
// Kernel threads have no pids, lol
debugs(DEBUG_DEFAULT, "K?");
} else {
debugf(DEBUG_DEFAULT, "%d", it->pid);
}
if (it->next) {
debugs(DEBUG_DEFAULT, ", ");
}
}
debugs(DEBUG_DEFAULT, " ]\n");
}
kdebug("--- ----- ---\n");
syscall_count = 0;
+4
View File
@@ -387,6 +387,10 @@ static int cmd_exec(const char *line) {
}
int main(int argc, char **argv) {
if (getpid() != 1) {
printf("Won't work if PID is not 1\n");
return -1;
}
char linebuf[512];
char c;
size_t l = 0;