tspp: update to kk_3.5
staging: android: lowmemorykiller: select a new task to kill

Under certain circumstances, a process may take time to handle a SIGKILL.
When lowmemkiller is called again shortly after, it would pick the same
process to kill over and over, so that we cann't get free memory for long time.

Solution is to check fatal_signal_pending() on the selected task, and if it's
already pending, select a new task to kill.

Cherry-pick 5e3358093351e5d48e21250e31896b855542f22c
Reviewed-on: http://gerrit.pcs.mot.com/479831

Change-Id: I53445114451ffaba293f3c7174fb0b01ed0d34b6
Signed-off-by: Tianshui Shi <kfp634@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/505410
Tested-by: Jira Key <JIRAKEY@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
Reviewed-by: Jason Hrycay <jason.hrycay@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
(cherry picked from commit da093001caf06ed2296b4f79c84cc48ce713eac6)

Signed-off-by: Luis Cruz <ljc2491@gmail.com>
staging: android: persistent_ram: allow printing to old buf

This change adds interface which can be used to print to old
persistent ram. We'll be able to add some useful annotations
to last_kmsg.

Change-Id: I4b6aaaaf3285d31b2e1ac0244d7ba01399bb7fa6
Signed-off-by: Yuanyuan Zhong <a6510c@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/504784
Tested-by: Jira Key <JIRAKEY@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
Reviewed-by: Jason Hrycay <jason.hrycay@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-by: Igor Kovalenko <cik009@motorola.com>
(cherry picked from commit 616fadfe57503a765d3034fa33dab0445d3f1967)
staging: android: binder:add ioctl BINDER_GET_PEER_PID

Add new ioctl BINDER_GET_PEER_PID to let user-space app to
inquire peer's pid of current transaction.

This is ported from

 *(CR): Scorpion_mini:UT: System Server Watchdog
  Reviewed-on: http://gerrit.pcs.mot.com/466351

Change-Id: Idfffd7e3bb9a81e52068ba599c25e605b612675e
Signed-off-by: Yi-wei Zhao <gbjc64@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/506479
Tested-by: Jira Key <JIRAKEY@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
(cherry picked from commit 40b6938286a96c80f27ad9ccbe013b44599dd9ad)

Conflicts:
	drivers/staging/android/binder.h
staging: android: persistent_ram: free temporary buffer

When there is no valid old persistent_ram buffer, we need to free
the temporary buffers which are supposed to be merged into old
persistent_ram buffer.

Change-Id: I2fc06dbb78a98f0734fc866fa7ef92a140578bb7
Signed-off-by: Yuanyuan Zhong <a6510c@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/508951
Tested-by: Jira Key <JIRAKEY@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-by: Igor Kovalenko <cik009@motorola.com>
(cherry picked from commit f540c1b3bf666ee1a5f288e76e2774293b3ed5e9)
staging: android: fdleak_dbg: Debugging FD leak

File Descriptor leak checking will be disabled in "user" build,
but enabled in "userdebug" and "eng" builds. When enabled, if
a process tries to create a big file descriptor (i.e. >= 512),
or to inject a big file descriptor into a remote process via
Binder IPC, the culprit thread's backtrace will be dumped in
Android "main" log.

If the culprit process' executable file is /system/bin/app_process,
the process must be an Android process with one SignalCatcher thread.
Then kernel sends SIGUSR1 to the process and waits <= 100ms until
the process' SignalCatcher thread finishes dumping the Java and
native backtrace of the culprit thread.

If the culprit process' executable file is not /system/bin/app_process,
kernel considers the culprit thread as a non-Java pthread, and launches
"/system/bin/helsmon start log_backtrace -p <culprit_thread_tid> --big_fd_created <fd>"
, which requests "/system/bin/helsmond" to dump the culprit thread's
native backtrace

Use http://zch68maindev.ap.mot.com/stabdev/tools/tombstones.php
to parse the native backtrace

Change-Id: I1a6d04007b9e901c66b22e5c655753473b828c19
Signed-off-by: GAO LIANG-TAO <w20048@motorola.com>
Change-Id: I0d8ef47b679a7162c2c0c4da7438e888913dc7a1
Reviewed-on: http://gerrit.pcs.mot.com/512022
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Check Patch <CHEKPACH@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit fef661186e4f33758ecf2b71088903c48b01b626)
staging: android: binder: Debugging FD leak

