m8: defconfig update

Change-Id: I19f9732aaf6a22012ff086dbcf226af5264c556a

Conflicts:
	arch/arm/configs/liquid_m8_defconfig
Squashed msm_mpdecision and added optimizations

mach-msm: Add msm_mpdecision Kconfig & Makefile hooks
Also rename qcom's mpdecision to stay in place and be used if CONFIG_MSM_MPDEC is not set

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/Makefile

Conflicts:
	arch/arm/mach-msm/Makefile

Change-Id: Ia6f6a385eafaf40574a1b530e1752e3df83386ab

Conflicts:
	arch/arm/mach-msm/Makefile

mach-msm: Add msm_mpdecision
This currently only does the following thing:
Screen on -> CPU1 online
Screen off -> CPU1 offline

More to come.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mach-msm: mpdecision: small cleanup

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: add load based decision making

This now works like the mpdecision binary from QCOM.
CPU hotplugging/unplugging based on system load.

A sysfs interface will be built in with a later commit.

Signed-off-by: showp1984 <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/msm_rq_stats.c

mach-msm: mpdecision: restructure locks, add delay

The new delay allows the CPU to come up before any other action is taken.
This prevents fast plugging and also ensures the CPU hotplug process
is really done, before trying to unplug it again (or plug it).

The new locks are more efficient, and only used if necessary.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: pause if CPU is unplugged outside of mpdecision

This fixes cpu wars if something else tries to control the cpus.
default delay: 10000ms

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: change early_suspend_level to blank_screen

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: don't start immediately

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: show cpumask after up/down

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: always set the suspend var

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: remove up/down delay, our default delay is large enough

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: add email to (c)

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: fix foreign hotplug/unplug detection

Signed-off-by: showp1984 <showp1984@gmail.com>

Conflicts:

	arch/arm/mach-msm/msm_mpdecision.c

mach-msm: mpdecision: show how long the cpu was online

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: rename msm_mpdec_suspend to msm_mpdec_cpudata

Since this is being used for more than suspend stuff the old name
just isn't accurate anymore.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: add sysfs interface

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: remove debug output

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: increase startdelay for sense

Surprise! Sense needs a lot longer to boot up than aosp...

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: adjust thresholds for sense

Sense is just too hungry...

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: fix foreign cpu control detection

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: allow mpdecision to be disabled (sysfs)

This allows disabling/enabling of mpdecision over sysfs.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: increase start delay for Sense

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: increase up threshold for Sense

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: sysfs: check if cpu is offline before hotplugging it

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: don't turn off cpu1 if freq > idle

This fixes cpu1 being turned off though it is still working
with a high frequency. The idle_freq can be modified through sysfs.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: fixup: move idle block to mpdecision()

This belongs in mp_decision() because this influences the decision
mpdecision is about to make.

Signed-off-by: showp1984 <showp1984@gmail.com>

mach-msm: mpdecision: don't turn on cpu1 if cpu0 freq is below idle_freq
If the clock of cpu0 is below the set idle_freq don't enable cpu1 and
disregard the runqueue value.

Signed-off-by: showp1984 <showp1984@gmail.com>

msm_mpdecision: fix check for khz/mhz value (idle_freq sysfs)

Signed-off-by: showp1984 <showp1984@gmail.com>

msm_mpdecision: add debug output

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make mpdecision() core independent

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make msm_mpdec_work_thread() core independent

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix get_slowest_cpu()

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make debug output more compact & informative

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: decrease startup delay

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: decrease decision delay

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: update core data on first call

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: don't let msm_mpdec_work_thread() run if we are still booting

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: make earlysuspend/lateresume core independent

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: update header to include full feature list

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: export the new, larger nwns/twts arrays to sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix disabling mpdecision over sysfs for multicore

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: remove useless locking

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: use own workqueues

This will alter mpdecision to alloc it's own wq rather than using
the predefined queue which is a shared resource.

The WQ is not bound to the issuer CPU (=high-priority), has a
rescue worker task and is freezable.
Also destroy the workqueue on exit, and rename msm_mpdec to
msm_mpdec_init.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: cancel/resume main work thread on ES/LR

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: use unique lock names

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add max/min cpu limits to sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: use CONFIG_NR_CPUS for max_cpu sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: decrease delay between checks to 70ms

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add get_rate()

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix merge errors

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: various fixes and tweaks

- fix get_slowest_cpu_rate(): don't cut off rate to int
- fix get_slowest_cpu_rate(): don't use values from an offline cpu
- fix get_slowest_cpu(): don't return cpu0.
- tweak hotplug thresholds

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: disable debug

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: remove early_suspend, add fb callback

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: when returning from sleep, start immediately

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: we can't turn off cpu0

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: turn on cpu1 early

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: on resume pull up cpu1

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: tweak hotplug values

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdecision: don't use sleep, cancel/resume wq instead

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdecision: checking every 100ms is enough

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdecision: update copyright

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Revert "mpdecision: don't use sleep, cancel/resume wq instead"

This reverts commit 4b6f8555481d2c5049eb7cb496283749ed7cd7ca.

msm_mpdecision: add stats & expose to sysfs

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix sleep, don't use pause

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Revert "msm_mpdecision: remove early_suspend, add fb callback"

This reverts commit 56fa75bf888aaf21ce82b84cafa5b10e077e3d5b.

msm_mpdecision: fix spacing across the whole file
In the past year this evolved to a battlefield of tabs, spaces and different sizes of them. Fix that.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: stats: if cpu is online, add current ontime to stats

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add input event boost [read more]

This adds an input event boost to mpdecision.
It will basically boost the min freq of all cpus to predefined values if an
input event is detected.
Devices that qualify as boosters must fullfill one of these conditions:
- contain touch in their name
- contain keyboard in their name
This also boosts cpus independently from each other. Meaning:
If a cpu is hotplugged after the boost of another cpu was initiated the next
boost pulse will boost that cpu too.

Sysfs interface underway.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add sysfs interface for input event boost

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: input event boost: fix not resetting boost if cpu was unplugged before

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: tune hotplug values

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: boost: detect changed min frequency and update accordingly

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: boost: don't schedule more check than needed

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: increasing the check delay to 130ms
This change brings us down from 10 to 8 checks each second. The input boost reacts without
delay which is why we don't need to check for hotplugs so often anymore.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: change frequencies for input boost
This should provide us with a more battery friendly setup in light
usage situations while it still provides the obvious advantages
the input boost gives us (faster reaction).

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: min_cpus & max_cpus should on/offline affected cpus

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: several changes [read more]
reworked cpu_up/down handling which removed redundant code
reworked max/min_cpus settings
reworked suspend/resume handling to obide by these new changes
also reworked locking for per cpu settings

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix changing boost freq sets min = boost freq

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: boost: if we are not boosted, revib_wq does not need to run at all

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add fb callback, keep earlysuspend

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: update inputboost frequencies

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: switch to lcd callback and improve sus/res code

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: remove per_cpu suspend value
This is unneccessary and produces overhead when checking/setting over loops

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: offload definitions to header

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix definitions for earlysuspend/lcd callback switch

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix whitespaces throughout the file to comply with linux coding styles

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/msm_mpdecision.c

msm_mpdecision: early continue get_slowest_cpu() and _rate() to save some cycles

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: move startdelay to init to save cycles on each work call

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: also verify that boost frequencies are > minfreq

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix boost_time not respecting sysfs changes
This fixes issue #17

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add missing #ifdefs around thermal related code
This fixes issue #19 (compilation without thermal)

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add input boost triggers
This fixes issue #27 - No boost event triggered
&
issue #28 - Power button should trigger boost_freq

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: fix early_suspend compilation

This was not changed because we do not compile with early suspend
and hence didn't encounter any errors. Fix it.

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: add locking to early_suspend related code, even if we do not use it

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: opt out early if we are thermal throttled

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mdpec: fix missing ifdefs when compiling with earlysuspend

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

msm_mpdecision: Back off just a tad

* Currently this is too aggressive just by a tad.  Let's hold this back a bit and give a little bit more space for cpu governors to work their magic before engaging more cores.

Change-Id: I2ed8635bdbed6b1726c061ba8d4e61e92dd55169
Signed-off-by: Chet Kener <Cl3Kener@gmail.com>

mpdec: FIX BUG#27

Unplugging a boosted CPU will cause it to come back with
the boosted minimum frequency and stay on it.
(it gets stuck on boost)

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdec: if !scroff_single_core unboost all cpus while suspending

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

mpdec: fix missing log message on resume if !scroff_single_core

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>
cpuinit: fixes from showp1984

Change-Id: I854a7d06988dfba044b4f647a203562518924664
cpuinit: get rid of __cpuinit, manual fixups

a few final fixups that haven't been caught by regexps

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/x86/kernel/cpu/common.c
	arch/x86/kernel/cpu/cyrix.c
	drivers/cpufreq/longhaul.h
	kernel/rcutree_plugin.h

Change-Id: I8e4cbc23895af0eb223f6990a3755a7449a279f9
more cpuinit fixes

