Backport AIO from Linux 3.6.x

Conflicts:
	fs/aio.c
aio: convert the ioctx list to radix tree

Date	Wed, 3 Apr 2013 16:20:48 +0300

When using a large number of threads performing AIO operations the
IOCTX list may get a significant number of entries which will cause
significant overhead. For example, when running this fio script:

rw=randrw; size=256k ;directory=/mnt/fio; ioengine=libaio; iodepth=1
blocksize=1024; numjobs=512; thread; loops=100

on an EXT2 filesystem mounted on top of a ramdisk we can observe up to
30% CPU time spent by lookup_ioctx:

 32.51%  [guest.kernel]  [g] lookup_ioctx
  9.19%  [guest.kernel]  [g] __lock_acquire.isra.28
  4.40%  [guest.kernel]  [g] lock_release
  4.19%  [guest.kernel]  [g] sched_clock_local
  3.86%  [guest.kernel]  [g] local_clock
  3.68%  [guest.kernel]  [g] native_sched_clock
  3.08%  [guest.kernel]  [g] sched_clock_cpu
  2.64%  [guest.kernel]  [g] lock_release_holdtime.part.11
  2.60%  [guest.kernel]  [g] memcpy
  2.33%  [guest.kernel]  [g] lock_acquired
  2.25%  [guest.kernel]  [g] lock_acquire
  1.84%  [guest.kernel]  [g] do_io_submit

This patchs converts the ioctx list to a radix tree. For a performance
comparison the above FIO script was run on a 2 sockets 8 core
machine. This are the results for the original list based
implementation and for the radix tree based implementation:

cores         1         2         4         8         16        32
list        111025 ms  62219 ms  34193 ms  22998 ms  19335 ms  15956 ms
radix        75400 ms  42668 ms  23923 ms  17206 ms  15820 ms  13295 ms
% of radix
relative      68%       69%       70%       75%       82%       83%
to list

To consider the impact of the patch on the typical case of having
only one ctx per process the following FIO script was run:

rw=randrw; size=100m ;directory=/mnt/fio; ioengine=libaio; iodepth=1
blocksize=1024; numjobs=1; thread; loops=100

on the same system and the results are the following:

list        65241 ms
radix       65402 ms
% of radix
relative    100.25%
to list

Cc: Andi Kleen <ak@linux.intel.com>

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
modified for Mako hybrid from LKML

Signed-off-by: Paul Reioux <reioux@gmail.com>
hardfloat vfp flags
 ARM: OMAP2+: PRCM: Clear reset sources after boot

According to TRMs the reset source flags have to be cleared by
software, in another case the flags stay after reboot. So clear
them to avoid the flag gathering.

Change-Id: Ia4a5dadd67a2459f6b644d629768d7d51a365efb
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com
 OMAP: process tput request made before PM init.

Because driver load order is uncertain, drivers could request bus
throughput constraints before the PM subsystem had initialized.  The
constraints would be recorded, but would have no effect on the actual
L3 clock.  This change suppresses attempts to set L3 scaling before PM
has initialized, and causes the PM subsystem to apply any pending bus
throughput constraints immediately after it has initialized itself.

Change-Id: If2a1f5315b8c1b084e4e4b3ce8e6844d92dd59b6
Signed-off-by: John Grossman <johngro@google.com>
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>

Conflicts:
	arch/arm/boot/zImage
 OMAP4: Enable wake-up feature for sys_nirq2

sys_nirq2 pin is used for twl6040 interrupt line which handles
events (like headset plug detection) that may need to wake-up the
device.

Change-Id: I5480a533116096be7678f516e31952a887b22e38
Signed-off-by: Krishnan Vaidyanathan <krishnanvv@ti.com>
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>

    icepeda-panda-4aj22

Conflicts:
	arch/arm/boot/zImage
fix copy n paste

Conflicts:
	arch/arm/boot/zImage
 omap4: hwmod_data: add clocks to ipu processor devices

The ipu processor hwmod devices (ipu_c0 & ipu_c1) are defined
primarily as pseudo-hwmod devices with only reset controls.
These share the same functional clock along with the ipu hwmod
device that is mainly used for controlling the MMU. This clock
name is added to these pseudo-hwmod devices, as it will improve
the robustness to any HW_AUTO settings performed within the
hwmod framework. There is no major effect on the clock framework
itself, as the clock enable & disable will simply be reference
counted and the functionality would be identical as before.

Change-Id: I865e9690b503e601df27aa0a55cfac45622c4259
Signed-off-by: Suman Anna <s-anna@ti.com>
OMAP: I2C: Wait till functional part of the I2C controller completely becomes valid

Bus busy status bit is not effective when functional part of the I2C controller
is not valid, and bus busy detection in omap_i2c_wait_for_bb() will be skipped
sometimes. So we should wait till functional part of the I2C controller
completely becomes valid, after setting the I2Ci.I2C_CON[15] I2C_EN bit to 1.
For doing that we have to wait till RDONE bit of SYSS register reach "1".

For details see TRM, 23.1.4.3 HS I2C Software Reset.

Change-Id: I989855d6cb2b1aa0098e11245dacb77583fe6647
Signed-off-by: Semen Protsenko <semen.protsenko@ti.com>

Conflicts:
	drivers/i2c/busses/i2c-omap.c
OMAP4: OMAPDSS: Request higher bandwidth for 1080p FB

