include: mm: increase readahead buffer
Disable GENTLE_FAIR_SLEEPERS
Makefile: enable some optimizations
FIX: irq_time - CAF - cherry picked from intersactRaven

sched: match mainline commit
    f26f9af (Sched: fix skip_clock_update optimization)

    This is needed for the following 2 commits, and is related to https://bugzilla.kernel.org/show_bug.cgi?id=23902 which was introduced in 2.6.35.12. I don't know if we were really impacted by this issue, but it's best to fix the logic. Hopefully it will be properly fixed in 2.6.35.14.

sched: Fix the irqtime code to deal with u64 wraps

    Some ARM systems have a short sched_clock() [ which needs to be fixed
    too ], but this exposed a bug in the irq_time code as well, it doesn't
    deal with wraps at all.

    Fix the irq_time code to deal with u64 wraps by re-writing the code to
    only use delta increments, which avoids the whole issue.

    Reviewed-by: Venkatesh Pallipadi <venki@google.com>
    Reported-by: Mikael Pettersson <mikpe@it.uu.se>
    Tested-by: Mikael Pettersson <mikpe@it.uu.se>
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    LKML-Reference: <1292242433.6803.199.camel@twins>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>

sched: Fix the irqtime code for 32bit

    Since the irqtime accounting is using non-atomic u64 and can be read
    from remote cpus (writes are strictly cpu local, reads are not) we
    have to deal with observing partial updates.

    When we do observe partial updates the clock movement (in particular,
    ->clock_task movement) will go funny (in either direction), a
    subsequent clock update (observing the full update) will make it go
    funny in the oposite direction.

    Since we rely on these clocks to be strictly monotonic we cannot
    suffer backwards motion. One possible solution would be to simply
    ignore all backwards deltas, but that will lead to accounting
    artefacts, most notable: clock_task + irq_time != clock, this
    inaccuracy would end up in user visible stats.

    Therefore serialize the reads using a seqcount.

    Reviewed-by: Venkatesh Pallipadi <venki@google.com>
    Reported-by: Mikael Pettersson <mikpe@it.uu.se>
    Tested-by: Mikael Pettersson <mikpe@it.uu.se>
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    LKML-Reference: <1292242434.6803.200.camel@twins>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
Fixed ext4 disk write performance regression
sched_fair: lower granularity
Add: Cleancache

Conflicts:

	scripts/basic/docproc
	scripts/basic/fixdep
	scripts/basic/hash
rcu: priority boosting for TINY_PREEMPT_RCU

Add priority boosting, but only for TINY_PREEMPT_RCU.  This is enabled
by the default-off RCU_BOOST kernel parameter.  The priority to which to
boost preempted RCU readers is controlled by the RCU_BOOST_PRIO kernel
parameter (defaulting to real-time priority 1) and the time to wait
before boosting the readers blocking a given grace period is controlled
by the RCU_BOOST_DELAY kernel parameter (defaulting to 500 milliseconds).

Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
msm: rpc: While powering down flush all the rpcrouter workqueues

When the device is powered down, RPC Router closes all the transports
and releases all the associated data structures. This sometimes lead to
works queued in the RPC router workqueues to access stale data and hence
cause kernel panic. So when the device is powered down, abort the works
queued in the workqueues and wait until the workqueues are flushed and
then free the associated data structures.

CRs-Fixed: 312078
Signed-off-by: Karthikeyan Ramasubramanian <kramasub@codeaurora.org>
(cherry picked from commit c74ab97)

Change-Id: Ia342637156df0cc3f934bc7778c2ef94dda735c3
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
modified by faux123
msm:pm-8x60: Free memory on failure to add Kobject

CRs-fixed: 304135
Signed-off-by: Praveen Chidambaram <pchidamb@codeaurora.org>
(cherry picked from commit 2cfda63a88655bf053a1aff0a200b6ae4fc374dd)

