1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-26 02:05:08 +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

@ -71,6 +71,18 @@ String ProcessModel::column_name(int column) const
return "F:Zero";
case Column::CowFaults:
return "F:CoW";
case Column::IPv4SocketReadBytes:
return "IPv4 In";
case Column::IPv4SocketWriteBytes:
return "IPv4 Out";
case Column::UnixSocketReadBytes:
return "Unix In";
case Column::UnixSocketWriteBytes:
return "Unix Out";
case Column::FileReadBytes:
return "File In";
case Column::FileWriteBytes:
return "File Out";
default:
ASSERT_NOT_REACHED();
}
@ -107,6 +119,18 @@ GModel::ColumnMetadata ProcessModel::column_metadata(int column) const
return { 60, TextAlignment::CenterRight };
case Column::CowFaults:
return { 60, TextAlignment::CenterRight };
case Column::FileReadBytes:
return { 60, TextAlignment::CenterRight };
case Column::FileWriteBytes:
return { 60, TextAlignment::CenterRight };
case Column::UnixSocketReadBytes:
return { 60, TextAlignment::CenterRight };
case Column::UnixSocketWriteBytes:
return { 60, TextAlignment::CenterRight };
case Column::IPv4SocketReadBytes:
return { 60, TextAlignment::CenterRight };
case Column::IPv4SocketWriteBytes:
return { 60, TextAlignment::CenterRight };
default:
ASSERT_NOT_REACHED();
}
@ -164,6 +188,18 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
return (int)thread.current_state.zero_faults;
case Column::CowFaults:
return (int)thread.current_state.cow_faults;
case Column::IPv4SocketReadBytes:
return (int)thread.current_state.ipv4_socket_read_bytes;
case Column::IPv4SocketWriteBytes:
return (int)thread.current_state.ipv4_socket_write_bytes;
case Column::UnixSocketReadBytes:
return (int)thread.current_state.unix_socket_read_bytes;
case Column::UnixSocketWriteBytes:
return (int)thread.current_state.unix_socket_write_bytes;
case Column::FileReadBytes:
return (int)thread.current_state.file_read_bytes;
case Column::FileWriteBytes:
return (int)thread.current_state.file_write_bytes;
}
ASSERT_NOT_REACHED();
return {};
@ -216,6 +252,18 @@ GVariant ProcessModel::data(const GModelIndex& index, Role role) const
return (int)thread.current_state.zero_faults;
case Column::CowFaults:
return (int)thread.current_state.cow_faults;
case Column::IPv4SocketReadBytes:
return (int)thread.current_state.ipv4_socket_read_bytes;
case Column::IPv4SocketWriteBytes:
return (int)thread.current_state.ipv4_socket_write_bytes;
case Column::UnixSocketReadBytes:
return (int)thread.current_state.unix_socket_read_bytes;
case Column::UnixSocketWriteBytes:
return (int)thread.current_state.unix_socket_write_bytes;
case Column::FileReadBytes:
return (int)thread.current_state.file_read_bytes;
case Column::FileWriteBytes:
return (int)thread.current_state.file_write_bytes;
}
}
@ -241,6 +289,12 @@ void ProcessModel::update()
state.inode_faults = thread.inode_faults;
state.zero_faults = thread.zero_faults;
state.cow_faults = thread.cow_faults;
state.unix_socket_read_bytes = thread.unix_socket_read_bytes;
state.unix_socket_write_bytes = thread.unix_socket_write_bytes;
state.ipv4_socket_read_bytes = thread.ipv4_socket_read_bytes;
state.ipv4_socket_write_bytes = thread.ipv4_socket_write_bytes;
state.file_read_bytes = thread.file_read_bytes;
state.file_write_bytes = thread.file_write_bytes;
state.name = it.value.name;
state.amount_virtual = it.value.amount_virtual;
state.amount_resident = it.value.amount_resident;