Re: [PATCH] sched, fair: Allow a small degree of load imbalance between SD_NUMA domains v2

From: Mel Gorman
Date: Tue Jan 07 2020 - 06:42:19 EST


On Tue, Jan 07, 2020 at 12:22:55PM +0100, Peter Zijlstra wrote:
> > Much more importantly, doing what you suggest allows an imbalance
> > of more CPUs than are backed by a single LLC. On high-end AMD EPYC 2
> > machines, busiest->group_weight scaled by imbalance_pct spans multiple L3
> > caches. That is going to have side-effects. While I also do not account
> > for the LLC group_weight, it's unlikely the cut-off I used would be
> > smaller than an LLC cache on a large machine as the cache.
> >
> > These two points are why I didn't take the group weight into account.
> >
> > Now if you want, I can do what you suggest anyway as long as you are happy
> > that the child domain weight is also taken into account and to bound the
> > largest possible allowed imbalance to deal with the case of a node having
> > multiple small LLC caches. That means that some machines will be using the
> > size of the node and some machines will use the size of an LLC. It's less
> > predictable overall as some machines will be "special" relative to others
> > making it harder to reproduce certain problems locally but it would take
> > imbalance_pct into account in a way that you're happy with.
> >
> > Also bear in mind that whether LLC is accounted for or not, the final
> > result should be halved similar to the other imbalance calculations to
> > avoid over or under load balancing.
>
> > + /* Consider allowing a small imbalance between NUMA groups */
> > + if (env->sd->flags & SD_NUMA) {
> > + struct sched_domain *child = env->sd->child;
>
> This assumes sd-child exists, which should be true for NUMA domains I
> suppose.
>

I would be stunned if it was not. What sort of NUMA domain would not have
child domains? Does a memory-only NUMA node with no CPUs even generate
a scheduler domain? If it does, then I guess the check is necessary.

> > + unsigned int imbalance_adj;
> > +
> > + /*
> > + * Calculate an acceptable degree of imbalance based
> > + * on imbalance_adj. However, do not allow a greater
> > + * imbalance than the child domains weight to avoid
> > + * a case where the allowed imbalance spans multiple
> > + * LLCs.
> > + */
>
> That comment is a wee misleading, @child is not an LLC per se. This
> could be the NUMA distance 2 domain, in which case @child is the NUMA
> distance 1 group.
>
> That said, even then it probably makes sense to ensure you don't idle a
> whole smaller distance group.
>

I hadn't considered that case but even then, it's just a comment fix.
Thanks.

--
Mel Gorman
SUSE Labs