Re: [RFC v5 8/9] sched/deadline: base GRUB reclaiming on the inactive utilization

From: Luca Abeni
Date: Mon May 08 2017 - 03:41:19 EST


Hi Peter,

sorry for the delay; anyway, I am working on fixing the patchset
according to the comments I received....

When working on one of your comments, I have a doubt:

On Mon, 27 Mar 2017 16:26:33 +0200
Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
[...]
>
>
> #define BW_SHIFT 20
> #define BW_UNIT (1 << BW_SHIFT)
>
> static inline
> u64 grub_reclaim(u64 delta, struct rq *rq, struct sched_dl_entity
> *dl_se) {
> u64 u_inact = rq->dl.this_bw - rq->dl.running_bw; /* Utot -
> Uact */ u64 u_act;
[...]

I think introducing the BW_SHIFT and BW_UNIT defines can be more useful
in a previous patch (patch 4, where I introduce the "grub_reclaim()"
function, and use ">> 20" for the first time.

Moreover, the "20" magic number is already used in core.c... Should I
introduce the defines in sched/sched.h, and change the existing core.c
code too? Is it ok to embed this change in patch 4 (sched/deadline:
implement GRUB accounting), or should it go in a separate patch?


Thanks,
Luca

>
> /*
> * What we want to write is:
> *
> * max(BW_UNIT - u_inact, dl_se->dl_bw)
> *
> * but we cannot do that since Utot can be larger than 1,
> * which means u_inact can be larger than 1, which would
> * have the above result in negative values.
> */
> if (u_inact > (BW_UNIT - dl_se->dl_bw))
> u_act = dl_se->dl_bw;
> else
> u_act = BW_UNIT - u_inact;
>
> return (delta * u_act) >> BW_SHIFT;
> }
>
> Hmm?