From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EB793311C09 for ; Mon, 1 Dec 2025 13:53:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764597204; cv=none; b=lB2CdpE+xdrt8CTw9LrHYkRUS2Q1uAngtzDDQ60yvhFI+NxGwyPkQQXnfjGcdFQql9A/UeR+5iozF11mbx6dvD/3CJJdEOnL2VJbZjTIR3PugydS8Ye4RLejCoSGZF3cwUHlDGKwnXF8amdTEzAXjbPXzsrLv0wSm2BAxgY8Gm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764597204; c=relaxed/simple; bh=tQpbtCm5H87DQC2DzVKiAZbEdPy/R9JG8ID7mkMRgGs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ID8DNpQchrUkklJ0elLMQxBdOr0Yj/sbK2bb4fGyQ2PO2mKQodCw+rpFM9nE93PHZgEK+AqFhGZJW9NpXtLv62w643R7Ekpmoe4KXfJZD2gNWs3SXEPMUI2F6xeOcQzLoAB5+R0y0FGFt3bRIBJUJiG3sv7vcAeVXDLfRiz6FS4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 713DA153B; Mon, 1 Dec 2025 05:53:13 -0800 (PST) Received: from [10.1.29.49] (e127648.arm.com [10.1.29.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C6BB53F73B; Mon, 1 Dec 2025 05:53:17 -0800 (PST) Message-ID: Date: Mon, 1 Dec 2025 13:53:15 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 6/6 v7] sched/fair: Add EAS and idle cpu push trigger To: Vincent Guittot , mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, linux-kernel@vger.kernel.org, pierre.gondois@arm.com, kprateek.nayak@amd.com Cc: qyousef@layalina.io, hongyan.xia2@arm.com, luis.machado@arm.com References: <20251201091308.761711-1-vincent.guittot@linaro.org> <20251201091308.761711-7-vincent.guittot@linaro.org> Content-Language: en-US From: Christian Loehle In-Reply-To: <20251201091308.761711-7-vincent.guittot@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Some nits below for now On 12/1/25 09:13, Vincent Guittot wrote: > EAS is based on wakeup events to efficiently place tasks on the system, but > there are cases where a task doesn't have wakeup events anymore or at a far > too low pace. For such cases, we check if it's worht pushing hte task on worth the > another CPUs instead of putting it back in the enqueued list. > > Wake up events remain the main way to migrate tasks but we now detect > situation where a task is stuck on a CPU by checking that its utilization > is larger than the max available compute capacity (max cpu capacity or > uclamp max setting) > > When the system becomes overutilized and some CPUs are idle, we try to > push tasks instead of waiting periodic load balance. > > Signed-off-by: Vincent Guittot > --- > kernel/sched/fair.c | 65 +++++++++++++++++++++++++++++++++++++++++ > kernel/sched/topology.c | 3 ++ > 2 files changed, 68 insertions(+) > > diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c > index 9af8d0a61856..e9e1d0c05805 100644 > --- a/kernel/sched/fair.c > +++ b/kernel/sched/fair.c > @@ -6990,6 +6990,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *p, int flags) > } > > static void fair_remove_pushable_task(struct rq *rq, struct task_struct *p); > + This doesn't belong here > /* > * Basically dequeue_task_fair(), except it can deal with dequeue_entity() > * failing half-way through and resume the dequeue later. > @@ -8499,8 +8500,72 @@ static inline bool sched_push_task_enabled(void) > return static_branch_unlikely(&sched_push_task); > } > > +static inline bool task_stuck_on_cpu(struct task_struct *p, int cpu) > +{ > + unsigned long max_capa, util; > + > + max_capa = min(get_actual_cpu_capacity(cpu), > + uclamp_eff_value(p, UCLAMP_MAX)); > + util = max(task_util_est(p), task_runnable(p)); > + > + /* > + * Return true only if the task might not sleep/wakeup because of a low > + * compute capacity. Tasks, which wake up regularly, will be handled by > + * feec(). > + */ > + return (util > max_capa); > +} > + > +static inline bool sched_energy_push_task(struct task_struct *p, struct rq *rq) > +{ > + if (!sched_energy_enabled()) > + return false; > + > + if (is_rd_overutilized(rq->rd)) > + return false; > + > + if (task_stuck_on_cpu(p, cpu_of(rq))) > + return true; > + > + if (!task_fits_cpu(p, cpu_of(rq))) > + return true; > + > + return false; > +} > + > +static inline bool sched_idle_push_task(struct task_struct *p, struct rq *rq) > +{ > + if (rq->nr_running == 1) > + return false; > + > + if (!is_rd_overutilized(rq->rd)) > + return false; > + > + /* If there are idle cpus in the llc then try to push the task on it */ > + if (test_idle_cores(cpu_of(rq))) > + return true; > + > + return false; > +} > + > + > static bool fair_push_task(struct rq *rq, struct task_struct *p) > { > + if (!task_on_rq_queued(p)) > + return false; > + > + if (p->se.sched_delayed) > + return false; > + > + if (p->nr_cpus_allowed == 1) > + return false; > + > + if (sched_energy_push_task(p, rq)) > + return true; > + > + if (sched_idle_push_task(p, rq)) > + return true; > + > return false; > } > > diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c > index cf643a5ddedd..5edf7b117ed9 100644 > --- a/kernel/sched/topology.c > +++ b/kernel/sched/topology.c > @@ -391,10 +391,13 @@ static void sched_energy_set(bool has_eas) > if (sched_debug()) > pr_info("%s: stopping EAS\n", __func__); > static_branch_disable_cpuslocked(&sched_energy_present); > + static_branch_dec_cpuslocked(&sched_push_task); > + } else if (has_eas && !sched_energy_enabled()) { > } else if (has_eas && !static_branch_unlikely(&sched_energy_present)) { This could just be (has_eas && && sched_energy_enabled() && !static_branch_unlikely(&sched_energy_present)) to avoid the awkward else if above > if (sched_debug()) > pr_info("%s: starting EAS\n", __func__); > static_branch_enable_cpuslocked(&sched_energy_present); > + static_branch_inc_cpuslocked(&sched_push_task); > } > } >