lowmemorykiller: sysfs node and notifications

Create node "/sys/kernel/mm/lowmem_notify/notify_trigger_active",
on which an userspace application can poll for notification when
the number of free physical memory pages in the system falls below
a set threshold. The threshold is set by the new module parameter
"/sys/module/lowmemorykiller/parameters/notify_trigger".
The threshold should be typically set to be higher than the largest
free pages value in /sys/module/lowmemorykiller/parameters/minfree,
so that notification happens before any processes get killed.

Change-Id: Iccb2d1ff699e34b2c22687997e428eec27787b82
Signed-off-by: Bhargav Gurappadi <bhargavg1@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
android: lowmemorykiller: notify_trigger_active compatibility

Rename the "/sys/kernel/mm/lowmem_notify/notify_trigger_active" sysfs node
to "/sys/kernel/mm/lowmemorykiller/notify_trigger_active" to present the same
interface used by older kernels.

Change-Id: I49533fa005c965f5a4d6bd2f771e0f7ddfb1a8f3
Signed-off-by: Michael Vines <mvines@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
PM: devfreq: Fixup device transition and usage statistics

Ignore bogus data during slumber in transition and usage stats that
rendered the output basically useless. Also fix the reported GPU
frequency.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
PM: devfreq: Use high priority workqueue

It does not make sense to run kgsl on high and devfreq on regular
priority.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
PM: devfreq: Adapt devfreq_get_freq_level to cpubw requirements

Signed-off-by: Dan Trifan <jimsth@gmail.com>
PM / devfreq: Rewrite devfreq_update_status() to fix multiple bugs

The current devfreq_update_status() has the following bugs:
- When the new frequency doesn't have a valid level, the time spent in the
  new frequency is counted towards the next valid frequency switch instead
  of being ignored.
- The time spent on the previous frequency is added to the new frequency's
  stats instead of the previous frequency's stats.

This patch fixes all of this.

Change-Id: I7bbdafca78d1565cdbf815356556fe6d6cca9e3f
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
PM / devfreq: Check for GPU busy time before sending the sample

Sometimes GPU busy time is very low during sampling. Accumulate
the statistics and send them with the next sample.

Change-Id: I77e568b48afc3a4922c7c341d9478705b7ae3a30
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
lowmemorykiller: Account for highmem during kswapd reclaim

Currenlty most memory reclaim is done through kswapd.
Since kswapd uses a gfp mask of GFP_KERNEL, and because
the lowmemorykiller is zone aware, the lowmemorykiller will
ignore highmem most of the time.
This results in the lowmemorykiller being overly aggressive.

The fix to this issue is to allow the lowmemorykiller to
count highmem when being called by the kswapd if the lowmem
watermarks are satisfied.

Change-Id: I938644584f374763d10d429d835e74daa4854a38
Signed-off-by: Liam Mark <lmark@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
cpufreq: cpu-boost: Increase sync thread policy and priority

More or less all cpufreq related threads run in a high priority.

Also, CMs patch series was somehow out of sync and incomplete,
readd the unchanged policy update to source cpu bit. And readd
the check for a possible corner case in try_to_wake_up() that
was already missing before.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Revert "arm: arch_timer: set memory mapped timer interrupt as IRQF_TIMER"

This reverts commit af1b6c97f389b3bc8f568f9e4f8fad783ca6bfc1.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: return EBUSY when hw is overloaded

Component reports hw error to client immediately in
the same thread after stream on failure and blocks
subsequence errors to client. Therefore, the async
v4l2 event "V4L2_EVENT_MSM_VIDC_HW_OVERLOAD" will
be ignored in component.
When loading resource fails because of hw
overload, instead of sending V4l2 event, we are
going to return EBUSY and this return value will
be checked in userspace.

Signed-off-by: Jia Meng <jmeng@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: remove non fatal error messages

V4L2 core fails reqbufs ioctl if file IO is in
progress. This message is non fatal, so avoid
logging it as a error message in the video driver.

Signed-off-by: Arun Menon <avmenon@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: Suppress spammy log

Suppress a needlessly spammy log that shows up when secure content is
being played.  Also make some other logs print out something useful.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
msm: vidc: introduce more checks to prevent panic

* We may see kernel panic due to garbage value inside
  get_same_fd_buffer().
* This may cause kernel panic while video playback.
* Introduce more checks to avoid same.

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>