mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 08:35:09 +00:00
Add zone dump to /proc/mm.
Sweet, now we can look at all the zones (physical memory) currently in play. Building the procfs files with ksprintf and rickety buffer presizing feels pretty shoddy but I'll fix it up eventually.
This commit is contained in:
parent
c76dc9a047
commit
3f050c1972
2 changed files with 11 additions and 1 deletions
|
@ -16,6 +16,7 @@ enum class PageFaultResponse {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Zone : public Retainable<Zone> {
|
struct Zone : public Retainable<Zone> {
|
||||||
|
friend ByteBuffer procfs$mm();
|
||||||
public:
|
public:
|
||||||
~Zone();
|
~Zone();
|
||||||
size_t size() const { return m_pages.size() * PAGE_SIZE; }
|
size_t size() const { return m_pages.size() * PAGE_SIZE; }
|
||||||
|
|
|
@ -121,10 +121,19 @@ void ProcFileSystem::removeProcess(Task& task)
|
||||||
ByteBuffer procfs$mm()
|
ByteBuffer procfs$mm()
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
auto buffer = ByteBuffer::createUninitialized(1024);
|
size_t zonePageCount = 0;
|
||||||
|
for (auto* zone : MM.m_zones)
|
||||||
|
zonePageCount += zone->m_pages.size();
|
||||||
|
auto buffer = ByteBuffer::createUninitialized(1024 + 80 * MM.m_zones.size() + zonePageCount * 10);
|
||||||
char* ptr = (char*)buffer.pointer();
|
char* ptr = (char*)buffer.pointer();
|
||||||
ptr += ksprintf(ptr, "Zone count: %u\n", MM.m_zones.size());
|
ptr += ksprintf(ptr, "Zone count: %u\n", MM.m_zones.size());
|
||||||
ptr += ksprintf(ptr, "Free physical pages: %u\n", MM.m_freePages.size());
|
ptr += ksprintf(ptr, "Free physical pages: %u\n", MM.m_freePages.size());
|
||||||
|
for (auto* zone : MM.m_zones) {
|
||||||
|
ptr += ksprintf(ptr, "Zone %p size: %u\n ", zone, zone->size());
|
||||||
|
for (auto page : zone->m_pages)
|
||||||
|
ptr += ksprintf(ptr, "%x ", page);
|
||||||
|
ptr += ksprintf(ptr, "\n");
|
||||||
|
}
|
||||||
buffer.trim(ptr - (char*)buffer.pointer());
|
buffer.trim(ptr - (char*)buffer.pointer());
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue