Hi Daniel,
Thanks for reveiwing.
On Wed, Jan 31, 2018 at 11:50:23AM +0100, Daniel Lezcano wrote:
On 19/01/2018 05:34, Leo Yan wrote:
This commit changes to use per cpu data to maintain energy environment structure, so can move it out from kernel stack and avoid the stack overflow issue if we want to add more items into energy environment structure for later optimization.
Change-Id: I7aed4c972c464ca683828d85b9b8f9311622da55 Signed-off-by: Leo Yan leo.yan@linaro.org
[ ... ]
@@ -7079,14 +7081,14 @@ static int select_energy_cpu_brute(struct task_struct *p, int prev_cpu, int sync
if (target_cpu != prev_cpu) { int delta = 0;
struct energy_env eenv = {
.util_delta = task_util(p),
.src_cpu = prev_cpu,
.dst_cpu = target_cpu,
.task = p,
.trg_cpu = target_cpu,
};
struct energy_env *eenv = this_cpu_ptr(&energy_env);
memset(eenv, 0x0, sizeof(*eenv));
eenv->util_delta = task_util(p);
eenv->task = p;
eenv->src_cpu = prev_cpu;
eenv->dst_cpu = target_cpu;
eenv->trg_cpu = target_cpu;
Allocating a structure on the stack is just a register address increment. Here, the result is the memset is much more expensive.
Regarding the stack overflow, I'm not sure it is worth to create a percpu variable. The issue must be caught and fixed in a proper way if it happens.
This patch is preparation for patch 3/3, patch 3/3 adds more elements to recording the CPU energy as cached value so cann't repeat calculations. After we add the per CPU data for caching energy and capacity, this is not scalable for system with many CPUs
If we only consider the system have 8 cpus for mobile platform, then the energy_env structure size will be increased 96 bytes (per cpu data for three items: int nrg, int cap, int used; so 4Bs x 3 x 8 = 96Bs); If system have 16 cpus, then the structure increases 192Bs, this is not big pressure for 4KB/8KB kernel stack size.
So we can drop this patch if we only consider mobile platform.
Thanks, Leo Yan