mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
Add a /proc/kmalloc stats file.
This commit is contained in:
parent
edb81a635c
commit
a447359916
1 changed files with 13 additions and 6 deletions
|
@ -64,13 +64,20 @@ bool ProcFileSystem::initialize()
|
||||||
{
|
{
|
||||||
SyntheticFileSystem::initialize();
|
SyntheticFileSystem::initialize();
|
||||||
|
|
||||||
|
addFile(createGeneratedFile("kmalloc", [] {
|
||||||
|
InterruptDisabler disabler;
|
||||||
|
auto buffer = ByteBuffer::createUninitialized(128);
|
||||||
|
char* ptr = (char*)buffer.pointer();
|
||||||
|
ptr += ksprintf(ptr, "alloc: %u\nfree: %u\n", sum_alloc, sum_free);
|
||||||
|
buffer.trim(ptr - (char*)buffer.pointer());
|
||||||
|
return buffer;
|
||||||
|
}));
|
||||||
|
|
||||||
addFile(createGeneratedFile("summary", [] {
|
addFile(createGeneratedFile("summary", [] {
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
auto tasks = Task::allTasks();
|
auto tasks = Task::allTasks();
|
||||||
char* buffer;
|
auto buffer = ByteBuffer::createUninitialized(tasks.size() * 256);
|
||||||
auto stringImpl = StringImpl::createUninitialized(tasks.size() * 256, buffer);
|
char* ptr = (char*)buffer.pointer();
|
||||||
memset(buffer, 0, stringImpl->length());
|
|
||||||
char* ptr = buffer;
|
|
||||||
ptr += ksprintf(ptr, "PID OWNER STATE PPID NSCHED FDS NAME\n");
|
ptr += ksprintf(ptr, "PID OWNER STATE PPID NSCHED FDS NAME\n");
|
||||||
for (auto* task : tasks) {
|
for (auto* task : tasks) {
|
||||||
ptr += ksprintf(ptr, "%w %w:%w %b %w %x %w %s\n",
|
ptr += ksprintf(ptr, "%w %w:%w %b %w %x %w %s\n",
|
||||||
|
@ -83,9 +90,9 @@ bool ProcFileSystem::initialize()
|
||||||
task->fileHandleCount(),
|
task->fileHandleCount(),
|
||||||
task->name().characters());
|
task->name().characters());
|
||||||
}
|
}
|
||||||
ptr += ksprintf(ptr, "kmalloc: alloc: %u / free: %u\n", sum_alloc, sum_free);
|
|
||||||
*ptr = '\0';
|
*ptr = '\0';
|
||||||
return ByteBuffer::copy((byte*)buffer, ptr - buffer);
|
buffer.trim(ptr - (char*)buffer.pointer());
|
||||||
|
return buffer;
|
||||||
}));
|
}));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue