diff --git a/Applications/SystemMonitor/ProcessModel.cpp b/Applications/SystemMonitor/ProcessModel.cpp index 2445976ade..9dbaf99807 100644 --- a/Applications/SystemMonitor/ProcessModel.cpp +++ b/Applications/SystemMonitor/ProcessModel.cpp @@ -237,10 +237,10 @@ void ProcessModel::update() ThreadState state; state.pid = it.value.pid; state.user = it.value.username; - state.syscall_count = it.value.syscall_count; - state.inode_faults = it.value.inode_faults; - state.zero_faults = it.value.zero_faults; - state.cow_faults = it.value.cow_faults; + state.syscall_count = thread.syscall_count; + state.inode_faults = thread.inode_faults; + state.zero_faults = thread.zero_faults; + state.cow_faults = thread.cow_faults; state.name = it.value.name; state.amount_virtual = it.value.amount_virtual; state.amount_resident = it.value.amount_resident; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index 928719b4fe..782c3f97e8 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -689,10 +689,6 @@ Optional procfs$all(InodeIdentifier) process_object.add("amount_virtual", (u32)process.amount_virtual()); process_object.add("amount_resident", (u32)process.amount_resident()); process_object.add("amount_shared", (u32)process.amount_shared()); - process_object.add("syscall_count", process.syscall_count()); - process_object.add("inode_faults", process.inode_faults()); - process_object.add("zero_faults", process.zero_faults()); - process_object.add("cow_faults", process.cow_faults()); process_object.add("icon_id", process.icon_id()); auto thread_array = process_object.add_array("threads"); process.for_each_thread([&](const Thread& thread) { @@ -702,6 +698,10 @@ Optional procfs$all(InodeIdentifier) thread_object.add("ticks", thread.ticks()); thread_object.add("state", thread.state_string()); thread_object.add("priority", to_string(thread.priority())); + thread_object.add("syscall_count", thread.syscall_count()); + thread_object.add("inode_faults", thread.inode_faults()); + thread_object.add("zero_faults", thread.zero_faults()); + thread_object.add("cow_faults", thread.cow_faults()); return IterationDecision::Continue; }); }; diff --git a/Kernel/Process.h b/Kernel/Process.h index 476f1162c4..fd5d957983 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -286,15 +286,6 @@ public: Lock& big_lock() { return m_big_lock; } - unsigned syscall_count() const { return m_syscall_count; } - void did_syscall() { ++m_syscall_count; } - unsigned inode_faults() const { return m_inode_faults; } - void did_inode_fault() { ++m_inode_faults; } - unsigned zero_faults() const { return m_zero_faults; } - void did_zero_fault() { ++m_zero_faults; } - unsigned cow_faults() const { return m_cow_faults; } - void did_cow_fault() { ++m_cow_faults; } - const ELFLoader* elf_loader() const { return m_elf_loader.ptr(); } int icon_id() const { return m_icon_id; } @@ -373,11 +364,6 @@ private: int m_next_tid { 0 }; - unsigned m_syscall_count { 0 }; - unsigned m_inode_faults { 0 }; - unsigned m_zero_faults { 0 }; - unsigned m_cow_faults { 0 }; - RefPtr m_tracer; OwnPtr m_elf_loader; diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp index 163d469e53..708bfc23b3 100644 --- a/Kernel/Syscall.cpp +++ b/Kernel/Syscall.cpp @@ -60,7 +60,7 @@ int handle(RegisterDump& regs, u32 function, u32 arg1, u32 arg2, u32 arg3) { ASSERT_INTERRUPTS_ENABLED(); auto& process = current->process(); - process.did_syscall(); + current->did_syscall(); if (function == SC_exit || function == SC_exit_thread) { // These syscalls need special handling since they never return to the caller. diff --git a/Kernel/Thread.h b/Kernel/Thread.h index 2b53b9b50f..74d4c8e938 100644 --- a/Kernel/Thread.h +++ b/Kernel/Thread.h @@ -331,6 +331,15 @@ public: void make_thread_specific_region(Badge); + unsigned syscall_count() const { return m_syscall_count; } + void did_syscall() { ++m_syscall_count; } + unsigned inode_faults() const { return m_inode_faults; } + void did_inode_fault() { ++m_inode_faults; } + unsigned zero_faults() const { return m_zero_faults; } + void did_zero_fault() { ++m_zero_faults; } + unsigned cow_faults() const { return m_cow_faults; } + void did_cow_fault() { ++m_cow_faults; } + Thread* clone(Process&); template @@ -376,6 +385,11 @@ private: Thread* m_joinee { nullptr }; void* m_exit_value { nullptr }; + unsigned m_syscall_count { 0 }; + unsigned m_inode_faults { 0 }; + unsigned m_zero_faults { 0 }; + unsigned m_cow_faults { 0 }; + FPUState* m_fpu_state { nullptr }; State m_state { Invalid }; ThreadPriority m_priority { ThreadPriority::Normal }; diff --git a/Kernel/VM/Region.cpp b/Kernel/VM/Region.cpp index 7104dd1534..80e38ab08c 100644 --- a/Kernel/VM/Region.cpp +++ b/Kernel/VM/Region.cpp @@ -308,7 +308,7 @@ PageFaultResponse Region::handle_zero_fault(size_t page_index_in_region) } if (current) - current->process().did_zero_fault(); + current->did_zero_fault(); auto physical_page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes); if (physical_page.is_null()) { @@ -338,7 +338,7 @@ PageFaultResponse Region::handle_cow_fault(size_t page_index_in_region) } if (current) - current->process().did_cow_fault(); + current->did_cow_fault(); #ifdef PAGE_FAULT_DEBUG dbgprintf(" >> It's a COW page and it's time to COW!\n"); @@ -382,7 +382,7 @@ PageFaultResponse Region::handle_inode_fault(size_t page_index_in_region) } if (current) - current->process().did_inode_fault(); + current->did_inode_fault(); #ifdef MM_DEBUG dbgprintf("MM: page_in_from_inode ready to read from inode\n"); diff --git a/Libraries/LibCore/CProcessStatisticsReader.cpp b/Libraries/LibCore/CProcessStatisticsReader.cpp index c9e2becbe2..39f8db097e 100644 --- a/Libraries/LibCore/CProcessStatisticsReader.cpp +++ b/Libraries/LibCore/CProcessStatisticsReader.cpp @@ -38,10 +38,6 @@ HashMap CProcessStatisticsReader::get_all() process.amount_virtual = process_object.get("amount_virtual").to_u32(); process.amount_resident = process_object.get("amount_resident").to_u32(); process.amount_shared = process_object.get("amount_shared").to_u32(); - process.syscall_count = process_object.get("syscall_count").to_u32(); - process.inode_faults = process_object.get("inode_faults").to_u32(); - process.zero_faults = process_object.get("zero_faults").to_u32(); - process.cow_faults = process_object.get("cow_faults").to_u32(); process.icon_id = process_object.get("icon_id").to_int(); auto thread_array = process_object.get("threads").as_array(); @@ -53,6 +49,10 @@ HashMap CProcessStatisticsReader::get_all() thread.state = thread_object.get("state").to_string(); thread.ticks = thread_object.get("ticks").to_u32(); thread.priority = thread_object.get("priority").to_string(); + thread.syscall_count = thread_object.get("syscall_count").to_u32(); + thread.inode_faults = thread_object.get("inode_faults").to_u32(); + thread.zero_faults = thread_object.get("zero_faults").to_u32(); + thread.cow_faults = thread_object.get("cow_faults").to_u32(); process.threads.append(move(thread)); }); diff --git a/Libraries/LibCore/CProcessStatisticsReader.h b/Libraries/LibCore/CProcessStatisticsReader.h index 848821cb26..bb6da21d31 100644 --- a/Libraries/LibCore/CProcessStatisticsReader.h +++ b/Libraries/LibCore/CProcessStatisticsReader.h @@ -8,6 +8,10 @@ struct CThreadStatistics { int tid; unsigned times_scheduled; unsigned ticks; + unsigned syscall_count; + unsigned inode_faults; + unsigned zero_faults; + unsigned cow_faults; String state; String priority; }; @@ -28,10 +32,6 @@ struct CProcessStatistics { size_t amount_virtual; size_t amount_resident; size_t amount_shared; - unsigned syscall_count; - unsigned inode_faults; - unsigned zero_faults; - unsigned cow_faults; int icon_id; Vector threads; diff --git a/Userland/top.cpp b/Userland/top.cpp index de987d7055..d892130b4b 100644 --- a/Userland/top.cpp +++ b/Userland/top.cpp @@ -88,10 +88,10 @@ static Snapshot get_snapshot() thread_data.amount_virtual = stats.amount_virtual; thread_data.amount_resident = stats.amount_resident; thread_data.amount_shared = stats.amount_shared; - thread_data.syscall_count = stats.syscall_count; - thread_data.inode_faults = stats.inode_faults; - thread_data.zero_faults = stats.zero_faults; - thread_data.cow_faults = stats.cow_faults; + thread_data.syscall_count = thread.syscall_count; + thread_data.inode_faults = thread.inode_faults; + thread_data.zero_faults = thread.zero_faults; + thread_data.cow_faults = thread.cow_faults; thread_data.icon_id = stats.icon_id; thread_data.times_scheduled = thread.times_scheduled; thread_data.priority = thread.priority;