From nobody Wed Nov 27 07:36:54 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DF512178F2 for ; Fri, 11 Oct 2024 12:32:46 +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=1728649968; cv=none; b=B1DJgnMpYXyjMkMjQE4ggqE/znsYsWOsFLyfTTojIsy+48vYf247E05SANYSQzI6FPDpUzTrSf1rvsxq3WT80fFkXXBY37TO5W7yo4ahTRH09x3Q0kT8qo8IRTUB0ApEfg3vkVlR2o3/lfnWtDCtwvIxHD4LHv+oLGvlpoL+2PU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728649968; c=relaxed/simple; bh=ys+GKF2df3/9xfmVx3qNMei1OJBfqQN3jCZN6DqV/DY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yckm/JdQhkFwLtw206snveDV38YdtirZuBKHPvdFxpvi0HKGrgOeRX2H0yuwvbz/DRVrbuJQX6NMUjvGm9fiLZ1/N3mV0JY86HusTrmz0Wj5vh9zSM2zoTMdhyOJcxoIQaTXiWHK2TiRwXhCbAQt8g7q4v25XRR7IrqmZs2YTnM= 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 7819ADA7; Fri, 11 Oct 2024 05:33:15 -0700 (PDT) Received: from e126645.arm.com (e126645.nice.arm.com [10.34.129.34]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E734E3F64C; Fri, 11 Oct 2024 05:32:42 -0700 (PDT) From: Pierre Gondois To: linux-kernel@vger.kernel.org Cc: Hongyan Xia , Chritian Loehle , Pierre Gondois , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider Subject: [PATCH 1/1] sched/fair: Update blocked averages on tick Date: Fri, 11 Oct 2024 14:32:22 +0200 Message-Id: <20241011123222.1282936-2-pierre.gondois@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241011123222.1282936-1-pierre.gondois@arm.com> References: <20241011123222.1282936-1-pierre.gondois@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The Energy Aware Scheduler (EAS) relies on CPU/tasks utilization signals. On an idle CPU, the blocked load is updated during load balancing. sd->balance_interval increases with the number of CPUs in the domain. On an Arm DynamIQ system, sched domains containing CPUs with the same capacity do not exist. On a Pixel6 with 4 little, 2 mid, 2 big CPUs: - sd->min_interval =3D 8 - sd->min_interval =3D 16 The balance interval is doubled if the system is balanced, meaning that a balanced system will likely update blocked load every 16ms. The find_energy_efficient_cpu() function might thus relies on outdated util signals to place tasks, leading to bad energy placement. Update blocked load on sched tick if: - the rq is idle - the load balancer will not be triggered. Signed-off-by: Pierre Gondois --- kernel/sched/fair.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 225b31aaee55..2f03bd10ac7a 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9841,15 +9841,12 @@ static unsigned long task_h_load(struct task_struct= *p) } #endif =20 -static void sched_balance_update_blocked_averages(int cpu) +static void update_blocked_averages(struct rq *rq) { bool decayed =3D false, done =3D true; - struct rq *rq =3D cpu_rq(cpu); - struct rq_flags rf; =20 - rq_lock_irqsave(rq, &rf); - update_blocked_load_tick(rq); update_rq_clock(rq); + update_blocked_load_tick(rq); =20 decayed |=3D __update_blocked_others(rq, &done); decayed |=3D __update_blocked_fair(rq, &done); @@ -9857,6 +9854,18 @@ static void sched_balance_update_blocked_averages(in= t cpu) update_blocked_load_status(rq, !done); if (decayed) cpufreq_update_util(rq, 0); +} + +static void sched_balance_update_blocked_averages(int cpu) +{ + struct rq *rq =3D cpu_rq(cpu); + struct cfs_rq *cfs_rq; + struct rq_flags rf; + + cfs_rq =3D &rq->cfs; + + rq_lock_irqsave(rq, &rf); + update_blocked_averages(rq); rq_unlock_irqrestore(rq, &rf); } =20 @@ -12877,6 +12886,8 @@ void sched_balance_trigger(struct rq *rq) =20 if (time_after_eq(jiffies, rq->next_balance)) raise_softirq(SCHED_SOFTIRQ); + else if (idle_cpu(rq->cpu)) + update_blocked_averages(rq); =20 nohz_balancer_kick(rq); } --=20 2.25.1