Merge pull request #874 from hodgesds/layered-fallback-stall

scx_layered: Add additional drain to fallback DSQs
This commit is contained in:
Daniel Hodges 2024-11-01 10:43:55 -04:00 committed by GitHub
commit 9bba51a485
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -15,6 +15,7 @@ struct cost {
u32 idx; u32 idx;
bool overflow; bool overflow;
bool has_parent; bool has_parent;
bool drain_fallback;
}; };
@ -217,6 +218,7 @@ static int record_cpu_cost(struct cost *costc, u32 layer_id, s64 amount)
__sync_fetch_and_sub(&costc->budget[layer_id], amount); __sync_fetch_and_sub(&costc->budget[layer_id], amount);
if (costc->budget[layer_id] <= 0) { if (costc->budget[layer_id] <= 0) {
costc->drain_fallback = true;
if (costc->has_parent) { if (costc->has_parent) {
s64 budget = acquire_budget(costc, layer_id, s64 budget = acquire_budget(costc, layer_id,
costc->capacity[layer_id] + amount); costc->capacity[layer_id] + amount);

View File

@ -1067,7 +1067,7 @@ void BPF_STRUCT_OPS(layered_enqueue, struct task_struct *p, u64 enq_flags)
* usually important for system performance and responsiveness. * usually important for system performance and responsiveness.
*/ */
if (!layer->preempt && if (!layer->preempt &&
(p->flags & PF_KTHREAD) && p->nr_cpus_allowed == 1) { (p->flags & PF_KTHREAD) && p->nr_cpus_allowed < nr_possible_cpus) {
struct cpumask *layer_cpumask; struct cpumask *layer_cpumask;
if (!layer->open && if (!layer->open &&
@ -1444,6 +1444,18 @@ void BPF_STRUCT_OPS(layered_dispatch, s32 cpu, struct task_struct *prev)
return; return;
} }
/*
* Fallback DSQs don't have cost accounting. When the budget runs out
* for a layer we do an extra consume of the fallback DSQ to ensure
* that it doesn't stall out when the system is being saturated.
*/
if (costc->drain_fallback) {
costc->drain_fallback = false;
dsq_id = cpu_hi_fallback_dsq_id(cpu);
if (scx_bpf_consume(dsq_id))
return;
}
u32 my_llc_id = cpu_to_llc_id(cpu); u32 my_llc_id = cpu_to_llc_id(cpu);
/* consume preempting layers first */ /* consume preempting layers first */