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.
-- http://www.linaro.org/ Linaro.org │ Open source software for ARM SoCs
Follow Linaro: http://www.facebook.com/pages/Linaro Facebook | http://twitter.com/#!/linaroorg Twitter | http://www.linaro.org/linaro-blog/ Blog