Change-Id: Id0dd1302472bb21b0cf8f416c3ab9a2d4c9cf5d9
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
cpu-hotplug: Add the function 'cpu_hotplug_inprogress'

Allows a caller to detect whether a cpu hotplug operation
is in progress. This is useful for optimizing code paths
based on this condition.

Signed-off-by: Maya Spivak <mspivak@codeaurora.org>
(cherry picked from commit 9f6cabec8fd0d0cb95084d18ee7cddbcf922ac2d)

Change-Id: I2eae7fbb819e3a776dba77a061eb89f30ac3176d
Signed-off-by: Swetha Basineni <sbasin@codeaurora.org>
CPU hotplug, PM: Remove unused symbol 'suspend_cpu_hotplug'

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
cpufreq: Fix ondemand governor powersave_bias execution time misuse

Ondemand governor use powersave_bias tunable to do aggressive power save by
decrease CPU average frequency. The average frequency achieve by adjust low and
high frequency's execution time proportion during one sample time interval.

Current kernel, only the high frequency executes in time proportion, but the low
frequency wrongly execute in one whole sample time interval when powersave_bias
is set.

The patch fix it by set low frequency execution time to it deserved.

Signed-off-by: Youquan Song <youquan.song@intel.com>
mmc: core: put eMMC in sleep (cmd5) mode before suspend

Put MMC to sleep if it supports SLEEP/AWAKE (CMD5) in the mmc suspend
to minimize power consumption.

Signed-off-by: Balaji T K <balajitk@ti.com>
Acked-by: Venkatraman S <svenkatr@ti.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit 3765839119eb540b87bdbf8d6869c60658cb99e7)

Change-Id: I0c0d5d06c4204b15471d1ca95aec0c7fcaaae816
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
kernel:smp: Match on_each_cpu behaviour on UP to SMP

The comment in the SMP implementation of on_each_cpu says:
 "May be used during early boot while
  early_boot_irqs_disabled is set.  Use local_irq_save/restore() instead
  of local_irq_disable/enable()."

but the existing UP macro version uses local_irq_disable/enable().

Do the safe thing - make the UP version match the SMP one.

Signed-off-by: Gilad Ben-Yossef <gilad@benyossef.com>
CC: Jiri Kosina <trivial@kernel.org>
CC: Randy Dunlap <rdunlap@xenotime.net>
msm: clock-8x60: Remove temporary 'always on' votes for ADM clocks

Other subsystems now vote for these clocks as required, so the
temporary vote holding the clock on can now be removed.  These
clocks should now gate as needed.

(cherry picked from commit 3d484bff16b5851cb4292bfbcd9fd15ad6f627c1)

CRs-Fixed: 274976
Change-Id: Ica0b7e0be74227de53678e57520acb2a16913855
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
block: limit default readahead size for small devices

Linus reports a _really_ small & slow (505kB, 15kB/s) USB device,
on which blkid runs unpleasantly slow. He manages to optimize the blkid
reads down to 1kB+16kB, but still kernel read-ahead turns it into 48kB.

     lseek 0,    read 1024   => readahead 4 pages (start of file)
     lseek 1536, read 16384  => readahead 8 pages (page contiguous)

The readahead heuristics involved here are reasonable ones in general.
So it's good to fix blkid with fadvise(RANDOM), as Linus already did.

For the kernel part, Linus suggests:
  So maybe we could be less aggressive about read-ahead when the size of
  the device is small? Turning a 16kB read into a 64kB one is a big deal,
  when it's about 15% of the whole device!

This looks reasonable: smaller device tend to be slower (USB sticks as
well as micro/mobile/old hard disks).

Given that the non-rotational attribute is not always reported, we can
take disk size as a max readahead size hint. This patch uses a formula
that generates the following concrete limits:

        disk size    readahead size
     (scale by 4)      (scale by 2)
               1M                8k
               4M               16k
              16M               32k
              64M               64k
             256M              128k
        --------------------------- (*)
               1G              256k
               4G              512k
              16G             1024k
              64G             2048k
             256G             4096k
