Re: [PATCH v2 3/3] sched/fair: add lsub_positive and use it consistently

From: Ingo Molnar
Date: Sun Nov 11 2018 - 23:17:05 EST



* Patrick Bellasi <patrick.bellasi@xxxxxxx> wrote:

> The following pattern:
>
> var -= min_t(typeof(var), var, val);
>
> is used multiple times in fair.c.
>
> The existing sub_positive() already capture that pattern but it adds
> also explicit load-sotre to properly support lockless observations.
> In other cases, the patter above is used to update local, and/or not
> concurrently accessed, variables.

> Let's add a simpler version of sub_positive, targeted to local variables
> updates, which gives the same readability benefits at calling sites
> without enforcing {READ,WRITE}_ONCE barriers.

> +/*
> + * Remove and clamp on negative, from a local variable.
> + *
> + * A variant of sub_positive which do not use explicit load-store
> + * and thus optimized for local variable updates.

I fixed up the two typos ('load-sotre', 'patter'), and fixed eight
grammar mistakes (!) in the changelog and in the code comments, but
*please* read the changelogs and code you are writing, this is scheduler
code after all ...

( Please also use the fn() notation in changelogs consistently in the
future: first you use 'sub_positive()' correctly then it becomes
'sub_positive'. )

Anyway, the fix looks sane so I've applied it to sched/urgent.

Thanks,

Ingo