ProcessController: Report kernel memory and fix some TODOs.
* Restore logic for excluding app_server side of bitmaps (though this may not work for server-cloned areas, only server-allocated ones.) * Leave TODO in place for media buffers. * Add all kernel-writable areas of the system (kernel) team to writable memory, but exclude the block_cache. Fixes display of kernel memory information in ProcessController's memory usage menu.
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
* Copyright 2022, Haiku, Inc. All rights reserved.
|
* Copyright 2022, Haiku, Inc. All rights reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MemoryBarMenuItem.h"
|
#include "MemoryBarMenuItem.h"
|
||||||
|
|
||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
|
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
#include <ControlLook.h>
|
#include <ControlLook.h>
|
||||||
|
#include <KernelExport.h>
|
||||||
#include <StringForSize.h>
|
#include <StringForSize.h>
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -216,27 +218,44 @@ MemoryBarMenuItem::BarUpdate()
|
|||||||
int64 lwram_size = 0;
|
int64 lwram_size = 0;
|
||||||
bool exists = false;
|
bool exists = false;
|
||||||
|
|
||||||
|
const bool isAppServer = (strcmp(Label(), "app_server") == 0);
|
||||||
|
|
||||||
while (get_next_area_info(fTeamID, &cookie, &areaInfo) == B_OK) {
|
while (get_next_area_info(fTeamID, &cookie, &areaInfo) == B_OK) {
|
||||||
exists = true;
|
exists = true;
|
||||||
lram_size += areaInfo.ram_size;
|
lram_size += areaInfo.ram_size;
|
||||||
|
|
||||||
// TODO: this won't work this way anymore under Haiku!
|
if (isAppServer && strncmp(areaInfo.name, "a:", 2) == 0) {
|
||||||
// int zone = (int (areaInfo.address) & 0xf0000000) >> 24;
|
// app_server side of client memory (e.g. bitmaps), ignore.
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fTeamID == B_SYSTEM_TEAM) {
|
||||||
|
if ((areaInfo.protection & B_KERNEL_WRITE_AREA) != 0)
|
||||||
|
areaInfo.protection |= B_WRITE_AREA;
|
||||||
|
}
|
||||||
|
// TODO: Exclude media buffers
|
||||||
|
|
||||||
if ((areaInfo.protection & B_WRITE_AREA) != 0)
|
if ((areaInfo.protection & B_WRITE_AREA) != 0)
|
||||||
lwram_size += areaInfo.ram_size;
|
lwram_size += areaInfo.ram_size;
|
||||||
// && (zone & 0xf0) != 0xA0 // Exclude media buffers
|
|
||||||
// && (fTeamID != gAppServerTeamID || zone != 0x90)) // Exclude app_server side of bitmaps
|
|
||||||
}
|
}
|
||||||
if (!exists) {
|
if (fTeamID == B_SYSTEM_TEAM) {
|
||||||
|
system_info info;
|
||||||
|
status_t status = get_system_info(&info);
|
||||||
|
if (status == B_OK) {
|
||||||
|
// block_cache memory will be in writable areas
|
||||||
|
lwram_size -= info.block_cache_pages * B_PAGE_SIZE;
|
||||||
|
}
|
||||||
|
} else if (!exists) {
|
||||||
team_info info;
|
team_info info;
|
||||||
exists = get_team_info(fTeamID, &info) == B_OK;
|
exists = get_team_info(fTeamID, &info) == B_OK;
|
||||||
|
if (!exists) {
|
||||||
|
fWriteMemory = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (exists) {
|
|
||||||
fWriteMemory = lwram_size / 1024;
|
fWriteMemory = lwram_size / 1024;
|
||||||
fAllMemory = lram_size / 1024;
|
fAllMemory = lram_size / 1024;
|
||||||
DrawBar(false);
|
DrawBar(false);
|
||||||
} else
|
|
||||||
fWriteMemory = -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user