2018-05-11 08:23:44

by Du, Changbin

[permalink] [raw]
Subject: [PATCH v5 0/4] kernel hacking: GCC optimization for better debug experience (-Og)

From: Changbin Du <[email protected]>

Hi all,
I know some kernel developers was searching for a method to dissable GCC
optimizations, probably they want to apply GCC '-O0' option. But since Linux
kernel replys on GCC optimization to remove some dead code, so '-O0' just
breaks the build. They do need this because they want to debug kernel with
qemu, simics, kgtp or kgdb.

Thanks for the GCC '-Og' optimization level introduced in GCC 4.8, which
offers a reasonable level of optimization while maintaining fast compilation
and a good debugging experience. It is similar to '-O1' while perferring to
keep debug ability over runtime speed. With '-Og', we can build a kernel with
better debug ability and little performance drop after some simple change.

In this series, firstly introduce a new config CONFIG_NO_AUTO_INLINE after two
fixes for this new option. With this option, only functions explicitly marked
with "inline" will be inlined. This will allow the function tracer to trace
more functions because it only traces functions that the compiler has not
inlined.

Then introduce new config CC_OPTIMIZE_FOR_DEBUGGING which apply '-Og'
optimization level for whole kernel, with a simple fix in fix_to_virt().
Currently I have only tested this option on x86 and ARM platform. Other
platforms should also work but probably need some compiling fixes as what
having done in this series. I leave that to who want to try this debug
option.

Comparison of vmlinux size: a bit smaller.

w/o CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ size vmlinux
text data bss dec hex filename
22665554 9709674 2920908 35296136 21a9388 vmlinux

w/ CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ size vmlinux
text data bss dec hex filename
21499032 10102758 2920908 34522698 20ec64a vmlinux


Comparison of system performance: a bit drop (~6%).
This benchmark of kernel compilation is suggested by Ingo Molnar.
https://lkml.org/lkml/2018/5/2/74

Preparation: Set cpufreq to 'performance'.
for ((cpu=0; cpu<120; cpu++)); do
G=/sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_governor
[ -f $G ] && echo performance > $G
done

w/o CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ perf stat --repeat 5 --null --pre '\
cp -a kernel ../kernel.copy.$(date +%s); \
rm -rf *; \
git checkout .; \
echo 1 > /proc/sys/vm/drop_caches; \
find ../kernel* -type f | xargs cat >/dev/null; \
make -j kernel >/dev/null; \
make clean >/dev/null 2>&1; \
sync '\
\
make -j8 >/dev/null

Performance counter stats for 'make -j8' (5 runs):

219.764246652 seconds time elapsed ( +- 0.78% )

w/ CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ perf stat --repeat 5 --null --pre '\
cp -a kernel ../kernel.copy.$(date +%s); \
rm -rf *; \
git checkout .; \
echo 1 > /proc/sys/vm/drop_caches; \
find ../kernel* -type f | xargs cat >/dev/null; \
make -j kernel >/dev/null; \
make clean >/dev/null 2>&1; \
sync '\
\
make -j8 >/dev/null

Performance counter stats for 'make -j8' (5 runs):

233.574187771 seconds time elapsed ( +- 0.19% )

v5:
o Exchange the position of last two patches to avoid compiling error.
v4:
o Remove aready merged one "regulator: add dummy function of_find_regulator_by_node".

Changbin Du (4):
x86/mm: surround level4_kernel_pgt with #ifdef
CONFIG_X86_5LEVEL...#endif
kernel hacking: new config NO_AUTO_INLINE to disable compiler
auto-inline optimizations
ARM: mm: fix build error in fix_to_virt with
CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
kernel hacking: new config CC_OPTIMIZE_FOR_DEBUGGING to apply GCC -Og
optimization

Makefile | 10 ++++++++++
arch/arm/mm/mmu.c | 2 +-
arch/x86/include/asm/pgtable_64.h | 2 ++
arch/x86/kernel/head64.c | 13 ++++++-------
include/linux/compiler-gcc.h | 2 +-
include/linux/compiler.h | 2 +-
init/Kconfig | 19 +++++++++++++++++++
lib/Kconfig.debug | 17 +++++++++++++++++
8 files changed, 57 insertions(+), 10 deletions(-)

--
2.7.4



2018-05-11 08:21:25

by Du, Changbin

[permalink] [raw]
Subject: [PATCH v5 4/4] kernel hacking: new config CC_OPTIMIZE_FOR_DEBUGGING to apply GCC -Og optimization

From: Changbin Du <[email protected]>

This will apply GCC '-Og' optimization level which is supported
since GCC 4.8. This optimization level offers a reasonable level
of optimization while maintaining fast compilation and a good
debugging experience. It is similar to '-O1' while perferring
to keep debug ability over runtime speed.

If enabling this option breaks your kernel, you should either
disable this or find a fix (mostly in the arch code). Currently
this option has only been tested on x86_64 and arm platform.

This option can satisfy people who was searching for a method
to disable compiler optimizations so to achieve better kernel
debugging experience with kgdb or qemu.

The main problem of '-Og' is we must not use __attribute__((error(msg))).
The compiler will report error though the call to error function
still can be optimize out. So we must fallback to array tricky.

Comparison of vmlinux size: a bit smaller.

w/o CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ size vmlinux
text data bss dec hex filename
22665554 9709674 2920908 35296136 21a9388 vmlinux

w/ CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ size vmlinux
text data bss dec hex filename
21499032 10102758 2920908 34522698 20ec64a vmlinux

Comparison of system performance: a bit drop (~6%).
This benchmark of kernel compilation is suggested by Ingo Molnar.
https://lkml.org/lkml/2018/5/2/74

Preparation: Set cpufreq to 'performance'.
for ((cpu=0; cpu<120; cpu++)); do
G=/sys/devices/system/cpu/cpu$cpu/cpufreq/scaling_governor
[ -f $G ] && echo performance > $G
done

w/o CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ perf stat --repeat 5 --null --pre '\
cp -a kernel ../kernel.copy.$(date +%s); \
rm -rf *; \
git checkout .; \
echo 1 > /proc/sys/vm/drop_caches; \
find ../kernel* -type f | xargs cat >/dev/null; \
make -j kernel >/dev/null; \
make clean >/dev/null 2>&1; \
sync '\
\
make -j8 >/dev/null

Performance counter stats for 'make -j8' (5 runs):

219.764246652 seconds time elapsed ( +- 0.78% )

w/ CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
$ perf stat --repeat 5 --null --pre '\
cp -a kernel ../kernel.copy.$(date +%s); \
rm -rf *; \
git checkout .; \
echo 1 > /proc/sys/vm/drop_caches; \
find ../kernel* -type f | xargs cat >/dev/null; \
make -j kernel >/dev/null; \
make clean >/dev/null 2>&1; \
sync '\
\
make -j8 >/dev/null

Performance counter stats for 'make -j8' (5 runs):

233.574187771 seconds time elapsed ( +- 0.19% )

Signed-off-by: Changbin Du <[email protected]>
Acked-by: Steven Rostedt (VMware) <[email protected]>
---
v3:
o Rename DEBUG_EXPERIENCE to CC_OPTIMIZE_FOR_DEBUGGING
o Move new configuration item to "General setup->Compiler optimization level"
v2:
o Improve performance benchmark as suggested by Ingo.
o Grammar updates in description. (Randy Dunlap)
---
Makefile | 4 ++++
include/linux/compiler-gcc.h | 2 +-
include/linux/compiler.h | 2 +-
init/Kconfig | 19 +++++++++++++++++++
4 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 6720c40..977418a 100644
--- a/Makefile
+++ b/Makefile
@@ -639,6 +639,9 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation)
KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow)
KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context)

+ifdef CONFIG_CC_OPTIMIZE_FOR_DEBUGGING
+KBUILD_CFLAGS += $(call cc-option, -Og)
+else
ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
KBUILD_CFLAGS += $(call cc-option,-Oz,-Os)
KBUILD_CFLAGS += $(call cc-disable-warning,maybe-uninitialized,)
@@ -649,6 +652,7 @@ else
KBUILD_CFLAGS += -O2
endif
endif
+endif

KBUILD_CFLAGS += $(call cc-ifversion, -lt, 0409, \
$(call cc-disable-warning,maybe-uninitialized,))
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
index b4bf73f..586ed11 100644
--- a/include/linux/compiler-gcc.h
+++ b/include/linux/compiler-gcc.h
@@ -192,7 +192,7 @@

#define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)

