From fcdd2027419607bed6b24a9ee364d6ad4cd99a41 Mon Sep 17 00:00:00 2001 From: Daniel Bertalan Date: Thu, 16 Dec 2021 18:11:25 +0100 Subject: [PATCH] Kernel: Return the actual number of CPU cores that we have ... instead of returning the maximum number of Processor objects that we can allocate. Some ports (e.g. gdb) rely on this information to determine the number of worker threads to spawn. When gdb spawned 64 threads, the kernel could not cope with generating backtraces for it, which prevented us from debugging it properly. This commit also removes the confusingly named `Processor::processor_count` function so that this mistake can't happen again. --- Kernel/Arch/x86/Processor.h | 2 -- Kernel/Syscalls/sysconf.cpp | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Kernel/Arch/x86/Processor.h b/Kernel/Arch/x86/Processor.h index 2aab603edb..e49b34cb3c 100644 --- a/Kernel/Arch/x86/Processor.h +++ b/Kernel/Arch/x86/Processor.h @@ -179,8 +179,6 @@ public: void flush_gdt(); const DescriptorTablePointer& get_gdtr(); - static size_t processor_count() { return processors().size(); } - template Callback> static inline IterationDecision for_each(Callback callback) { diff --git a/Kernel/Syscalls/sysconf.cpp b/Kernel/Syscalls/sysconf.cpp index ce6b649480..b7a82d73d4 100644 --- a/Kernel/Syscalls/sysconf.cpp +++ b/Kernel/Syscalls/sysconf.cpp @@ -18,7 +18,7 @@ ErrorOr Process::sys$sysconf(int name) return 1; case _SC_NPROCESSORS_CONF: case _SC_NPROCESSORS_ONLN: - return Processor::processor_count(); + return Processor::count(); case _SC_OPEN_MAX: return OpenFileDescriptions::max_open(); case _SC_PAGESIZE: