Scheduler - Add Simple IO Scheduler (SIO) - Oops forgot to add
sio-iosched: Changed parameters
Version 0.1 - first release

Changelog:

       - codebase latest smoove governor version from midnight kernel (https://github.com/mialwe/mngb/)
       - modified frequency tables to match I9300 standard frequency range 200-1400 mhz
       - added cpu hotplug functionality with strictly cpu switching
         (modifications partially taken from ktoonservative governor from
         ktoonsez KT747-JB kernel https://github.com/ktoonsez/KT747-JB)
Version 0.2 - improved

Changelog:

       - added tuneables to be able to adjust values on early suspend (screen off) via sysfs instead
         of using only hardcoded defaults
       - modified hotplug implementation to be able to tune threshold range per core indepentently
         and to be able to manually turn cores offline

         for this functions following new tuneables were indroduced:

         sampling_rate_sleep_multiplier -> sampling rate multiplier on early suspend (possible values 1 or 2, default: 2)
         up_threshold_sleep             -> up threshold on early suspend (possible range from above 'down_threshold_sleep' up to 100, default: 90)
         down_threshold_sleep           -> down threshold on early suspend (possible range from 11 to 'under up_threshold_sleep', default: 44)
         smooth_up_sleep                -> smooth up scaling on early suspend (possible range from 1 to 100, default: 100)
         up_threshold_hotplug1          -> hotplug threshold for cpu1 (0 disable core1, possible range from 'down_threshold' up to 100, default: 68)
         up_threshold_hotplug2          -> hotplug threshold for cpu2 (0 disable core2, possible range from 'down_threshold' up to 100, default: 68)
         up_threshold_hotplug3          -> hotplug threshold for cpu3 (0 disable core3, possible range from 'down_threshold' up to 100, default: 68)
         down_threshold_hotplug1        -> hotplug threshold for cpu1 (possible range from 11 to under 'up_threshold', default: 55)
         down_threshold_hotplug2        -> hotplug threshold for cpu2 (possible range from 11 to under 'up_threshold', default: 55)
         down_threshold_hotplug3        -> hotplug threshold for cpu3 (possible range from 11 to under 'up_threshold', default: 55)

Conflicts:
	README.md
Version 0.3 - more improvements

Changelog:

       - added tuneable 'hotplug_sleep' to be able to turn cores offline only on early suspend (screen off) via sysfs
         possible values: 0 do not touch hotplug-settings on early suspend, values 1, 2 or 3 are equivalent to
         cores which should be online at early suspend
       - modified scaling frequency table to match 'overclock' freqencies to max 1600 mhz
       - fixed black screen of dead problem in hotplug logic due to missing mutexing on 3-core and 2-core settings
       - code cleaning and documentation
Version 0.4 - limits

Changelog:

      - added 'soft'-freqency-limit. the term 'soft' means here that this is unfortuneately not a hard limit. a hard limit is only possible with
        cpufreq driver which is the freqency 'giver' the governor is only the 'consultant'. So now the governor will scale up to only the given up
        limit on higher system load but if the cpufreq driver 'wants' to go above that limit the freqency will go up there. u can see this for
        example with touchboost or wake up freqencies (1000 and 800 mhz) where the governor obviously will be 'bypassed' by the cpufreq driver.
        but nevertheless this soft-limit will now reduce the use of freqencies higer than given limit and therefore it will reduce power consumption.

        for this function following new tuneables were indroduced:

        freq_limit_sleep               -> limit freqency on early suspend (possible values 0 disable limit, 200-1600, default: 0)
        freq_limit                     -> limit freqency on awake (possible values 0 disable limit, 200-1600, default: 0)

      - added scaling frequencies to frequency tables for a faster up/down scaling. This should bring more performance but on the other hand it
        can be of course a little bit more power consumptive.

        for this function following new tuneables were indroduced:

        fast_scaling                   -> fast scaling on awake (possible values 0 disable or 1 enable, default: 0)
        fast_scaling_sleep (sysfs)     -> fast scaling on early suspend (possible values 0 disable or 1 enable, default: 0)

      - added tuneable 'freq_step_sleep' for setting the freq step at early suspend (possible values same as freq_step 0 to 100, default 5)
      - added DEF_FREQ_STEP and IGNORE_NICE macros
      - changed downscaling cpufreq relation to the 'lower way'
      - code/documentation cleaning
Version 0.5 - performance and fixes

Changelog:

    - completely reworked fast scaling functionality. now using a 'line jump' logic instead of fixed freq 'colums'.
      fast scaling now in 4 steps and 2 modes possible (mode 1: only fast scaling up and mode2: fast scaling up/down)
    - added support for 'Dynamic Screen Frequency Scaling' (original implementation into zzmoove governor highly improved by Yank555)
      originated by AndreiLux more info: http://forum.xda-developers.com/showpost.php?p=38499071&postcount=3
    - re-enabled broken conservative sampling down factor functionality ('down skip' method).
      originated by Stratosk - upstream kernel 3.10rc1:
      https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/?id=refs%2Ftags%2Fv3.10-rc1&qt=author&q=Stratos+Ka
    - changed down threshold check to act like it should.
      originated by Stratosk - upstream kernel 3.10rc1:
      https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/log/?id=refs%2Ftags%2Fv3.10-rc1&qt=author&q=Stratos+Ka
    - implemented/ported 'early demand' from ondemand governor.
      originated by Stratosk - more info: http://www.semaphore.gr/80-latests/98-ondemand-early-demand
    - implemented/ported 'sampling down momentum' from ondemand governor.
      originated by Stratosk - more info: http://www.semaphore.gr/80-latests/80-sampling-down-momentum
    - modified some original conservative code parts regarding frequency scaling which should work better now.
      originated by DerTeufel1980: https://github.com/DerTeufel/android_kernel_samsung_smdk4412/commit/6bab622344c548be853db19adf28c3917896f0a0
    - added the possibility to use sampling down momentum or conservative 'down skip' method.
    - increased possible max sampling rate sleep multiplier to 4 and sampling down factor to 100000
      accordingly to sampling down momentum implementation.
    - added frequency search limit for more efficient frequency searching in scaling 'table' and for improving
      frequency 'hard' and 'soft' limit handling.
    - added cpu idle exit time handling like it is in lulzactive
      again work from ktoonsez : https://github.com/ktoonsez/KT747-JB/commit/a5931bee6ea9e69f386a340229745da6f2443b78
      description in lulzactive governor:
      https://github.com/ktoonsez/KT747-JB/blob/a5931bee6ea9e69f386a340229745da6f2443b78/drivers/cpufreq/cpufreq_lulzactive.c
    - fixed a little scaling step mistake and added overclocking frequencies up to 1800 mhz in scaling frequency 'tables'.
    - fixed possible freezes during start/stop/reload of governor and frequency limit change.
    - fixed hotplugging logic at online core 0+3 or 0+2 situations and improved hotplugging in general by
      removing mutex locks and skipping hotplugging when it is not needed.
    - added possibility to disable hotplugging (that's a debugging relict but i thought maybe someone will find that usefull so i didn't remove it)
    - try to fix lags when coming from suspend if hotplug limitation at sleep was active by enabling all offline cores during resume.
    - code cleaning and documentation.

      for this functions following new tuneables were indroduced:

      Early Demand:
      -------------
      early_demand          -> switch to enable/disable early demand functionality (possible values 0 disable or 1 enable, default: 0)
      grad_up_threshold     -> scale up frequency if the load goes up in one step of grad up value (possible range from 11 to 100, default 50)
                               little example for understanding: when the load rises up in one big 50% step then the
                               frequency will be scaled up immediately instead of wating till up_threshold is reached.

      Fast Scaling (improved):
      ------------------------
      Fast scaling has now 8 levels which at the same time have 2 modes included. Values from 1-4 equals to scaling jumps in the frequency table
      and uses the Fast Scaling up but normal scaling down mode. Values from 5-8 equals to 1-4 scaling jumps but uses the fast scaling up and fast
      scaling down mode.

      Hotplugging switch:
      -------------------
      disable_hotplug       -> switch to enable/disable hotplugging (possible values are any value above 0 to disable hotplugging and 0 to
                               enable it, default 0)

      Sampling Down Factor and Sampling Down Momentum:
      ------------------------------------------------
      Description: From the original author of ondemand_sampling_factor David Niemi:
      'This improves performance by reducing the overhead of load evaluation and helping the CPU stay
      at its top speed when truly busy, rather than shifting back and forth in speed.'

      And that 'Sampling Down Momentum' function from stratosk does this dynamicly now! ;)

      sampling_down_max_momentum          -> max sampling down factor which should be set by momentum (0 disable momentum, possible range from
                                             sampling_down_factor up to MAX_SAMPLING_DOWN_FACTOR, default 0 disabled)
      sampling_down_momentum_sensitivity  -> how fast the sampling down factor should be switched (possible values from 1 to 500, default 50)
      sampling_down_factor                -> depending on which mode is active the factor for sampling rate multiplier which influences the whole
                                             sampling rate or the value for stock 'down skip' functionality which influences only the down scaling
                                             mechanism (possible values are from 1 to MAX_SMPLING_DOWN_FACTOR, default 1 disabled)

      Original conservative 'down skip' or 'stock' method can be enabled by setting the momentum tuneable to 0. so if momentum is inactive there will
      be a fallback to the stock method. as the name 'down skip' says this method works 'slightly' different from the ondemand stock sampling down method
      (on which momentum was based on). It just skips the scaling down code for the given samples. if u want to completely disable the sampling down
      functionality u can achieve this by setting sampling down factor to 1. so concluded: setting sampling_down_momentum = 0 and sampling_down_factor = 1
      will disable sampling down completely (that is also the governor default setting)

      Dynamic Screen Frequency Scaling:
      --------------------------------
      Dynamicly switches the screen frequency to 40hz or 60hz depending on cpu scaling and hotplug settings.
      For compiling and enabling this functionality u have to do some more modification to the kernel sources, please take a look at AndreiLux Perseus
      repository and there at following commit: https://github.com/AndreiLux/Perseus-S3/commit/3476799587d93189a091ba1db26a36603ee43519
      After adding this patch u can enable the feature by setting 'CPU_FREQ_LCD_FREQ_DFS=y' in your kernel config and if u want to check if it is
      really working at runtime u can also enable the accounting which AndreiLux added by setting LCD_FREQ_SWITCH_ACCOUNTING=y in the kernel config.
      If all goes well and u have the DFS up and running u can use following tuneables to do some screen magic:
      (thx to Yank555 for highly extend and improving this)

      lcdfreq_enable                     -> to enable/disable LCDFreq scaling (possible values 0 disable or 1 enable, default: 0)
      lcdfreq_kick_in_down_delay         -> the amount of samples to wait below the threshold frequency before entering low display frequency mode (40hz)
      lcdfreq_kick_in_up_delay           -> the amount of samples to wait over the threshold frequency before entering high display frequency mode (60hz)
      lcdfreq_kick_in_freq               -> the frequency threshold - below this cpu frequency the low display frequency will be active
      lcdfreq_kick_in_cores              -> the number of cores which should be online before switching will be active. (also useable in combination
                                            with kickin_freq)

      So this version is a kind of 'featured by' release as i took (again *g*) some ideas and work from other projects and even some of that work
      comes directly from other devs so i wanna thank and give credits:

      First of all to stratosk for his great work 'sampling down momentum' and 'early demand' and for all the code fixes which found their way into
      the upstream kernel version of conservative governor! congrats and props on that stratos, happy to see such a nice and talented dev directly
      contibuting to the upstream kernel, that is a real enrichment for all of us!

      Second to Yank555 for coming up with the idea and improving/completeing (leaves nothing to be desired now *g*) my first
      rudimentary implementation of Dynamic Screen Frequency Scaling from AndreiLux (credits for the idea/work also to him at this point).

      Third to DerTeufel1980 for his first implementation of stratosk's early demand functionality into version 0.3 of zzmoove governor
      (even though i had to modify the original implementation a 'little bit' to get it working properly ;)) and for some code optimizations/fixes
      regarding scaling.

      Last but not least again to ktoonsez - I 'cherry picked' again some code parts of his ktoonservative governor which should improve this governor
      too.
