mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 02:17:34 +00:00
ProcessManager: Show some basic system memory stats below the process table.
This really improves the feeling of "system overview" :^)
This commit is contained in:
parent
8017c1e17c
commit
37388b311f
9 changed files with 158 additions and 9 deletions
|
@ -12,6 +12,8 @@
|
|||
//#define PAGE_FAULT_DEBUG
|
||||
|
||||
static MemoryManager* s_the;
|
||||
unsigned MemoryManager::s_user_physical_pages_in_existence;
|
||||
unsigned MemoryManager::s_super_physical_pages_in_existence;
|
||||
|
||||
MemoryManager& MM
|
||||
{
|
||||
|
@ -686,6 +688,10 @@ PhysicalPage::PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_retu
|
|||
, m_supervisor(supervisor)
|
||||
, m_paddr(paddr)
|
||||
{
|
||||
if (supervisor)
|
||||
++MemoryManager::s_super_physical_pages_in_existence;
|
||||
else
|
||||
++MemoryManager::s_user_physical_pages_in_existence;
|
||||
}
|
||||
|
||||
void PhysicalPage::return_to_freelist()
|
||||
|
|
|
@ -228,6 +228,7 @@ class MemoryManager {
|
|||
friend class Region;
|
||||
friend class VMObject;
|
||||
friend ByteBuffer procfs$mm(InodeIdentifier);
|
||||
friend ByteBuffer procfs$memstat(InodeIdentifier);
|
||||
public:
|
||||
[[gnu::pure]] static MemoryManager& the();
|
||||
|
||||
|
@ -254,6 +255,9 @@ public:
|
|||
|
||||
size_t ram_size() const { return m_ram_size; }
|
||||
|
||||
int user_physical_pages_in_existence() const { return s_user_physical_pages_in_existence; }
|
||||
int super_physical_pages_in_existence() const { return s_super_physical_pages_in_existence; }
|
||||
|
||||
private:
|
||||
MemoryManager();
|
||||
~MemoryManager();
|
||||
|
@ -383,6 +387,9 @@ private:
|
|||
dword* m_pte;
|
||||
};
|
||||
|
||||
static unsigned s_user_physical_pages_in_existence;
|
||||
static unsigned s_super_physical_pages_in_existence;
|
||||
|
||||
PageTableEntry ensure_pte(PageDirectory&, LinearAddress);
|
||||
|
||||
RetainPtr<PageDirectory> m_kernel_page_directory;
|
||||
|
|
|
@ -31,6 +31,7 @@ enum ProcFileType {
|
|||
FI_Root_df,
|
||||
FI_Root_kmalloc,
|
||||
FI_Root_all,
|
||||
FI_Root_memstat,
|
||||
FI_Root_summary,
|
||||
FI_Root_cpuinfo,
|
||||
FI_Root_inodes,
|
||||
|
@ -537,6 +538,22 @@ ByteBuffer procfs$summary(InodeIdentifier)
|
|||
return builder.to_byte_buffer();
|
||||
}
|
||||
|
||||
ByteBuffer procfs$memstat(InodeIdentifier)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
StringBuilder builder;
|
||||
builder.appendf("%u,%u,%u,%u,%u,%u,%u\n",
|
||||
kmalloc_sum_eternal,
|
||||
sum_alloc,
|
||||
sum_free,
|
||||
MM.user_physical_pages_in_existence() - MM.m_free_physical_pages.size(),
|
||||
MM.m_free_physical_pages.size(),
|
||||
MM.super_physical_pages_in_existence() - MM.m_free_supervisor_physical_pages.size(),
|
||||
MM.m_free_supervisor_physical_pages.size()
|
||||
);
|
||||
return builder.to_byte_buffer();
|
||||
}
|
||||
|
||||
ByteBuffer procfs$all(InodeIdentifier)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
|
@ -1112,6 +1129,7 @@ ProcFS::ProcFS()
|
|||
m_entries[FI_Root_df] = { "df", FI_Root_df, procfs$df };
|
||||
m_entries[FI_Root_kmalloc] = { "kmalloc", FI_Root_kmalloc, procfs$kmalloc };
|
||||
m_entries[FI_Root_all] = { "all", FI_Root_all, procfs$all };
|
||||
m_entries[FI_Root_memstat] = { "memstat", FI_Root_memstat, procfs$memstat };
|
||||
m_entries[FI_Root_summary] = { "summary", FI_Root_summary, procfs$summary };
|
||||
m_entries[FI_Root_cpuinfo] = { "cpuinfo", FI_Root_cpuinfo, procfs$cpuinfo};
|
||||
m_entries[FI_Root_inodes] = { "inodes", FI_Root_inodes, procfs$inodes };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue