[Nexus 4 Original Android Development] Net.silb:
New Hotplugging Logic Suggestion

[MENTION=3292224]franciscofranco[/MENTION]

Here is the new hotplugging logic I suggest:

Of course that you don't have to use it and of course if you do use it you can change it to your liking or even just take pieces of it.

Now, If I had more knowledge regarding kernel coding I would happily write the code for this myself, but unfortunately I don't. Therefore I wrote the hotplugging logic in words.

General Logic of Hotplugging:

Instead of guessing when the user is interacting with the screen we can make two

separate reasons for hotplugging:

1. Load.

2. User interaction with the device.

No matter what, when we are interacting with the device, at least cores_on_touch_event cores will be on. When we are not interacting with the device:

- If the load is above high_load - all cores will be on.

- Otherwise, if the load is above medium_load - one more core will be enabled.

- Otherwise, if the load is below very_low_load - only one core will remain online.

- Otherwise, if the load is lower than low_load - one core will be disabled (unless there is only one core online).

- Otherwise, if the load is between medium_load and low_load - the amount of online cores will not change.

User Definable Parameters:

String touch_event - "None" - Do nothing when the user interacts with the screen. "Touch" - The user is touching the screen, includes swiping. "Swipe" - The user is swiping the screen, excludes touching.

int cores_on_touch_event - The minimum amount of cores that should be online during a touch event. Example value - 2

int t_since_hotplugging - The amount of time in seconds that has passed since onlining a core.

int t_delay - The amount of time in seconds to wait before offlining any cores after onlining a core. Example value - 2

int high_load - Whether the user is interacting with the screen or not, If the load is between this value and 100%, all four cores will be enabled. Example value - 90

int medium_load - If the user is interacting with the screen and the load is above this value - If the amount of cores + 1 is bigger or equals cores_on_touch_event, enable another core. If the user is not interacting with the screen, then If the load is between this value and high_load, enable another core. Example value - 50

int very_low_load - As long as the user is not interacting with the screen, if the load is between this value and 0%, disable all cores but one. Example value - 10

int low_load - As long as the user is not interacting with the screen, if the load is between this value and very_low_load, disable one core. Example value - 30

Hotplugging Algorithm:

1 - If, touch_event happens:

1.1 - If, online_cores < 4:

1.1.1 - If, load >= high_load:

1.1 - Enable all cores.

1.2 - Scale interactive tunables accordingly.

1.1.2 - Else:

2.1 If, load >= medium_load && online_cores + 1 > cores_on_touch_event:

2.1.1 - Enable one more core.

2.1.2 - Scale interactive tunables accordingly.

2.2 - Else:

2.2.1 - Enable another cores_on_touch_event - online_cores cores.

2.2.2 - Scale interactive tunables accordingly.

2 - Else:

2.1 - If, load >= high_load:

2.1.1 - If, online_cores < 4:

2.1.1.1 - Enable all cores.

2.1.1.2 - Scale interactive tunables accordingly.

2.2 - Else, If, load >= medium_load && online_cores < 4:

2.2.1 - If, online_cores < 4:

2.2.1.1 - Enable one more core.

2.2.1.2 - Scale interactive tunables accordingly.

2.3 - Else, If, online_cores > 1 && t_since_hotplugging > t_delay:

2.3.1 - If, load <= very_low_load:

2.3.1.1 - Disable all cores but one.

2.3.1.2 - Scale interactive tunables accordingly.

2.3.2 - Else, If, load <= low_load:

2.3.2.1 - Disable one core.

2.3.2.2 - Scale interactive tunables accordingly.

I hope you like it and I hope you use it.

Feel free to let me know what you think of this.