From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.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 F15A738D3F6 for ; Fri, 12 Jun 2026 01:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781228058; cv=none; b=QDskd8isUve8d7PyDTj+8a/gQcBDg3Mnnn++dKPfSGkx6wJH3N4Wt6cRauVzn+gdFaq+g6ALySug6xsNjnD049c/20q6L/X6Bm/XUGWaosdiKeFcmu2cLwwgVrQc/AP9Y6oSLw4A6Avgm3jZz8f7wDJcVFI6jikn3qfjC5MT2No= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781228058; c=relaxed/simple; bh=zEeIioN7oPapJU3c9h2RVk4/EEKpXxCPOa9eJ8a1a+A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N4/C4apt2NQJCfT1KdRU0xQN2ugkc8578zFuhAleIAtKaHesgQQAaNr03iFnmBxJ7N4VI10WfCnIRBDIakaws4BeWR6evMQ9xzWz+1avDHDKQZ9H4qHl3GEkX2TyMK+XB/Ka2ZIL3HxvcY/KlaMs5JnjkhrRGBRH8evdWumVvSM= 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=TW3lTVUP; arc=none smtp.client-ip=209.85.216.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="TW3lTVUP" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-36b903567fdso600814a91.1 for ; Thu, 11 Jun 2026 18:34:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781228056; x=1781832856; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UNVO+jh+8aLfTJNTOqrL5GNoeR3NQijoBRRQ+uUU0zA=; b=TW3lTVUP220JrA86kyovA0ZqVKJ1r7ngag1XMOfpsgzfGbeWNPVH9mIQ6A9ilXWx5y xS6phDZVtXbpDGCpnl0K/EvlHbwvmPZPPw4mITZRpQNrukSVuqjwhZ7W8Q9/CFZWas37 ePGkMsxBBLqfFmCDWfhEmkq1VvisLRUralh6+JIm+Mfk+d38vq5oHaEl2Vx+jaSt3rsK dtTNBTcoLWI+Jd6WZNV0uB3WW1n+So8JDWatQBZ9aheZWDog0Lfwh39KvEOgnOCX91EU +KrXdN8++BRJuHDFNn0EA2UUIkM6jqEABcht2Ru1Bcrk09HuZup95WQYhoHl/GdwNUNA tv/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781228056; x=1781832856; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=UNVO+jh+8aLfTJNTOqrL5GNoeR3NQijoBRRQ+uUU0zA=; b=pxW+BK556nXZglbGa1D0bfMKcioSQCVnxgfzR0BRZt4WRVBBB17uejvbsT+3pV2u4c YPkyskCHSIjKmuzum62de2fhDLqnDUsNKuUYVCxg8QbHFTEoWBRzlfjY9jyYabL31r+U sSbAg0ybSecaZmvkwl0MK7ZRO7bcr591qaE1X/CST59CwnUV3sBxbQzU/t9JB7XSt/RL t/dxRghddaEUKlvCNkNZIPw2Lk/dFoN8U4hWFv8dwncIY5dJfi5X40s68rmzEtw3Gtx9 fDG10PD/rlB0fLBDgHO563ucC+9vvkafz6QObiQ9zP6jCmOM3j5abmngiS3TQwFIis5F 0GdA== X-Forwarded-Encrypted: i=1; AFNElJ/UwlE1oWNPyqshKFNtbDP82ytk0VEj8AZ6hujgUbvm0EoFwVfp3HF6dwV6OZsZMAwkUegTKdy7jVRqwgo=@vger.kernel.org X-Gm-Message-State: AOJu0Yz96gZ4Lk/fnNJSSnTIoVc+6xgcYVSjIvD8VdTZQNzNmSQVWu7v K5huajIiID0nihN8xH4HkWK9bRWo/O6LeKB787HtFhsh15kYWAhaK9g6 X-Gm-Gg: Acq92OGzCNCdwOktw36qkdPrVKCRZLSUByxO8qLInnoFHzbM0HccwLkcoWcU6yKxN8F 5+L5wVbWJLJVrhN/XNx3rWrhkkmgjjva87Lg7Pdjk6/ZF68QO/YlTJo8mcn0lMz1+0FXLUOQ16O L9j8S0v7YqB/IM7AxuFOiHNANYoHZiWBZ3k0YV1+1N3AFfjvE0dNNcunCesEOBCcBZKk3hVvd+y GT66BXJN86Wi3WWXSgx8eAWgc3mrVfKf+X3Hu4mUQShTwdE958sGZQJchtaPcBzMBOAhPEL/mfL um1O+6l+yGJFGKavNhKtAKLjCqjSzpIkw9qGJBa87yhqPSGYQqnzZV4syopDho+Nkm6XRDwXC/R Lxy1CCHZAEvc+6buwqPSrE9Pk4yFb5ONGXbygnwvzFV872RHUVHuQOHPoaV1QIhqLFq6ocIRp8k TqBZSuBMUlOu9Krsqek/MqgRsdjQ== X-Received: by 2002:a17:90a:dfc6:b0:36d:6315:1de5 with SMTP id 98e67ed59e1d1-37a03ccc5c1mr890655a91.18.1781228056379; Thu, 11 Jun 2026 18:34:16 -0700 (PDT) Received: from wanpengli.. ([2408:822f:1aba:84a0:651:104c:ba0c:1f4a]) by smtp.googlemail.com with ESMTPSA id 98e67ed59e1d1-37a1f07bbfdsm250713a91.5.2026.06.11.18.34.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jun 2026 18:34:16 -0700 (PDT) From: Wanpeng Li To: Peter Zijlstra , Ingo Molnar , Thomas Gleixner , Paolo Bonzini , Sean Christopherson Cc: K Prateek Nayak , Christian Borntraeger , Steven Rostedt , Vincent Guittot , Juri Lelli , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Wanpeng Li , Richie Buturla Subject: [PATCH v3 03/10] sched/fair: Credit queued next-buddy via canonical requeue Date: Fri, 12 Jun 2026 09:33:48 +0800 Message-ID: <20260612013355.59231-4-kernellwp@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260612013355.59231-1-kernellwp@gmail.com> References: <20260612013355.59231-1-kernellwp@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Wanpeng Li eevdf_credit_entity_vlag() handles cfs_rq->curr, which is off-tree. Extend it to a queued entity, which is the common case when yield_to() targets a task that is runnable but not currently executing. A queued entity's key contributes to cfs_rq->sum_w_vruntime, so its vruntime cannot be shifted in place. Use the canonical place_entity()- paired requeue pattern: snapshot vlag, make the deadline relative to se->vruntime, dequeue the entity, apply the credit via place_entity(), and enqueue it again. This keeps sum_w_vruntime consistent with entity_key(), preserves the slice, and shifts the deadline by the same amount as the off-tree current-entity path. The helper is not called in this change; there is no functional change. Signed-off-by: Wanpeng Li --- kernel/sched/fair.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index c6502db62cd3..c28682fedb36 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -9372,7 +9372,9 @@ eevdf_persistent_margin(struct cfs_rq *cfs_rq, struct sched_entity *se) * to a bounded positive-vlag margin so pick_eevdf()'s PICK_BUDDY branch * keeps returning it across several picks, without exceeding entity_lag()'s * legal bound. cfs_rq->curr is shifted in place (off-tree, carrying any - * vprot window). Queued entities are left unchanged. + * vprot window); a queued entity uses the canonical + * place_entity()-paired requeue, keeping sum_w_vruntime consistent with + * entity_key(). * * Idempotent once @se holds the margin. Caller must hold * rq_of(cfs_rq)->lock with rq_clock up to date. @@ -9422,7 +9424,22 @@ eevdf_credit_entity_vlag(struct cfs_rq *cfs_rq, struct sched_entity *se) return; } - /* Queued entities are left unchanged by this helper path. */ + /* + * Canonical place_entity()-paired requeue: see dequeue_entity() and + * requeue_delayed_entity(). place_entity() restores the deadline via + * "se->deadline += se->vruntime", so make the deadline relative to + * se->vruntime here (not avg_vruntime). This preserves the slice and + * shifts the deadline by exactly -credit, mirroring the curr branch + * and keeping deadline > vruntime. + */ + se->vlag = vlag + (s64)credit; + se->deadline -= se->vruntime; + se->rel_deadline = 1; + cfs_rq->nr_queued--; + __dequeue_entity(cfs_rq, se); + place_entity(cfs_rq, se, 0); + __enqueue_entity(cfs_rq, se); + cfs_rq->nr_queued++; } /* -- 2.43.0