From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f49.google.com (mail-ed1-f49.google.com [209.85.208.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 551E91F936 for ; Tue, 2 Dec 2025 13:01:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.49 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764680515; cv=none; b=Fbwah7P+XEqgV/2xwsv3DpXJbvmAz4Oj9Ko7/tQOL8LcDSUZ1oTuX1kH3fkjNq3mAEhSPtGSs0pd1hZYORJR/0Fehmm3OcNk0aPfJDYGU0qpPUzo/4MuVMqBIwGA79jUeVOW7B0Cwzal5brYx0x13YwKQ1g8COAmHCssoBueGRI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764680515; c=relaxed/simple; bh=ltQVFC6T5MyJQgZ8pfL4s24JgWy9PuDbKTY8/nMDvhY=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=NVQFwD7LvOH2wh9KmmC49f2gyhXU8+jyN7Y9XLZZJXU6B1QEvh1p9Y/hxu/cUeZKJxvKrKoQJs2CAF3YYBJrxYTH4R75x/irDieTQ9bX9+I2rglVdEbNF/EKJD5WDPJVs6I6siUW9F4L+oUCZMghzbuzbtO8dq30Ked+bB4AQqk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=oNgI2DUH; arc=none smtp.client-ip=209.85.208.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oNgI2DUH" Received: by mail-ed1-f49.google.com with SMTP id 4fb4d7f45d1cf-64080ccf749so7976894a12.2 for ; Tue, 02 Dec 2025 05:01:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1764680512; x=1765285312; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=keynYMHD5LthwALCo4CgV/j8RPDlciB09WpK9+UzZk0=; b=oNgI2DUH/XAYTSucy0myo/HN5Fj+kz0AT2qTQoCvzIpgBtyGr/VXXlC1flJmpa/u3+ eqCN8zeKNy5neM6gW8UcV0hcTvqpKDqGyWQNE6aBqAGS080pjYokif2VNVXi3EaqKGbl aP92gSnfQ5gTHo93L+SrcN+qHJBItIx1OQ5zli374qa+XCsFrU7fJ2jqHKu/iudSXo6a ZVLBrbGMEtKVSY8gOzvgE9L/ZIqIzr4RiDvpHSr4SRTmAzC6AL/YN7+gimcWfXWZP2Zt oO9psC3V9JibhVK7l3RJIw1LNzwL78F32+fzcDjJuWXFMz8D3EiVkbqgcrM/bkJpIRsm sFfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764680512; x=1765285312; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=keynYMHD5LthwALCo4CgV/j8RPDlciB09WpK9+UzZk0=; b=oOX2xvMilEyRYZZ7JGL8SrKB8Yi9MfBJLvZ4wXd2ySToBeLkEIimnKrrsu2Scj/soG waWP4cyVWkiucV2FIib++XUHbSHRm5elw5vnr9QtqvO++EPTrPPaEg6FQ0RS9VlX1WhQ WjrtMaRAwFcLo5HqRcPOZ3bUP50FfEZcuM2RZI+ueVauOb1Ev4t2Ka8ZrjkLLRJt5orO bhzojECqqZL9p3hpqilMyut2Mu9O0Mxrz1dWVpZZFz2VDoCP8xm0kx2KKzjBZHBiEoOS DcPWmtUjF3sV+wfWHomRwg4F9BZZMXTcBKlx+inJTqzF0roUzOaMaZ8k3vjzBYTZf49y 7w5g== X-Forwarded-Encrypted: i=1; AJvYcCU9SwekP7c1Q042y+wM86/s8JzFj+7OM5TiK+bnSmoI+Kt+YRxCeSXnqrf6vO250gpHG0DvZ7q9jLoDH2M=@vger.kernel.org X-Gm-Message-State: AOJu0YxlS3wh00YZjJx9W3eMOmTtn0Lf0tsNCHGHWq8RQBZU2B6JbdnU L5C7S80m9SPcH3VWVLaqSwiBqnlEoecvci5Jz2BBx2gFCO9oQmukT2T+w/qpslPnVuSHItNsxI0 Q2s5CghYDRKrT1AIFfrX7g3UtO41EuM0c3FBdXDQT0g== X-Gm-Gg: ASbGncvu+R2kh3honJUyj2VpudWL0bZxQfzezoVUJxmgCOvpEyrdmrQ0g3xH0T3Cqs7 sFTcheba/5/mpFVBZaJeC9ClxZ1e/EEobOYsvvEEfAaDXHLgxQ0pKpXwfgEAphlyM+aNT/E5G1O v+YDp8cGxtEmc/0ckxIPZUW2+gwjgVBImkpfQVV0rZFApePaXa1p0m7EiJQV8HTEkycZAMyCjzN 3WtTJSQZx6OOU8esF3FebI7WKFMu+lx9LgJ9VaOhF0dvNDh+7bUASPdjEVGOBM7PWp0D8m4UQab F06WEukaVbHBztF4bZRdjMCqVKffD4KMFQ== X-Google-Smtp-Source: AGHT+IHknEWncH22QVk/bYxdxakqKSqHcoCJBWijA5oe0rjMLA08BigvtcUz7qofxvTgZoRUp3dRhlEtT9i/U+j1JnQ= X-Received: by 2002:a05:6402:4311:b0:640:c454:e9 with SMTP id 4fb4d7f45d1cf-64555b86b59mr37003653a12.4.1764680511366; Tue, 02 Dec 2025 05:01:51 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20251201091308.761711-1-vincent.guittot@linaro.org> <20251201091308.761711-7-vincent.guittot@linaro.org> <20251202094454.9608-1-hdanton@sina.com> In-Reply-To: <20251202094454.9608-1-hdanton@sina.com> From: Vincent Guittot Date: Tue, 2 Dec 2025 14:01:39 +0100 X-Gm-Features: AWmQ_bm_3uGED3g_fUmip-rvCXufqwAGb37axguKflSYFUB_qEJ0TWnFkScYKGw Message-ID: Subject: Re: [RFC PATCH 6/6 v7] sched/fair: Add EAS and idle cpu push trigger To: Hillf Danton Cc: peterz@infradead.org, linux-kernel@vger.kernel.org, pierre.gondois@arm.com, kprateek.nayak@amd.com, qyousef@layalina.io, christian.loehle@arm.com, luis.machado@arm.com Content-Type: text/plain; charset="UTF-8" On Tue, 2 Dec 2025 at 10:45, Hillf Danton wrote: > > On Mon, 1 Dec 2025 10:13:08 +0100 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 > > 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); > > + > > /* > > * 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; > > Task is queued on rq. > > + > > + 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 task is stuck on CPU, it could not be on rq. Weird. May be it comes from my description and I should use task_stuck_on_rq By stuck, I mean that the task doesn't have any opportunity to migrate on another cpu/rq and stay "forever" (at least until next sleep) on this cpu/rq because load balancing is disabled/bypassed w/ EAS Here Stuck does not mean blocked/sleeping > > + > > + if (sched_idle_push_task(p, rq)) > > + return true; > > + > > return false; > > } > > > More, in the tick path, > > task_tick_fair > check_pushable_task > fair_push_task > task_on_rq_queued // this check makes no sense I want to use a single entry point (fair_push_task) for deciding to push a task so I agree that testing task_on_rq_queued() at tick is useless but it is needed for other cases when the task is put back in the rb tree