cpufreq: Break out early when frequency equals target_freq

Many drivers keep frequencies in frequency table in ascending
or descending order. When governor tries to change to policy->min
or policy->max respectively then the cpufreq_frequency_table_target
could return on first iteration. This will save some iteration cycles.

So, break out early when a frequency in cpufreq_frequency_table
equals to target one.

Testing this during kernel compilation using ondemand governor
with a frequency table in ascending order, the
cpufreq_frequency_table_target returned early on the first
iteration at about 30% of times called.

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
cpufreq: Optimize cpufreq_frequency_table_verify()

cpufreq_frequency_table_verify() is rewritten here to make it more logical
and efficient.
 - merge multiple lines for variable declarations together.
 - quit early if any frequency between min/max is found.
 - don't call cpufreq_verify_within_limits() in case any valid freq is
   found as it is of no use.
 - rename the count variable as found and change its type to boolean.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
cpufreq: Introduce new relation for freq selection

Introduce CPUFREQ_RELATION_C for frequency selection.
It selects the frequency with the minimum euclidean distance
to target. In case of equal distance between 2 frequencies,
it will select the greater freq.

Signed-off-by: Stratos Karafotis <stratosk@semaphore.gr>
Fix gcc-4.9.0 miscompilation of load_balance() in scheduler

commit 2062afb4f804afef61cbe62a30cac9a46e58e067 upstream.

Michel Dänzer and a couple of other people reported inexplicable random
oopses in the scheduler, and the cause turns out to be gcc mis-compiling
the load_balance() function when debugging is enabled.  The gcc bug
apparently goes back to gcc-4.5, but slight optimization changes means
that it now showed up as a problem in 4.9.0 and 4.9.1.

The instruction scheduling problem causes gcc to schedule a spill
operation to before the stack frame has been created, which in turn can
corrupt the spilled value if an interrupt comes in.  There may be other
effects of this bug too, but that's the code generation problem seen in
Michel's case.

This is fixed in current gcc HEAD, but the workaround as suggested by
Markus Trippelsdorf is pretty simple: use -fno-var-tracking-assignments
when compiling the kernel, which disables the gcc code that causes the
problem.  This can result in slightly worse debug information for
variable accesses, but that is infinitely preferable to actual code
generation problems.

Doing this unconditionally (not just for CONFIG_DEBUG_INFO) also allows
non-debug builds to verify that the debug build would be identical: we
can do

    export GCC_COMPARE_DEBUG=1

to make gcc internally verify that the result of the build is
independent of the "-g" flag (it will make the compiler build everything
twice, toggling the debug flag, and compare the results).