Signed-off-by: GAO LIANG-TAO <w20048@motorola.com>
(cherry picked from commit cdae4b7951c96c28030daf3d801dcc322989c946)

Change-Id: Ic876b03f82cc8d400c9bd5901001ff0852afef84
staging: android: fdleak_dbg: Use MIN_BIG_FD as bottom line

Signed-off-by: GAO LIANG-TAO <w20048@motorola.com>
Change-Id: Ifb337feb4667e7194d029389f413e63357fb74b6
Reviewed-on: http://gerrit.pcs.mot.com/513326
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Check Patch <CHEKPACH@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit 866789473ec06db9524ef3befa5f232d8425fa7d)
android: binder: reduce memory for binder debugfs

Reduce the amount of memory the binder debugfs seq_file's need
to output the large amount of data they provide.  This breaks up
the individual reads into smaller objects to limit the kmalloc'd
memory to a PAGE.  This helps reduce OOM conditions when these
files are read in mildly fragmented systems.

PROPAGATED_from: (CR)
Change-Id: I368573914f73975321270ea1cafe3fb3ef7de28a
Signed-off-by: Jason Hrycay <jason.hrycay@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/391877
Tested-by: Jira Key <JIRAKEY@motorola.com>
Reviewed-by: Igor Kovalenko <Igor.Kovalenko@motorola.com>
Reviewed-by: Check Patch <CHEKPACH@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Christopher Fries <C.Fries@motorola.com>
(cherry picked from commit 9f6c9a4758d372039f1bef9b22dc7c90b3164558)

Conflicts:

	drivers/staging/android/binder.c

Signed-off-by: Jason Hrycay <jason.hrycay@motorola.com>
Change-Id: Ibdaa5a659ba2267a17716139da601a7711dd5fd7
Reviewed-on: http://gerrit.pcs.mot.com/520867
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Check Patch <CHEKPACH@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
Reviewed-by: Christopher Fries <qcf001@motorola.com>
Reviewed-by: Igor Kovalenko <cik009@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit 2a4028119f6b88b6d26a37383935edc77af388d3)
Signed-off-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
staging: android: fdleak_dbg: Improve FD leak debugging

(CR) enabled FD Leak debugging in Android platform.
However, often when a big FD is reopened the previous backtrace log
is useless; as a result the log has a lot of useless backtrace dumps
of reused big FDs.

This CR improves FD Leak debugging in that it doesn't spam the log
with too many useless backtraces at the time of big FD creation;
instead it shows the united big FD backtraces at the time of bug
(ANR/ForceClose/Tombstone/SystemServerWatchdogReset)
in occurrence-count descending order.

Signed-off-by: GAO LIANG-TAO <w20048@motorola.com>
Change-Id: I8c30b2cdfed2065484389b70d5b1fe5527b0cd14
Reviewed-on: http://gerrit.pcs.mot.com/524958
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Check Patch <CHEKPACH@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
SLT-Approved: Gerrit Code Review <gerrit-blurdev@motorola.com>
(cherry picked from commit 257f0fb1bf1514bb3914706f2e60ddfd63bcbe95)
trace: allow memkill tracing to be selectively enabled

Change-Id: I8a50d6b121192b0dc94e2a9a0e05246a47045e81
Signed-off-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/482673
Reviewed-on: http://gerrit.pcs.mot.com/513906
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Thirumarai Selvi S <a16462@motorola.com>
Reviewed-by: Check Patch <CHEKPACH@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit fd9bd32cd8f005b0d2f6438935fdd0bc9654c938)
staging: android: persistent_ram: add ram_add API

Add new API that simply adds a new persistent ram to the list. This is
almost same as persistent_ram_early_init except it doesn't reserve the
memory block. This new API is to be utilized by DT-based systems where
the reserved block is done in the kernel's mm system.

Change-Id: I769e03e7b1dae6e12f883ecd82f0e5542fe5f1aa
Signed-off-by: Jason Hrycay <jason.hrycay@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/538632
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-by: John Michelau <w14107@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
staging: android: persistent_ram: drop __init prefixes

Remove the __init prefixes that are used with the _oldbuf_ APIs that
were added to allow appending of information to last_kmsg.  These may
be called from probe functions as migration to the OF DT eliminates
many arch-init hacks.  If the request to append to last_kmsg comes
after the old buffers have been 'closed', a kernel warning is already
displayed, lets live with runtime restriction as opposed to compile
time.

Change-Id: I52c8330eb54741baa84c89fd859ed9beae305e5a
Signed-off-by: Jason Hrycay <jason.hrycay@motorola.com>
(cherry picked from commit 56d1c855297bcaf0c3997a1a0f5ae3d22697b0b9)
Reviewed-on: http://gerrit.pcs.mot.com/540752
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-by: Alexander Filonenko <vtp684@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
Reviewed-by: Christopher Fries <c.fries@motorola.com>
android: persistent_ram: move persistent_ram_add to devinit

persistent_ram_list is marked as __devinitdata, and it only appears to
make sense to call persistent_ram_add from devinit or earlier stages.

Change-Id: I9dd925d0e01c446eed3db7dfa3727da69d28dcf3
Signed-off-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/545010
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Jason Hrycay <jason.hrycay@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
staging: android: lmk: check free memory when tasks switch to background

Add more free-memory check point.
This patch trigger low memory killer to scan free memory when a process is moved
to background task groups.

Change-Id: If50eef2fb2c05f57ab808f95a9408204058f4f9b
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/557973
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
SLTApproved: Yi-Wei Zhao <gbjc64@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>

Conflicts:
	drivers/staging/android/Kconfig
staging: android: lmk: check free memory when tasks switch to background

Add more free-memory check point.
This patch trigger low memory killer to scan free memory when a process is moved
to background task groups.

Change-Id: If50eef2fb2c05f57ab808f95a9408204058f4f9b
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/557973
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
SLTApproved: Yi-Wei Zhao <gbjc64@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
trace: memkill: trace LMK and OOM kills

How to enable tracer:

  # mount -t debugfs nodev /sys/kernel/debug
  # echo 1 > /sys/kernel/debug/tracing/tracing_on
  # echo 1 > /sys/kernel/debug/tracing/events/memkill/enable
  # cat /sys/kernel/debug/tracing/trace

Event format:

  oom_kill: <pid> <comm> <total_vm> <anon_rss> <file_rss> <oom_score_adj> <order> <points> <cached> <freeswap>
  oom_kill_shared: <pid> <comm>
  lmk_kill: <pid> <comm> <selected_oom_adj> <selected_tasksize> <min_adj> <cached> <freeswap>

Change-Id: Ic45e181c62aead9b19d2a40363217f9220896096
Signed-off-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/480746
Reviewed-on: http://gerrit.pcs.mot.com/513174
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Jason Hrycay <jason.hrycay@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Thirumarai Selvi S <a16462@motorola.com>
Reviewed-by: Check Patch <CHEKPACH@motorola.com>
Reviewed-by: Christopher Fries <qcf001@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit ef733ddfbb73cd33daf36720fa474ce4c8acb1f7)

Conflicts:
	drivers/staging/android/lowmemorykiller.c
PM / Sleep: Add wake lock api wrapper on top of wakeup sources

Change-Id: Icaad02fe1e8856fdc2e4215f380594a5dde8e002
Signed-off-by: Arve Hjønnevåg <arve@android.com>

Conflicts:
	kernel/power/Kconfig
Power: add an API to log wakeup reasons

Add API log_wakeup_reason() and expose it to userspace via sysfs path
/sys/kernel/wakeup_reasons/last_resume_reason

Change-Id: I81addaf420f1338255c5d0638b0d244a99d777d1
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>

Conflicts:
	kernel/power/Makefile
POWER: fix compile warnings in log_wakeup_reason

Change I81addaf420f1338255c5d0638b0d244a99d777d1 introduced compile
warnings, fix these.

Change-Id: I05482a5335599ab96c0a088a7d175c8d4cf1cf69
Signed-off-by: Ruchi Kandoi <kandoiruchi@google.com>