On Tue, 2015-06-02 at 21:30 +0800, Alex Shi wrote:
Cc to Tixy and Chris.
I've some comments below, and have added Patrick to the CC too as he works with Chris on HMP.
-------- Original Message -------- Subject: LSK feature request Date: Tue, 2 Jun 2015 10:26:29 +0000 From: Gaurav Jindal (Gaurav Jindal) Gaurav.Jindal@spreadtrum.com To: Alex.Shi@linaro.org Alex.Shi@linaro.org, khilman@linaro.org khilman@linaro.org, linaro-kernel@lists.linaro.org linaro-kernel@lists.linaro.org
Hi all
Please find the patch for Save extra cpu cycles in getting slow/fast domain(*Commit ID* : 2926ff354657c02ad4e1c453138f8670d031d7c4)
*Description:*
In present code, it is compulsory to check if the cpu is in slowest/fastest domain before calling the functions;
hmp_slower_domain() and hmp_faster_domain() to get the relative slower/faster domains.
If the caller calls without checking, it will give invlaid address which can result in undefined behavior.
Has this problem been observed in running code? I.e. does this change fix a real bug people are hitting or are we talking about a hypothetical situation?
Also in the functions
hmp_select_slower_cpu(), hmp_select_faster_cpu() and hmp_best_little_cpu(),
extra cpu cycles and instructions can be saved by changing the flow to get the relative slower/faster domain.
As with this change the function
hmp_slower_domain() and hmp_faster_domain() will itself take care of the condition if the current cpu is in slowest or fastest domain.
So extra checks before getting the relative faster/slower domains can be avoided thus reducing function calls and prevent cpu cycles thus improving the performance.
All the function in question are simple and 'static inline' so I would expect any change to be insignificant. To confirm this I compared disassemblies of kernel/sched/fair.o before and after applying this patch and it showed the proposed changes actually increases the number of instructions. Even if it had saved a small number of instructions and CPU cycles we generally wouldn't want to alter core and critical code like the scheduler for such minor gains for fear of introducing bugs.