Discussion:
[PATCH v2] sched/cpuset: distribute tasks within affinity masks
(too old to reply)
Peter Zijlstra
2020-03-17 19:24:01 UTC
Permalink
Currently, when updating the affinity of tasks via either cpusets.cpus,
or, sched_setaffinity(); tasks not currently running within the newly
specified mask will be arbitrarily assigned to the first CPU within the
mask.
This (particularly in the case that we are restricting masks) can
result in many tasks being assigned to the first CPUs of their new
masks.
1) Can induce scheduling delays while the load-balancer has a chance to
spread them between their new CPUs.
2) Can antogonize a poor load-balancer behavior where it has a
difficult time recognizing that a cross-socket imbalance has been
forced by an affinity mask.
This change adds a new cpumask interface to allow iterated calls to
distribute within the intersection of the provided masks.
- modifying cpuset.cpus
- when tasks join a cpuset
- when modifying a task's affinity via sched_setaffinity(2)
Anyway, for the API.
Thanks guys!
Josh Don
2020-03-17 21:35:32 UTC
Permalink
This actually helps me fix a similar problem I faced in RT [1]. If multiple RT
tasks wakeup at the same time we get a 'thundering herd' issue where they all
end up going to the same CPU, just to be pushed out again.
Beside this will help fix another problem for RT tasks fitness, which is
a manifestation of the problem above. If two tasks wake up at the same time and
they happen to run on a little cpu (but request to run on a big one), one of
them will end up being migrated because find_lowest_rq() will return the first
cpu in the mask for both tasks.
I tested the API (not the change in sched/core.c) and it looks good to me.
Nice, glad that the API already has another use case. Thanks for taking a look.
nit: cpumask_first_and() is better here?
Yea, I would also prefer to use it, but the definition of
cpumask_first_and() follows this section, as it itself uses
cpumask_next_and().
It might be a good idea to split the API from the user too.
Not sure what you mean by this, could you clarify?
Anyway, for the API.
Thanks guys!
Thanks Peter, any other comments or are you happy with merging this patch as-is?
Loading...