From 61598093bbdd283a7edc367d900f223070ead8d2 Mon Sep 17 00:00:00 2001 From: hc <hc@nodka.com> Date: Fri, 10 May 2024 07:43:03 +0000 Subject: [PATCH] add ax88772C AX88772C_eeprom_tools --- kernel/kernel/sched/deadline.c | 118 +++++++++++++++++++++++++++++++++++------------------------ 1 files changed, 70 insertions(+), 48 deletions(-) diff --git a/kernel/kernel/sched/deadline.c b/kernel/kernel/sched/deadline.c index 61d3c34..98c69a7 100644 --- a/kernel/kernel/sched/deadline.c +++ b/kernel/kernel/sched/deadline.c @@ -17,6 +17,7 @@ */ #include "sched.h" #include "pelt.h" +#include <linux/cpuset.h> struct dl_bandwidth def_dl_bandwidth; @@ -565,7 +566,7 @@ static inline bool need_pull_dl_task(struct rq *rq, struct task_struct *prev) { - return rq->online && dl_task(prev); + return dl_task(prev); } static DEFINE_PER_CPU(struct callback_head, dl_push_head); @@ -1847,8 +1848,7 @@ deadline_queue_push_tasks(rq); } -static struct sched_dl_entity *pick_next_dl_entity(struct rq *rq, - struct dl_rq *dl_rq) +static struct sched_dl_entity *pick_next_dl_entity(struct dl_rq *dl_rq) { struct rb_node *left = rb_first_cached(&dl_rq->root); @@ -1867,7 +1867,7 @@ if (!sched_dl_runnable(rq)) return NULL; - dl_se = pick_next_dl_entity(rq, dl_rq); + dl_se = pick_next_dl_entity(dl_rq); BUG_ON(!dl_se); p = dl_task_of(dl_se); set_next_task_dl(rq, p, true); @@ -1922,7 +1922,7 @@ static int pick_dl_task(struct rq *rq, struct task_struct *p, int cpu) { if (!task_running(rq, p) && - cpumask_test_cpu(cpu, &p->cpus_mask)) + cpumask_test_cpu(cpu, p->cpus_ptr)) return 1; return 0; } @@ -2012,8 +2012,8 @@ return this_cpu; } - best_cpu = cpumask_any_and_distribute(later_mask, - sched_domain_span(sd)); + best_cpu = cpumask_first_and(later_mask, + sched_domain_span(sd)); /* * Last chance: if a CPU being in both later_mask * and current sd span is valid, that becomes our @@ -2035,7 +2035,7 @@ if (this_cpu != -1) return this_cpu; - cpu = cpumask_any_distribute(later_mask); + cpu = cpumask_any(later_mask); if (cpu < nr_cpu_ids) return cpu; @@ -2072,7 +2072,7 @@ /* Retry if something changed. */ if (double_lock_balance(rq, later_rq)) { if (unlikely(task_rq(task) != rq || - !cpumask_test_cpu(later_rq->cpu, &task->cpus_mask) || + !cpumask_test_cpu(later_rq->cpu, task->cpus_ptr) || task_running(rq, task) || !dl_task(task) || !task_on_rq_queued(task))) { @@ -2139,9 +2139,6 @@ return 0; retry: - if (is_migration_disabled(next_task)) - return 0; - if (WARN_ON(next_task == rq->curr)) return 0; @@ -2219,7 +2216,7 @@ static void pull_dl_task(struct rq *this_rq) { int this_cpu = this_rq->cpu, cpu; - struct task_struct *p, *push_task; + struct task_struct *p; bool resched = false; struct rq *src_rq; u64 dmin = LONG_MAX; @@ -2249,7 +2246,6 @@ continue; /* Might drop this_rq->lock */ - push_task = NULL; double_lock_balance(this_rq, src_rq); /* @@ -2281,28 +2277,17 @@ src_rq->curr->dl.deadline)) goto skip; - if (is_migration_disabled(p)) { - trace_sched_migrate_pull_tp(p); - push_task = get_push_task(src_rq); - } else { - deactivate_task(src_rq, p, 0); - set_task_cpu(p, this_cpu); - activate_task(this_rq, p, 0); - dmin = p->dl.deadline; - resched = true; - } + resched = true; + + deactivate_task(src_rq, p, 0); + set_task_cpu(p, this_cpu); + activate_task(this_rq, p, 0); + dmin = p->dl.deadline; /* Is there any other task even earlier? */ } skip: double_unlock_balance(this_rq, src_rq); - - if (push_task) { - raw_spin_unlock(&this_rq->lock); - stop_one_cpu_nowait(src_rq->cpu, push_cpu_stop, - push_task, &src_rq->push_work); - raw_spin_lock(&this_rq->lock); - } } if (resched) @@ -2326,8 +2311,7 @@ } static void set_cpus_allowed_dl(struct task_struct *p, - const struct cpumask *new_mask, - u32 flags) + const struct cpumask *new_mask) { struct root_domain *src_rd; struct rq *rq; @@ -2356,7 +2340,7 @@ raw_spin_unlock(&src_dl_b->lock); } - set_cpus_allowed_common(p, new_mask, flags); + set_cpus_allowed_common(p, new_mask); } /* Assumes rq->lock is held */ @@ -2437,6 +2421,12 @@ if (task_on_rq_queued(p) && p->dl.dl_runtime) task_non_contending(p); + /* + * In case a task is setscheduled out from SCHED_DEADLINE we need to + * keep track of that on its cpuset (for correct bandwidth tracking). + */ + dec_dl_tasks_cs(p); + if (!task_on_rq_queued(p)) { /* * Inactive timer is armed. However, p is leaving DEADLINE and @@ -2476,6 +2466,12 @@ { if (hrtimer_try_to_cancel(&p->dl.inactive_timer) == 1) put_task_struct(p); + + /* + * In case a task is setscheduled to SCHED_DEADLINE we need to keep + * track of that on its cpuset (for correct bandwidth tracking). + */ + inc_dl_tasks_cs(p); /* If p is not queued we will update its parameters at next wakeup. */ if (!task_on_rq_queued(p)) { @@ -2554,7 +2550,6 @@ .rq_online = rq_online_dl, .rq_offline = rq_offline_dl, .task_woken = task_woken_dl, - .find_lock_rq = find_lock_later_rq, #endif .task_tick = task_tick_dl, @@ -2866,26 +2861,38 @@ return ret; } -int dl_cpu_busy(int cpu, struct task_struct *p) +enum dl_bw_request { + dl_bw_req_check_overflow = 0, + dl_bw_req_alloc, + dl_bw_req_free +}; + +static int dl_bw_manage(enum dl_bw_request req, int cpu, u64 dl_bw) { - unsigned long flags, cap; + unsigned long flags; struct dl_bw *dl_b; - bool overflow; + bool overflow = 0; rcu_read_lock_sched(); dl_b = dl_bw_of(cpu); raw_spin_lock_irqsave(&dl_b->lock, flags); - cap = dl_bw_capacity(cpu); - overflow = __dl_overflow(dl_b, cap, 0, p ? p->dl.dl_bw : 0); - if (!overflow && p) { - /* - * We reserve space for this task in the destination - * root_domain, as we can't fail after this point. - * We will free resources in the source root_domain - * later on (see set_cpus_allowed_dl()). - */ - __dl_add(dl_b, p->dl.dl_bw, dl_bw_cpus(cpu)); + if (req == dl_bw_req_free) { + __dl_sub(dl_b, dl_bw, dl_bw_cpus(cpu)); + } else { + unsigned long cap = dl_bw_capacity(cpu); + + overflow = __dl_overflow(dl_b, cap, 0, dl_bw); + + if (req == dl_bw_req_alloc && !overflow) { + /* + * We reserve space in the destination + * root_domain, as we can't fail after this point. + * We will free resources in the source root_domain + * later on (see set_cpus_allowed_dl()). + */ + __dl_add(dl_b, dl_bw, dl_bw_cpus(cpu)); + } } raw_spin_unlock_irqrestore(&dl_b->lock, flags); @@ -2893,6 +2900,21 @@ return overflow ? -EBUSY : 0; } + +int dl_bw_check_overflow(int cpu) +{ + return dl_bw_manage(dl_bw_req_check_overflow, cpu, 0); +} + +int dl_bw_alloc(int cpu, u64 dl_bw) +{ + return dl_bw_manage(dl_bw_req_alloc, cpu, dl_bw); +} + +void dl_bw_free(int cpu, u64 dl_bw) +{ + dl_bw_manage(dl_bw_req_free, cpu, dl_bw); +} #endif #ifdef CONFIG_SCHED_DEBUG -- Gitblit v1.6.2