Change-Id: I7a4151ed31424f5ebdea26ed0f10b7ed927e22ce
kbuild: drop cpuinit/cpuexit checks in modpost

With the removal of cpuinit/cpuexit we no longer need to
do section mismatch checks on these sections.

Drop it from modpost.

Change-Id: I5ab4a5752a962c09d60f759de6c9888a8f85a6f9
Signed-off-by: Dennis Rassmann <showp1984@gmail.com>
Squashed franco's hotplug driver from mako

Add mako Hotplug driver.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

Conflicts:
	Makefile

Change-Id: I5e91c9cb7290398b7aef107c955a94db6efdebe4

cpufreq: Break out early if freq equals to target_freq

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

cpufreq: Initial CPU utilization should be 0

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

cpufreq: add missing util on the struct.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

mako_hotplug: don't need this now.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

cpufreq: ondemand: add util hook for my hotplug driver.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>

lib/int_sqrt.c: optimize square root algorithm

Optimize the current version of the shift-and-subtract (hardware)
algorithm, described by John von Newmann[1] and Guy L Steele.

Iterating 1,000,000 times, perf shows for the current version:

 Performance counter stats for './sqrt-curr' (10 runs):

         27.170996 task-clock                #    0.979 CPUs utilized            ( +-  3.19% )
                 3 context-switches          #    0.103 K/sec                    ( +-  4.76% )
                 0 cpu-migrations            #    0.004 K/sec                    ( +-100.00% )
               104 page-faults               #    0.004 M/sec                    ( +-  0.16% )
        64,921,199 cycles                    #    2.389 GHz                      ( +-  0.03% )
        28,967,789 stalled-cycles-frontend   #   44.62% frontend cycles idle     ( +-  0.18% )
   <not supported> stalled-cycles-backend
       104,502,623 instructions              #    1.61  insns per cycle
                                             #    0.28  stalled cycles per insn  ( +-  0.00% )
        34,088,368 branches                  # 1254.587 M/sec                    ( +-  0.00% )
             4,901 branch-misses             #    0.01% of all branches          ( +-  1.32% )

       0.027763015 seconds time elapsed                                          ( +-  3.22% )

And for the new version:

Performance counter stats for './sqrt-new' (10 runs):

          0.496869 task-clock                #    0.519 CPUs utilized            ( +-  2.38% )
                 0 context-switches          #    0.000 K/sec
                 0 cpu-migrations            #    0.403 K/sec                    ( +-100.00% )
               104 page-faults               #    0.209 M/sec                    ( +-  0.15% )
           590,760 cycles                    #    1.189 GHz                      ( +-  2.35% )
           395,053 stalled-cycles-frontend   #   66.87% frontend cycles idle     ( +-  3.67% )
   <not supported> stalled-cycles-backend
           398,963 instructions              #    0.68  insns per cycle
                                             #    0.99  stalled cycles per insn  ( +-  0.39% )
            70,228 branches                  #  141.341 M/sec                    ( +-  0.36% )
             3,364 branch-misses             #    4.79% of all branches          ( +-  5.45% )

       0.000957440 seconds time elapsed                                          ( +-  2.42% )

Furthermore, this saves space in instruction text:

   text    data     bss     dec     hex filename
    111       0       0     111      6f lib/int_sqrt-baseline.o
     89       0       0      89      59 lib/int_sqrt.o

[1] http://en.wikipedia.org/wiki/First_Draft_of_a_Report_on_the_EDVAC

Signed-off-by: Davidlohr Bueso <davidlohr.bueso@hp.com>
Reviewed-by: Jonathan Gonzalez <jgonzlez@linets.cl>
Tested-by: Jonathan Gonzalez <jgonzlez@linets.cl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>

CPU hotplug, writeback: Don't call writeback_set_ratelimit() too often during hotplug

The CPU hotplug callback related to writeback calls writeback_set_ratelimit()
during every state change in the hotplug sequence. This is unnecessary
since num_online_cpus() changes only once during the entire hotplug operation.

So invoke the function only once per hotplug, thereby avoiding the
unnecessary repetition of those costly calculations.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
writeback: fix writeback cache thrashing

From: Namjae Jeon <namjae.jeon@samsung.com>

Consider Process A: huge I/O on sda
        doing heavy write operation - dirty memory becomes more
        than dirty_background_ratio
        on HDD - flusher thread flush-8:0

Consider Process B: small I/O on sdb
        doing while [1]; read 1024K + rewrite 1024K + sleep 2sec
        on Flash device - flusher thread flush-8:16

