From nobody Sun Feb 8 13:27:54 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8754FD515; Sun, 18 Aug 2024 06:23:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723962190; cv=none; b=I6/OZus9oJBs/OwikZjfbanUPndarKF3TH/iYJUuUt1+7kA27N7LuVhaHcpGwJkojvKf3SOxGBWCUNUO4qUxjsbfrNFYcReXRvipGCgIpdEnkbsLCI097RnnkXhlhQAHueNsXRAGYWA0AsRcagubGIjpb17cOx2MKiyf96b0kZc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723962190; c=relaxed/simple; bh=v452g5+XYCAEskfn79b0coyLuREekR8EczBitfHdQO8=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=o3YvrXrTqToAoFcKNdVhUXTRtNVlFpdb8l/7ZXSPPR0PuJkbVs/ujnKZGHbQV4KIOfzpGgwS6mOWEyZgC7FLrfsoT164u7g6Q6Hhh4JZvAa6lWASubBPxus6akO80Xb9CnKx1OZTiLMnqpafApCOzeaisIGQqMZ59pGfusB3I+I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=PXuCgwVb; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=FJBkwGuS; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PXuCgwVb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="FJBkwGuS" Date: Sun, 18 Aug 2024 06:23:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1723962186; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0+oOXkzWU58lBWC17sVrQoX8Q5qKW6L1Z+s1MmY7Ps=; b=PXuCgwVbaHPaLIbuGtfPPH4uJDLmpvB+u0JK/pvOVGDAYZpzgx6xiAEa/fxOI8VqCYNVQ1 ZlWHJXDg+j45gHklVoiayoEP5s+ONcJGkKGRn3dOFq9sQLqfz+GQhEFjxnEK/YWpmZrw9K iV4Tibgo4dpG3hvW8fZ5ZL2rtfOVpgv/GrbKznEskxccvr2LpspIxSGSXL2AsdjfP0xocU kFl3dFRQl01bI2hyn+bFr26kskpCj3LsoI3gAeXcDkm8zxFU3SfWlBO8PV2qORTvKcbQ2Q s15K3i7DK34v3DV2pfW5ZFAtBv/cPExGPmcbVK5BJP3vxnC6rst43pHXxKSPtw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1723962186; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n0+oOXkzWU58lBWC17sVrQoX8Q5qKW6L1Z+s1MmY7Ps=; b=FJBkwGuSIe29TcSdIuhxRBpy45Gszvt9HHaGvCZ7ihpy9z1/l78+NXgl16sp2/bD3hfC/x ONpRzKeLLhZd1sAA== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] sched/eevdf: Propagate min_slice up the cgroup hierarchy Cc: "Peter Zijlstra (Intel)" , Valentin Schneider , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240727105030.948188417@infradead.org> References: <20240727105030.948188417@infradead.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <172396218582.2215.18076645488650391869.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the sched/core branch of tip: Commit-ID: aef6987d89544d63a47753cf3741cabff0b5574c Gitweb: https://git.kernel.org/tip/aef6987d89544d63a47753cf3741cabff= 0b5574c Author: Peter Zijlstra AuthorDate: Thu, 20 Jun 2024 13:16:49 +02:00 Committer: Peter Zijlstra CommitterDate: Sat, 17 Aug 2024 11:06:46 +02:00 sched/eevdf: Propagate min_slice up the cgroup hierarchy In the absence of an explicit cgroup slice configureation, make mixed slice length work with cgroups by propagating the min_slice up the hierarchy. This ensures the cgroup entity gets timely service to service its entities that have this timing constraint set on them. Signed-off-by: Peter Zijlstra (Intel) Tested-by: Valentin Schneider Link: https://lkml.kernel.org/r/20240727105030.948188417@infradead.org --- include/linux/sched.h | 1 +- kernel/sched/fair.c | 57 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index 89a3d8d..3709ded 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -542,6 +542,7 @@ struct sched_entity { struct rb_node run_node; u64 deadline; u64 min_vruntime; + u64 min_slice; =20 struct list_head group_node; unsigned char on_rq; diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 3284d3c..fea057b 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -782,6 +782,21 @@ static void update_min_vruntime(struct cfs_rq *cfs_rq) cfs_rq->min_vruntime =3D __update_min_vruntime(cfs_rq, vruntime); } =20 +static inline u64 cfs_rq_min_slice(struct cfs_rq *cfs_rq) +{ + struct sched_entity *root =3D __pick_root_entity(cfs_rq); + struct sched_entity *curr =3D cfs_rq->curr; + u64 min_slice =3D ~0ULL; + + if (curr && curr->on_rq) + min_slice =3D curr->slice; + + if (root) + min_slice =3D min(min_slice, root->min_slice); + + return min_slice; +} + static inline bool __entity_less(struct rb_node *a, const struct rb_node *= b) { return entity_before(__node_2_se(a), __node_2_se(b)); @@ -798,19 +813,34 @@ static inline void __min_vruntime_update(struct sched= _entity *se, struct rb_node } } =20 +static inline void __min_slice_update(struct sched_entity *se, struct rb_n= ode *node) +{ + if (node) { + struct sched_entity *rse =3D __node_2_se(node); + if (rse->min_slice < se->min_slice) + se->min_slice =3D rse->min_slice; + } +} + /* * se->min_vruntime =3D min(se->vruntime, {left,right}->min_vruntime) */ static inline bool min_vruntime_update(struct sched_entity *se, bool exit) { u64 old_min_vruntime =3D se->min_vruntime; + u64 old_min_slice =3D se->min_slice; struct rb_node *node =3D &se->run_node; =20 se->min_vruntime =3D se->vruntime; __min_vruntime_update(se, node->rb_right); __min_vruntime_update(se, node->rb_left); =20 - return se->min_vruntime =3D=3D old_min_vruntime; + se->min_slice =3D se->slice; + __min_slice_update(se, node->rb_right); + __min_slice_update(se, node->rb_left); + + return se->min_vruntime =3D=3D old_min_vruntime && + se->min_slice =3D=3D old_min_slice; } =20 RB_DECLARE_CALLBACKS(static, min_vruntime_cb, struct sched_entity, @@ -823,6 +853,7 @@ static void __enqueue_entity(struct cfs_rq *cfs_rq, str= uct sched_entity *se) { avg_vruntime_add(cfs_rq, se); se->min_vruntime =3D se->vruntime; + se->min_slice =3D se->slice; rb_add_augmented_cached(&se->run_node, &cfs_rq->tasks_timeline, __entity_less, &min_vruntime_cb); } @@ -6911,6 +6942,7 @@ enqueue_task_fair(struct rq *rq, struct task_struct *= p, int flags) int idle_h_nr_running =3D task_has_idle_policy(p); int task_new =3D !(flags & ENQUEUE_WAKEUP); int rq_h_nr_running =3D rq->cfs.h_nr_running; + u64 slice =3D 0; =20 if (flags & ENQUEUE_DELAYED) { requeue_delayed_entity(se); @@ -6940,7 +6972,18 @@ enqueue_task_fair(struct rq *rq, struct task_struct = *p, int flags) break; } cfs_rq =3D cfs_rq_of(se); + + /* + * Basically set the slice of group entries to the min_slice of + * their respective cfs_rq. This ensures the group can service + * its entities in the desired time-frame. + */ + if (slice) { + se->slice =3D slice; + se->custom_slice =3D 1; + } enqueue_entity(cfs_rq, se, flags); + slice =3D cfs_rq_min_slice(cfs_rq); =20 cfs_rq->h_nr_running++; cfs_rq->idle_h_nr_running +=3D idle_h_nr_running; @@ -6962,6 +7005,9 @@ enqueue_task_fair(struct rq *rq, struct task_struct *= p, int flags) se_update_runnable(se); update_cfs_group(se); =20 + se->slice =3D slice; + slice =3D cfs_rq_min_slice(cfs_rq); + cfs_rq->h_nr_running++; cfs_rq->idle_h_nr_running +=3D idle_h_nr_running; =20 @@ -7027,11 +7073,15 @@ static int dequeue_entities(struct rq *rq, struct s= ched_entity *se, int flags) int idle_h_nr_running =3D 0; int h_nr_running =3D 0; struct cfs_rq *cfs_rq; + u64 slice =3D 0; =20 if (entity_is_task(se)) { p =3D task_of(se); h_nr_running =3D 1; idle_h_nr_running =3D task_has_idle_policy(p); + } else { + cfs_rq =3D group_cfs_rq(se); + slice =3D cfs_rq_min_slice(cfs_rq); } =20 for_each_sched_entity(se) { @@ -7056,6 +7106,8 @@ static int dequeue_entities(struct rq *rq, struct sch= ed_entity *se, int flags) =20 /* Don't dequeue parent if it has other entities besides us */ if (cfs_rq->load.weight) { + slice =3D cfs_rq_min_slice(cfs_rq); + /* Avoid re-evaluating load for this entity: */ se =3D parent_entity(se); /* @@ -7077,6 +7129,9 @@ static int dequeue_entities(struct rq *rq, struct sch= ed_entity *se, int flags) se_update_runnable(se); update_cfs_group(se); =20 + se->slice =3D slice; + slice =3D cfs_rq_min_slice(cfs_rq); + cfs_rq->h_nr_running -=3D h_nr_running; cfs_rq->idle_h_nr_running -=3D idle_h_nr_running;