block: Switch from BFQ-v7r3 for 3.0.0 to BFQ-v7r4 for 3.0.0

. BUGFIX. Modified the code so as to be robust against late detection of
  NCQ support for a rotational device.
. BUGFIX. Removed a bug that hindered the correct throughput distribution
  on flash-based devices when not every process had to receive the same
  fraction of the throughput. This fix entailed also a little efficiency
  improvement, because it implied the removal of a short function executed
  in a hot path.
. CODESTYLE IMPROVEMENT: removed quoted strings split across lines.

Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Reported-by: Steven Barrett <damentz@gmail.com>
Reported-by: Claire Farron <diesal3@googlemail.com>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
Revert "fs/dcache: vfs_cache_pressure 100 -> 133"

This reverts commit c0b18c4910c08ba102432eea8f8050e8582717b1.
mm: Add 1024 of extra free RAM
block: Switch from BFQ-v7r4 for 3.0.0 to BFQ-v7r5 for 3.0.0

. IMPROVEMENT: Improve throughput boosting by idling the device
  only for processes that, in addition to perform sequential I/O,
  are I/O-bound (apart from weight-raised queues, for which idling
  is always performed to guarantee them a low latency).
. IMPROVEMENT: Improve throughput boosting by depriving processes
  that cooperate often of weight-raising.
. CODE IMPROVEMENT: Pass of improvement of the readability of both
  comments and actual code.

Signed-off-by: Paolo Valente <paolo.valente@unimore.it>
Tested-by: Takashi Iwai <tiwai@suse.de>
Reported-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Arianna Avanzini <avanzini.arianna@gmail.com>
[CPUFREQ] CPUfreq ondemand: update sampling rate without waiting for next sampling

When a new sampling rate is shorter than the current one, (e.g., 1 sec
--> 10 ms) regardless how short the new one is, the current ondemand
mechanism wait for the previously set timer to be expired.

For example, if the user has just expressed that the sampling rate
should be 10 ms from now and the previous was 1000 ms, the new rate may
become effective 999 ms later, which could be not acceptable for the
user if the user has intended to speed up sampling because the system is
expected to react to CPU load fluctuation quickly from __now__.

In order to address this issue, we need to cancel the previously set
timer (schedule_delayed_work) and reset the timer if resetting timer is
expected to trigger the delayed_work ealier.

Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Dave Jones <davej@redhat.com>
cpufreq: fix utilization statistics for sync cpus

If the cpus are using related_cpus policy, then the
current implementaion will overwrite the the calculated
load for every iteration in the for loop. Hence, mpdecision
will read incorrect value, if the cores are using related
cpus policy. With this change mpdecision will read the
sum of the loads of all cpu's, if related cpu policy is
used.

Change-Id: I242c8fe39fd75dc3e48750a5b78a5d218b536ddd
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
cpufreq: notify avg load for short sampling_rate

If the sampling rate is less than 50ms reporting
the actual load may lead to poor decision making
at user space. So, for sampling rates less than 50ms
report the average of load across two samples.

Change-Id: I0d1cf00801732bee8e4380158d7e892758226594
Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>
lowmemorykiller: Compact memory when killing processes

Memory compaction is never invoked on Android because we avoid swap
and don't allocate huge pages. Fix it by invoking compaction from the
LMK when a process is killed to reduce memory fragmentation.
netfilter: xt_qtaguid: fix ipv6 protocol lookup

When updating the stats for a given uid it would incorrectly assume
IPV4 and pick up the wrong protocol when IPV6.

Change-Id: Iea4a635012b4123bf7aa93809011b7b2040bb3d5
Signed-off-by: JP Abgrall <jpa@google.com>
netfilter: xt_qtaguid: start tracking iface rx/tx at low level

qtaguid tracks the device stats by monitoring when it goes up and down,
then it gets the dev_stats().
But devs don't correctly report stats (either they don't count headers
symmetrically between rx/tx, or they count internal control messages).

Now qtaguid counts the rx/tx bytes/packets during raw:prerouting and
mangle:postrouting (nat is not available in ipv6).

The results are in
  /proc/net/xt_qtaguid/iface_stat_fmt
which outputs a format line (bash expansion):
  ifname  total_skb_{rx,tx}_{bytes,packets}

Added event counters for pre/post handling.
Added extra ctrl_*() pid/uid debugging.

Change-Id: Id84345d544ad1dd5f63e3842cab229e71d339297
Signed-off-by: JP Abgrall <jpa@google.com>
mmc: Make sure host is disabled on suspend

Change-Id: Ie0bf2004e173cef8dad66722a152658d7727ab65
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
ARM: disable preemption in machine_shutdown

Since the smp call to stop the other cpus are handled in those
cpus in interrupt context, there's a potential for those smp
handlers to interrupt threads holding spin locks (such as the
one a mutex holds).  This prevents those threads from ever
releasing their spin lock, so if the cpu doing the shutdown
is allowed to switch to another thread that tries to grab the
same lock/mutex, we could get into a deadlock (the spin lock
call is called with preemption disabled in the mutex lock code).

To avoid that possibility, disable preemption before doing the
smp_send_stop().

Change-Id: I7976c5382d7173fcb3cd14da8cc5083d442b2544
Signed-off-by: Mike J. Chen <mjchen@google.com>
timekeeping: fix 32-bit overflow in get_monotonic_boottime

get_monotonic_boottime adds three nanonsecond values stored
in longs, followed by an s64.  If the long values are all
close to 1e9 the first three additions can overflow and
become negative when added to the s64.  Cast the first
value to s64 so that all additions are 64 bit.

Change-Id: Ic996d8b6fbef0b72f2d027b0d8ef5259b5c1a540
Signed-off-by: Colin Cross <ccross@android.com>
PM / Sleep: Do not check wakeup too often in try_to_freeze_tasks()

Use the observation that it is more efficient to check the wakeup
variable once before the loop reporting tasks that were not
frozen in try_to_freeze_tasks() than to do that in every step of that
loop.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>

Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
(cherry picked from commit a15cc22b56b803b8f943c57d9535bdb9953ff3ec)

Change-Id: Ic41cd71a0ec49cd0c633c14aa3fce02025a4de3f
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
ipv4: Check if dev_out is NULL in ip_route_output_slow()

Change-Id: If04a8e99942dbe7e099e736dc87c2a49e1e778f9
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
ipv4: Skip calling fib_detect_death() if fib_dev is NULL

Change-Id: I1b8c6c7e79cb8a05b4b715ddb3299d74edef0e14
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
drivers: cpufreq: Send a uevent when governor changes

* Useful so userspace tools can reconfigure.
netfilter: xt_qtaguid: fix error exit that would keep a spinlock.

qtudev_open() could return with a uid_tag_data_tree_lock held
when an kzalloc(..., GFP_ATOMIC) would fail.
Very unlikely to get triggered AND survive the mayhem of running out of mem.

Signed-off-by: JP Abgrall <jpa@google.com>
netfilter: qtaguid: Don't BUG_ON if create_if_tag_stat fails

If create_if_tag_stat fails to allocate memory (GFP_ATOMIC) the
following will happen:

qtaguid: iface_stat: tag stat alloc failed
...
kernel BUG at xt_qtaguid.c:1482!

Signed-off-by: Pontus Fuchs <pontus.fuchs@gmail.com>
netfilter: xt_qtaguid: remove AID_* dependency for access control

qtaguid limits what can be done with /ctrl and /stats based on group
membership.
This changes removes AID_NET_BW_STATS and AID_NET_BW_ACCT, and picks
up the groups from the gid of the matching proc entry files.

Signed-off-by: JP Abgrall <jpa@google.com>
Change-Id: I42e477adde78a12ed5eb58fbc0b277cdaadb6f94