(*) Since the default readahead size is 128k, this limit only takes
effect for devices whose size is less than 256M.

The formula is determined on the following data, collected by script:

	#!/bin/sh

	# please make sure BDEV is not mounted or opened by others
	BDEV=sdb

	for rasize in 4 16 32 64 128 256 512 1024 2048 4096 8192
	do
		echo $rasize > /sys/block/$BDEV/queue/read_ahead_kb
		time dd if=/dev/$BDEV of=/dev/null bs=4k count=102400
	done
The principle is, the formula shall not limit readahead size to such a
degree that will impact some device's sequential read performance.

The Intel SSD is special in that its throughput increases steadily with
larger readahead size. However it may take years for Linux to increase
its default readahead size to 2MB, so we don't take it seriously in the
formula.

SSD 80G Intel x25-M SSDSA2M080 (reported by Li Shaohua)

	rasize	1st run		2nd run
	----------------------------------
	  4k	123 MB/s	122 MB/s
	 16k  	153 MB/s	153 MB/s
	 32k	161 MB/s	162 MB/s
	 64k	167 MB/s	168 MB/s
	128k	197 MB/s	197 MB/s
	256k	217 MB/s	217 MB/s
	512k	238 MB/s	234 MB/s
	  1M	251 MB/s	248 MB/s
	  2M	259 MB/s	257 MB/s
==>	  4M	269 MB/s	264 MB/s
	  8M	266 MB/s	266 MB/s
Note that ==> points to the readahead size that yields plateau throughput.

SSD 22G MARVELL SD88SA02 MP1F (reported by Jens Axboe)

	rasize  1st             2nd
	--------------------------------
	  4k     41 MB/s         41 MB/s
	 16k     85 MB/s         81 MB/s
	 32k    102 MB/s        109 MB/s
	 64k    125 MB/s        144 MB/s
	128k    183 MB/s        185 MB/s
	256k    216 MB/s        216 MB/s
	512k    216 MB/s        236 MB/s
	1024k   251 MB/s        252 MB/s
	  2M    258 MB/s        258 MB/s
==>       4M    266 MB/s        266 MB/s
	  8M    266 MB/s        266 MB/s
SSD 30G SanDisk SATA 5000

	  4k	29.6 MB/s	29.6 MB/s	29.6 MB/s
	 16k	52.1 MB/s	52.1 MB/s	52.1 MB/s
	 32k	61.5 MB/s	61.5 MB/s	61.5 MB/s
	 64k	67.2 MB/s	67.2 MB/s	67.1 MB/s
	128k	71.4 MB/s	71.3 MB/s	71.4 MB/s
	256k	73.4 MB/s	73.4 MB/s	73.3 MB/s
==>	512k	74.6 MB/s	74.6 MB/s	74.6 MB/s
	  1M	74.7 MB/s	74.6 MB/s	74.7 MB/s
	  2M	76.1 MB/s	74.6 MB/s	74.6 MB/s

USB stick 32G Teclast CoolFlash idVendor=1307, idProduct=0165

	  4k	7.9 MB/s 	7.9 MB/s 	7.9 MB/s
	 16k	17.9 MB/s	17.9 MB/s	17.9 MB/s
	 32k	24.5 MB/s	24.5 MB/s	24.5 MB/s
	 64k	28.7 MB/s	28.7 MB/s	28.7 MB/s
	128k	28.8 MB/s	28.9 MB/s	28.9 MB/s
==>	256k	30.5 MB/s	30.5 MB/s	30.5 MB/s
	512k	30.9 MB/s	31.0 MB/s	30.9 MB/s
	  1M	31.0 MB/s	30.9 MB/s	30.9 MB/s
	  2M	30.9 MB/s	30.9 MB/s	30.9 MB/s

USB stick 4G SanDisk  Cruzer idVendor=0781, idProduct=5151

	  4k	6.4 MB/s 	6.4 MB/s 	6.4 MB/s
	 16k	13.4 MB/s	13.4 MB/s	13.2 MB/s
	 32k	17.8 MB/s	17.9 MB/s	17.8 MB/s
	 64k	21.3 MB/s	21.3 MB/s	21.2 MB/s
	128k	21.4 MB/s	21.4 MB/s	21.4 MB/s
==>	256k	23.3 MB/s	23.2 MB/s	23.2 MB/s
	512k	23.3 MB/s	23.8 MB/s	23.4 MB/s
	  1M	23.8 MB/s	23.4 MB/s	23.3 MB/s
	  2M	23.4 MB/s	23.2 MB/s	23.4 MB/s

USB stick 2G idVendor=0204, idProduct=6025 SerialNumber: 08082005000113

	  4k	6.7 MB/s 	6.9 MB/s 	6.7 MB/s
	 16k	11.7 MB/s	11.7 MB/s	11.7 MB/s
	 32k	12.4 MB/s	12.4 MB/s	12.4 MB/s
   	 64k	13.4 MB/s	13.4 MB/s	13.4 MB/s
	128k	13.4 MB/s	13.4 MB/s	13.4 MB/s
==>	256k	13.6 MB/s	13.6 MB/s	13.6 MB/s
	512k	13.7 MB/s	13.7 MB/s	13.7 MB/s
	  1M	13.7 MB/s	13.7 MB/s	13.7 MB/s
	  2M	13.7 MB/s	13.7 MB/s	13.7 MB/s

64 MB, USB full speed (collected by Clemens Ladisch)
Bus 003 Device 003: ID 08ec:0011 M-Systems Flash Disk Pioneers DiskOnKey

	4KB:    139.339 s, 376 kB/s
	16KB:   81.0427 s, 647 kB/s
	32KB:   71.8513 s, 730 kB/s
==>	64KB:   67.3872 s, 778 kB/s
	128KB:  67.5434 s, 776 kB/s
	256KB:  65.9019 s, 796 kB/s
	512KB:  66.2282 s, 792 kB/s
	1024KB: 67.4632 s, 777 kB/s
	2048KB: 69.9759 s, 749 kB/s

An unnamed SD card (Yakui):

         4k     195.873 s,  5.5 MB/s
         8k     123.425 s,  8.7 MB/s
         16k    86.6425 s, 12.4 MB/s
         32k    66.7519 s, 16.1 MB/s
==>      64k    58.5262 s, 18.3 MB/s
         128k   59.3847 s, 18.1 MB/s
         256k   59.3188 s, 18.1 MB/s
         512k   59.0218 s, 18.2 MB/s

CC: Li Shaohua <shaohua.li@intel.com>
CC: Clemens Ladisch <clemens@ladisch.de>
Acked-by: Jens Axboe <jens.axboe@oracle.com>
Acked-by: Rik van Riel <riel@redhat.com>
Tested-by: Vivek Goyal <vgoyal@redhat.com>
Tested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
PM / Suspend: Fix bug in suspend statistics update

A pair of missing braces inside the state_store() function causes even
invalid arguments to suspend to be wrongly treated as failed suspend
attempts. Fix this.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
From: Sumit Bhattacharya <sumitb@nvidia.com>

dma_alloc_coherent wants to split pages after allocation in order to
reduce the memory footprint. This does not work well with GFP_COMP
pages, so drop this flag before allocation.

This patch is ported from arch/avr32
(commit 3611553).

Signed-off-by: Sumit Bhattacharya <sumitb@nvidia.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
arm: Implement ticket spin-locks

Introduce optional ticket locks to help ensure fairness in
contended locks, as well as preventing livelock.

CRs-fixed: 302764
Signed-off-by: Brent DeGraaf <bdegraaf@codeaurora.org>
(cherry picked from commit bdd8a9c)

Change-Id: I8f4aece6ce1228f54407785ba05674b6e31f7c7c
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>