Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c72d3a46 authored by Pavankumar Kondeti's avatar Pavankumar Kondeti
Browse files

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: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent 04570ccd
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -1824,11 +1824,9 @@ static int find_lowest_rq(struct task_struct *task)
			cpumask_andnot(&backup_search_cpu, &backup_search_cpu,
				       &search_cpu);

#ifdef CONFIG_SCHED_CORE_ROTATE
			cpu = find_first_cpu_bit(task, &search_cpu, sg_target,
						 &avoid_prev_cpu, &do_rotate,
						 &first_cpu_bit_env);
#endif
		} else {
			cpumask_copy(&search_cpu, lowest_mask);
			cpumask_clear(&backup_search_cpu);
@@ -1912,6 +1910,7 @@ static int find_lowest_rq(struct task_struct *task)
		} else if (!cpumask_empty(&backup_search_cpu)) {
			cpumask_copy(&search_cpu, &backup_search_cpu);
			cpumask_clear(&backup_search_cpu);
			cpu = -1;
			goto retry;
		}
	}
+2 −0
Original line number Diff line number Diff line
@@ -2853,4 +2853,6 @@ int
find_first_cpu_bit(struct task_struct *p, const cpumask_t *search_cpus,
		   struct sched_group *sg_target, bool *avoid_prev_cpu,
		   bool *do_rotate, struct find_first_cpu_bit_env *env);
#else
#define find_first_cpu_bit(...) -1
#endif