Skip to content

Commit 9168e2d

Browse files
committed
smp: Aggressively finish work
1 parent 66a36cf commit 9168e2d

2 files changed

Lines changed: 11 additions & 16 deletions

File tree

src/platform/x86_pc/apic_revenant.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,27 +42,21 @@ static bool revenant_task_doer(smp_system_stuff& system)
4242
lock(smp_main.flock);
4343
smp_main.completed.push_back(std::move(task.done));
4444
unlock(smp_main.flock);
45-
return true;
45+
// signal home
46+
PER_CPU(smp_system).work_done = true;
4647
}
47-
// we did work, but we aren't going to signal back
48-
return false;
48+
return true;
4949
}
5050
static void revenant_task_handler()
5151
{
52-
bool work_done = false;
53-
bool did_something = false;
54-
do {
55-
// cpu-specific tasks
56-
did_something = revenant_task_doer(PER_CPU(smp_system));
57-
work_done = work_done || did_something;
58-
// global tasks (by taking from index 0)
59-
did_something = revenant_task_doer(smp_system[0]);
60-
work_done = work_done || did_something;
61-
// continue as long as something was done
62-
// because there could be more
63-
} while (did_something);
52+
auto& system = PER_CPU(smp_system);
53+
system.work_done = false;
54+
// cpu-specific tasks
55+
while(revenant_task_doer(PER_CPU(smp_system)));
56+
// global tasks (by taking from index 0)
57+
while (revenant_task_doer(smp_system[0]));
6458
// if we did any work with done functions, signal back
65-
if (work_done) {
59+
if (system.work_done) {
6660
x86::APIC::get().send_bsp_intr();
6761
}
6862
}

src/platform/x86_pc/apic_revenant.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct smp_system_stuff
4747
{
4848
spinlock_t tlock;
4949
std::deque<smp_task> tasks;
50+
bool work_done;
5051
};
5152
extern SMP_ARRAY<smp_system_stuff> smp_system;
5253

0 commit comments

Comments
 (0)