From nobody Mon Jun 15 13:57:30 2026 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 A381A3D75C8 for ; Fri, 10 Apr 2026 14:48:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775832502; cv=none; b=oqOtlw2hHw+gASvBGHre1BbaquWheAWUSx/Rlr5J75eFjh7HhndxXNWefraLe2SHlykn7Ji8XuyJ2GTY8JDkSeJUP8odtUa1LD6TbF7M8tEDQcVqVkbJhCDpxoJIfr/iI+eNBdB84oPA4gWfdxyR45FRoZP3gk64mSq42+l8yP4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775832502; c=relaxed/simple; bh=gyp8WJtixzd8cVEMFBtL7n8gyoz3RgW5i5laUNl2HDM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ZYR0XpNIfk/Lumo88GA8tkqHM/Ofq7jucFQTnhxbNGRk0VDZypzt6SrIVIiSYyac5NLsu3Tk+qR2bVlGHf5vBta/iHo/Uq13JuGM+29HHseBhFd77YZApJ7hvaUJoHvEy0oE/F9hx2UAmAgp8fHAwTuTb/Km7+4OlRc8qr3mIuk= 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=lKUq7Fy4; arc=none smtp.client-ip=209.85.221.45 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="lKUq7Fy4" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-43b9d3ebed5so1748136f8f.1 for ; Fri, 10 Apr 2026 07:48:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1775832499; x=1776437299; 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=to4s3tk0PRhhTuDibPSsHK7EgozVPqVZN+E3xC1i0Wo=; b=lKUq7Fy4ATmSWGlg2IXZZz2EnT1ME1cAptvJIMfFevSyacWVs5ySkeUbhgKilDmWSJ hYw2X4458UIxCmbX3fU3TrWHJHHIopXFLkh71pj2Temkpi5LUPBxfJVERN8nxB7KFo2C JRcrDzkda6xOVPqBKhSQkmknja0dZYgW7xeFiaL1eSScLaqbp5td1m1Jw//65GQtNCBa SUXieD6iRtMbvRMUeszXNEZmwKXjypskMh7Y6d26Fe9C4RX2O+o3k5nkBiQLsTXiKtnK WSlY99Of03l6vNSt6Vn3a3B0mB38TTCuRQh/TZSHoDCLBklFbWOq2RDRES07iWgxOYA0 CLGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775832499; x=1776437299; 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=to4s3tk0PRhhTuDibPSsHK7EgozVPqVZN+E3xC1i0Wo=; b=jCHo/HFUZZTRzqViASAne14g774EHod3iPFEKos2dbOsVkI+A98APODQxZx2ZCr5yv a54VBpDx3PIGOoeAVt6LFS/8w53Mf2ktEDYjjp3x1mOsS4WJovUx7Hf2lpZAowtCeXEZ 1uZJysHFYjSQKiKBdBsiA52RjnOeIygvw8vYiQJWwLGAIQ6hy6xYX+DrloyMPg8EtQfy pINcsSriEyMn65TPERBU3ks9ibY7i5HAe2HHA2Ele2ZM3G2AaiNSmo2XSQpXd1FUSu5M TlIbSBoMw0AQNnYw3PKedztGoEVlzsM2ahGnz1y0oUdRKnYFKff4BuzD9jqVeU/3FkRS O5xg== X-Forwarded-Encrypted: i=1; AJvYcCVzUiWcndB7qQ0fyZnBCoK7bQViGNJpYru4FG6uTShY4BNwlBzP2uZ1bNFIEJZ9V3mNeqQmHPaU3WrVBLk=@vger.kernel.org X-Gm-Message-State: AOJu0YwCuMlbJyAtDuTX8Z6sAcY/yRAPZKDy2crz07F9J9H9HWbzKloc pUhBphfAnXLbv3Tv/L+KZ98DynqJ+jsq67kWYPXXYIdOL+0oZTlEdGlX/WffkS3eDm8= X-Gm-Gg: AeBDieviDeMd2zIGJWsmapAGvw2p6IWpdHUZj6VtCv4hrn02N9u8b9+TnvZukr9+RWc JziwF3faBW6BT7TlnpnRhnG6vx7vGzE6o28ASqgq8fnRwmviqkjR9i7e3SGO6/GL9bg+f/xwxBh 5cyvpivivWx/hz4mHtJufbvPhhwMm1F7FZaiIoCd4darPsFZC28jir+KtiMPA+k2H3TMCH4WSQ6 hcsWxMzdA2as1akaAieI+xqqz3zJPPwIZTtkwNLlhMPbTU59dxCBFXMqTjaeNd1phFELeXv92tB FlaKRysifB04z6oLvGdH2T91GTrGcC1nMm66MQHGxKQ+tzZ2Ig7be5s6gI3lwRRSuQCPYDXqYaS 09OYVeHbSt4npoUmW+EsOh4xvxdBXsRJjLCjFbuXMbXhWaRg4+T5kOwWeJfBD0ru/0vb/19MwUf 9wgy4JuNHLXx8oEMxlv4AGhYb6793Xw6Tw X-Received: by 2002:a05:6000:4007:b0:43b:54c9:85f4 with SMTP id ffacd0b85a97d-43d642b192dmr5279565f8f.39.1775832498866; Fri, 10 Apr 2026 07:48:18 -0700 (PDT) Received: from vingu-cube.. ([2a01:e0a:f:6020:d339:889f:6b52:541d]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d63e5c98fsm8514512f8f.35.2026.04.10.07.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2026 07:48:18 -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] sched/fair: delayed dequeued entity bias wakeup preempt short Date: Fri, 10 Apr 2026 16:48:08 +0200 Message-ID: <20260410144808.2943278-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" When checking if a shorter slice entity can preempt curr, we compare it with the next entity to be picked but delayed dequeue entities can screw the decision whereas they will be dequeued when picking next entity. Dequeue them while checking for preemption as they will be dequeued anyway when picking next entity. Test on snapdragon rb5: hackbench -T -p -l 16000000 -g 2 1> /dev/null & cyclictest -t 1 -i 2777 -D 63 --policy=3Dfair --mlock -h 20000 -q tip/sched/core tip/sched/core +this patch cyclictest slice (ms) (default)2.8 8 8 hackbench slice (ms) (default)2.8 20 20 Total Samples | 22559 22595 22683 Average (us) | 157 64( 59%) 59( 8%) Median (P50) (us) | 57 57( 0%) 58(- 2%) 90th Percentile (us) | 64 60( 6%) 60( 0%) 99th Percentile (us) | 2407 67( 97%) 67( 0%) 99.9th Percentile (us) | 3400 2288( 33%) 727( 68%) Maximum (us) | 5037 9252(-84%) 7461( 19%) Signed-off-by: Vincent Guittot --- kernel/sched/fair.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 0c6b9541d864..f479666ddb9e 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -8987,7 +8987,7 @@ static void wakeup_preempt_fair(struct rq *rq, struct= task_struct *p, int wake_f { enum preempt_wakeup_action preempt_action =3D PREEMPT_WAKEUP_PICK; struct task_struct *donor =3D rq->donor; - struct sched_entity *se =3D &donor->se, *pse =3D &p->se; + struct sched_entity *nse, *se =3D &donor->se, *pse =3D &p->se; struct cfs_rq *cfs_rq =3D task_cfs_rq(donor); int cse_is_idle, pse_is_idle; =20 @@ -9098,12 +9098,17 @@ static void wakeup_preempt_fair(struct rq *rq, stru= ct task_struct *p, int wake_f } =20 pick: - /* - * If @p has become the most eligible task, force preemption. - */ - if (__pick_eevdf(cfs_rq, preempt_action !=3D PREEMPT_WAKEUP_SHORT) =3D=3D= pse) + nse =3D __pick_eevdf(cfs_rq, preempt_action !=3D PREEMPT_WAKEUP_SHORT); + /* If @p has become the most eligible task, force preemption */ + if (nse =3D=3D pse) goto preempt; =20 + /* If the most eligible task is delayed, dequeue it and retry */ + if (nse && nse->sched_delayed) { + dequeue_entities(rq, nse, DEQUEUE_SLEEP | DEQUEUE_DELAYED); + goto pick; + } + if (sched_feat(RUN_TO_PARITY)) update_protect_slice(cfs_rq, se); =20 --=20 2.43.0