sched: fix OOPS when build_sched_domains percpu allocation fails

From: "he, bo" <bo.he@intel.com>

Under extreme memory used up situation, percpu allocation
might fails. We hit it when system go to suspend-to-ram.

EIP: [<c124411a>] build_sched_domains+0x23a/0xad0
SS:ESP 0068:de725d04
CR2: 0000000034811000
---[ end trace d6086359b670b975 ]---
Kernel panic - not syncing: Fatal exception
Pid: 3026, comm: kworker/u:3 Tainted: G      D W
3.0.8-137473-gf42fbef #1
Call Trace:
 [<c18cc4f2>] panic+0x66/0x16c
 [<c12521a1>] ? oops_exit+0x61/0x90
 [<c1205f89>] oops_end+0xb9/0xd0
 [<c1227796>] no_context+0xc6/0x1f0
 [<c1227958>] __bad_area_nosemaphore+0x98/0x140
 [<c1204ebf>] ? dump_trace+0x7f/0xf0
 [<c1227d30>] ? pgtable_bad+0x130/0x130
 [<c1227a17>] bad_area_nosemaphore+0x17/0x20
 [<c1227fa0>] do_page_fault+0x270/0x3c0
 [<c1306afa>] ? pcpu_alloc+0x12ca/0x1300
 [<c1227d30>] ? pgtable_bad+0x130/0x130
 [<c1227d30>] ? pgtable_bad+0x130/0x130
 [<c18d09d3>] error_code+0x5f/0x64
 [<c13000d8>] ? shmem_setattr+0x198/0x230
 [<c1227d30>] ? pgtable_bad+0x130/0x130
 [<c124411a>] ? build_sched_domains+0x23a/0xad0
 [<c18d01a6>] ? _raw_spin_unlock_irqrestore+0x26/0x50
 [<c1244c37>] partition_sched_domains+0x287/0x4b0
 [<c12a77be>] cpuset_update_active_cpus+0x1fe/0x210
 [<c1673017>] ? __cpufreq_remove_dev+0x167/0x360
 [<c18cf03c>] ? down_write+0x1c/0x40
 [<c123712d>] cpuset_cpu_inactive+0x1d/0x30
 [<c127dff2>] notifier_call_chain+0x52/0x90
 [<c127e04e>] __raw_notifier_call_chain+0x1e/0x30
 [<c18b37c9>] _cpu_down+0x89/0x230
 [<c12547f9>] disable_nonboot_cpus+0x79/0x100
 [<c1299fb3>] suspend_devices_and_enter+0x133/0x2e0
 [<c129a27d>] enter_state+0x11d/0x180
 [<c129a307>] pm_suspend+0x27/0x70
 [<c129b8b6>] suspend+0x96/0x1d0
 [<c1271aa3>] process_one_work+0x103/0x400
 [<c129b820>] ? power_suspend_late+0x90/0x90
 [<c12728ac>] worker_thread+0x12c/0x4b0
 [<c123748d>] ? sub_preempt_count+0x3d/0x50
 [<c18d01a6>] ? _raw_spin_unlock_irqrestore+0x26/0x50
 [<c1272780>] ? manage_workers+0x520/0x520
 [<c1276f44>] kthread+0x74/0x80
 [<c1276ed0>] ? __init_kthread_worker+0x30/0x30
 [<c18d113a>] kernel_thread_helper+0x6/0x10
Signed-off-by: he, bo <bo.he@intel.com>
Reviewed-by: Zhang, Yanmin <yanmin.zhang@intel.com>
backported for Linux 3.0 from Linux 3.4+ by faux123
procfs: add num_to_str() to speed up /proc/stat

== stat_check.py
num = 0
with open("/proc/stat") as f:
        while num < 1000 :
                data = f.read()
                f.seek(0, 0)
                num = num + 1
==

perf shows

    20.39%  stat_check.py  [kernel.kallsyms]    [k] format_decode
    13.41%  stat_check.py  [kernel.kallsyms]    [k] number
    12.61%  stat_check.py  [kernel.kallsyms]    [k] vsnprintf
    10.85%  stat_check.py  [kernel.kallsyms]    [k] memcpy
     4.85%  stat_check.py  [kernel.kallsyms]    [k] radix_tree_lookup
     4.43%  stat_check.py  [kernel.kallsyms]    [k] seq_printf

This patch removes most of calls to vsnprintf() by adding num_to_str()
and seq_print_decimal_ull(), which prints decimal numbers without rich
functions provided by printf().

On my 8cpu box.
== Before patch ==
[root@bluextal test]# time ./stat_check.py

real    0m0.150s
user    0m0.026s
sys     0m0.121s

== After patch ==
[root@bluextal test]# time ./stat_check.py

real    0m0.055s
user    0m0.022s
sys     0m0.030s

[akpm@linux-foundation.org: remove incorrect comment, use less statck in num_to_str(), move comment from .h to .c, simplify seq_put_decimal_ull()]
[andrea@betterlinux.com: avoid breaking the ABI in /proc/stat]
Signed-off-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrea Righi <andrea@betterlinux.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Glauber Costa <glommer@parallels.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Paul Turner <pjt@google.com>
Cc: Russell King <rmk@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
backported from Linux 3.4-rc4 to Linux 3.0.x by faux123
lib/lzo: Rename lzo1x_decompress.c to lzo1x_decompress_safe.c

Rename the source file to match the function name and thereby
also make room for a possible future even slightly faster
"non-safe" decompressor version.

Signed-off-by: Markus F.X.J. Oberhumer <markus@oberhumer.com>
lib/lzo: Update LZO compression to current upstream version

This commit updates the kernel LZO code to the current upsteam version
which features a significant speed improvement - benchmarking the Calgary
and Silesia test corpora typically shows a doubled performance in
both compression and decompression on modern i386/x86_64/powerpc machines.

Signed-off-by: Markus F.X.J. Oberhumer <markus@oberhumer.com>
sched: task_times() explosion avoidance for tasks with > 2^32 acrued ticks

If stime + utime > 2^32, and lower 32 are 0 when user calls getrusage(),
you've got a dead box.
Signed-off-by: Mike Galbraith <efault@gmx.de>
backported from Linux 3.5+ to Linux 3.0 by faux123
timer: optimize apply_slack()

__fls(mask) is equivalent to find_last_bit(&mask, BITS_PER_LONG), but cheaper.
find_last_bit was showing up high on the list when I was profiling for stalls
on icache misses on a system with very small cache size (MIPS).

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
ARM: net: JIT compiler for packet filters

based of Matt Evans's PPC64 implementation.

The compiler generates ARM instructions but interworking is
supported for Thumb2 kernels.

Supports both little and big endian. Unaligned loads are emitted
for ARMv6+. Not all the BPF opcodes that deal with ancillary data
are supported. The scratch memory of the filter lives on the stack.
Hardware integer division is used if it is available.

Enabled in the same way as for x86-64 and PPC64:

	echo 1 > /proc/sys/net/core/bpf_jit_enable

A value greater than 1 enables opcode output.

Signed-off-by: Mircea Gherzan <mgherzan@xxxxxxxxx>
ARM: net: JIT compiler for packet filters enabled by default
net: wireless: bcmdhd: Update wireless stack pm mode
net: wireless: bcmdhd: Add sync for wlfc data access

Change-Id: I2269eb3c26f0a14c1e01f067ac724fbfa6a4fb7b
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
Kernel 1.3.7B testing!
iopoll: Introduce memory-mapped IO polling macros

It is sometimes necessary to poll a memory-mapped register until its
value satisfies some condition. Introduce a family of convenience macros
that do this. Tight-loop and sleeping versions are provided with and
without timeouts.

Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Change-Id: Ia7db00cbe60ded8b0ed9bbff264aaea0841da92a
iopoll: Tweak min sleep time used with usleep_range()

Users of the iopoll macros may need to poll addresses that take
a long time to update. In such cases, the hardcoded value of 1 us
passed as the minimum delay to usleep_range() may result in
reads that occur more often than necessary.

Use (sleep_us/4) as the min delay instead of 1 us to resolve this
is a scalable way.

Change-Id: I8f679a7ecdb9ea2666c78aabca3c8ba806e0ead3
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
iopoll: Introduce the readl_iopoll_timeout_noirq macro

It is sometimes necessary to poll a register - until a
certain value is read - in atomic context. Introduce
a macro that allows one to specify the maximum number
of reads attempts and the number of microseconds to
delay between each read attempt.

Change-Id: Ice27e78cf4e156da9de00d58783c220bdbc758d3
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
(cherry picked from commit 7a35f5abde0192e72d4e7982411e376d8b898944)
mmc_ops: Add sys interface to provide emmc firmware date
Kernel 1.3.7C Testing
Merge remote branch 'halaszk/master-3.0.31' into master-3.0.31