Re: [PATCH v2 4/5] sched/pelt: Add a new runnable average signal

From: Peter Zijlstra
Date: Tue Feb 18 2020 - 10:12:40 EST


On Tue, Feb 18, 2020 at 02:54:40PM +0000, Valentin Schneider wrote:
> Humph, that's an exact copy of update_tg_cfs_util(). FWIW the following
> eldritch horror compiles...
>

> +#define DECLARE_UPDATE_TG_CFS_SIGNAL(signal) \
> +static inline void \
> +update_tg_cfs_##signal(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) \
> +{ \
> + long delta = gcfs_rq->avg.signal##_avg - se->avg.signal##_avg; \
> + \
> + /* Nothing to update */ \
> + if (!delta) \
> + return; \
> + \
> + /* \
> + * The relation between sum and avg is: \
> + * \
> + * LOAD_AVG_MAX - 1024 + sa->period_contrib \
> + * \
> + * however, the PELT windows are not aligned between grq and gse. \
> + */ \
> + /* Set new sched_entity's runnable */ \
> + se->avg.signal##_avg = gcfs_rq->avg.signal##_avg; \
> + se->avg.signal##_sum = se->avg.signal##_avg * LOAD_AVG_MAX; \
> + \
> + /* Update parent cfs_rq signal## */ \
> + add_positive(&cfs_rq->avg.signal##_avg, delta); \
> + cfs_rq->avg.signal##_sum = cfs_rq->avg.signal##_avg * LOAD_AVG_MAX; \
> +} \
>
> - /* Update parent cfs_rq runnable */
> - add_positive(&cfs_rq->avg.runnable_avg, delta);
> - cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * LOAD_AVG_MAX;
> -}
> +DECLARE_UPDATE_TG_CFS_SIGNAL(util);
> +DECLARE_UPDATE_TG_CFS_SIGNAL(runnable);

I'm not sure that's actually better though... :-)