scheduler: Fix power saving mode and other minor improvements
This commit is contained in:
@@ -685,7 +685,7 @@ void assign_io_interrupt_to_cpu(long vector, int32 newCPU)
|
|||||||
|
|
||||||
if (newCPU == -1)
|
if (newCPU == -1)
|
||||||
newCPU = assign_cpu();
|
newCPU = assign_cpu();
|
||||||
dprintf_no_syslog("IRQ %ld CPU %" B_PRId32 " -> CPU %" B_PRId32 "\n", vector, oldCPU, newCPU);
|
|
||||||
if (newCPU == oldCPU)
|
if (newCPU == oldCPU)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,12 @@ switch_to_mode(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_cpu_enabled(int32 /* cpu */, bool /* enabled */)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
has_cache_expired(Thread* thread)
|
has_cache_expired(Thread* thread)
|
||||||
{
|
{
|
||||||
@@ -180,6 +186,7 @@ scheduler_mode_operations gSchedulerLowLatencyMode = {
|
|||||||
true,
|
true,
|
||||||
|
|
||||||
switch_to_mode,
|
switch_to_mode,
|
||||||
|
set_cpu_enabled,
|
||||||
has_cache_expired,
|
has_cache_expired,
|
||||||
choose_core,
|
choose_core,
|
||||||
should_rebalance,
|
should_rebalance,
|
||||||
|
|||||||
@@ -16,6 +16,21 @@ using namespace Scheduler;
|
|||||||
static int32 sSmallTaskCore;
|
static int32 sSmallTaskCore;
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
switch_to_mode(void)
|
||||||
|
{
|
||||||
|
sSmallTaskCore = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_cpu_enabled(int32 cpu, bool enabled)
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
sSmallTaskCore = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
has_cache_expired(Thread* thread)
|
has_cache_expired(Thread* thread)
|
||||||
{
|
{
|
||||||
@@ -31,13 +46,6 @@ has_cache_expired(Thread* thread)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
switch_to_mode(void)
|
|
||||||
{
|
|
||||||
sSmallTaskCore = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
try_small_task_packing(Thread* thread)
|
try_small_task_packing(Thread* thread)
|
||||||
{
|
{
|
||||||
@@ -244,6 +252,7 @@ scheduler_mode_operations gSchedulerPowerSavingMode = {
|
|||||||
false,
|
false,
|
||||||
|
|
||||||
switch_to_mode,
|
switch_to_mode,
|
||||||
|
set_cpu_enabled,
|
||||||
has_cache_expired,
|
has_cache_expired,
|
||||||
choose_core,
|
choose_core,
|
||||||
should_rebalance,
|
should_rebalance,
|
||||||
|
|||||||
@@ -583,9 +583,6 @@ should_rebalance(Thread* thread)
|
|||||||
{
|
{
|
||||||
ASSERT(!gSingleCore);
|
ASSERT(!gSingleCore);
|
||||||
|
|
||||||
if (thread_is_idle_thread(thread))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return sCurrentMode->should_rebalance(thread);
|
return sCurrentMode->should_rebalance(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -600,9 +597,6 @@ compute_cpu_load(int32 cpu)
|
|||||||
if (oldLoad < 0)
|
if (oldLoad < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (gCPUEntries[cpu].fLoad > kVeryHighLoad)
|
|
||||||
sCurrentMode->rebalance_irqs(false);
|
|
||||||
|
|
||||||
if (oldLoad != gCPUEntries[cpu].fLoad) {
|
if (oldLoad != gCPUEntries[cpu].fLoad) {
|
||||||
int32 core = gCPUToCore[cpu];
|
int32 core = gCPUToCore[cpu];
|
||||||
|
|
||||||
@@ -611,6 +605,9 @@ compute_cpu_load(int32 cpu)
|
|||||||
|
|
||||||
update_load_heaps(core);
|
update_load_heaps(core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gCPUEntries[cpu].fLoad > kVeryHighLoad)
|
||||||
|
sCurrentMode->rebalance_irqs(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1069,8 +1066,7 @@ static inline void
|
|||||||
update_cpu_performance(Thread* thread, int32 thisCore)
|
update_cpu_performance(Thread* thread, int32 thisCore)
|
||||||
{
|
{
|
||||||
int32 load = max_c(thread->scheduler_data->load,
|
int32 load = max_c(thread->scheduler_data->load,
|
||||||
gCoreEntries[thisCore].fLoad);
|
get_core_load(&gCoreEntries[thisCore]));
|
||||||
load /= gCoreEntries[thisCore].fCPUCount;
|
|
||||||
load = min_c(max_c(load, 0), kMaxLoad);
|
load = min_c(max_c(load, 0), kMaxLoad);
|
||||||
|
|
||||||
if (load < kTargetLoad) {
|
if (load < kTargetLoad) {
|
||||||
@@ -1369,6 +1365,8 @@ scheduler_set_cpu_enabled(int32 cpu, bool enabled)
|
|||||||
|
|
||||||
gCPU[cpu].disabled = !enabled;
|
gCPU[cpu].disabled = !enabled;
|
||||||
|
|
||||||
|
sCurrentMode->set_cpu_enabled(cpu, enabled);
|
||||||
|
|
||||||
CoreEntry* core = &gCoreEntries[gCPUToCore[cpu]];
|
CoreEntry* core = &gCoreEntries[gCPUToCore[cpu]];
|
||||||
PackageEntry* package = &gPackageEntries[gCPUToPackage[cpu]];
|
PackageEntry* package = &gPackageEntries[gCPUToPackage[cpu]];
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ struct scheduler_mode_operations {
|
|||||||
bool avoid_boost;
|
bool avoid_boost;
|
||||||
|
|
||||||
void (*switch_to_mode)(void);
|
void (*switch_to_mode)(void);
|
||||||
|
void (*set_cpu_enabled)(int32 cpu, bool enabled);
|
||||||
bool (*has_cache_expired)(Thread* thread);
|
bool (*has_cache_expired)(Thread* thread);
|
||||||
int32 (*choose_core)(Thread* thread);
|
int32 (*choose_core)(Thread* thread);
|
||||||
bool (*should_rebalance)(Thread* thread);
|
bool (*should_rebalance)(Thread* thread);
|
||||||
|
|||||||
Reference in New Issue
Block a user