amartinz / DeviceControl

GNU General Public License v3.0
182 stars 94 forks source link

Unnecessary offine/online CPU cores on each preference change #10

Closed Decatf closed 9 years ago

Decatf commented 9 years ago

It is not necessary to bring the CPU core offline then online each time a preference change is made. It's currently being done on governor change and min/max frequency change.

This behavior is problematic on the Galaxy Tab 10.1 a.k.a. p7510/p7500 a.k.a. p4wifi/p4. It's uses a kernel based on Linux 3.1.10 and hotplugging is completely broken for this device. Taking a cores offline and online will crash the kernel.

I think this behavior is overkill anyways. I pretty sure it's not a requirement of the cpufreq interface to hotplug the cores like this.

Here's a change that fixes the issue on my device. Decatf/android_packages_apps_DeviceControl@eafecfda7e2bb32df2824b69ec5c7c57cbd6417c

amartinz commented 9 years ago

This behavior is a requirement for almost every device i know.

If a core is not online, the toggles are not present and changing anything in fact does nothing on such devices. Bringing all cores online to switch the configuration is needed to make it stick on 95% of the devices (excluded are those with fixed kernel, means those which share cpu policies)

Decatf commented 9 years ago

It looks like it toggles the core regardless of whether it's online already. What about first checking if it is online or offline. So only bring online a core if it is offline.

This could maintain the previous behavior while also removing an unnecessary turning offline/online of already online cores. Would this work?

amartinz commented 9 years ago

If the core is already online, writing 1 to bring it online does not matter at all, as far as i know.

reading, checking and writing has a higher cost than just writing.

Decatf commented 9 years ago

It turns off the core and turns it back on in onlineCpu()

    sb.append(Utils.getWriteCommand(pathOnline, "0"));
    sb.append(Utils.getWriteCommand(pathOnline, "1"));