lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAKfTPtAZkp+D6Fw_QRGPmxS63E6FEWPnw8nX_fAMv8+Rte6vRQ@mail.gmail.com>
Date: Fri, 23 Jan 2026 18:37:15 +0100
From: Vincent Guittot <vincent.guittot@...aro.org>
To: Peter Zijlstra <peterz@...radead.org>
Cc: "wangtao (EQ)" <wangtao554@...wei.com>, K Prateek Nayak <kprateek.nayak@....com>, mingo@...hat.com, 
	juri.lelli@...hat.com, dietmar.eggemann@....com, rostedt@...dmis.org, 
	bsegall@...gle.com, mgorman@...e.de, vschneid@...hat.com, 
	tanghui20@...wei.com, zhangqiao22@...wei.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] sched/eevdf: Update se->vprot in reweight_entity()

On Fri, 23 Jan 2026 at 16:39, Peter Zijlstra <peterz@...radead.org> wrote:
>
> 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.

Fair enough
I never noticed this

>
> Anyway, I ended up with something like so (should probably be split in
> two patches).

yes 2 patches should be better

>
> ---
> 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);
>         }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