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

Commit 9c2c61ce authored by Pavankumar Kondeti's avatar Pavankumar Kondeti Committed by Gerrit - the friendly Code Review server
Browse files

core_ctl: Update cluster nr_run and cpu busy stats under state lock



The cpu busy stats must be updated atomically for all cpus in
a cluster. The nr_run and max_nr stats must be updated atomically
for a cluster. These stats are accessed under state lock else where,
so take the same lock while updating them.

Change-Id: I3ff8eda7982b570105e922209045933cff14b30b
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
Signed-off-by: default avatarSatya Durga Srinivasu Prabhala <satyap@codeaurora.org>
parent fe9673a6
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -474,16 +474,19 @@ static void update_running_avg(void)
	int max_nr, big_max_nr;
	struct cluster_data *cluster;
	unsigned int index = 0;
	unsigned long flags;

	sched_get_nr_running_avg(&avg, &iowait_avg, &big_avg,
				 &max_nr, &big_max_nr);

	spin_lock_irqsave(&state_lock, flags);
	for_each_cluster(cluster, index) {
		if (!cluster->inited)
			continue;
		cluster->nrrun = cluster->is_big_cluster ? big_avg : avg;
		cluster->max_nr = cluster->is_big_cluster ? big_max_nr : max_nr;
	}
	spin_unlock_irqrestore(&state_lock, flags);
}

#define MAX_NR_THRESHOLD	4
@@ -669,6 +672,7 @@ void core_ctl_check(u64 window_start)
	struct cpu_data *c;
	struct cluster_data *cluster;
	unsigned int index = 0;
	unsigned long flags;

	if (unlikely(!initialized))
		return;
@@ -678,6 +682,7 @@ void core_ctl_check(u64 window_start)

	core_ctl_check_timestamp = window_start;

	spin_lock_irqsave(&state_lock, flags);
	for_each_possible_cpu(cpu) {

		c = &per_cpu(cpu_state, cpu);
@@ -688,6 +693,7 @@ void core_ctl_check(u64 window_start)

		c->busy = sched_get_cpu_util(cpu);
	}
	spin_unlock_irqrestore(&state_lock, flags);

	update_running_avg();