From nobody Sun Jun 14 04:20:27 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 7B74F175A6D for ; Sun, 3 May 2026 10:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777805109; cv=none; b=pp/LPebYq2JFbbpYgf9wPeXnEVrNH/q0J3YRaT6Q5m6QLR+3pspFDLjYwgyBvSJhC7owaS/yfwp7ERJ+XtppkiDY1UGaf9FONc+B22C5Z3wyy5Shb3lQl9wDYcWku/5FC95GraQUyd3377TNHhaWmUq0hfoau4Gj3GQangv17TE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777805109; c=relaxed/simple; bh=9C/zqD3JJwRWO/lBP+FuVD988C5L0Vf06bwSJCjA4Gs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=lznlNwp/x0Ayrm/mZ4bcq4cjFl05aAaU1/p7XUvLIgcg0jMOmlCtD7s+zRumw+hhcqm6udzTP4D4VWxOoQWukkh/DHsZ6r9FCV/hxf8y110f9VLagG24AnR2TOHofbX5RPF9JEMKvhUKDK/ZXbjz5Hgufq7m5LsCi+dDadt15Ys= 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=MCpZ+lFt; arc=none smtp.client-ip=209.85.128.50 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="MCpZ+lFt" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-488b0e1b870so51413995e9.2 for ; Sun, 03 May 2026 03:45:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1777805106; x=1778409906; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=c4+lEXsfYKn05rcbvLfuMUjaDm28a7XDgpkohIxIVLs=; b=MCpZ+lFtjp9pkAmrkXVuyk9KZO7IX10pdhzSkvLIg8A67NvDnPDRik99Z+y3Rtue5K xsNaeo3lRHJGJ0Mo+IagmDAgu7nIsTWMKuyhziTwWeYiVoIzpoActPaJq+5Oc3G9sB9Z Gh6e36VGOz3l4/omm2vbO9hxL7KTjCmDSiZ8hWCrrfpOc7ftMJrKDDDtIjQ6E7t2vCZY SvmraRaymbSxqPd46JHFXsKuWhUg0RrpuWUR+EYTAG3Bd0KK+gmLCPrdLzCAaubWQCq7 HYtXgFb2/aF2s7KMaFK/L7eJscdV7T82WkZP1GbhPJs0N4KSCq2bT0xvUO+rrDmBnNG+ giVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777805106; x=1778409906; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=c4+lEXsfYKn05rcbvLfuMUjaDm28a7XDgpkohIxIVLs=; b=GZdjv3khU8SHlvVJ61Ol11yH65i0KtocayC3LQ9BvWqdosq3iVzsbh0lJEW1KfObvC 6uRy5M3n3bijyW0KUVkqLfouOcx/AHpey4BrqIFg0q1eWOB/fpqv1xrsKOlNftyHL1N5 Z9/2BP1l4kRmHZqDTDMYmDKzs6R7VdlVpFrw8Aqj9HvS89qnhycCP/2AjsCg6VbtL21I DDlzJYdw+mTO/16FDQEqEFFJTiu6K9LtGdG8lGUhYqTgM+qggTl1po4h1sE0edkP+yFz Y423cnEv5FdKDO+Ga0cAzmOKKjrS9/ZnfiUwuwiIilmq0bPT6dMCXxUucikOaNIn8t3D TF5w== X-Forwarded-Encrypted: i=1; AFNElJ+HW/vvWITFFm77kPE9gdOc0wSPgd7pkTqpXOA81bwwmAnQPcyCXyb+Ye/qmlKW+garxWGP4KmvHITSUEI=@vger.kernel.org X-Gm-Message-State: AOJu0YwqOIQbZP8e9uJ3keFLr6WYcdWAYzrhSwOuyofQIbt325hMsjrA Rg8rRm63ifv+riGJSEzPei+hKGAYFY748IiJiYXQ6Lre/R+VW80UunYCkvaJbzl7pd4= X-Gm-Gg: AeBDieszR/ANS+XKi8Wwvh5XXd1Z6+jhazPaLqm93qmSkcColzBHxRmusgHBRq54Pqf CPuYa+pM4h1BMY1Indk5IBxS9EyvWU6mIXgPmnz1PZYpz2dzkfbkdNi8HFesBKPGVasKiWtph+Q SZaWuuHdU1sV0arx8VDkk6xfoYV5m0mR+wbJGWWAWT5KFAPgFU96WP/RSyFwb/AEgFp6zVN1oGb OfjDRCXG3H8xmW4OBaZGNhLgmSZg6VZmTOm76+P2G5Za1Ghh07rsJUXUt77jQFA1Gmw2NS0BNk7 hM/p7bBG0RCn2VinkTyRKjJxZGhioIAKP819/296oX0Sh13N+uMgTrLhTkKtJEQdpPfxbuBZ8GN FDQGmUgKWyYm3P/pfCvWEQtgbM4GaXG8hXMfgL7z5UUlGDa2hot0/f/A1fUWZtd/RAqGbVGjiFl bCbJXdJqqin/DvVVKSpipEYD1wnE/I4XafK+JskQOe7usNW4WZVSSk9Q== X-Received: by 2002:a05:600c:c101:b0:488:8c89:cfaa with SMTP id 5b1f17b1804b1-48a9852f492mr67116615e9.3.1777805105768; Sun, 03 May 2026 03:45:05 -0700 (PDT) Received: from vingu-cube.. ([2a01:e0a:f:6020:6d7d:3973:fbfb:dfc4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a81b99127sm245238785e9.0.2026.05.03.03.45.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 May 2026 03:45:05 -0700 (PDT) From: Vincent Guittot To: 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, kprateek.nayak@amd.com, linux-kernel@vger.kernel.org, qyousef@layalina.io Cc: Vincent Guittot Subject: [PATCH v2] sched/fair: Fix wakeup_preempt_fair for not waking up task Date: Sun, 3 May 2026 12:45:03 +0200 Message-ID: <20260503104503.1732682-1-vincent.guittot@linaro.org> X-Mailer: git-send-email 2.43.0 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 assumption that p is always enqueued and not delayed, is only true for wakeup. If p was moved while delayed, pick_next_entity will dequeue it and the cfs might become empty. Test if there are still queued tasks before trying again to determine if p could be the next one to be picked. There are at least 2 cases: When cfs becomes idle, it tries to pull tasks but if those pulled tasks are delayed, they will be dequeued when attached to cfs. attach_tasks() -> attach_task() -> wakeup_preempt(rq, p, 0); A misfit task running on cfs A triggers a load balance to be pulled on a better cpu, the load balance on cfs B starts an active load balance to pulled the running misfit task. If there is a delayed dequeue task on cfs A , it can be pulled instead of the previously running misfit task. attach_one_task() -> attach_task() -> wakeup_preempt(rq, p, 0); Fixes: ac8e69e69363 ("sched/fair: Fix wakeup_preempt_fair() vs delayed dequ= eue") Signed-off-by: Vincent Guittot --- Change since v1: - Use cfs_rq->nr_queued instead of WF_TTWU flag to cover all cases instead of just wakeup. I'm preparing patches to cover those useless newly idle and active load balance task migration. kernel/sched/fair.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 728965851842..24087b0f25f6 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9145,9 +9145,10 @@ static void wakeup_preempt_fair(struct rq *rq, struc= t task_struct *p, int wake_f =20 /* * Because p is enqueued, nse being null can only mean that we - * dequeued a delayed task. + * dequeued a delayed task. If there are still entities queued in + * cfs, check if the next one will be p. */ - if (!nse) + if (!nse && cfs_rq->nr_queued) goto pick; =20 if (sched_feat(RUN_TO_PARITY)) --=20 2.43.0