From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 9FEE01FFC59 for ; Fri, 23 Jan 2026 15:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769182746; cv=none; b=tH31chQwBoXS1sJNbh7SUqyryWcsM9DJ9Q2yq77NXC/LXy1nzr5c5FjXsSOLuCBvCy2zdadV9SzxeL5s5rt1IbtPuZsP04FO3GPKUVjSkNZThbE58Miru2IOCf0YWm90v96v6VdFEkpW69Da3MwrUcCIxDvs77MwYASgk/nBU9A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769182746; c=relaxed/simple; bh=+13uKrqd70cSIXFb0cRrkDun/f3A3NGqP00Zo94c2kk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tSs0k+/mVwl3bxZa3d1Wdz2xprfPhEuZTfZhj5YCnk5u0n2gs6zhjqXpM28M6EHLEe0PtEpOXu2+XQV0CLfZfAZjl6TLOaAjO8xJPVyEiRCDWZ79fXX9VbOOhJKa9qBJxdmN7SI/mNVF4eIJtzqVKLbM5XeCYfQg8iucTbvyxZA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=gIMQKL1t; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="gIMQKL1t" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=txIh9ryTgOsQa1pQV6mAbyPrYLODjKCE6iokZrPZ7YY=; b=gIMQKL1tvg+oRcw3NnSDqlfGMg ph4Lh10wwsyS8qNf0b2JHa2qaoPS+3jHJMWT2kMSOG3Qsa3J+IqQRGpGxck6MiTRw+cHT8Ek2dotu EyR5TcTsnPUziArXlZjmXeCP/NfVLtDPodeUq6PqsIIL4ygw8x8mJNZVYTIe0nkVWdGu2pgxJB7Mw MyujG6gM4NgAU7cr15642volhbe5wHz8ThbGgkI6eC92chZVzZ+KZs+1DjW/LgIqcb2QzVDAntDnU p3DJRKjkxKsjtZtVu/AoPtztFHSUYM5Q79pMc6SnEx8WSv/WO4MU2/76KUGZBHyUGYPVW7ImP7gmP r1kyvxRA==; Received: from 2001-1c00-8d85-5700-266e-96ff-fe07-7dcc.cable.dynamic.v6.ziggo.nl ([2001:1c00:8d85:5700:266e:96ff:fe07:7dcc] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1vjJFP-00000001wiH-494X; Fri, 23 Jan 2026 15:38:56 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id E75B83007E1; Fri, 23 Jan 2026 16:38:54 +0100 (CET) Date: Fri, 23 Jan 2026 16:38:54 +0100 From: Peter Zijlstra To: Vincent Guittot Cc: "wangtao (EQ)" , K Prateek Nayak , mingo@redhat.com, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, vschneid@redhat.com, tanghui20@huawei.com, zhangqiao22@huawei.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] sched/eevdf: Update se->vprot in reweight_entity() Message-ID: <20260123153854.GU166857@noisy.programming.kicks-ass.net> References: <20260120123113.3518950-1-wangtao554@huawei.com> <8e7aadf8-b7a0-4500-ad2d-507665007694@amd.com> <15d8374f-b1a5-4946-829d-8e9c6ef39272@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Wed, Jan 21, 2026 at 06:00:15PM +0100, Vincent Guittot wrote: > Why not use update_protect_slice() like when a new task with a shorter > slice is added ? That seems wrong too... I was going over this, and should we not limit set_protect_slice() to the first set_next_entity(). That is, AFAICT we'll re-set it on sched_change -- which sounds wrong to me. Anyway, I ended up with something like so (should probably be split in two patches). --- diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index eca642295c4b..bab51da3d179 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3790,6 +3790,7 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, unsigned long weight) { bool curr = cfs_rq->curr == se; + u64 vprot = 0; if (se->on_rq) { /* commit outstanding execution time */ @@ -3797,6 +3798,9 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, update_entity_lag(cfs_rq, se); se->deadline -= se->vruntime; se->rel_deadline = 1; + if (curr && protect_slice(se)) + vprot = se->vprot - se->vruntime; + cfs_rq->nr_queued--; if (!curr) __dequeue_entity(cfs_rq, se); @@ -3812,6 +3816,9 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, if (se->rel_deadline) se->deadline = div_s64(se->deadline * se->load.weight, weight); + if (vprot) + vprot = div_s64(vprot * se->load.weight, weight); + update_load_set(&se->load, weight); do { @@ -3823,6 +3830,8 @@ static void reweight_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, enqueue_load_avg(cfs_rq, se); if (se->on_rq) { place_entity(cfs_rq, se, 0); + if (vprot) + se->vprot = se->vruntime + vprot; update_load_add(&cfs_rq->load, se->load.weight); if (!curr) __enqueue_entity(cfs_rq, se); @@ -5420,7 +5429,7 @@ dequeue_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags) } static void -set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) +set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, bool first) { clear_buddies(cfs_rq, se); @@ -5435,7 +5444,8 @@ set_next_entity(struct cfs_rq *cfs_rq, struct sched_entity *se) __dequeue_entity(cfs_rq, se); update_load_avg(cfs_rq, se, UPDATE_TG); - set_protect_slice(cfs_rq, se); + if (first) + set_protect_slice(cfs_rq, se); } update_stats_curr_start(cfs_rq, se); @@ -8958,13 +8968,13 @@ pick_next_task_fair(struct rq *rq, struct task_struct *prev, struct rq_flags *rf pse = parent_entity(pse); } if (se_depth >= pse_depth) { - set_next_entity(cfs_rq_of(se), se); + set_next_entity(cfs_rq_of(se), se, true); se = parent_entity(se); } } put_prev_entity(cfs_rq, pse); - set_next_entity(cfs_rq, se); + set_next_entity(cfs_rq, se, true); __set_next_task_fair(rq, p, true); } @@ -13578,7 +13588,7 @@ static void set_next_task_fair(struct rq *rq, struct task_struct *p, bool first) for_each_sched_entity(se) { struct cfs_rq *cfs_rq = cfs_rq_of(se); - set_next_entity(cfs_rq, se); + set_next_entity(cfs_rq, se, first); /* ensure bandwidth has been allocated on our new cfs_rq */ account_cfs_rq_runtime(cfs_rq, 0); }