sched/rt: Fix an incorrect initialization bug in CPU selection

When SCHED_CORE_ROTATE config is not enabled, the CPU search
should be done in the numerical order. For this to happen,
cpumask_next(cpu, cpumask) should be called with -1 for the
first time in the loop. The current code does not initialize
cpu to -1 when SCHED_CORE_ROTATE is not enabled. This can
potentially result in skipping the CPU search completely. Fix
this issue by defining find_first_cpu_bit to -1 when
SCHED_CORE_ROTATE is not enabled.

	cpu = find_first_cpu_bit(task, &search_cpu, sg_target,
				 &avoid_prev_cpu, &do_rotate,
				 &first_cpu_bit_env);

...

retry:
	while ((cpu = cpumask_next(cpu, &search_cpu)) < nr_cpu_ids) {
		cpumask_clear_cpu(cpu, &search_cpu);
		...
	}

Also, while at it fix a similar bug where we could potentially skip
the backup CPU search irrespective of SCHED_CORE_ROTATE config status.

Change-Id: I69599f6687269e9970a6d483d0605efc1d725a0c
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
2 files changed