mmc: core: Fix possbile memory leak

Fix possible memory leak detected by kmemleak:

unreferenced object 0xc0f80f00 (size 64):
  comm "swapper/0", pid 1, jiffies 4294937508 (age 82.980s)
  hex dump (first 32 bytes):
    6d 6d 63 30 5f 64 65 74 65 63 74 00 72 79 2e 68  mmc0_detect.ry.h
    00 07 00 00 68 77 63 61 70 2e 68 00 02 00 00 70  ....hwcap.h....p
  backtrace:
    [<c010a1fc>] __kmalloc+0x164/0x220
    [<c01e1630>] kvasprintf+0x38/0x58
    [<c01e1668>] kasprintf+0x18/0x24
    [<c02fcf60>] mmc_alloc_host+0x114/0x1b4
    [<c0311c84>] msmsdcc_probe+0xc14/0x1fd8
    [<c022b40c>] platform_drv_probe+0x14/0x18
    [<c022a144>] driver_probe_device+0x144/0x334
    [<c022a394>] __driver_attach+0x60/0x84
    [<c022884c>] bus_for_each_dev+0x4c/0x78
    [<c0229720>] bus_add_driver+0xd0/0x250
    [<c022a884>] driver_register+0x9c/0x128
    [<c00086bc>] do_one_initcall+0x90/0x160
    [<c06d1904>] kernel_init+0xe8/0x1a4
    [<c000ee4c>] kernel_thread_exit+0x0/0x8
    [<ffffffff>] 0xffffffff

Change-Id: I3b29d71463af849a072cabbe56637adf6db6d0da
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
random: entropy tweaks are all the rage nowadays

use nonblocking for all.  Read this web page:
http://lwn.net/Articles/489734/
Boottime: A tool for automatic measurement of kernel/bootloader boot time

The overhead is very low and the results will be found under
sysfs/bootime, as well as detailed results in debugfs under
boottime/. The bootgraph* files are compatible with
scripts/bootgraph.pl. The reason for this patch is to provide
data (sysfs/boottime) suitable for automatic testcases as
well as help for developers to reduce the boot time (debugfs).

Cc: Russell King <linux@arm.linux.org.uk>
Cc: Will Deacon <will.deacon@arm.com>
Signed-off-by: Jonas Aaberg <jonas.aberg@stericsson.com>
Signed-off-by: Mian Yousaf Kaukab <mian.yousaf.kaukab@stericsson.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Reviewed-by: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
Tested-by: Mian Yousaf KAUKAB <mian.yousaf.kaukab@stericsson.com>
backported from Linux 3.6+ to Tuna Hybrid kernel by faux123
android: logger: enforce GID and CAP check on log flush

Restrict log flushing to those in the logs group, or
anyone with CAP_SYSLOG.

Change-Id: I5d6977d1c0d60ffe8487771cc195789e5db95454
Signed-off-by: Charndeep Grewal <csgrewa@tycho.ncsc.mil>
irq: Set CPU affinity as soon as the irq thread is created

In an embedded target where IRQ affinities are pre-configured during
boot-time (and not modified through /proc/irq/../smp_affinity) during
run-time, the extra latency due to irq_thread_check_affinity can be
avoided during processing of the first interrupt with this patch.
Thoughts?

backported from Linux 3.5+ by faux123
Backport AIO from Linux 3.6.x
Backport KSM from Linux 3.6.8
slub: set slub_max_order to 0

To avoid locking and per-cpu overhead, SLUB optimisically uses
high-order allocations up to order-3 by default and falls back to lower
allocations if they fail.

So, with the default value (slub_max_order = 3), the kernel may ask up
to 3 contigous pages for each slab. However, with a reduced amount of
memory it is not worth to try to do order-3 allocations, it adds more
overhead (shrinkers have to free more objects to release any memory) and
probably it can easily fail to success with order-3 allocations.

For this reason it is better to immediately fallback to oder-0
allocations to reduce unnecessary overhead.

Signed-off-by: Andrea Righi <andrea@betterlinux.com>
sched_fair.c: Optimize latency values
The swap token is only useful in conditions of swap thrash, and actually worsens the common case by causing more swapping. Make it only have an effect when swap is more than half full.

-ck
While it may be nice to have a copy of pages on swap once written there, the more garbage we leave in the swapspace the slower any further writes and reads to and from it are. Just free swapcache whenever we can.

-ck
When kswapd is awoken due to reclaim by a running task, set the priority of kswapd to that of the calling task thus making memory reclaim cpu activity affected by nice level.

-ck
Add a background scanning timer to restore the watermarks to the pages_lots level and only call on it if kswapd has not been called upon for the last 5 seconds. This allows us to balance all zones to the more generous pages_lots watermark at a time unrelated to page allocation thus leading to lighter levels of vm load when called upon under page allocation.

Signed-off-by: Con Kolivas <kernel@kolivas.org>

The -ck patches modify mm/vmscan.c and add a timer to wake up kswapd every 5
seconds. This timer is initialized after the creation of the kswapd thread.

The kswapd() thread function calls mod_timer at the front of its infinite
service loop (to reset the timer to 5 seconds in the future). mod_timer()
includes a BUG_ON() to assert that the timer's callback function is set.

Since the wakeup timer is initialized after the kswapd thread is created, if
kswapd gets scheduled before kswapd_run() has prepared the timer, the
BUG_ON() check will throw a stack trace and immediately terminate the kswapd
thread.

This patch modifies the kswapd_run() function in mm/vmscan.c to initialize the
watermark timer before starting the kswapd thread.

Signed-off-by: Chase Venters <chase.venters at clientec.com>

-ck