Version 0.5.1b - bugfixes and more optimisations (in cooperation with Yank555)

Changelog:

    - highly optimised scaling logic (thx and credits to Yank555)
    - simplified some tuneables by using already available stuff instead of using redundant code (thx Yank555)
    - reduced/optimised hotplug logic and preperation for automatic detection of available cores
      (maybe this fixes also the scaling/core stuck problems)
    - finally fixed the freezing issue on governor stop!
Version 0.6 - flexibility (in cooperation with Yank555)

Changelog:

       - removed fixed scaling lookup tables and use the system frequency table instead
         changed scaling logic accordingly for this modification (thx and credits to Yank555)
       - reduced new hotplug logic loop to a minimum
       - again try to fix stuck issues by using seperate hotplug functions out of dbs_check_cpu (credits to ktoonesz)
       - added support for 2 and 8 core systems and added automatic detection of cores were it is needed
         (for setting the different core modes you can use the macro 'MAX_CORES'. possible values are: 2,4 or 8, default are 4 cores)
         reduced core threshold defaults to only one up/down default and use an array to hold all threshold values
       - fixed some mistakes in 'frequency tuneables' (Yank555):
         stop looping once the frequency has been found
         return invalid error if new frequency is not found in the frequency table
Version 0.6a - scaling logic felxibility (in cooperation with Yank555)