As Process A is a heavy dirtier, dirty memory becomes more
than dirty_background_thresh. Due to this, below check becomes
true(checking global_page_state in over_bground_thresh)
for all bdi devices(even for very small dirtied bdi - sdb):

In this case, even small cached data on 'sdb' is forced to flush
and writeback cache thrashing happens.

When we added debug prints inside above 'if' condition and ran
above Process A(heavy dirtier on bdi with flush-8:0) and
Process B(1024K frequent read/rewrite on bdi with flush-8:16)
we got below prints:

[Test setup: ARM dual core CPU, 512 MB RAM]

[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  56064 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  56704 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 84720 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 94720 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   384 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   960 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =    64 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 92160 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   256 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   768 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =    64 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   256 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   320 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =     0 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 92032 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 91968 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   192 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =  1024 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =    64 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   192 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   576 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =     0 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 84352 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   192 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =   512 KB
[over_bground_thresh]: wakeup flush-8:16 : BDI_RECLAIMABLE =     0 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 92608 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE = 92544 KB

As mentioned in above log, when global dirty memory > global background_thresh
small cached data is also forced to flush by flush-8:16.
If removing global background_thresh checking code, we can reduce cache
thrashing of frequently used small data.
And It will be great if we can reserve a portion of writeback cache using
min_ratio.

After applying patch:
$ echo 5 > /sys/block/sdb/bdi/min_ratio
$ cat /sys/block/sdb/bdi/min_ratio
5
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  56064 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  56704 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  84160 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  96960 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  94080 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  93120 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  93120 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  91520 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  89600 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  93696 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  93696 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  72960 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  90624 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  90624 KB
[over_bground_thresh]: wakeup flush-8:0 : BDI_RECLAIMABLE =  90688 KB

As mentioned in the above logs, once cache is reserved for Process B,
and patch is applied there is less writeback cache thrashing on sdb
by frequent forced writeback by flush-8:16 in over_bground_thresh.

After all, small cached data will be flushed by periodic writeback
once every dirty_writeback_interval.

Suggested-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Vivek Trivedi <t.vivek@samsung.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
writeback: Fix occasional slow sync(1)

In case when system contains no dirty pages, wakeup_flusher_threads()
will submit WB_SYNC_NONE writeback for 0 pages so wb_writeback() exits
immediately without doing anything. Thus sync(1) will write all the
dirty inodes from a WB_SYNC_ALL writeback pass which is slow.

Fix the problem by using get_nr_dirty_pages() in
wakeup_flusher_threads() instead of calculating number of dirty pages
manually. That function also takes number of dirty inodes into account.

CC: stable@vger.kernel.org
Reported-by: Paul Taysom <taysom@chromium.org>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Cristoforo Cataldo <cristoforo.cataldo@gmail.com>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
audit: kiss goodbye you stupid piece of crap logging messages.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
block: Reserve only one queue tag for sync IO if only 3 tags are available

In case a device has three tags available we still reserve two of them
for sync IO. That leaves only a single tag for async IO such as
writeback from flusher thread which results in poor performance.

Allow async IO to consume two tags in case queue has three tag availabe
to get a decent async write performance.

This patch improves streaming write performance on a machine with such disk
from ~21 MB/s to ~52 MB/s. Also postmark throughput in presence of
streaming writer improves from 8 to 12 transactions per second so sync
IO doesn't seem to be harmed in presence of heavy async writer.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mm, vmalloc: use well-defined find_last_bit() func

Our intention in here is to find last_bit within the region to flush.
There is well-defined function, find_last_bit() for this purpose and its
performance may be slightly better than current implementation.  So change
it.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
mm, vmalloc: remove useless variable in vmap_block

vbq in vmap_block isn't used. So remove it.

Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Reviewed-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
deadline: Allow 0ms deadline latency, increase the read speed

Change a timer compare from after to after-equals, thus allowing
0 timeout and making deadline schedule FIFO.

Signed-off-by: xiaobing tu <xiaobing.tu@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Add a generic touchboost handler.

Change-Id: Ibe1fb4b88d52fadfbfb1d6da951e0ec5353a1847
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpufreq: add generic get_cpuidle_time to the cpufreq headers

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
module: bypass vermagic check for wlan module.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
cpu: fix merge derp.

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
sched: LOAD_FREQ (4*HZ+61) avoids loadavg Moire. From http://ripke.com/loadavg/moire

Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Revert "cpufreq: add generic get_cpuidle_time to the cpufreq headers"

This reverts commit 8c680c0f69f913c98b6d3e27b7fdda3e80aeab5f.