Request higher L3 bandwidth when we have 1080p, or higher,
resolution framebuffer. This is done to avoid underflow on
DSS pipelines.

Change-Id: Ieca56ae8bc9ec6147ab9301c267c29279a9399ca
Signed-off-by: Dandawate Saket <dsaket@ti.com>
Signed-off-by: Peter Nordström <nordstrom@ti.com>
OMAPDSS: DSS: Relax L3 bus bandwidth constraint

In a current codebase L3 BW constraint is set if
any display has resution higher or equal FullHD.

Estimated available DSS bandwidth on L3@OPP50 is ~800MB/s.
It is approximately 3 WXGA layers or almost 1.5 FullHD layers at
60fps rate.

This patch relaxes L3 BW constraint and set it only
if current overlays' configuration needs higher BW.

Change-Id: I45afe36876e9898b45e20901d2b5c2633f32b914
Signed-off-by: Taras Kondratiuk <taras@ti.com>
OMAPDSS: DISPC: do not lose taps selection

Move taps selection logic before scaling check, so 3- of 5-tap always
get selected, no metter whether we do scaling or not.

Change-Id: I284b29933ca9fd69ae2088f279554dab9a66542c
Signed-off-by: Sergiy Kibrik <sergiy.kibrik@globallogic.com>
Bluetooth: Replace sprintf with snprintf

Change will replace sprintf with snprintf, since sprintf is a
banned function.

CRs-FIxed: 548220
Change-Id: I32f5ab1f3707e5bbe43c31a7ad4611b67557b267
Signed-off-by: Juffin Alex Varghese <jalex@codeaurora.org>
ARM: be strict about FP exceptions in kernel mode

The support code in vfp_support_entry does not care whether the
exception that caused it to be invoked occurred in kernel mode or
in user mode. However, neither condition that could trigger this
exception (lazy restore and VFP bounce to support code) is
currently allowable in kernel mode.

In either case, print a message describing the condition before
letting the undefined instruction handler run its course and trigger
an oops.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel at linaro.org>
Acked-by: Nicolas Pitre <nico at linaro.org>
Signed-off-by: Paul Reioux <reioux@gmail.com>
async: Fixed an include coding style issue

Added <linux/atomic.h>,<linux/ktime.h> and Removed <asm/atomic.h>.
Added KERN_DEBUG to printk() functions.

Acked-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Paul McQuade <tungstentide@gmail.com>
Link: http://lkml.kernel.org/r/4DE596B4.7030904@gmail.com
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
async: uninitialized warning corrections

The variables here are really not used uninitialized.

kernel/async.c: In function 'async_synchronize_cookie_domain':
kernel/async.c:270:10: warning: 'starttime.tv64' may be used uninitialized in this function
kernel/async.c: In function 'async_run_entry_fn':
kernel/async.c:122:10: warning: 'calltime.tv64' may be used uninitialized in this function

Signed-off-by: Vitaliy Ivanov <vitalivanov@gmail.com>
Signed-off-by: Konstantin Khlebnikov <khlebnikov@openvz.org>
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
ARM Patches

Conflicts:
	arch/arm/include/asm/errno.h
	arch/arm/include/asm/poll.h
	arch/arm/include/asm/sections.h
	arch/arm/kernel/machine_kexec.c

Conflicts:
	arch/arm/include/asm/Kbuild
 ARM: backtrace: avoid crash on large invalid fp value

Wraparound on invalid frame pointer (signed) -4 <= fp <= -1
defeats check for too high.
locking, rwsem: Annotate inner lock as raw

There is no reason to allow the lock protecting rwsems (the
ownerless variant) to be preemptible on -rt. Convert it to raw.

In mainline this change documents the low level nature of
the lock - otherwise there's no functional difference. Lockdep
and Sparse checking will work as usual.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Conflicts:
	lib/rwsem-spinlock.c
	lib/rwsem.c
rwsem-spinlock: Implement writer lock-stealing for better scalability

We (Linux Kernel Performance project) found a regression
introduced by commit:

  5a505085f043 mm/rmap: Convert the struct anon_vma::mutex to an rwsem

which converted all anon_vma::mutex locks rwsem write locks.

The semantics are the same, but the behavioral difference is
quite huge in some cases. After investigating it we found the
root cause: mutexes support lock stealing while rwsems don't.

Here is the link for the detailed regression report:

  https://lkml.org/lkml/2013/1/29/84

Ingo suggested adding write lock stealing to rwsems:

    "I think we should allow lock-steal between rwsem writers - that
     will not hurt fairness as most rwsem fairness concerns relate to
     reader vs. writer fairness"

And here is the rwsem-spinlock version.

With this patch, we got a double performance increase in one
test box with following aim7 workfile:

    FILESIZE: 1M
    POOLSIZE: 10M
    10 fork_test

 /usr/bin/time output w/o patch                       /usr/bin/time_output with patch
 -- Percent of CPU this job got: 369%                 Percent of CPU this job got: 537%
 Voluntary context switches: 640595016                Voluntary context switches: 157915561

We got a 45% increase in CPU usage and saved about 3/4 voluntary context switches.

Reported-by: LKP project <lkp@linux.intel.com>
Suggested-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
Cc: Alex Shi <alex.shi@intel.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Anton Blanchard <anton@samba.org>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: paul.gortmaker@windriver.com
Link: http://lkml.kernel.org/r/1359716356-23865-1-git-send-email-yuanhan.liu@linux.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>