From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 0844439F160 for ; Thu, 30 Apr 2026 09:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777540892; cv=none; b=I+mFrwWdtXGpEXxvq0E5DZs/NGM7y2v0hxOCN0a2nYCsluRFqhsBer4LAQczIy2D9p9dtsF+DyfZnfPSDwMZMyaqDSb+9An1eIjYstc5QPKmEucJBXozKyQeeG1rCiGR1xYO72b5yKXGJ3jFK8wK0Afr/clHtjUiwcyLNIKn2Os= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777540892; c=relaxed/simple; bh=DoB8C8SMEKSIJICTQ/UudEMD0VWvYa3YcOyPij+AR1A=; h=Message-ID:Date:MIME-Version:Subject:To:References:From: In-Reply-To:Content-Type; b=AzyAjGuwkx+qwqiwIWEYfkHGkHrmEuOLvntlX1MInVw5rcGjTiqUW4uSsROAT2yk1fVCNgKYsASmoT1u9yzw6+7O6Of0mwKkhJ5G3/LDfAiQvxjZRiNJQVAYF+TufBlox0AyVK7B2TdFPADD/ns3GShxppSB8sVhC1o7IT1EMek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FjAijxiS; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FjAijxiS" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-483487335c2so7627055e9.2 for ; Thu, 30 Apr 2026 02:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777540889; x=1778145689; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=5bq2AAQNTxfDoItGim9hi5rm4RG3eqgWn4wRnc/v8GQ=; b=FjAijxiShfKYh0b2SiLnBocpSg9ty07ReSuF2L0Zc4YOCzoVTLefi8400QQIfZmJba Ktiv3eu01KK5ae9znUc+sQON1nTA59g5/sTQIyLtMHjgf5TF1r1RyHtX8J/gX0/UowY9 ntjUz7lwmRD7O6jZSIIRcFqm6DFuUxtS9X4F5ZoxlGGihh7WgXU514upCehwNGziLVnY X8tQ5RV4uDmAmD7iAVsUrp8vSZu7jevkypDaI4LzxTcHvfSA03yn3UaMTNvgAGoK2gD3 9Tng0gjj73jZGJSOTxP74yDbXj3iGMQr3F3gFjY0nswWFpdyNuaRluOkU1VaCNDbPkAm SdQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777540889; x=1778145689; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5bq2AAQNTxfDoItGim9hi5rm4RG3eqgWn4wRnc/v8GQ=; b=V6nDI+Lp7HZKWktGZZv8OqVBiKLjmkbU1QgCwlVQiNjVSEmEN4S8nkU4Q5ZzrDUH5I xS0y3ZjQdAMuk8b4AgNjco7b84se5+EAW2Jhd5V+g/nFIgD1pBq1eWJIzFRnzEzy2AH/ j9XEm85XBYmVpO/0YeglWEOsZHL0wMW3Gf6op+JTOTL+VXqE5Wvbfi1CaGNrpwAwt5wy kI0/fAAVefT6ijngNSD4qYlMWBw+rC48o5poSimUToLK5BG2VrcQnhfGisT31nfYMop0 p/gCAlfL+yHSd227ssCDyyGLC1iQtM+zLIfXkkJBTaZqO9KudRtKCZ6i+7hsTgDTs+eY CukQ== X-Forwarded-Encrypted: i=1; AFNElJ//oOiqvne45qXB9J9P49CBAGRJe+agq6+fAjGK2Wk1pRXy1Aj9QmjT5838DFip6At8zLaAG5BUkw7c6aU=@vger.kernel.org X-Gm-Message-State: AOJu0YyBUpQyspeIgxqTM0z8uKaJAbX8VvNGzHyXlu3Z+r0XPeuW/CkN AKtEAiHrYt/QBIlAs9ZfXhT67ANQ+4JFIvAx8zYm9XsdGDN6jlvHlSqi X-Gm-Gg: AeBDiesotz6aKSTux379ZPxTaW1l+3vn9B+9716LbxirRBrFi1Z5YOnSAqYarP0pEmd ODHaV/Z/qBS41FLqetSSeDa4jGp+jPh+0z+sovjJzYt6TAHcGv5o1KRoDqkxWvbIVOQZxprCJXC YQ6Te8aBNvlqBKglD8RLOuBtUG0p3uGSFwRvGau/kI6aX5/Wa7Jea57NS8oGD00AqOqzE9NIk1S o+Xsy8oeY7I5o95zS4wGnT2XsKrUc3sx0ySp8aiYmKiOMk0BhFJ1h4Gf6PDt3b6QOM7qobM/+2H uigUhMZgsmgJ6kY5lMgHcVGxz5uQI/PoE2yDi6Va/D1KPbmpmRPr5+jAfAC9GmiPIAgQ5Fh2wUI vwAq/7Ma9MjO9DmGHqG493nMifW2j7zAFNZ7bXE0W8UWCpiB2Qax/JFvOIT23MNuNihfBeJsm1r Fjqd0xVY92NzkzR/i9RMN7C3GInEjlEcpfBe30T8cwYA== X-Received: by 2002:a05:600c:638f:b0:489:2005:b36e with SMTP id 5b1f17b1804b1-48a845210a5mr33422055e9.19.1777540888952; Thu, 30 Apr 2026 02:21:28 -0700 (PDT) Received: from [192.168.1.109] ([85.107.100.155]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a7c31fb8asm37629805e9.30.2026.04.30.02.21.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2026 02:21:28 -0700 (PDT) Message-ID: <97020e49-566f-436a-a8d4-92a4acca1461@gmail.com> Date: Thu, 30 Apr 2026 12:21:20 +0300 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: [PATCH] sched/fair: Fix wakeup_preempt_fair for not waking up task To: K Prateek Nayak , 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, qyousef@layalina.io References: <20260429164102.1388139-1-vincent.guittot@linaro.org> <06f3e135-f706-4b6c-8fce-40f562116939@amd.com> Content-Language: en-US From: =?UTF-8?B?RnVya2FuIMOHYWzEscWfa2Fu?= In-Reply-To: <06f3e135-f706-4b6c-8fce-40f562116939@amd.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi K Prateek, On 4/30/26 10:49, K Prateek Nayak wrote: > Hello Furkan, > > On 4/30/2026 11:46 AM, Furkan Çalışkan wrote: >> On 4/29/26 19:41, Vincent Guittot wrote: >>> The assumption that p is always enqueued and not delayed, is only true for >>> wakeup. If p was moved while sched_delayed, pick_next_entity will dequeue >>> it during the attach and the cfs might become empty. >>> >>> Fixes: ac8e69e69363 ("sched/fair: Fix wakeup_preempt_fair() vs delayed dequeue") >>> Signed-off-by: Vincent Guittot >>> --- >>> >>> I have triggered this while running my latency stress test on a new platform. >>> >>> kernel/sched/fair.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c >>> index 728965851842..99fb524c4922 100644 >>> --- a/kernel/sched/fair.c >>> +++ b/kernel/sched/fair.c >>> @@ -9147,7 +9147,7 @@ static void wakeup_preempt_fair(struct rq *rq, struct task_struct *p, int wake_f >>> * Because p is enqueued, nse being null can only mean that we >>> * dequeued a delayed task. >>> */ >>> - if (!nse) >>> + if (!nse && (wake_flags & WF_TTWU)) >>> goto pick; >>> >>> if (sched_feat(RUN_TO_PARITY)) >> >> When a sched_delayed task is migrated (which can only happen via >> MIGRATE_LOAD per can_migrate_task()), enqueuing it on the dest cpu will >> call wakeup_preempt_fair immediately, and if the dest cpu is not busy, >> pick_next_entity() will likely pick and dequeue it immediately. So a >> wasted enqueue+dequeue pair. Could we skip the enqueue when >> sched_delayed is set, and defer it to the actual wakeup path? > > That requires some considerations - if we are migrating a delayed task > to an idle CPU, we can readily block the delayed task if we don't have > other tasks on the migration list. > > If the destination is busy, or if we are migrating a bunch of tasks, > we need to know what the final state of the task_timeline will > be to make a decision whether it is okay to block them immediately. > > We need to know where the avg_vruntime() and deadline ends up to know > if the task will get picked immediately and we cannot do that without > going through place_entity + __enqueue_entity(). > > There is also cgroup implication where, the delayed task might not be > picked immediately if it is on a cgroup whose entity is not eligible > and that requires going through the full enqueue + pick. > You're right - skipping the enqueue introduces far more complexity than the cost of the enqueue+dequeue pair it avoids, since it requires reasoning about the full migration list, destination CPU state, cgroup eligiblity and avg_vruntime placement. Thanks for the detailed explanation