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

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

sched: walt: Sort the clusters based on the energy-model



Make use of the cluster level energy information for sorting
the clusters. Currently we assume power is inversely proportional
to the capacity which may not necessarily be true for all systems.

Change-Id: I2f3881121148076d90bd7c83d8deb9225e870cf6
Signed-off-by: default avatarPavankumar Kondeti <pkondeti@codeaurora.org>
parent ffab6924
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -28,6 +28,8 @@
#include <linux/pm_opp.h>
#include <linux/platform_device.h>

#include "sched.h"

struct sched_group_energy *sge_array[NR_CPUS][NR_SD_LEVELS];

static void free_resources(void)
@@ -269,6 +271,7 @@ static int sched_energy_probe(struct platform_device *pdev)

	kfree(max_frequencies);

	walt_sched_energy_populated_callback();
	dev_info(&pdev->dev, "Sched-energy-costs capacity updated\n");
	return 0;

+16 −3
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/irq_work.h>
#include <linux/tick.h>
#include <linux/slab.h>
#include <linux/sched_energy.h>

#include "cpupri.h"
#include "cpudeadline.h"
@@ -2708,11 +2709,21 @@ extern void sched_boost_parse_dt(void);
extern void clear_ed_task(struct task_struct *p, struct rq *rq);
extern bool early_detection_notify(struct rq *rq, u64 wallclock);

static inline unsigned int power_cost(int cpu, u64 demand)
static inline unsigned int power_cost(int cpu, bool max)
{
	struct sched_group_energy *sge = sge_array[cpu][SD_LEVEL1];

	if (!sge || !sge->nr_cap_states)
		return cpu_max_possible_capacity(cpu);

	if (max)
		return sge->cap_states[sge->nr_cap_states - 1].power;
	else
		return sge->cap_states[0].power;
}

extern void walt_sched_energy_populated_callback(void);

#else	/* CONFIG_SCHED_WALT */

struct walt_sched_stats;
@@ -2829,11 +2840,13 @@ static inline bool early_detection_notify(struct rq *rq, u64 wallclock)
	return 0;
}

static inline unsigned int power_cost(int cpu, u64 demand)
static inline unsigned int power_cost(int cpu, bool max)
{
	return SCHED_CAPACITY_SCALE;
}

static inline void walt_sched_energy_populated_callback(void) { }

#endif	/* CONFIG_SCHED_WALT */

static inline bool energy_aware(void)
+10 −3
Original line number Diff line number Diff line
@@ -2145,7 +2145,7 @@ compare_clusters(void *priv, struct list_head *a, struct list_head *b)
	return ret;
}

void sort_clusters(void)
static void sort_clusters(void)
{
	struct sched_cluster *cluster;
	struct list_head new_head;
@@ -2155,9 +2155,9 @@ void sort_clusters(void)

	for_each_sched_cluster(cluster) {
		cluster->max_power_cost = power_cost(cluster_first_cpu(cluster),
							       max_task_load());
							       true);
		cluster->min_power_cost = power_cost(cluster_first_cpu(cluster),
							       0);
							       false);

		if (cluster->max_power_cost > tmp_max)
			tmp_max = cluster->max_power_cost;
@@ -2176,6 +2176,13 @@ void sort_clusters(void)
	move_list(&cluster_head, &new_head, false);
}

void walt_sched_energy_populated_callback(void)
{
	mutex_lock(&cluster_lock);
	sort_clusters();
	mutex_unlock(&cluster_lock);
}

static void update_all_clusters_stats(void)
{
	struct sched_cluster *cluster;
+0 −2
Original line number Diff line number Diff line
@@ -281,8 +281,6 @@ static inline int same_cluster(int src_cpu, int dst_cpu)
	return cpu_rq(src_cpu)->cluster == cpu_rq(dst_cpu)->cluster;
}

void sort_clusters(void);

void walt_irq_work(struct irq_work *irq_work);

void walt_sched_init(struct rq *rq);