1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 05:27:45 +00:00

Kernel+SystemMonitor: Log amounts of I/O per thread

This patch adds these I/O counters to each thread:

- (Inode) file read bytes
- (Inode) file write bytes
- Unix socket read bytes
- Unix socket write bytes
- IPv4 socket read bytes
- IPv4 socket write bytes

These are then exposed in /proc/all and seen in SystemMonitor.
This commit is contained in:
Andreas Kling 2019-12-01 17:36:06 +01:00
parent a18aa8fd5f
commit 5a45376180
10 changed files with 171 additions and 17 deletions

View file

@ -15,15 +15,20 @@ InodeFile::~InodeFile()
ssize_t InodeFile::read(FileDescription& description, u8* buffer, ssize_t count)
{
return m_inode->read_bytes(description.offset(), count, buffer, &description);
ssize_t nread = m_inode->read_bytes(description.offset(), count, buffer, &description);
if (nread > 0)
current->did_file_read(nread);
return nread;
}
ssize_t InodeFile::write(FileDescription& description, const u8* data, ssize_t count)
{
ssize_t ret = m_inode->write_bytes(description.offset(), count, data, &description);
if (ret > 0)
ssize_t nwritten = m_inode->write_bytes(description.offset(), count, data, &description);
if (nwritten > 0) {
m_inode->set_mtime(kgettimeofday().tv_sec);
return ret;
current->did_file_write(nwritten);
}
return nwritten;
}
KResultOr<Region*> InodeFile::mmap(Process& process, FileDescription& description, VirtualAddress preferred_vaddr, size_t offset, size_t size, int prot)

View file

@ -725,6 +725,12 @@ Optional<KBuffer> procfs$all(InodeIdentifier)
thread_object.add("inode_faults", thread.inode_faults());
thread_object.add("zero_faults", thread.zero_faults());
thread_object.add("cow_faults", thread.cow_faults());
thread_object.add("file_read_bytes", thread.file_read_bytes());
thread_object.add("file_write_bytes", thread.file_write_bytes());
thread_object.add("unix_socket_read_bytes", thread.unix_socket_read_bytes());
thread_object.add("unix_socket_write_bytes", thread.unix_socket_write_bytes());
thread_object.add("ipv4_socket_read_bytes", thread.ipv4_socket_read_bytes());
thread_object.add("ipv4_socket_write_bytes", thread.ipv4_socket_write_bytes());
return IterationDecision::Continue;
});
};