Re: [PATCH 2/2] sched: load_balance: Reset env when going to redodue to all pinned

From: Peter Zijlstra
Date: Mon Sep 16 2013 - 04:16:47 EST


On Mon, Sep 16, 2013 at 12:08:59PM +0400, Vladimir Davydov wrote:
> >>Signed-off-by: Vladimir Davydov<vdavydov@xxxxxxxxxxxxx>
> >>---
> >> kernel/sched/fair.c | 12 ++++++++++--
> >> 1 file changed, 10 insertions(+), 2 deletions(-)
> >>
> >>diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
> >>index cd59640..d840e51 100644
> >>--- a/kernel/sched/fair.c
> >>+++ b/kernel/sched/fair.c
> >>@@ -5289,8 +5289,16 @@ more_balance:
> >> if (unlikely(env.flags & LBF_ALL_PINNED)) {
> >> cpumask_clear_cpu(cpu_of(busiest), cpus);
> >> if (!cpumask_empty(cpus)) {
> >>- env.loop = 0;
> >>- env.loop_break = sched_nr_migrate_break;
> >>+ env.dst_cpu = this_cpu;
> >>+ env.dst_rq = this_rq;
> >>+ env.flags = 0;
> >>+ env.loop = 0;
> >>+ env.loop_break = sched_nr_migrate_break;
> >>+
> >>+ /* Reset cpus cleared in LBF_SOME_PINNED case */
> >>+ if (env.dst_grpmask)
> >>+ cpumask_or(cpus, cpus, env.dst_grpmask);
> >>+
> >> goto redo;
> >> }
> >> goto out_balanced;
> >So the problem I have with this is that it removes the bound on the
> >number of iterations we do. Currently we're limited by the bits in cpus,
> >but by resetting those we can do on and on and on...
>
> find_busiest_group() never selects the local group, doesn't it? So none of
> env.dst_grpmask, which is initialized to sched_group_cpus(this_rq->sd), can
> be selected for the source cpu. That said, resetting env.dst_grpmask bits in
> the cpus bitmask actually doesn't affect the number of balance iterations.

Going by e02e60c10 the bits in cpus are what limit the DST_PINNED
(formerly SOME_PINNED) retry loop.

But yes, as you said, the entire scenario is entirely unlikely. I'll
drop this patch for now.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/