Changelog:

  - added check if CPU freq. table is in ascending or descending order and scale accordingly
    (compatibility for systems with 'inverted' frequency table like it is on OMAP4 platform)
    thanks and credits to Yank555
Version 0.7 - slow down (in cooperation with Yank555)

Changelog:

        - reindroduced the 'old way' of hotplugging and scaling in form of the 'Legacy Mode' (macros for enabling/disabling this done by Yank555, thx)
          NOTE: this mode can only handle 4 cores and a scaling max frequency up to 1800mhz.
        - added hotplug idle threshold for a balanced load at CPU idle to reduce possible higher idle temperatures when running on just one core.
          (inspired by JustArchi's observations, thx)
        - added hotplug block cycles to reduce possible hotplugging overhead (credits to ktoonsez)
        - added possibility to disable hotplugging only at suspend (inspired by a request of STAticKY, thx for the idea)
        - introduced hotplug frequency thresholds (credits to Yank555)
        - hotplug tuneables handling optimized (credits to Yank555)
        - added version information tuneable (credits to Yank555)

          for this functions following new tuneables were indroduced:

          legacy_mode                   -> for switching to the 'old' method of scaling/hotplugging. possible values 0 to disable,
                                           any values above 0 to enable (default is 0)
                                           NOTE: the legacy mode has to be enabled by uncommenting the macro ENABLE_LEGACY_MODE below
          hotplug_idle_threshold        -> amount of load under which hotplugging should be disabled at idle times (respectively at scaling minimum).
                                           possible values 0 disable, from 1 to 100 (default is 0)
          hotplug_block_cycles          -> slow down hotplugging by waiting a given amount of cycles before plugging.
                                           possible values 0 disbale, any values above 0 (default is 0)
          disable_hotplug_sleep         -> same as disable_hotplug but will only take effect at suspend.
                                           possible values 0 disable, any values above 0 to enable (default is 0)
          up_threshold_hotplug_freq1    -> hotplug up frequency threshold for core1.
                                           possible values 0 disable and range from over down_threshold_hotplug_freq1 to max scaling freqency (default is 0)
          up_threshold_hotplug_freq2    -> hotplug up frequency threshold for core2.
                                           possible values 0 disable and range from over down_threshold_hotplug_freq2 to max scaling freqency (default is 0)
          up_threshold_hotplug_freq3    -> hotplug up frequency threshold for core3.
                                           possible values 0 disable and range from over down_threshold_hotplug_freq3 to max scaling freqency (default is 0)
          down_threshold_hotplug_freq1  -> hotplug down frequency threshold for core1.
                                           possible values 0 disable and range from min saling to under up_threshold_hotplug_freq1 freqency (default is 0)
          down_threshold_hotplug_freq2  -> hotplug down frequency threshold for core2.
                                           possible values 0 disable and range from min saling to under up_threshold_hotplug_freq2 freqency (default is 0)
          down_threshold_hotplug_freq3  -> hotplug down frequency threshold for core3.
                                           possible values 0 disable and range from min saling to under up_threshold_hotplug_freq3 freqency (default is 0)
          version                       -> show the version of zzmoove governor
Version 0.7a - little fix

Changelog:

        - fixed a glitch in hotplug freq threshold tuneables which prevented setting of values in hotplug down freq thresholds when hotplug
          up freq thresholds were set to 0
Version 0.7b - compatibility improved and forgotten things

Changelog:

        - fixed stuck at max scaling frequency when using stock kernel sources with unmodified cpufreq driver and without any oc capabilities.
        - readded forgotten frequency search optimisation in scaling logic (only effective when using governor soft frequency limit)
        - readded forgotten minor optimisation in dbs_check_cpu function
        - as forgotten to switch in last version Legacy Mode now again disabled by default
        - minor code format and comment fixes
Version 0.7c - again compatibility and optimisations

Changelog:

        - frequency search optimisation now fully compatible with ascending ordered system frequency tables (thx to psndna88 for testing)
        - again minor optimisations at multiple points in dbs_check_cpu function
        - code cleaning - removed some unnecessary things and whitespaces nuked (sry for the bigger diff but from now on it will be clean ;))
        - corrected changelog for previous version regarding limits
