1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 21:47:43 +00:00

Kernel: Make syscall counters and page fault counters per-thread

Now that we show individual threads in SystemMonitor and "top",
it's also very nice to have individual counters for the threads. :^)
This commit is contained in:
Andreas Kling 2019-11-26 21:35:24 +01:00
parent 712ae73581
commit 5b8cf2ee23
9 changed files with 38 additions and 38 deletions

View file

@ -689,10 +689,6 @@ Optional<KBuffer> 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<KBuffer> 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;
});
};

View file

@ -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<ProcessTracer> m_tracer;
OwnPtr<ELFLoader> m_elf_loader;

View file

@ -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.

View file

@ -331,6 +331,15 @@ public:
void make_thread_specific_region(Badge<Process>);
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<typename Callback>
@ -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 };

View file

@ -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");