-#ifndef __CHECKER__
+#if !defined(__CHECKER__) && !defined(CONFIG_CC_OPTIMIZE_FOR_DEBUGGING)
# define __compiletime_warning(message) __attribute__((warning(message)))
# define __compiletime_error(message) __attribute__((error(message)))
#endif /* __CHECKER__ */
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index ab4711c..e97caf4 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -301,7 +301,7 @@ unsigned long read_word_at_a_time(const void *addr)
* sparse see a constant array size without breaking compiletime_assert on old
* versions of GCC (e.g. 4.2.4), so hide the array from sparse altogether.
*/
-# ifndef __CHECKER__
+# if !defined(__CHECKER__) && !defined(CONFIG_CC_OPTIMIZE_FOR_DEBUGGING)
# define __compiletime_error_fallback(condition) \
do { ((void)sizeof(char[1 - 2 * condition])); } while (0)
# endif
diff --git a/init/Kconfig b/init/Kconfig
index f013afc..aa52535 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -1036,6 +1036,25 @@ config CC_OPTIMIZE_FOR_SIZE

If unsure, say N.

+config CC_OPTIMIZE_FOR_DEBUGGING
+ bool "Optimize for better debugging experience (-Og)"
+ select NO_AUTO_INLINE
+ help
+ This will apply GCC '-Og' optimization level which is supported
+ since GCC 4.8. This optimization level offers a reasonable level
+ of optimization while maintaining fast compilation and a good
+ debugging experience. It is similar to '-O1' while preferring to
+ keep debug ability over runtime speed. The overall performance
+ will drop a bit (~6%).
+
+ Use only if you want to debug the kernel, especially if you want
+ to have better kernel debugging experience with gdb facilities
+ like kgdb or qemu. If enabling this option breaks your kernel,
+ you should either disable this or find a fix (mostly in the arch
+ code).
+
+ If unsure, select N.
+
endchoice

config SYSCTL
--
2.7.4


2018-05-11 08:22:03

by Du, Changbin

[permalink] [raw]
Subject: [PATCH v5 3/4] ARM: mm: fix build error in fix_to_virt with CONFIG_CC_OPTIMIZE_FOR_DEBUGGING

From: Changbin Du <[email protected]>

With '-Og' optimization level, GCC would not optimize a count for a loop
as a constant value. But BUILD_BUG_ON() only accept compile-time constant
values. Let's use __fix_to_virt() to avoid the error.

arch/arm/mm/mmu.o: In function `fix_to_virt':
/home/changbin/work/linux/./include/asm-generic/fixmap.h:31: undefined reference to `__compiletime_assert_31'
Makefile:1051: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

Signed-off-by: Changbin Du <[email protected]>
Acked-by: Steven Rostedt (VMware) <[email protected]>
---
v2: use __fix_to_virt() to fix the issue.
---
arch/arm/mm/mmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index e46a6a4..c08d74e 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1599,7 +1599,7 @@ static void __init early_fixmap_shutdown(void)
pte_t *pte;
struct map_desc map;

- map.virtual = fix_to_virt(i);
+ map.virtual = __fix_to_virt(i);
pte = pte_offset_early_fixmap(pmd_off_k(map.virtual), map.virtual);

/* Only i/o device mappings are supported ATM */
--
2.7.4


2018-05-11 08:23:15

by Du, Changbin

[permalink] [raw]
Subject: [PATCH v5 1/4] x86/mm: surround level4_kernel_pgt with #ifdef CONFIG_X86_5LEVEL...#endif

From: Changbin Du <[email protected]>

The level4_kernel_pgt is only defined when X86_5LEVEL is enabled. So
surround level4_kernel_pgt with #ifdef CONFIG_X86_5LEVEL...#endif to
make code correct.

Signed-off-by: Changbin Du <[email protected]>
Acked-by: Steven Rostedt (VMware) <[email protected]>
---
arch/x86/include/asm/pgtable_64.h | 2 ++
arch/x86/kernel/head64.c | 13 ++++++-------
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
index 877bc27..9e7f667 100644
--- a/arch/x86/include/asm/pgtable_64.h
+++ b/arch/x86/include/asm/pgtable_64.h
@@ -15,7 +15,9 @@
#include <linux/bitops.h>
#include <linux/threads.h>

