scheduler: Preallocate temporary heaps for debug commands
This commit is contained in:
parent
308f594e2a
commit
6fb61d001a
@ -91,6 +91,7 @@ should_rebalance(Thread* thread)
|
|||||||
CoreEntry* other = gCoreLoadHeap->PeekMinimum();
|
CoreEntry* other = gCoreLoadHeap->PeekMinimum();
|
||||||
if (other == NULL)
|
if (other == NULL)
|
||||||
other = gCoreHighLoadHeap->PeekMinimum();
|
other = gCoreHighLoadHeap->PeekMinimum();
|
||||||
|
ASSERT(other != NULL);
|
||||||
return coreEntry->fLoad - other->fLoad >= kLoadDifference * 2;
|
return coreEntry->fLoad - other->fLoad >= kLoadDifference * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,6 +99,10 @@ public:
|
|||||||
|
|
||||||
} // namespace Scheduler
|
} // namespace Scheduler
|
||||||
|
|
||||||
|
static CPUHeap* sDebugCPUHeap;
|
||||||
|
static CoreLoadHeap* sDebugCoreHeap;
|
||||||
|
static PackageHeap* sDebugPackageHeap;
|
||||||
|
|
||||||
|
|
||||||
CPUEntry::CPUEntry()
|
CPUEntry::CPUEntry()
|
||||||
:
|
:
|
||||||
@ -248,8 +252,6 @@ dump_run_queue(int argc, char **argv)
|
|||||||
static void
|
static void
|
||||||
dump_heap(CPUHeap* heap)
|
dump_heap(CPUHeap* heap)
|
||||||
{
|
{
|
||||||
CPUHeap temp(smp_get_num_cpus());
|
|
||||||
|
|
||||||
kprintf("cpu priority load\n");
|
kprintf("cpu priority load\n");
|
||||||
CPUEntry* entry = heap->PeekMinimum();
|
CPUEntry* entry = heap->PeekMinimum();
|
||||||
while (entry) {
|
while (entry) {
|
||||||
@ -259,17 +261,17 @@ dump_heap(CPUHeap* heap)
|
|||||||
gCPUEntries[cpu].fLoad / 10);
|
gCPUEntries[cpu].fLoad / 10);
|
||||||
|
|
||||||
heap->RemoveMinimum();
|
heap->RemoveMinimum();
|
||||||
temp.Insert(entry, key);
|
sDebugCPUHeap->Insert(entry, key);
|
||||||
|
|
||||||
entry = heap->PeekMinimum();
|
entry = heap->PeekMinimum();
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = temp.PeekMinimum();
|
entry = sDebugCPUHeap->PeekMinimum();
|
||||||
while (entry) {
|
while (entry) {
|
||||||
int32 key = CPUHeap::GetKey(entry);
|
int32 key = CPUHeap::GetKey(entry);
|
||||||
temp.RemoveMinimum();
|
sDebugCPUHeap->RemoveMinimum();
|
||||||
heap->Insert(entry, key);
|
heap->Insert(entry, key);
|
||||||
entry = temp.PeekMinimum();
|
entry = sDebugCPUHeap->PeekMinimum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -277,7 +279,6 @@ dump_heap(CPUHeap* heap)
|
|||||||
static void
|
static void
|
||||||
dump_core_load_heap(CoreLoadHeap* heap)
|
dump_core_load_heap(CoreLoadHeap* heap)
|
||||||
{
|
{
|
||||||
CoreLoadHeap temp(gRunQueueCount);
|
|
||||||
int32 cpuPerCore = smp_get_num_cpus() / gRunQueueCount;
|
int32 cpuPerCore = smp_get_num_cpus() / gRunQueueCount;
|
||||||
|
|
||||||
CoreEntry* entry = heap->PeekMinimum();
|
CoreEntry* entry = heap->PeekMinimum();
|
||||||
@ -287,17 +288,17 @@ dump_core_load_heap(CoreLoadHeap* heap)
|
|||||||
entry->fLoad / cpuPerCore / 10);
|
entry->fLoad / cpuPerCore / 10);
|
||||||
|
|
||||||
heap->RemoveMinimum();
|
heap->RemoveMinimum();
|
||||||
temp.Insert(entry, key);
|
sDebugCoreHeap->Insert(entry, key);
|
||||||
|
|
||||||
entry = heap->PeekMinimum();
|
entry = heap->PeekMinimum();
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = temp.PeekMinimum();
|
entry = sDebugCoreHeap->PeekMinimum();
|
||||||
while (entry) {
|
while (entry) {
|
||||||
int32 key = CoreLoadHeap::GetKey(entry);
|
int32 key = CoreLoadHeap::GetKey(entry);
|
||||||
temp.RemoveMinimum();
|
sDebugCoreHeap->RemoveMinimum();
|
||||||
heap->Insert(entry, key);
|
heap->Insert(entry, key);
|
||||||
entry = temp.PeekMinimum();
|
entry = sDebugCoreHeap->PeekMinimum();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +349,6 @@ dump_idle_cores(int argc, char** argv)
|
|||||||
} else
|
} else
|
||||||
kprintf("No idle packages.\n");
|
kprintf("No idle packages.\n");
|
||||||
|
|
||||||
PackageHeap temp(smp_get_num_cpus());
|
|
||||||
kprintf("\nPackages with idle cores:\n");
|
kprintf("\nPackages with idle cores:\n");
|
||||||
|
|
||||||
PackageEntry* entry = gPackageUsageHeap->PeekMinimum();
|
PackageEntry* entry = gPackageUsageHeap->PeekMinimum();
|
||||||
@ -374,17 +374,17 @@ dump_idle_cores(int argc, char** argv)
|
|||||||
kprintf("\n");
|
kprintf("\n");
|
||||||
|
|
||||||
gPackageUsageHeap->RemoveMinimum();
|
gPackageUsageHeap->RemoveMinimum();
|
||||||
temp.Insert(entry, entry->fIdleCoreCount);
|
sDebugPackageHeap->Insert(entry, entry->fIdleCoreCount);
|
||||||
|
|
||||||
entry = gPackageUsageHeap->PeekMinimum();
|
entry = gPackageUsageHeap->PeekMinimum();
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = temp.PeekMinimum();
|
entry = sDebugPackageHeap->PeekMinimum();
|
||||||
while (entry != NULL) {
|
while (entry != NULL) {
|
||||||
int32 key = PackageHeap::GetKey(entry);
|
int32 key = PackageHeap::GetKey(entry);
|
||||||
temp.RemoveMinimum();
|
sDebugPackageHeap->RemoveMinimum();
|
||||||
gPackageUsageHeap->Insert(entry, key);
|
gPackageUsageHeap->Insert(entry, key);
|
||||||
entry = temp.PeekMinimum();
|
entry = sDebugPackageHeap->PeekMinimum();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1429,6 +1429,29 @@ build_topology_mappings(int32& cpuCount, int32& coreCount, int32& packageCount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static status_t
|
||||||
|
create_debug_heaps()
|
||||||
|
{
|
||||||
|
sDebugCPUHeap = new(std::nothrow) CPUHeap(smp_get_num_cpus());
|
||||||
|
if (sDebugCPUHeap == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
ObjectDeleter<CPUHeap> cpuDeleter(sDebugCPUHeap);
|
||||||
|
|
||||||
|
sDebugCoreHeap = new(std::nothrow) CoreLoadHeap(smp_get_num_cpus());
|
||||||
|
if (sDebugCoreHeap == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
ObjectDeleter<CoreLoadHeap> coreDeleter(sDebugCoreHeap);
|
||||||
|
|
||||||
|
sDebugPackageHeap = new(std::nothrow) PackageHeap(smp_get_num_cpus());
|
||||||
|
if (sDebugPackageHeap == NULL)
|
||||||
|
return B_NO_MEMORY;
|
||||||
|
|
||||||
|
coreDeleter.Detach();
|
||||||
|
cpuDeleter.Detach();
|
||||||
|
return B_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static status_t
|
static status_t
|
||||||
_scheduler_init()
|
_scheduler_init()
|
||||||
{
|
{
|
||||||
@ -1488,7 +1511,7 @@ _scheduler_init()
|
|||||||
for (int32 i = 0; i < coreCount; i++) {
|
for (int32 i = 0; i < coreCount; i++) {
|
||||||
gCoreEntries[i].fCoreID = i;
|
gCoreEntries[i].fCoreID = i;
|
||||||
|
|
||||||
status_t result = gCoreLoadHeap->Insert(&gCoreEntries[i], 0);
|
result = gCoreLoadHeap->Insert(&gCoreEntries[i], 0);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1507,7 +1530,7 @@ _scheduler_init()
|
|||||||
if (gCPUPriorityHeaps[core].PeekMaximum() == NULL)
|
if (gCPUPriorityHeaps[core].PeekMaximum() == NULL)
|
||||||
gPackageEntries[package].fIdleCores.Insert(&gCoreEntries[core]);
|
gPackageEntries[package].fIdleCores.Insert(&gCoreEntries[core]);
|
||||||
|
|
||||||
status_t result
|
result
|
||||||
= gCPUPriorityHeaps[core].Insert(&gCPUEntries[i], B_IDLE_PRIORITY);
|
= gCPUPriorityHeaps[core].Insert(&gCPUEntries[i], B_IDLE_PRIORITY);
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
@ -1522,7 +1545,7 @@ _scheduler_init()
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
ArrayDeleter<ThreadRunQueue> pinnedRunQueuesDeleter(gPinnedRunQueues);
|
ArrayDeleter<ThreadRunQueue> pinnedRunQueuesDeleter(gPinnedRunQueues);
|
||||||
for (int i = 0; i < cpuCount; i++) {
|
for (int i = 0; i < cpuCount; i++) {
|
||||||
status_t result = gPinnedRunQueues[i].GetInitStatus();
|
result = gPinnedRunQueues[i].GetInitStatus();
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1536,11 +1559,16 @@ _scheduler_init()
|
|||||||
return B_NO_MEMORY;
|
return B_NO_MEMORY;
|
||||||
ArrayDeleter<ThreadRunQueue> runQueuesDeleter(gRunQueues);
|
ArrayDeleter<ThreadRunQueue> runQueuesDeleter(gRunQueues);
|
||||||
for (int i = 0; i < coreCount; i++) {
|
for (int i = 0; i < coreCount; i++) {
|
||||||
status_t result = gRunQueues[i].GetInitStatus();
|
result = gRunQueues[i].GetInitStatus();
|
||||||
if (result != B_OK)
|
if (result != B_OK)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// create temporary heaps for debugging commands
|
||||||
|
result = create_debug_heaps();
|
||||||
|
if (result != B_OK)
|
||||||
|
return result;
|
||||||
|
|
||||||
scheduler_set_operation_mode(SCHEDULER_MODE_LOW_LATENCY);
|
scheduler_set_operation_mode(SCHEDULER_MODE_LOW_LATENCY);
|
||||||
|
|
||||||
add_debugger_command_etc("run_queue", &dump_run_queue,
|
add_debugger_command_etc("run_queue", &dump_run_queue,
|
||||||
|
Loading…
Reference in New Issue
Block a user