ashmem: avoid deadlock between read and mmap calls

Avoid holding ashmem_mutex across code that can page fault.  Page faults
grab the mmap_sem for the process, which are also held by mmap calls
prior to calling ashmem_mmap, which locks ashmem_mutex.  The reversed
order of locking between the two can deadlock.

The calls that can page fault are read() and the ASHMEM_SET_NAME and
ASHMEM_GET_NAME ioctls.  Move the code that accesses userspace pages
outside the ashmem_mutex.

Bug: 9261835
Change-Id: If1322e981d29c889a56cdc9dfcbc6df2729a45e9
Signed-off-by: Todd Poynor <toddpoynor@google.com>
__________________

ashmem: fix deadlock when system is low on memory When system is
low on memory, allocating memory while holding the ashmem_mutex may try
to directly reclaim memory. Then ashmem_shrink() is called in same thread.
It will deadlock at acquiring ashmem_mutex. This change lets
ashmem_shrink() return failure if ashmem_mutex is not available. Memory
will be reclaimed from others.

Change-Id: I3b6024d5477d37245f4ebde6d7069fb77af789ee
Signed-off-by: Yuanyuan Zhong <yuanyuan.zhong@gmail.com>
ROW I/O scheduler: set as default and remove SIO scheduler
Testing of ROW completed without any problems, SIO is not needed anymore
mm: pass readahead info down to the i/o scheduler
Some i/o schedulers (i.e. row-iosched, cfq-iosched) deploy an idling
algorithm in order to be better synced with the readahead algorithm.
Idling is a prediction algorithm for incoming read requests.

In this patch we mark pages which are part of a readahead window, by
setting a newly introduced flag. With this flag, the i/o scheduler can
identify a request which is associated with a readahead page. This
enables the i/o scheduler's idling mechanism to be en-sync with the
readahead mechanism and, in turn, can increase read throughput.

Change-Id: I0654f23315b6d19d71bcc9cc029c6b281a44b196
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
block: row-iosched idling triggered by readahead pages
In the current implementation idling is triggered only by request
insertion frequency. This heuristic is not very accurate and may hit
random requests that shouldn't trigger idling. This patch uses the
PG_readahead flag in struct page's flags, which indicates that the page
is part of a readahead window, to start idling upon dispatch of a request
associated with a readahead page.

The above readehead flag is used together with the existing
insertion-frequency trigger. The frequency timer will catch read requests
which are not part of a readahead window, but are still part of a
sequential stream (and therefore dispatched in small time intervals).

Change-Id: Icb7145199c007408de3f267645ccb842e051fd00
Signed-off-by: Lee Susman <lsusman@codeaurora.org>
Linux 3.0.84
msm_thermal: re-enable after disable without rebooting
thanks to showp1984, I have adapted a slightly modified fix
msm_thermal: switch back to original CAF code with single temp phase
keep sysfs interface for single phase
msm_mpdecision: fixes and cleanup
- additional checks for max_cpus and min_cpus changes in sysfs
- no need to check above again in mp_decision, eliminate if statements
- if min_cpus == CONFIG_NR_CPUS no need to do mpdecision when
  screen is on, save some overhead
- adapt dual-core parameters for NwNs and TwTs thresholds
- space patrol: use tabs consistent with the rest of Linux kernel
msm_mpdecision: start in disabled state
mpdecision still handles turning the second core off when screen turns off
msm_mpdecision: make scroff_single_core sysfs parameter functional
  followings are backported from bricked-mako kernel with modifications
  Thanks to showp1984
- added scroff_single_core check to early_suspend and late_resume
- simplified early_suspend and late_resume functions
- added mpdec_cpu_down and mpdec_cpu_up functions to avoid using the same
  code at several places
- cancel workqueue when mpdecision is disabled and use mpdec_cpu_up
msm_mpdecision: simplify the workqueue, eliminate redundant calls
make mpdec_cpu_up and mpdec_cpu_down boolean functions instead of void
to return value of cpu_online(cpu) function. This way cpu_online is called
only once instead of three times and increase efficiency.
msm_mpdecision: fix a bug introduced in one of previous commits
The if statement structure was not correct in the following commit
https://github.com/mrg666/android_kernel_shooter/commit/671350a445c5da0422345d8c879b62ed255e1ac0
msm_mpdecision: more optimizations
- simplify get_slowest_cpu and get_slowest_cpu_rate
  also eliminate small possibility of returning cpu=0
  in get_slowest_cpu in case mpdecision is bypassed
- add mpdec_pause function to make workqueue more readable
  also eliminate code repetition, this function can also be used
  later for additional error checks in other places
Linux 3.0.85
_________________

Liang Li <liang.li@windriver.com>
    pch_uart: fix a deadlock when pch_uart as console

Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
    UBIFS: fix a horrid bug

Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
    UBIFS: prepare to fix a horrid bug

Stephane Eranian <eranian@google.com>
    perf: Disable monitoring on setuid processes for regular users

Zefan Li <lizefan@huawei.com>
    dlci: validate the net device in dlci_del()

Zefan Li <lizefan@huawei.com>
    dlci: acquire rtnl_lock before calling __dev_get_by_name()

Oleg Nesterov <oleg@redhat.com>
    hw_breakpoint: Use cpu_possible_mask in {reserve,release}_bp_slot()

Anderson Lizardo <anderson.lizardo@openbossa.org>
    Bluetooth: Fix crash in l2cap_build_cmd() with small MTU
msm_thermal: fix clock restore at low temp
this bug was introduced with previous commit