+#ifdef CONFIG_X86_5LEVEL
extern p4d_t level4_kernel_pgt[512];
+#endif
extern p4d_t level4_ident_pgt[512];
extern pud_t level3_kernel_pgt[512];
extern pud_t level3_ident_pgt[512];
diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
index 0c408f8..775d7a6 100644
--- a/arch/x86/kernel/head64.c
+++ b/arch/x86/kernel/head64.c
@@ -143,16 +143,15 @@ unsigned long __head __startup_64(unsigned long physaddr,

pgd = fixup_pointer(&early_top_pgt, physaddr);
p = pgd + pgd_index(__START_KERNEL_map);
- if (la57)
- *p = (unsigned long)level4_kernel_pgt;
- else
- *p = (unsigned long)level3_kernel_pgt;
- *p += _PAGE_TABLE_NOENC - __START_KERNEL_map + load_delta;
-
+#ifdef CONFIG_X86_5LEVEL
if (la57) {
+ *p = (unsigned long)level4_kernel_pgt;
p4d = fixup_pointer(&level4_kernel_pgt, physaddr);
p4d[511] += load_delta;
- }
+ } else
+#endif
+ *p = (unsigned long)level3_kernel_pgt;
+ *p += _PAGE_TABLE_NOENC - __START_KERNEL_map + load_delta;

pud = fixup_pointer(&level3_kernel_pgt, physaddr);
pud[510] += load_delta;
--
2.7.4


2018-05-11 08:23:35

by Du, Changbin

[permalink] [raw]
Subject: [PATCH v5 2/4] kernel hacking: new config NO_AUTO_INLINE to disable compiler auto-inline optimizations

From: Changbin Du <[email protected]>

This patch add a new kernel hacking option NO_AUTO_INLINE. Selecting
this option will prevent the compiler from optimizing the kernel by
auto-inlining functions not marked with the inline keyword.

With this option, only functions explicitly marked with "inline" will
be inlined. This will allow the function tracer to trace more functions
because it only traces functions that the compiler has not inlined.

Signed-off-by: Changbin Du <[email protected]>
Acked-by: Steven Rostedt (VMware) <[email protected]>

---
v2: Some grammar updates from Steven.
---
Makefile | 6 ++++++
lib/Kconfig.debug | 17 +++++++++++++++++
2 files changed, 23 insertions(+)

diff --git a/Makefile b/Makefile
index d0d2652..6720c40 100644
--- a/Makefile
+++ b/Makefile
@@ -775,6 +775,12 @@ KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
$(call cc-option,-fno-var-tracking)
endif

+ifdef CONFIG_NO_AUTO_INLINE
+KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions) \
+ $(call cc-option, -fno-inline-small-functions) \
+ $(call cc-option, -fno-inline-functions-called-once)
+endif
+
ifdef CONFIG_FUNCTION_TRACER
ifndef CC_FLAGS_FTRACE
CC_FLAGS_FTRACE := -pg
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index c40c7b7..da52243 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -198,6 +198,23 @@ config GDB_SCRIPTS
instance. See Documentation/dev-tools/gdb-kernel-debugging.rst
for further details.

+config NO_AUTO_INLINE
+ bool "Disable compiler auto-inline optimizations"
+ help
+ This will prevent the compiler from optimizing the kernel by
+ auto-inlining functions not marked with the inline keyword.
+ With this option, only functions explicitly marked with
+ "inline" will be inlined. This will allow the function tracer
+ to trace more functions because it only traces functions that
+ the compiler has not inlined.
+
+ Enabling this function can help debugging a kernel if using
+ the function tracer. But it can also change how the kernel
+ works, because inlining functions may change the timing,
+ which could make it difficult while debugging race conditions.
+
+ If unsure, select N.
+
config ENABLE_WARN_DEPRECATED
bool "Enable __deprecated logic"
default y
--
2.7.4


2018-05-17 15:50:25

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v5 2/4] kernel hacking: new config NO_AUTO_INLINE to disable compiler auto-inline optimizations

Hi Changbin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/changbin-du-intel-com/kernel-hacking-GCC-optimization-for-better-debug-experience-Og/20180512-001150
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

drivers/video/fbdev/i740fb.c: In function 'i740_calc_fifo.isra.0':
>> drivers/video/fbdev/i740fb.c:331:9: warning: 'wm' may be used uninitialized in this function [-Wmaybe-uninitialized]
return wm;
^~
--
drivers/pci/host/pci-xgene.c: In function 'xgene_pcie_setup_ib_reg':
>> drivers/pci/host/pci-xgene.c:532:2: warning: 'pim_reg' may be used uninitialized in this function [-Wmaybe-uninitialized]
xgene_pcie_setup_pims(port, pim_reg, pci_addr, ~(size - 1));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vim +/wm +331 drivers/video/fbdev/i740fb.c