Version 0.7d - broken things

Changelog:

    - fixed hotplug up threshold tuneables to be able again to disable cores manually via sysfs by setting them to 0
    - fixed the problem caused by a wrong tuneable apply order of non sticking values in hotplug down threshold tuneables when
      hotplug up values are lower than down values during apply.
      NOTE: due to this change right after start of the governor the full validation of given values to these tuneables is disabled till
      all the tuneables were set for the first time. so if you set them for example with an init.d script or let them set automatically
      with any tuning app be aware that there are illogical value combinations possible then which might not work properly!
      simply be sure that all up values are higher than the down values and vice versa. after first set full validation checks are enabled
      again and setting of values manually will be checked again.
    - fixed a typo in hotplug threshold tuneable macros (would have been only a issue in 8-core mode)
    - fixed unwanted disabling of cores when setting hotplug threshold tuneables to lowest or highest possible value
      which would be a load of 100%/11% in up/down_hotplug_threshold and/or scaling frequency min/max in up/down_hotplug_threshold_freq
block: Adding ROW scheduling algorithm

This patch adds the implementation of a new scheduling algorithm - ROW.
The policy of this algorithm is to prioritize READ requests over WRITE
as much as possible without starving the WRITE requests.
The requests are kept in queues according to their priority. The dispatch
is done in a Round Robin manner with a different slice for each queue.
READ request queues get bigger dispatch quantum than the write requests.