Without the "-fno-var-tracking-assignments" option, the build would fail
(even with 4.8.3 that didn't show the actual stack frame bug) with a gcc
compare failure.

See also gcc bugzilla:

  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61801

Reported-by: Michel Dänzer <michel@daenzer.net>
Suggested-by: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: Jakub Jelinek <jakub@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sched: Add sysinterface for GENTLE_FAIR_SLEEPERS

Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
ARM: compressed/head.S: work around new binutils warning

In August 2012, Matthew Gretton-Dann checked a change
into binutils labelled "Error on obsolete & warn on
deprecated registers", apparently as part of ARMv8
support. Apparently, this was supposed to emit
the message "Warning: This coprocessor register access
is deprecated in ARMv8" when using certain mcr/mrc
instructions and building for ARMv8. Unfortunately,
the message that is actually emitted appears to be
'(null)', which is less helpful in comparison.

Even more unfortunately, this is biting us on
every single kernel build with a new gas, because
arch/arm/boot/compressed/head.S and some other files
in that directory are built with -march=all since
kernel commit 80cec14a8 "[ARM] Add -march=all to
assembly file build in arch/arm/boot/compressed"
back in v2.6.28.

This patch reverts Russell's nice solution and
replaces it with a more complex one that sprinkles
.arch statements inside of the head.S file in
functions that are executed in different architecture
levels, which seems to solve the original problem
just as well, and gets rid of the new one, too.

Without this patch, building anything results in:

arch/arm/boot/compressed/head.S: Assembler messages:
arch/arm/boot/compressed/head.S:565: Warning: (null)
arch/arm/boot/compressed/head.S:676: Warning: (null)
arch/arm/boot/compressed/head.S:698: Warning: (null)
arch/arm/boot/compressed/head.S:722: Warning: (null)
arch/arm/boot/compressed/head.S:726: Warning: (null)
arch/arm/boot/compressed/head.S:957: Warning: (null)
arch/arm/boot/compressed/head.S:996: Warning: (null)
arch/arm/boot/compressed/head.S:997: Warning: (null)
arch/arm/boot/compressed/head.S:1027: Warning: (null)
arch/arm/boot/compressed/head.S:1035: Warning: (null)
arch/arm/boot/compressed/head.S:1046: Warning: (null)
arch/arm/boot/compressed/head.S:1060: Warning: (null)
arch/arm/boot/compressed/head.S:1092: Warning: (null)
arch/arm/boot/compressed/head.S:1094: Warning: (null)
arch/arm/boot/compressed/head.S:1095: Warning: (null)
arch/arm/boot/compressed/head.S:1102: Warning: (null)
arch/arm/boot/compressed/head.S:1134: Warning: (null)

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Matthew Gretton-Dann <matthew.gretton-dann@arm.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Paul Beeler <sparksco@gmail.com>
toolchain: linaro: Fix a bunch of warnings and errors

Change-Id: I74dc4a9a1c46a9d84d2a592d24a905b21aa87a15
toolchain: linaro: Fix a bunch of warnings and errors II

toolchain: linaro: fix uninitialized kbuf in sysctl.c for linaro optimizations

Change-Id: Idd983e621b67d4016ff113b18de8f8a59bc70c85

toolchain: linaro: fix warning subbuf.pages may be used uninitialized

Change-Id: I0aaa7ccb4a29ec58d7d05e24c19f22c8cc50c8cb

toolchain: linaro: fix ICE in fs/fs-writeback.c with gcc4.7

fs/fs-writeback.c: In function 'bdi_writeback_thread':
fs/fs-writeback.c:993:1: internal compiler error: in push_minipool_fix, at config/arm/arm.c:13180
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
make[1]: *** [fs/fs-writeback.o] Error 1
make: *** [fs] Error 2

$ arm-eabi-gcc -v
Using built-in specs.
COLLECT_GCC=/home/showp1984/WORK/toolchain/android-toolchain-eabi/bin/arm-eabi-gcc
COLLECT_LTO_WRAPPER=/home/showp1984/WORK/toolchain/android-toolchain-eabi/bin/../libexec/gcc/arm-eabi/4.7.2/lto-wrapper
Target: arm-eabi
Configured with: /mnt/jenkins/workspace/linaro-android_toolchain-4.7-2012.09/build/objdir/temp-src/gcc-linaro-4.7-2012.09/configure --prefix=/tmp/android-toolchain-eabi --host=x86_64-linux-gnu --build=x86_64-linux-gnu --with-gnu-as --with-gnu-ld --enable-languages=c,c++ --with-gmp=/mnt/jenkins/workspace/linaro-android_toolchain-4.7-2012.09/build/objdir/temp-install --with-mpfr=/mnt/jenkins/workspace/linaro-android_toolchain-4.7-2012.09/build/objdir/temp-install --with-mpc=/mnt/jenkins/workspace/linaro-android_toolchain-4.7-2012.09/build/objdir/temp-install --with-cloog=/mnt/jenkins/workspace/linaro-android_toolchain-4.7-2012.09/build/objdir/temp-install --with-ppl=/mnt/jenkins/workspace/linaro-android_toolchain-4.7-2012.09/build/objdir/temp-install --disable-ppl-version-check --disable-cloog-version-check --enable-cloog-backend=isl --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --disable-libssp --disable-nls --disable-libmudflap --disable-shared --disable-sjlj-exceptions --disable-libquadmath --disable-libitm --disable-libatomic --with-float=soft --with-fpu=vfp --with-arch=armv5te --enable-target-optspace --prefix=/tmp/android-toolchain-eabi --disable-docs --disable-nls --with-gcc-version=linaro-4.7-2012.09 --with-binutils-version=2.23.51.0.3 --with-gmp-version=5.0.5 --with-mpfr-version=3.1.1 --with-mpc-version=1.0 --target=arm-eabi --enable-threads --enable-tls --disable-libgomp --disable-libstdc__-v3 --disable-libitm --disable-libatomic
Thread model: single
gcc version 4.7.2 20120910 (prerelease) (Linaro GCC 4.7-2012.09)

Change-Id: Ibf92c1f6d844368fe9da52315a975dc1928962a7
Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

toolchain: linaro: Fix a bunch of warnings and errors -O3

- Fixes a bunch of initiliazed vars
- Compile lib/bitmap.c with -Os due of a bug
  Reference: https://code.google.com/p/bricked/source/detail?repo=tenderloin&r=cb8b2fe72f43c5146cb340abb2026810e50a23fc
- Disable array-bounds warning on staging prima driver

Change-Id: If17b3db45d8494bb5b5f8e13b8e8478e4fc9b10f

toolchain: linaro: fix warning: 'it.task' may be used uninitialized in this function

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

toolchain: linaro: xc5000: fix warning 'quality' may be used uninitialized in this function

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

toolchain: linaro: fix warning 'kernel_dev' may be used uninitialized in this function

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

toolchain: linaro: fix 'warning: 'kernel_type' may be used uninitialized in this function

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

toolchain: linaro: xc5000: fix warning 'frame_lines' may be used uninitialized in this function

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

toolchain: linaro: l2cap_core: fix 'warning: '...' may be used uninitialized in this function

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

fix: kernel/auditsc.c:927:23: warning: 'state' may be used uninitialized in this function

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

drivers/media/common/tuners/xc5000: fix 'warning: 'lock_status' may be used uninitialized in this function'

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

drivers/media/common/tuners/xc5000: fix 'warning: 'adc_envelope' may be used uninitialized in this function'

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

drivers/media/common/tuners/xc4000: fix 'warning: '...' may be used uninitialized in this function'

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

drivers/usb/host/ehci-sched: fix: 'warning: 'c_mask' may be used uninitialized in this function'

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

fs/fuse/control: fix 'warning: 'val' may be used uninitialized in this function'

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

fs/jbd2/journal: fix: 'warning: 'blocknr' may be used uninitialized in this function'

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

net/unix/af_unix: fix: 'warning: '...' may be used uninitialized in this function'

Signed-off-by: Dennis Rassmann <showp1984@gmail.com>

Conflicts:
	arch/arm/mach-msm/clock-generic.c
	drivers/hwmon/qpnp-adc-current.c
	mm/compaction.c
block: Reserve only one queue tag for sync IO if only 3 tags are available

In case a device has three tags available we still reserve two of them
for sync IO. That leaves only a single tag for async IO such as
writeback from flusher thread which results in poor performance.

Allow async IO to consume two tags in case queue has three tag availabe
to get a decent async write performance.

This patch improves streaming write performance on a machine with such disk
from ~21 MB/s to ~52 MB/s. Also postmark throughput in presence of
streaming writer improves from 8 to 12 transactions per second so sync
IO doesn't seem to be harmed in presence of heavy async writer.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>