5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 207
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 208 static u32 i740_calc_fifo(struct i740fb_par *par, u32 freq, int bpp)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 209 {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 210 /*
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 211 * Would like to calculate these values automatically, but a generic
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 212 * algorithm does not seem possible. Note: These FIFO water mark
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 213 * values were tested on several cards and seem to eliminate the
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 214 * all of the snow and vertical banding, but fine adjustments will
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 215 * probably be required for other cards.
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 216 */
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 217
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 218 u32 wm;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 219
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 220 switch (bpp) {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 221 case 8:
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 222 if (freq > 200)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 223 wm = 0x18120000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 224 else if (freq > 175)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 225 wm = 0x16110000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 226 else if (freq > 135)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 227 wm = 0x120E0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 228 else
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 229 wm = 0x100D0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 230 break;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 231 case 15:
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 232 case 16:
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 233 if (par->has_sgram) {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 234 if (freq > 140)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 235 wm = 0x2C1D0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 236 else if (freq > 120)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 237 wm = 0x2C180000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 238 else if (freq > 100)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 239 wm = 0x24160000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 240 else if (freq > 90)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 241 wm = 0x18120000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 242 else if (freq > 50)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 243 wm = 0x16110000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 244 else if (freq > 32)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 245 wm = 0x13100000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 246 else
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 247 wm = 0x120E0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 248 } else {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 249 if (freq > 160)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 250 wm = 0x28200000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 251 else if (freq > 140)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 252 wm = 0x2A1E0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 253 else if (freq > 130)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 254 wm = 0x2B1A0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 255 else if (freq > 120)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 256 wm = 0x2C180000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 257 else if (freq > 100)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 258 wm = 0x24180000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 259 else if (freq > 90)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 260 wm = 0x18120000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 261 else if (freq > 50)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 262 wm = 0x16110000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 263 else if (freq > 32)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 264 wm = 0x13100000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 265 else
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 266 wm = 0x120E0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 267 }
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 268 break;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 269 case 24:
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 270 if (par->has_sgram) {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 271 if (freq > 130)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 272 wm = 0x31200000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 273 else if (freq > 120)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 274 wm = 0x2E200000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 275 else if (freq > 100)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 276 wm = 0x2C1D0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 277 else if (freq > 80)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 278 wm = 0x25180000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 279 else if (freq > 64)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 280 wm = 0x24160000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 281 else if (freq > 49)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 282 wm = 0x18120000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 283 else if (freq > 32)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 284 wm = 0x16110000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 285 else
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 286 wm = 0x13100000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 287 } else {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 288 if (freq > 120)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 289 wm = 0x311F0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 290 else if (freq > 100)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 291 wm = 0x2C1D0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 292 else if (freq > 80)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 293 wm = 0x25180000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 294 else if (freq > 64)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 295 wm = 0x24160000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 296 else if (freq > 49)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 297 wm = 0x18120000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 298 else if (freq > 32)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 299 wm = 0x16110000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 300 else
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 301 wm = 0x13100000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 302 }
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 303 break;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 304 case 32:
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 305 if (par->has_sgram) {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 306 if (freq > 80)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 307 wm = 0x2A200000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 308 else if (freq > 60)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 309 wm = 0x281A0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 310 else if (freq > 49)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 311 wm = 0x25180000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 312 else if (freq > 32)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 313 wm = 0x18120000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 314 else
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 315 wm = 0x16110000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 316 } else {
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 317 if (freq > 80)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 318 wm = 0x29200000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 319 else if (freq > 60)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 320 wm = 0x281A0000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 321 else if (freq > 49)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 322 wm = 0x25180000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 323 else if (freq > 32)
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 324 wm = 0x18120000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 325 else
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 326 wm = 0x16110000;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 327 }
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 328 break;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 329 }
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 330
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 @331 return wm;
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 332 }
5350c65f drivers/video/i740fb.c Ondrej Zary 2012-02-10 333

:::::: The code at line 331 was first introduced by commit
:::::: 5350c65f4f15bbc111ffa629130d3f32cdd4ccf6 Resurrect Intel740 driver: i740fb

:::::: TO: Ondrej Zary <[email protected]>
:::::: CC: Florian Tobias Schandinat <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (12.09 kB)
.config.gz (57.63 kB)
Download all attachments

2018-05-17 17:59:58

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH v5 2/4] kernel hacking: new config NO_AUTO_INLINE to disable compiler auto-inline optimizations

Hi Changbin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v4.17-rc5 next-20180517]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/changbin-du-intel-com/kernel-hacking-GCC-optimization-for-better-debug-experience-Og/20180512-001150
config: sparc64-allyesconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64

Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings

All warnings (new ones prefixed by >>):

drivers//staging/comedi/drivers/pcl816.c: In function 'pcl816_ai_setup_chanlist':
>> drivers//staging/comedi/drivers/pcl816.c:171:2: warning: 'last_chan' may be used uninitialized in this function [-Wmaybe-uninitialized]
pcl816_ai_set_chan_scan(dev, first_chan, last_chan);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
drivers//staging/comedi/drivers/pcl818.c: In function 'pcl818_ai_setup_chanlist':
>> drivers//staging/comedi/drivers/pcl818.c:366:2: warning: 'last_chan' may be used uninitialized in this function [-Wmaybe-uninitialized]
pcl818_ai_set_chan_scan(dev, first_chan, last_chan);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
drivers/net/wireless/ath/ath10k/mac.c: In function 'ath10k_mac_init_rd':
>> drivers/net/wireless/ath/ath10k/mac.c:8172:39: warning: 'rd' may be used uninitialized in this function [-Wmaybe-uninitialized]
ar->ath_common.regulatory.current_rd = rd;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~
--
drivers/dma/stm32-mdma.c: In function 'stm32_mdma_setup_xfer':
>> drivers/dma/stm32-mdma.c:767:6: warning: 'ccr' may be used uninitialized in this function [-Wmaybe-uninitialized]
ccr &= ~STM32_MDMA_CCR_IRQ_MASK;
^~
--
drivers/gpio/gpio-aspeed.c: In function 'enable_debounce':
>> drivers/gpio/gpio-aspeed.c:708:6: warning: 'requested_cycles' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (requested_cycles == cycles)
^
--
drivers/mmc/host/sdhci-pci-core.c: In function 'intel_dsm_init.isra.3':
>> drivers/mmc/host/sdhci-pci-core.c:527:37: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
intel_host->d3_retune = err ? true : !!val;
~~~~~~~~~~~^~~~~~~

vim +/last_chan +171 drivers//staging/comedi/drivers/pcl816.c

19720c07 H Hartley Sweeten 2014-03-04 151
19720c07 H Hartley Sweeten 2014-03-04 152 static void pcl816_ai_setup_chanlist(struct comedi_device *dev,
19720c07 H Hartley Sweeten 2014-03-04 153 unsigned int *chanlist,
19720c07 H Hartley Sweeten 2014-03-04 154 unsigned int seglen)
19720c07 H Hartley Sweeten 2014-03-04 155 {
19720c07 H Hartley Sweeten 2014-03-04 156 unsigned int first_chan = CR_CHAN(chanlist[0]);
19720c07 H Hartley Sweeten 2014-03-04 157 unsigned int last_chan;
19720c07 H Hartley Sweeten 2014-03-04 158 unsigned int range;
19720c07 H Hartley Sweeten 2014-03-04 159 unsigned int i;
19720c07 H Hartley Sweeten 2014-03-04 160
19720c07 H Hartley Sweeten 2014-03-04 161 /* store range list to card */
19720c07 H Hartley Sweeten 2014-03-04 162 for (i = 0; i < seglen; i++) {
19720c07 H Hartley Sweeten 2014-03-04 163 last_chan = CR_CHAN(chanlist[i]);
19720c07 H Hartley Sweeten 2014-03-04 164 range = CR_RANGE(chanlist[i]);
19720c07 H Hartley Sweeten 2014-03-04 165
19720c07 H Hartley Sweeten 2014-03-04 166 pcl816_ai_set_chan_range(dev, last_chan, range);
19720c07 H Hartley Sweeten 2014-03-04 167 }
19720c07 H Hartley Sweeten 2014-03-04 168
19720c07 H Hartley Sweeten 2014-03-04 169 udelay(1);
19720c07 H Hartley Sweeten 2014-03-04 170
19720c07 H Hartley Sweeten 2014-03-04 @171 pcl816_ai_set_chan_scan(dev, first_chan, last_chan);
19720c07 H Hartley Sweeten 2014-03-04 172 }
19720c07 H Hartley Sweeten 2014-03-04 173

:::::: The code at line 171 was first introduced by commit
:::::: 19720c07f1f82c21311f3f7ac3e9b993598d6b70 staging: comedi: pcl816: cleanup setup_channel_list()

:::::: TO: H Hartley Sweeten <[email protected]>
:::::: CC: Greg Kroah-Hartman <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation


Attachments:
(No filename) (4.70 kB)
.config.gz (52.02 kB)
Download all attachments