Signed-off-by: Tatyana Brokhman <tlinder@xxxxxxxxxxxxxx>
---
v4:
  - Fix bug in idling mechanism:
    -- Fix the delay passed to scedule_delayed_work
    -- Change the idle delay and idling-trigger frequency to be HZ dependent
  - Destroy idle_workqueue on queue exit
  - Update the documentation

v3:
  - Fix bug in forced dispatch: Don't idle if forced dispatch

v2:
  No changes. Resend.

v1: Initial version
row-iosched: Backport to 3.0
Update ROW io scheduler (squashed commits)

The ROW scheduling algorithm will be used in mobile devices as default
block layer IO scheduling algorithm. ROW stands for "READ Over WRITE"
which is the main requests dispatch policy of this algorithm.

The ROW IO scheduler was developed with the mobile devices needs in
mind. In mobile devices we favor user experience upon everything else,
thus we want to give READ IO requests as much priority as possible.

In mobile devices we won’t have AS much parallel threads as on desktops.
Usually it’s a single thread or at most 2 simultaneous working threads
for read & write. Favoring READ requests over WRITEs decreases the READ
latency greatly. The main idea of the ROW scheduling policy is:
If there are READ requests in pipe - dispatch them but don't starve
the WRITE requests too much.
Update row
block: ROW: Correct minimum values of ROW tunable parameters
The ROW scheduling algorithm exposes several tunable parameters.
This patch updates the minimum allowed values for those parameters.

Change-Id: I5ec19d54b694e2e83ad5376bd99cc91f084967f5
Signed-off-by: Tatyana Brokhman <tlinder@codeaurora.org>