All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Built kernel without -O2 option
@ 2010-11-29  3:56 Hui Zhu
  2010-11-29  8:16 ` Américo Wang
                   ` (4 more replies)
  0 siblings, 5 replies; 45+ messages in thread
From: Hui Zhu @ 2010-11-29  3:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: gdb, hellogcc

Hi,

Now, there are a lot of ways to debug the Linux kernel with GDB, like
qemu, kgtp or kgdb and so on.
But the developer more like add a printk. It have a lot of reason, a big one is:
(gdb) p ret
$3 = <value optimized out>
And the code execution order is not right.

This is becuase the Kernel is bult with gcc -O2.  Gcc will not
generate enough debug message with file with -O2.
So GDB cannot work very well with Linux kernel.

So I make a patch that add a option in "Kernel hacking" called "Close
GCC optimization".  It will make kernel be built without -O2.

I built and use it in i386 and x86_64.  I will try to make it OK in other arch.

And I will put new patch in here and
http://code.google.com/p/kgtp/downloads/list

Thanks,
Hui

Signed-off-by: Hui Zhu <teawater@gmail.com>
---
 Makefile                                        |    2 ++
 arch/x86/crypto/Makefile                        |    6 ++++++
 arch/x86/include/asm/page_64_types.h            |    4 ++++
 arch/x86/include/asm/uaccess_32.h               |    4 ++++
 arch/x86/kernel/Makefile                        |    9 +++++++++
 arch/x86/kvm/Makefile                           |    5 +++++
 arch/x86/lib/Makefile                           |    4 ++++
 arch/x86/power/Makefile                         |    4 ++++
 crypto/Makefile                                 |    4 ++++
 drivers/char/mwave/Makefile                     |    4 ++++
 drivers/gpu/drm/i915/Makefile                   |    4 ++++
 drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
 drivers/gpu/drm/nouveau/Makefile                |    4 ++++
 drivers/gpu/drm/radeon/Makefile                 |    4 ++++
 drivers/infiniband/hw/qib/Makefile              |    4 ++++
 drivers/net/can/sja1000/Makefile                |    4 ++++
 drivers/staging/comedi/drivers/Makefile         |    4 ++++
 drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
 drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
 drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
 drivers/usb/gadget/f_loopback.c                 |    2 ++
 drivers/usb/gadget/f_sourcesink.c               |    2 ++
 drivers/usb/gadget/g_zero.h                     |    2 ++
 drivers/usb/host/Makefile                       |    4 ++++
 fs/Makefile                                     |    5 +++++
 include/linux/pagemap.h                         |    2 ++
 init/Kconfig                                    |    1 +
 kernel/Makefile                                 |    4 ++++
 kernel/kfifo.c                                  |    3 +++
 lib/Kconfig.debug                               |    8 ++++++++
 lib/raid6/Makefile                              |    6 ++++++
 mm/Makefile                                     |    6 ++++++
 mm/memory.c                                     |    2 ++
 mm/percpu.c                                     |    4 ++++
 net/mac80211/cfg.c                              |    2 ++
 net/mac80211/iface.c                            |   12 ++++++++++++
 net/mac80211/mesh.h                             |    2 ++
 net/mac80211/rx.c                               |    8 ++++++++
 net/mac80211/sta_info.c                         |    2 ++
 net/mac80211/status.c                           |    2 ++
 net/mac80211/tx.c                               |    4 ++++
 41 files changed, 181 insertions(+), 1 deletion(-)

--- a/Makefile
+++ b/Makefile
@@ -540,8 +540,10 @@ all: vmlinux
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os
 else
+ifndef CONFIG_CC_CLOSE_OPTIMIZATION
 KBUILD_CFLAGS	+= -O2
 endif
+endif

 include $(srctree)/arch/$(SRCARCH)/Makefile

--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -2,6 +2,12 @@
 # Arch-specific CryptoAPI modules.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_fpu.o				+= -O2
+CFLAGS_aesni-intel_glue.o		+= -O2
+CFLAGS_ghash-clmulni-intel_glue.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO_FPU) += fpu.o

 obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -1,7 +1,11 @@
 #ifndef _ASM_X86_PAGE_64_DEFS_H
 #define _ASM_X86_PAGE_64_DEFS_H

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+#define THREAD_ORDER	2
+#else
 #define THREAD_ORDER	1
+#endif
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE - 1))

--- a/arch/x86/include/asm/uaccess_32.h
+++ b/arch/x86/include/asm/uaccess_32.h
@@ -209,7 +209,11 @@ static inline unsigned long __must_check
 	if (likely(sz == -1 || sz >= n))
 		n = _copy_from_user(to, from, n);
 	else
+#ifndef CONFIG_CC_CLOSE_OPTIMIZATION
 		copy_from_user_overflow();
+#else
+		n = -EFAULT;
+#endif

 	return n;
 }
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o		:= n
 GCOV_PROFILE_tsc.o		:= n
 GCOV_PROFILE_paravirt.o		:= n

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_process_$(BITS).o	+= -O2
+CFLAGS_entry_$(BITS).o		+= -O2
+CFLAGS_traps.o			+= -O2
+CFLAGS_i387.o			+= -O2
+CFLAGS_xsave.o			+= -O2
+CFLAGS_hpet.o			+= -O2
+endif
+
 obj-y			:= process_$(BITS).o signal.o entry_$(BITS).o
 obj-y			+= traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time.o ioport.o ldt.o dumpstack.o
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -5,6 +5,11 @@ CFLAGS_x86.o := -I.
 CFLAGS_svm.o := -I.
 CFLAGS_vmx.o := -I.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_x86.o		+= -O2
+CFLAGS_emulate.o	+= -O2
+endif
+
 kvm-y			+= $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
 				coalesced_mmio.o irq_comm.o eventfd.o \
 				assigned-dev.o)
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -2,6 +2,10 @@
 # Makefile for x86 specific library files.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_memmove_64.o	+= -O2
+endif
+
 inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
 inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
 quiet_cmd_inat_tables = GEN     $@
--- a/arch/x86/power/Makefile
+++ b/arch/x86/power/Makefile
@@ -3,5 +3,9 @@
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_cpu.o	:= $(nostackp)

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_cpu.o	+= -O2
+endif
+
 obj-$(CONFIG_PM_SLEEP)		+= cpu.o
 obj-$(CONFIG_HIBERNATION)	+= hibernate_$(BITS).o hibernate_asm_$(BITS).o
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -2,6 +2,10 @@
 # Cryptographic API
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_xor.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO) += crypto.o
 crypto-objs := api.o cipher.o compress.o

--- a/drivers/char/mwave/Makefile
+++ b/drivers/char/mwave/Makefile
@@ -4,6 +4,10 @@
 # See the README file in this directory for more info. <paulsch@us.ibm.com>
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_smapi.o	+= -O2
+endif
+
 obj-$(CONFIG_MWAVE) += mwave.o

 mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_i915_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
 	  i915_debugfs.o \
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1121,7 +1121,11 @@ extern int intel_setup_gmbus(struct drm_
 extern void intel_teardown_gmbus(struct drm_device *dev);
 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#else
 extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#endif
 {
 	return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
 }
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_nv50_instmem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_radeon_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm

 hostprogs-y := mkregtable
--- a/drivers/infiniband/hw/qib/Makefile
+++ b/drivers/infiniband/hw/qib/Makefile
@@ -1,5 +1,9 @@
 obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_qib_iba7322.o	+= -O2
+endif
+
 ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
 	qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
 	qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
--- a/drivers/net/can/sja1000/Makefile
+++ b/drivers/net/can/sja1000/Makefile
@@ -2,6 +2,10 @@
 #  Makefile for the SJA1000 CAN controller drivers.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_kvaser_pci.o	+= -O2
+endif
+
 obj-$(CONFIG_CAN_SJA1000) += sja1000.o
 obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
 obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -1,6 +1,10 @@
 # Makefile for individual comedi drivers
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_cb_pcidas64.o	+= -O2
+endif
+
 # Comedi "helper" modules
 obj-$(CONFIG_COMEDI)			+= pcm_common.o

--- a/drivers/staging/et131x/et1310_address_map.h
+++ b/drivers/staging/et131x/et1310_address_map.h
@@ -212,12 +212,20 @@ struct global_regs {			/* Location: */
 #define INDEX10(x)	((x) & ET_DMA10_MASK)
 #define INDEX4(x)	((x) & ET_DMA4_MASK)

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void add_10bit(u32 *v, int n)
+#else
 extern inline void add_10bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void add_12bit(u32 *v, int n)
+#else
 extern inline void add_12bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
 }
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
 	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#else
 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#endif
 {
 	/* Single white space is for Linksys APs */
 	if (essid_len == 1 && essid[0] == ' ')
@@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
 	return 0;
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline int ieee80211_get_hdrlen(u16 fc)
+#else
 extern inline int ieee80211_get_hdrlen(u16 fc)
+#endif
 {
 	int hdrlen = 24;

--- a/drivers/staging/wlags49_h2/wl_internal.h
+++ b/drivers/staging/wlags49_h2/wl_internal.h
@@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
 /********************************************************************/
 /* Interrupt enable disable functions                               */
 /********************************************************************/
-
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void wl_act_int_on(struct wl_private *lp)
+#else
 extern inline void wl_act_int_on(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
@@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
 	}
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void wl_act_int_off(struct wl_private *lp)
+#else
 extern inline void wl_act_int_off(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		loopback_driver.descriptors = otg_desc;
 		loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
 }
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		sourcesink_driver.descriptors = otg_desc;
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
 }
--- a/drivers/usb/gadget/g_zero.h
+++ b/drivers/usb/gadget/g_zero.h
@@ -10,7 +10,9 @@

 /* global state */
 extern unsigned buflen;
+#ifdef CONFIG_USB_OTG
 extern const struct usb_descriptor_header *otg_desc[];
+#endif

 /* common utilities */
 struct usb_request *alloc_ep_req(struct usb_ep *ep);
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -4,6 +4,10 @@

 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_ehci-hcd.o	+= -O2
+endif
+
 isp1760-y := isp1760-hcd.o isp1760-if.o

 fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -13,6 +13,11 @@ obj-y :=	open.o read_write.o file_table.
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
 		stack.o fs_struct.o statfs.o

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_compat_ioctl.o	+= -O2
+CFLAGS_binfmt_elf.o	+= -O2
+endif
+
 ifeq ($(CONFIG_BLOCK),y)
 obj-y +=	buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
 else
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
 					unsigned long address)
 {
 	pgoff_t pgoff;
+#ifdef CONFIG_HUGETLBFS
 	if (unlikely(is_vm_hugetlb_page(vma)))
 		return linear_hugepage_index(vma, address);
+#endif
 	pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
 	pgoff += vma->vm_pgoff;
 	return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -817,6 +817,7 @@ endif

 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size"
+	depends on !CC_CLOSE_OPTIMIZATION
 	default y
 	help
 	  Enabling this option will pass "-Os" instead of "-O2" to gcc
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the linux kernel.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_sched.o	+= -O2
+endif
+
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
 		return max;
 	return len;
 }
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+EXPORT_SYMBOL(__kfifo_max_r);
+#endif

 #define	__KFIFO_PEEK(data, out, mask) \
 	((data)[(out) & (mask)])
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
 	  - Enable verbose reporting from modpost to help solving
 	    the section mismatches reported.

+config CC_CLOSE_OPTIMIZATION
+	bool "Close GCC optimization"
+	default n
+	help
+	  Enabling this option will let gcc build kernel without "-O2".
+
+	  If unsure, say N.
+
 config DEBUG_KERNEL
 	bool "Kernel debugging"
 	help
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -1,3 +1,9 @@
+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_mmx.o	+= -O2
+CFLAGS_sse1.o	+= -O2
+CFLAGS_sse2.o	+= -O2
+endif
+
 obj-$(CONFIG_RAID6_PQ)	+= raid6_pq.o

 raid6_pq-y	+= algos.o recov.o tables.o int1.o int2.o int4.o \
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -2,6 +2,12 @@
 # Makefile for the linux memory manager.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_slob.o	+= -O2
+CFLAGS_slab.o	+= -O2
+CFLAGS_slub.o	+= -O2
+endif
+
 mmu-y			:= nommu.o
 mmu-$(CONFIG_MMU)	:= fremap.o highmem.o madvise.o memory.o mincore.o \
 			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2697,7 +2697,9 @@ static int do_swap_page(struct mm_struct

 	if (ksm_might_need_to_copy(page, vma, address)) {
 		swapcache = page;
+#ifdef CONFIG_KSM
 		page = ksm_does_need_to_copy(page, vma, address);
+#endif

 		if (unlikely(!page)) {
 			ret = VM_FAULT_OOM;
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1890,7 +1890,11 @@ void __init percpu_init_late(void)
 		int *map;
 		const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]);

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+		BUG_ON(size > PAGE_SIZE);
+#else
 		BUILD_BUG_ON(size > PAGE_SIZE);
+#endif

 		map = pcpu_mem_alloc(size);
 		BUG_ON(!map);
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -698,6 +698,7 @@ static void sta_apply_parameters(struct
 						  params->ht_capa,
 						  &sta->sta.ht_cap);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
 		switch (params->plink_action) {
 		case PLINK_ACTION_OPEN:
@@ -708,6 +709,7 @@ static void sta_apply_parameters(struct
 			break;
 		}
 	}
+#endif
 }

 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -277,7 +277,9 @@ static int ieee80211_do_open(struct net_
 			local->fif_other_bss++;
 			ieee80211_configure_filter(local);

+#ifdef CONFIG_MAC80211_MESH
 			ieee80211_start_mesh(sdata);
+#endif
 		} else if (sdata->vif.type == NL80211_IFTYPE_AP) {
 			local->fif_pspoll++;
 			local->fif_probe_req++;
@@ -512,7 +514,9 @@ static void ieee80211_do_stop(struct iee

 			ieee80211_configure_filter(local);

+#ifdef CONFIG_MAC80211_MESH
 			ieee80211_stop_mesh(sdata);
+#endif
 		}
 		/* fall through */
 	default:
@@ -640,8 +644,10 @@ static void ieee80211_teardown_sdata(str
 		__skb_queue_purge(&sdata->fragments[i].skb_list);
 	sdata->fragment_next = 0;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_rmc_free(sdata);
+#endif

 	flushed = sta_info_flush(local, sdata);
 	WARN_ON(flushed);
@@ -817,7 +823,9 @@ static void ieee80211_iface_work(struct
 		case NL80211_IFTYPE_MESH_POINT:
 			if (!ieee80211_vif_is_mesh(&sdata->vif))
 				break;
+#ifdef CONFIG_MAC80211_MESH
 			ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+#endif
 			break;
 		default:
 			WARN(1, "frame for unexpected interface type");
@@ -838,7 +846,9 @@ static void ieee80211_iface_work(struct
 	case NL80211_IFTYPE_MESH_POINT:
 		if (!ieee80211_vif_is_mesh(&sdata->vif))
 			break;
+#ifdef CONFIG_MAC80211_MESH
 		ieee80211_mesh_work(sdata);
+#endif
 		break;
 	default:
 		break;
@@ -892,8 +902,10 @@ static void ieee80211_setup_sdata(struct
 		ieee80211_ibss_setup_sdata(sdata);
 		break;
 	case NL80211_IFTYPE_MESH_POINT:
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sdata->vif))
 			ieee80211_mesh_init_sdata(sdata);
+#endif
 		break;
 	case NL80211_IFTYPE_MONITOR:
 		sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -223,8 +223,10 @@ int ieee80211_fill_mesh_addresses(struct
 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
 		struct ieee80211_sub_if_data *sdata, char *addr4,
 		char *addr5, char *addr6);
+#ifdef CONFIG_MAC80211_MESH
 int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
 		struct ieee80211_sub_if_data *sdata);
+#endif
 bool mesh_matches_local(struct ieee802_11_elems *ie,
 		struct ieee80211_sub_if_data *sdata);
 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
 }


+#ifndef CONFIG_MAC80211_MESH
+static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
+		   struct ieee80211_sub_if_data *sdata)
+{
+	return 0;
+}
+#endif
+
 static ieee80211_rx_result
 ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
 {
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -465,8 +465,10 @@ int sta_info_insert_rcu(struct sta_info
 	rcu_read_lock();
 	mutex_unlock(&local->sta_mtx);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_accept_plinks_update(sdata);
+#endif

 	return 0;
  out_free:
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -237,8 +237,10 @@ void ieee80211_tx_status(struct ieee8021
 		}

 		rate_control_tx_status(local, sband, sta, skb);
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
 			ieee80211s_update_metric(local, sta, skb);
+#endif

 		if (!(info->flags & IEEE80211_TX_CTL_INJECTED) &&
 		    (info->flags & IEEE80211_TX_STAT_ACK))
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1615,6 +1615,7 @@ static void ieee80211_xmit(struct ieee80
 	hdr = (struct ieee80211_hdr *) skb->data;
 	info->control.vif = &sdata->vif;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) &&
 	    ieee80211_is_data(hdr->frame_control) &&
 		!is_multicast_ether_addr(hdr->addr1))
@@ -1623,6 +1624,7 @@ static void ieee80211_xmit(struct ieee80
 				rcu_read_unlock();
 				return;
 			}
+#endif

 	ieee80211_set_qos_hdr(local, skb);
 	ieee80211_tx(sdata, skb, false);
@@ -2278,7 +2280,9 @@ struct sk_buff *ieee80211_beacon_get_tim
 		*pos++ = WLAN_EID_SSID;
 		*pos++ = 0x0;

+#ifdef CONFIG_MAC80211_MESH
 		mesh_mgmt_ies_add(skb, sdata);
+#endif
 	} else {
 		WARN_ON(1);
 		goto out;

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  3:56 [PATCH] Built kernel without -O2 option Hui Zhu
@ 2010-11-29  8:16 ` Américo Wang
  2010-11-29  8:18   ` microcai
                     ` (2 more replies)
  2010-11-29  9:59 ` Andi Kleen
                   ` (3 subsequent siblings)
  4 siblings, 3 replies; 45+ messages in thread
From: Américo Wang @ 2010-11-29  8:16 UTC (permalink / raw)
  To: Hui Zhu; +Cc: linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>Hi,
>
>Now, there are a lot of ways to debug the Linux kernel with GDB, like
>qemu, kgtp or kgdb and so on.
>But the developer more like add a printk. It have a lot of reason, a big one is:
>(gdb) p ret
>$3 = <value optimized out>
>And the code execution order is not right.
>
>This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>generate enough debug message with file with -O2.
>So GDB cannot work very well with Linux kernel.
>
>So I make a patch that add a option in "Kernel hacking" called "Close
>GCC optimization".  It will make kernel be built without -O2.
>
>I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>

The problem is that some functions _have to_ be inlined and gcc without -O2
doesn't inline them. Have check all the cases? I doubt.

Also, what is size of vmlinux before applying your patch and after that?
Does it increase too much?

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:16 ` Américo Wang
@ 2010-11-29  8:18   ` microcai
  2010-11-29  8:24   ` Hui Zhu
  2010-11-29  9:44   ` Christian Borntraeger
  2 siblings, 0 replies; 45+ messages in thread
From: microcai @ 2010-11-29  8:18 UTC (permalink / raw)
  Cc: Hui Zhu, linux-kernel, gdb, hellogcc

2010/11/29 Américo Wang <xiyou.wangcong@gmail.com>:
> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>Hi,
>>
>>Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>qemu, kgtp or kgdb and so on.
>>But the developer more like add a printk. It have a lot of reason, a big one is:
>>(gdb) p ret
>>$3 = <value optimized out>
>>And the code execution order is not right.
>>
>>This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>generate enough debug message with file with -O2.
>>So GDB cannot work very well with Linux kernel.
>>
>>So I make a patch that add a option in "Kernel hacking" called "Close
>>GCC optimization".  It will make kernel be built without -O2.
>>
>>I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>
>
> The problem is that some functions _have to_ be inlined and gcc without -O2
> doesn't inline them. Have check all the cases? I doubt.
>
> Also, what is size of vmlinux before applying your patch and after that?
> Does it increase too much?
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:16 ` Américo Wang
  2010-11-29  8:18   ` microcai
@ 2010-11-29  8:24   ` Hui Zhu
       [not found]     ` <4CF36741.9000808@loongson.cn>
  2010-11-29  8:52     ` Américo Wang
  2010-11-29  9:44   ` Christian Borntraeger
  2 siblings, 2 replies; 45+ messages in thread
From: Hui Zhu @ 2010-11-29  8:24 UTC (permalink / raw)
  To: Américo Wang; +Cc: linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>Hi,
>>
>>Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>qemu, kgtp or kgdb and so on.
>>But the developer more like add a printk. It have a lot of reason, a big one is:
>>(gdb) p ret
>>$3 = <value optimized out>
>>And the code execution order is not right.
>>
>>This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>generate enough debug message with file with -O2.
>>So GDB cannot work very well with Linux kernel.
>>
>>So I make a patch that add a option in "Kernel hacking" called "Close
>>GCC optimization".  It will make kernel be built without -O2.
>>
>>I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>
>
> The problem is that some functions _have to_ be inlined and gcc without -O2
> doesn't inline them. Have check all the cases? I doubt.

If they really need O2, I set  them to O2.
Actually, this is the main work, find out the file that need the O2.  :)

For example:
ifdef CONFIG_CC_CLOSE_OPTIMIZATION
CFLAGS_fpu.o                           += -O2
CFLAGS_aesni-intel_glue.o              += -O2
CFLAGS_ghash-clmulni-intel_glue.o      += -O2
endif

And I will try to find more of these type files.

>
> Also, what is size of vmlinux before applying your patch and after that?
> Does it increase too much?
>

Before the patch:
ls -alh vmlinuz-2.6.37-rc3+
-rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
ls -alh b26no/vmlinux
-rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux

After the patch:
ls -alh vmlinuz-2.6.37-rc3debug+
-rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
ls -alh b26/vmlinux
-rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux

Thanks,
Hui

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
       [not found]     ` <4CF36741.9000808@loongson.cn>
@ 2010-11-29  8:47       ` Hui Zhu
  2010-11-29  8:55         ` Steven
  2010-11-29  9:45         ` 乔崇
  0 siblings, 2 replies; 45+ messages in thread
From: Hui Zhu @ 2010-11-29  8:47 UTC (permalink / raw)
  To: hellogcc; +Cc: Américo Wang, linux-kernel, gdb

In this way, you will got a lot of error.

Hui

On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
> does not need change kernel,just write a shell mycc as bellow:
>
> #!/bin/sh
> gcc "$@" -O0
>
> then
>
> make CC=./mycc vmlinux
>
> Hui Zhu said
>
> On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
> wrote:
>
>
> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>
>
> Hi,
>
> Now, there are a lot of ways to debug the Linux kernel with GDB, like
> qemu, kgtp or kgdb and so on.
> But the developer more like add a printk. It have a lot of reason, a big one
> is:
> (gdb) p ret
> $3 = <value optimized out>
> And the code execution order is not right.
>
> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
> generate enough debug message with file with -O2.
> So GDB cannot work very well with Linux kernel.
>
> So I make a patch that add a option in "Kernel hacking" called "Close
> GCC optimization".  It will make kernel be built without -O2.
>
> I built and use it in i386 and x86_64.  I will try to make it OK in other
> arch.
>
>
>
> The problem is that some functions _have to_ be inlined and gcc without -O2
> doesn't inline them. Have check all the cases? I doubt.
>
>
> If they really need O2, I set  them to O2.
> Actually, this is the main work, find out the file that need the O2.  :)
>
> For example:
> ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> CFLAGS_fpu.o                           += -O2
> CFLAGS_aesni-intel_glue.o              += -O2
> CFLAGS_ghash-clmulni-intel_glue.o      += -O2
> endif
>
> And I will try to find more of these type files.
>
>
>
> Also, what is size of vmlinux before applying your patch and after that?
> Does it increase too much?
>
>
>
> Before the patch:
> ls -alh vmlinuz-2.6.37-rc3+
> -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
> ls -alh b26no/vmlinux
> -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
>
> After the patch:
> ls -alh vmlinuz-2.6.37-rc3debug+
> -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
> ls -alh b26/vmlinux
> -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
>
> Thanks,
> Hui
>
>
>
>
> --
>
> 乔崇 qiaochong@loongson.cn
>
> 2010年 11月 29日 星期一 16:35:38 CST

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:24   ` Hui Zhu
       [not found]     ` <4CF36741.9000808@loongson.cn>
@ 2010-11-29  8:52     ` Américo Wang
  2010-11-29  9:11       ` Hui Zhu
                         ` (2 more replies)
  1 sibling, 3 replies; 45+ messages in thread
From: Américo Wang @ 2010-11-29  8:52 UTC (permalink / raw)
  To: Hui Zhu; +Cc: Américo Wang, linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 04:24:42PM +0800, Hui Zhu wrote:
>On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>>Hi,
>>>
>>>Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>>qemu, kgtp or kgdb and so on.
>>>But the developer more like add a printk. It have a lot of reason, a big one is:
>>>(gdb) p ret
>>>$3 = <value optimized out>
>>>And the code execution order is not right.
>>>
>>>This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>>generate enough debug message with file with -O2.
>>>So GDB cannot work very well with Linux kernel.
>>>
>>>So I make a patch that add a option in "Kernel hacking" called "Close
>>>GCC optimization".  It will make kernel be built without -O2.
>>>
>>>I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>>
>>
>> The problem is that some functions _have to_ be inlined and gcc without -O2
>> doesn't inline them. Have check all the cases? I doubt.
>
>If they really need O2, I set  them to O2.
>Actually, this is the main work, find out the file that need the O2.  :)
>
>For example:
>ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>CFLAGS_fpu.o                           += -O2
>CFLAGS_aesni-intel_glue.o              += -O2
>CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>endif

No, I didn't mean this, I meant some function that have to be inlined
are those who only work when being inlined, e.g. current_text_addr().

I think it is not alone. :)

Also, since many inline functions sit in hot-path, are there any
performance regressions with your patch applied?

BTW, you need to Cc kbuild for makefile changes like this.

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:47       ` [hellogcc] " Hui Zhu
@ 2010-11-29  8:55         ` Steven
  2010-11-29  8:57           ` Hui Zhu
  2010-11-29  9:45         ` 乔崇
  1 sibling, 1 reply; 45+ messages in thread
From: Steven @ 2010-11-29  8:55 UTC (permalink / raw)
  To: Hui Zhu; +Cc: hellogcc, Américo Wang, linux-kernel, gdb

I replace -O2 with -O0 in Makefile of kernel source code root directory?
I just do it and my gdb works well with this method.

You mean it is not enough?

Steven

On Mon, 2010-11-29 at 16:47 +0800, Hui Zhu wrote:
> In this way, you will got a lot of error.
> 
> Hui
> 
> On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
> > does not need change kernel,just write a shell mycc as bellow:
> >
> > #!/bin/sh
> > gcc "$@" -O0
> >
> > then
> >
> > make CC=./mycc vmlinux
> >
> > Hui Zhu said
> >
> > On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
> > wrote:
> >
> >
> > On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
> >
> >
> > Hi,
> >
> > Now, there are a lot of ways to debug the Linux kernel with GDB, like
> > qemu, kgtp or kgdb and so on.
> > But the developer more like add a printk. It have a lot of reason, a big one
> > is:
> > (gdb) p ret
> > $3 = <value optimized out>
> > And the code execution order is not right.
> >
> > This is becuase the Kernel is bult with gcc -O2.  Gcc will not
> > generate enough debug message with file with -O2.
> > So GDB cannot work very well with Linux kernel.
> >
> > So I make a patch that add a option in "Kernel hacking" called "Close
> > GCC optimization".  It will make kernel be built without -O2.
> >
> > I built and use it in i386 and x86_64.  I will try to make it OK in other
> > arch.
> >
> >
> >
> > The problem is that some functions _have to_ be inlined and gcc without -O2
> > doesn't inline them. Have check all the cases? I doubt.
> >
> >
> > If they really need O2, I set  them to O2.
> > Actually, this is the main work, find out the file that need the O2.  :)
> >
> > For example:
> > ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> > CFLAGS_fpu.o                           += -O2
> > CFLAGS_aesni-intel_glue.o              += -O2
> > CFLAGS_ghash-clmulni-intel_glue.o      += -O2
> > endif
> >
> > And I will try to find more of these type files.
> >
> >
> >
> > Also, what is size of vmlinux before applying your patch and after that?
> > Does it increase too much?
> >
> >
> >
> > Before the patch:
> > ls -alh vmlinuz-2.6.37-rc3+
> > -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
> > ls -alh b26no/vmlinux
> > -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
> >
> > After the patch:
> > ls -alh vmlinuz-2.6.37-rc3debug+
> > -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
> > ls -alh b26/vmlinux
> > -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
> >
> > Thanks,
> > Hui
> >
> >
> >
> >
> > --
> >
> > 乔崇 qiaochong@loongson.cn
> >
> > 2010年 11月 29日 星期一 16:35:38 CST


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:55         ` Steven
@ 2010-11-29  8:57           ` Hui Zhu
  0 siblings, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2010-11-29  8:57 UTC (permalink / raw)
  To: Steven; +Cc: hellogcc, Américo Wang, linux-kernel, gdb

On Mon, Nov 29, 2010 at 16:55, Steven <mqyoung@gmail.com> wrote:
> I replace -O2 with -O0 in Makefile of kernel source code root directory?
> I just do it and my gdb works well with this method.
>
> You mean it is not enough?
>
> Steven

Yes.

>
> On Mon, 2010-11-29 at 16:47 +0800, Hui Zhu wrote:
>> In this way, you will got a lot of error.
>>
>> Hui
>>
>> On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
>> > does not need change kernel,just write a shell mycc as bellow:
>> >
>> > #!/bin/sh
>> > gcc "$@" -O0
>> >
>> > then
>> >
>> > make CC=./mycc vmlinux
>> >
>> > Hui Zhu said
>> >
>> > On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
>> > wrote:
>> >
>> >
>> > On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>> >
>> >
>> > Hi,
>> >
>> > Now, there are a lot of ways to debug the Linux kernel with GDB, like
>> > qemu, kgtp or kgdb and so on.
>> > But the developer more like add a printk. It have a lot of reason, a big one
>> > is:
>> > (gdb) p ret
>> > $3 = <value optimized out>
>> > And the code execution order is not right.
>> >
>> > This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>> > generate enough debug message with file with -O2.
>> > So GDB cannot work very well with Linux kernel.
>> >
>> > So I make a patch that add a option in "Kernel hacking" called "Close
>> > GCC optimization".  It will make kernel be built without -O2.
>> >
>> > I built and use it in i386 and x86_64.  I will try to make it OK in other
>> > arch.
>> >
>> >
>> >
>> > The problem is that some functions _have to_ be inlined and gcc without -O2
>> > doesn't inline them. Have check all the cases? I doubt.
>> >
>> >
>> > If they really need O2, I set  them to O2.
>> > Actually, this is the main work, find out the file that need the O2.  :)
>> >
>> > For example:
>> > ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> > CFLAGS_fpu.o                           += -O2
>> > CFLAGS_aesni-intel_glue.o              += -O2
>> > CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>> > endif
>> >
>> > And I will try to find more of these type files.
>> >
>> >
>> >
>> > Also, what is size of vmlinux before applying your patch and after that?
>> > Does it increase too much?
>> >
>> >
>> >
>> > Before the patch:
>> > ls -alh vmlinuz-2.6.37-rc3+
>> > -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
>> > ls -alh b26no/vmlinux
>> > -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
>> >
>> > After the patch:
>> > ls -alh vmlinuz-2.6.37-rc3debug+
>> > -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
>> > ls -alh b26/vmlinux
>> > -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
>> >
>> > Thanks,
>> > Hui
>> >
>> >
>> >
>> >
>> > --
>> >
>> > 乔崇 qiaochong@loongson.cn
>> >
>> > 2010年 11月 29日 星期一 16:35:38 CST
>
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:52     ` Américo Wang
@ 2010-11-29  9:11       ` Hui Zhu
  2010-11-29 18:03       ` Valdis.Kletnieks
  2010-11-29 20:51       ` richard -rw- weinberger
  2 siblings, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2010-11-29  9:11 UTC (permalink / raw)
  To: Américo Wang; +Cc: linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 16:52, Américo Wang <xiyou.wangcong@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 04:24:42PM +0800, Hui Zhu wrote:
>>On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>>>Hi,
>>>>
>>>>Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>>>qemu, kgtp or kgdb and so on.
>>>>But the developer more like add a printk. It have a lot of reason, a big one is:
>>>>(gdb) p ret
>>>>$3 = <value optimized out>
>>>>And the code execution order is not right.
>>>>
>>>>This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>>>generate enough debug message with file with -O2.
>>>>So GDB cannot work very well with Linux kernel.
>>>>
>>>>So I make a patch that add a option in "Kernel hacking" called "Close
>>>>GCC optimization".  It will make kernel be built without -O2.
>>>>
>>>>I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>>>
>>>
>>> The problem is that some functions _have to_ be inlined and gcc without -O2
>>> doesn't inline them. Have check all the cases? I doubt.
>>
>>If they really need O2, I set  them to O2.
>>Actually, this is the main work, find out the file that need the O2.  :)
>>
>>For example:
>>ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>>CFLAGS_fpu.o                           += -O2
>>CFLAGS_aesni-intel_glue.o              += -O2
>>CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>>endif
>
> No, I didn't mean this, I meant some function that have to be inlined
> are those who only work when being inlined, e.g. current_text_addr().
>
> I think it is not alone. :)
>
> Also, since many inline functions sit in hot-path, are there any
> performance regressions with your patch applied?
>

I did some nm, looks each file that have inline have a special code
for inline function.

> BTW, you need to Cc kbuild for makefile changes like this.
>

Thanks for you remind me.

Best,
Hui

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:16 ` Américo Wang
  2010-11-29  8:18   ` microcai
  2010-11-29  8:24   ` Hui Zhu
@ 2010-11-29  9:44   ` Christian Borntraeger
  2010-11-29 11:12     ` Segher Boessenkool
  2010-12-01 12:18     ` Hui Zhu
  2 siblings, 2 replies; 45+ messages in thread
From: Christian Borntraeger @ 2010-11-29  9:44 UTC (permalink / raw)
  To: Américo Wang; +Cc: Hui Zhu, linux-kernel, gdb, hellogcc, linux-kbuild

Am 29.11.2010 09:16, schrieb Américo Wang:
> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>> Hi,
>>
>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>> qemu, kgtp or kgdb and so on.
>> But the developer more like add a printk. It have a lot of reason, a big one is:
>> (gdb) p ret
>> $3 = <value optimized out>
>> And the code execution order is not right.
>>
>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>> generate enough debug message with file with -O2.
>> So GDB cannot work very well with Linux kernel.
>>
>> So I make a patch that add a option in "Kernel hacking" called "Close
>> GCC optimization".  It will make kernel be built without -O2.
>>
>> I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>
> 
> The problem is that some functions _have to_ be inlined and gcc without -O2
> doesn't inline them. Have check all the cases? I doubt.

In essence -O2 just tells gcc to activate a list of optimizations
gcc  -Q -O2 --help=optimizers
tells you what.

So what about making this patch much smaller by explicitely using the optimizations
that are absolutely necessary?
e.g: 
-finline-small-functions -finline-functions-called-once
(what else do we need?)

We might even  be able to collapse this with the optimize for size option,
by providing a Kconfig entry that allows to choose between

-O0 -finline-small-functions -finline-functions-called-once
-O1 -finline-small-functions -finline-functions-called-once
-Os
-O2
-O3

Christian

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:47       ` [hellogcc] " Hui Zhu
  2010-11-29  8:55         ` Steven
@ 2010-11-29  9:45         ` 乔崇
  2010-11-29 18:10           ` Valdis.Kletnieks
  2010-12-01 12:23           ` bekars
  1 sibling, 2 replies; 45+ messages in thread
From: 乔崇 @ 2010-11-29  9:45 UTC (permalink / raw)
  To: hellogcc; +Cc: Américo Wang, linux-kernel, gdb

Hui Zhu 写道:
> In this way, you will got a lot of error.
>
> Hui
>
> On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
>   
>> does not need change kernel,just write a shell mycc as bellow:
>>
>> #!/bin/sh
>> gcc "$@" -O0
>>
>>     
change mycc to this will work,:)

#!/bin/sh
gcc "$@" -O0 ||
 gcc "$@" -O1 ||
 gcc "$@"
 

>> then
>>
>> make CC=./mycc vmlinux
>>
>> Hui Zhu said
>>
>> On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
>> wrote:
>>
>>
>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>
>>
>> Hi,
>>
>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>> qemu, kgtp or kgdb and so on.
>> But the developer more like add a printk. It have a lot of reason, a big one
>> is:
>> (gdb) p ret
>> $3 = <value optimized out>
>> And the code execution order is not right.
>>
>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>> generate enough debug message with file with -O2.
>> So GDB cannot work very well with Linux kernel.
>>
>> So I make a patch that add a option in "Kernel hacking" called "Close
>> GCC optimization".  It will make kernel be built without -O2.
>>
>> I built and use it in i386 and x86_64.  I will try to make it OK in other
>> arch.
>>
>>
>>
>> The problem is that some functions _have to_ be inlined and gcc without -O2
>> doesn't inline them. Have check all the cases? I doubt.
>>
>>
>> If they really need O2, I set  them to O2.
>> Actually, this is the main work, find out the file that need the O2.  :)
>>
>> For example:
>> ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> CFLAGS_fpu.o                           += -O2
>> CFLAGS_aesni-intel_glue.o              += -O2
>> CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>> endif
>>
>> And I will try to find more of these type files.
>>
>>
>>
>> Also, what is size of vmlinux before applying your patch and after that?
>> Does it increase too much?
>>
>>
>>
>> Before the patch:
>> ls -alh vmlinuz-2.6.37-rc3+
>> -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
>> ls -alh b26no/vmlinux
>> -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
>>
>> After the patch:
>> ls -alh vmlinuz-2.6.37-rc3debug+
>> -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
>> ls -alh b26/vmlinux
>> -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
>>
>> Thanks,
>> Hui
>>
>>
>>
>>
>> --
>>
>> 乔崇 qiaochong@loongson.cn
>>
>> 2010年 11月 29日 星期一 16:35:38 CST
>>     
>
>
>   


-- 

乔崇 qiaochong@loongson.cn
龙芯中科技术服务中心有限公司
office:010-62600855-615
mobile:13521990614

2010年 11月 29日 星期一 17:38:14 CST

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  3:56 [PATCH] Built kernel without -O2 option Hui Zhu
  2010-11-29  8:16 ` Américo Wang
@ 2010-11-29  9:59 ` Andi Kleen
  2010-11-29 10:12   ` Mark Wielaard
  2010-12-01 12:52   ` Hui Zhu
  2010-11-29 19:05 ` Jan Kratochvil
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 45+ messages in thread
From: Andi Kleen @ 2010-11-29  9:59 UTC (permalink / raw)
  To: Hui Zhu; +Cc: linux-kernel, gdb, hellogcc

Hui Zhu <teawater@gmail.com> writes:

> Now, there are a lot of ways to debug the Linux kernel with GDB, like
> qemu, kgtp or kgdb and so on.
> But the developer more like add a printk. It have a lot of reason, a big one is:
> (gdb) p ret
> $3 = <value optimized out>
> And the code execution order is not right.

Really the right place to fix a lot of this would be gcc (and perhaps
gdb). I suspect with some careful work the debugging experience
for -O2 could be improved a lot.
I also believe the latest gccs already have improvements in this area.

>
> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
> generate enough debug message with file with -O2.
> So GDB cannot work very well with Linux kernel.
>
> So I make a patch that add a option in "Kernel hacking" called "Close
> GCC optimization".  It will make kernel be built without -O2.


You need to at least keep aggressive inlining for header files,
otherwise there will be too much code bloat and bad code.

Like -O1 -finline-functions ? 

-Andi

-- 
ak@linux.intel.com -- Speaking for myself only.

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  9:59 ` Andi Kleen
@ 2010-11-29 10:12   ` Mark Wielaard
  2010-11-30  9:31     ` Américo Wang
  2010-12-01 12:52   ` Hui Zhu
  1 sibling, 1 reply; 45+ messages in thread
From: Mark Wielaard @ 2010-11-29 10:12 UTC (permalink / raw)
  To: Andi Kleen; +Cc: Hui Zhu, linux-kernel, gdb, hellogcc

On Mon, 2010-11-29 at 10:59 +0100, Andi Kleen wrote:
> Hui Zhu <teawater@gmail.com> writes:
> 
> > Now, there are a lot of ways to debug the Linux kernel with GDB, like
> > qemu, kgtp or kgdb and so on.
> > But the developer more like add a printk. It have a lot of reason, a big one is:
> > (gdb) p ret
> > $3 = <value optimized out>
> > And the code execution order is not right.
> 
> Really the right place to fix a lot of this would be gcc (and perhaps
> gdb). I suspect with some careful work the debugging experience
> for -O2 could be improved a lot.
> I also believe the latest gccs already have improvements in this area.

The VTA branch was merged for GCC 4.5
http://gcc.gnu.org/wiki/Var_Tracking_Assignments
Which helps a lot with generating dwarf for previously "optimized out"
values. There were also a couple of papers on generating even better
debuginfo at the recent GCC Summit: http://gcc.gnu.org/wiki/summit2010

Jakub Jelínek, Improving debug info for optimized away parameters
http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=jelinek.pdf
Alexandre Oliva, Consistent Views at Recommended Breakpoints
http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=oliva.pdf

Cheers,

Mark


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  9:44   ` Christian Borntraeger
@ 2010-11-29 11:12     ` Segher Boessenkool
  2010-11-29 11:17       ` Christian Borntraeger
  2010-12-01 12:18     ` Hui Zhu
  1 sibling, 1 reply; 45+ messages in thread
From: Segher Boessenkool @ 2010-11-29 11:12 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Américo Wang, Hui Zhu, linux-kernel, gdb, hellogcc, linux-kbuild

> In essence -O2 just tells gcc to activate a list of optimizations
> gcc  -Q -O2 --help=optimizers
> tells you what.

Not quite; see http://gcc.gnu.org/wiki/FAQ#optimization-options .


Segher


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29 11:12     ` Segher Boessenkool
@ 2010-11-29 11:17       ` Christian Borntraeger
  2010-11-29 11:57         ` Nicholas Mc Guire
  0 siblings, 1 reply; 45+ messages in thread
From: Christian Borntraeger @ 2010-11-29 11:17 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Américo Wang, Hui Zhu, linux-kernel, gdb, hellogcc, linux-kbuild

Am 29.11.2010 12:12, schrieb Segher Boessenkool:
>> In essence -O2 just tells gcc to activate a list of optimizations
>> gcc  -Q -O2 --help=optimizers
>> tells you what.
> 
> Not quite; see http://gcc.gnu.org/wiki/FAQ#optimization-options .
> 

Erm...right. Thank you.

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29 11:17       ` Christian Borntraeger
@ 2010-11-29 11:57         ` Nicholas Mc Guire
  0 siblings, 0 replies; 45+ messages in thread
From: Nicholas Mc Guire @ 2010-11-29 11:57 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Segher Boessenkool, Am?rico Wang, Hui Zhu, linux-kernel, gdb,
	hellogcc, linux-kbuild

On Mon, 29 Nov 2010, Christian Borntraeger wrote:

> Am 29.11.2010 12:12, schrieb Segher Boessenkool:
> >> In essence -O2 just tells gcc to activate a list of optimizations
> >> gcc  -Q -O2 --help=optimizers

I think for completness you would need to pass

 gcc -Wextra -Q -O2 --help=optimizers

or you could miss some options

> >> tells you what.
> > 
> > Not quite; see http://gcc.gnu.org/wiki/FAQ#optimization-options .
> > 
> 
> Erm...right. Thank you.

well I guess you always could explicidly turn off all optioins with 
-fnoWHATEVER you want to disable and thus remove all unwanted flags 
- admitedly a bit painfull though.

hofrat

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:52     ` Américo Wang
  2010-11-29  9:11       ` Hui Zhu
@ 2010-11-29 18:03       ` Valdis.Kletnieks
  2010-11-29 20:51       ` richard -rw- weinberger
  2 siblings, 0 replies; 45+ messages in thread
From: Valdis.Kletnieks @ 2010-11-29 18:03 UTC (permalink / raw)
  To: Américo Wang; +Cc: Hui Zhu, linux-kernel, gdb, hellogcc

[-- Attachment #1: Type: text/plain, Size: 621 bytes --]

On Mon, 29 Nov 2010 16:52:50 +0800, Américo Wang said:

> >For example:
> >ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> >CFLAGS_fpu.o                           += -O2
> >CFLAGS_aesni-intel_glue.o              += -O2
> >CFLAGS_ghash-clmulni-intel_glue.o      += -O2
> >endif
> 
> No, I didn't mean this, I meant some function that have to be inlined
> are those who only work when being inlined, e.g. current_text_addr().
> 
> I think it is not alone. :)

Anything that uses the gcc __builtin_return_adress() extension should also be
audited - that returns different results for inlined and non-inlined callers.


[-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29  9:45         ` 乔崇
@ 2010-11-29 18:10           ` Valdis.Kletnieks
  2010-11-29 18:34             ` Steven J. Magnani
  2010-11-29 22:03             ` Alexey Dobriyan
  2010-12-01 12:23           ` bekars
  1 sibling, 2 replies; 45+ messages in thread
From: Valdis.Kletnieks @ 2010-11-29 18:10 UTC (permalink / raw)
  To: 乔崇; +Cc: hellogcc, Américo Wang, linux-kernel, gdb

[-- Attachment #1: Type: text/plain, Size: 316 bytes --]

On Mon, 29 Nov 2010 17:45:15 +0800, 乔崇 said:

> change mycc to this will work,:)
> 
> #!/bin/sh
> gcc "$@" -O0 ||
>  gcc "$@" -O1 ||
>  gcc "$@"

That may result in issues - the problem is that there are places in the kernel
where 'gcc -O0' will *compile* cleanly, but not actually *run* correctly.


[-- Attachment #2: Type: application/pgp-signature, Size: 227 bytes --]

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29 18:10           ` Valdis.Kletnieks
@ 2010-11-29 18:34             ` Steven J. Magnani
  2010-11-29 22:03             ` Alexey Dobriyan
  1 sibling, 0 replies; 45+ messages in thread
From: Steven J. Magnani @ 2010-11-29 18:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: 乔崇, hellogcc, Américo Wang, gdb, Valdis.Kletnieks

On Mon, 2010-11-29 at 13:10 -0500, Valdis.Kletnieks@vt.edu wrote:
> On Mon, 29 Nov 2010 17:45:15 +0800, 乔崇 said:
> 
> > change mycc to this will work,:)
> > 
> > #!/bin/sh
> > gcc "$@" -O0 ||
> >  gcc "$@" -O1 ||
> >  gcc "$@"
> 
> That may result in issues - the problem is that there are places in the kernel
> where 'gcc -O0' will *compile* cleanly, but not actually *run* correctly.
> 

There may be arch-specific places that cannot be made to run -O0. 
See this thread from a few years ago:

http://www.spinics.net/lists/arm-kernel/msg24836.html

------------------------------------------------------------------------
 Steven J. Magnani               "I claim this network for MARS!
 www.digidescorp.com              Earthling, return my space modulator!"

 #include <standard.disclaimer>



^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  3:56 [PATCH] Built kernel without -O2 option Hui Zhu
  2010-11-29  8:16 ` Américo Wang
  2010-11-29  9:59 ` Andi Kleen
@ 2010-11-29 19:05 ` Jan Kratochvil
  2010-11-29 21:07 ` Arnaud Lacombe
  2011-01-24  7:47 ` Hui Zhu
  4 siblings, 0 replies; 45+ messages in thread
From: Jan Kratochvil @ 2010-11-29 19:05 UTC (permalink / raw)
  To: Hui Zhu; +Cc: linux-kernel, gdb, hellogcc

On Mon, 29 Nov 2010 04:56:15 +0100, Hui Zhu wrote:
> So I make a patch that add a option in "Kernel hacking" called "Close
> GCC optimization".  It will make kernel be built without -O2.

This seems to me as a workaround.  The real fix would be to use
	__attribute__((always_inline))
for functions requiring to be inlined and just compile everything with -O0 -g.

info '(gcc)Function Attributes'
`always_inline'
	Generally, functions are not inlined unless optimization is specified.
	For functions declared inline, this attribute inlines the function
	even if no optimization level was specified.

But `always_inline' has been discussed on linux-kernel million times.
I have not googled out a resolution why it is not applicable to this problem,
do you know why?


Thanks,
Jan

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  8:52     ` Américo Wang
  2010-11-29  9:11       ` Hui Zhu
  2010-11-29 18:03       ` Valdis.Kletnieks
@ 2010-11-29 20:51       ` richard -rw- weinberger
  2010-11-29 21:00         ` Arnaud Lacombe
  2 siblings, 1 reply; 45+ messages in thread
From: richard -rw- weinberger @ 2010-11-29 20:51 UTC (permalink / raw)
  To: Américo Wang; +Cc: Hui Zhu, linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 9:52 AM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 04:24:42PM +0800, Hui Zhu wrote:
>>On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>>>Hi,
>>>>
>>>>Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>>>qemu, kgtp or kgdb and so on.
>>>>But the developer more like add a printk. It have a lot of reason, a big one is:
>>>>(gdb) p ret
>>>>$3 = <value optimized out>
>>>>And the code execution order is not right.
>>>>
>>>>This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>>>generate enough debug message with file with -O2.
>>>>So GDB cannot work very well with Linux kernel.
>>>>
>>>>So I make a patch that add a option in "Kernel hacking" called "Close
>>>>GCC optimization".  It will make kernel be built without -O2.
>>>>
>>>>I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>>>
>>>
>>> The problem is that some functions _have to_ be inlined and gcc without -O2
>>> doesn't inline them. Have check all the cases? I doubt.
>>
>>If they really need O2, I set  them to O2.
>>Actually, this is the main work, find out the file that need the O2.  :)
>>
>>For example:
>>ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>>CFLAGS_fpu.o                           += -O2
>>CFLAGS_aesni-intel_glue.o              += -O2
>>CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>>endif
>
> No, I didn't mean this, I meant some function that have to be inlined
> are those who only work when being inlined, e.g. current_text_addr().

Can you please explain to me why some functions work only when they are inlined?
Is it because of asm() black magic?

> I think it is not alone. :)
>
> Also, since many inline functions sit in hot-path, are there any
> performance regressions with your patch applied?
>
> BTW, you need to Cc kbuild for makefile changes like this.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29 20:51       ` richard -rw- weinberger
@ 2010-11-29 21:00         ` Arnaud Lacombe
  2010-11-29 21:07           ` richard -rw- weinberger
  0 siblings, 1 reply; 45+ messages in thread
From: Arnaud Lacombe @ 2010-11-29 21:00 UTC (permalink / raw)
  To: richard -rw- weinberger
  Cc: Américo Wang, Hui Zhu, linux-kernel, gdb, hellogcc

Hi,

On Mon, Nov 29, 2010 at 3:51 PM, richard -rw- weinberger
<richard.weinberger@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 9:52 AM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>>> [...]
>> No, I didn't mean this, I meant some function that have to be inlined
>> are those who only work when being inlined, e.g. current_text_addr().
>
> Can you please explain to me why some functions work only when they are inlined?
> Is it because of asm() black magic?
>
obviously, you do not understand the purpose of this function...

 - Arnaud

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  3:56 [PATCH] Built kernel without -O2 option Hui Zhu
                   ` (2 preceding siblings ...)
  2010-11-29 19:05 ` Jan Kratochvil
@ 2010-11-29 21:07 ` Arnaud Lacombe
  2010-11-30 22:40   ` Petr Hluzín
  2010-12-01 13:10   ` Hui Zhu
  2011-01-24  7:47 ` Hui Zhu
  4 siblings, 2 replies; 45+ messages in thread
From: Arnaud Lacombe @ 2010-11-29 21:07 UTC (permalink / raw)
  To: Hui Zhu; +Cc: linux-kernel, gdb, hellogcc

Hi,

On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <teawater@gmail.com> wrote:
> Hi,
>
> Now, there are a lot of ways to debug the Linux kernel with GDB, like
> qemu, kgtp or kgdb and so on.
> But the developer more like add a printk. It have a lot of reason, a big one is:
> (gdb) p ret
> $3 = <value optimized out>
> And the code execution order is not right.
>
> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
> generate enough debug message with file with -O2.
> So GDB cannot work very well with Linux kernel.
>
> So I make a patch that add a option in "Kernel hacking" called "Close
> GCC optimization".  It will make kernel be built without -O2.
>
no, it does not, see below ..

> I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>
> And I will put new patch in here and
> http://code.google.com/p/kgtp/downloads/list
>
> Thanks,
> Hui
>
> Signed-off-by: Hui Zhu <teawater@gmail.com>
> ---
> [...]
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_process_$(BITS).o       += -O2
> +CFLAGS_entry_$(BITS).o         += -O2
> +CFLAGS_traps.o                 += -O2
> +CFLAGS_i387.o                  += -O2
> +CFLAGS_xsave.o                 += -O2
> +CFLAGS_hpet.o                  += -O2
> +endif
>
> [...]
>
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
>          - Enable verbose reporting from modpost to help solving
>            the section mismatches reported.
>
> +config CC_CLOSE_OPTIMIZATION
> +       bool "Close GCC optimization"
> +       default n
> +       help
> +         Enabling this option will let gcc build kernel without "-O2".
> +
> +         If unsure, say N.
> +
You are not consistent with yourself, you add an option saying "do not
build the kernel with -O2" and yet, you add "-O2" flags for unknown
reason all over the tree...

 - Arnaud

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29 21:00         ` Arnaud Lacombe
@ 2010-11-29 21:07           ` richard -rw- weinberger
  0 siblings, 0 replies; 45+ messages in thread
From: richard -rw- weinberger @ 2010-11-29 21:07 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Américo Wang, Hui Zhu, linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 10:00 PM, Arnaud Lacombe <lacombar@gmail.com> wrote:
> Hi,
>
> On Mon, Nov 29, 2010 at 3:51 PM, richard -rw- weinberger
> <richard.weinberger@gmail.com> wrote:
>> On Mon, Nov 29, 2010 at 9:52 AM, Américo Wang <xiyou.wangcong@gmail.com> wrote:
>>>> [...]
>>> No, I didn't mean this, I meant some function that have to be inlined
>>> are those who only work when being inlined, e.g. current_text_addr().
>>
>> Can you please explain to me why some functions work only when they are inlined?
>> Is it because of asm() black magic?
>>
> obviously, you do not understand the purpose of this function...

this is why i was asking!

anyway, now i got it.
thanks to peter zijlstra for the kind explanation on #kernelnewbies.

>  - Arnaud
>

-- 
Thanks,
//richard

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29 18:10           ` Valdis.Kletnieks
  2010-11-29 18:34             ` Steven J. Magnani
@ 2010-11-29 22:03             ` Alexey Dobriyan
  2010-12-01 13:21               ` Hui Zhu
  1 sibling, 1 reply; 45+ messages in thread
From: Alexey Dobriyan @ 2010-11-29 22:03 UTC (permalink / raw)
  To: Valdis.Kletnieks
  Cc: 乔崇, hellogcc, Américo Wang, linux-kernel, gdb

On Mon, Nov 29, 2010 at 01:10:29PM -0500, Valdis.Kletnieks@vt.edu wrote:
> That may result in issues - the problem is that there are places in the kernel
> where 'gcc -O0' will *compile* cleanly, but not actually *run* correctly.

Since nobody (no-bo-dy) runs kernel with -O0, I'd suggest original
poster to learn how to debug kernel with constrained information.

I'll be most certainly faster. :^)

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29 10:12   ` Mark Wielaard
@ 2010-11-30  9:31     ` Américo Wang
  2010-11-30 18:40       ` Michael Snyder
  0 siblings, 1 reply; 45+ messages in thread
From: Américo Wang @ 2010-11-30  9:31 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: Andi Kleen, Hui Zhu, linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 11:12:16AM +0100, Mark Wielaard wrote:
>On Mon, 2010-11-29 at 10:59 +0100, Andi Kleen wrote:
>> Hui Zhu <teawater@gmail.com> writes:
>> 
>> > Now, there are a lot of ways to debug the Linux kernel with GDB, like
>> > qemu, kgtp or kgdb and so on.
>> > But the developer more like add a printk. It have a lot of reason, a big one is:
>> > (gdb) p ret
>> > $3 = <value optimized out>
>> > And the code execution order is not right.
>> 
>> Really the right place to fix a lot of this would be gcc (and perhaps
>> gdb). I suspect with some careful work the debugging experience
>> for -O2 could be improved a lot.
>> I also believe the latest gccs already have improvements in this area.
>
>The VTA branch was merged for GCC 4.5
>http://gcc.gnu.org/wiki/Var_Tracking_Assignments
>Which helps a lot with generating dwarf for previously "optimized out"
>values. There were also a couple of papers on generating even better
>debuginfo at the recent GCC Summit: http://gcc.gnu.org/wiki/summit2010
>
>Jakub Jelínek, Improving debug info for optimized away parameters
>http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=jelinek.pdf
>Alexandre Oliva, Consistent Views at Recommended Breakpoints
>http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=oliva.pdf
>

Cool! It would be much more convenient if this is solved by gcc.

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-30  9:31     ` Américo Wang
@ 2010-11-30 18:40       ` Michael Snyder
  0 siblings, 0 replies; 45+ messages in thread
From: Michael Snyder @ 2010-11-30 18:40 UTC (permalink / raw)
  To: Américo Wang
  Cc: Mark Wielaard, Andi Kleen, Hui Zhu, linux-kernel, gdb, hellogcc

Américo Wang wrote:
> On Mon, Nov 29, 2010 at 11:12:16AM +0100, Mark Wielaard wrote:
>> On Mon, 2010-11-29 at 10:59 +0100, Andi Kleen wrote:
>>> Hui Zhu <teawater@gmail.com> writes:
>>>
>>>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>>> qemu, kgtp or kgdb and so on.
>>>> But the developer more like add a printk. It have a lot of reason, a big one is:
>>>> (gdb) p ret
>>>> $3 = <value optimized out>
>>>> And the code execution order is not right.
>>> Really the right place to fix a lot of this would be gcc (and perhaps
>>> gdb). I suspect with some careful work the debugging experience
>>> for -O2 could be improved a lot.
>>> I also believe the latest gccs already have improvements in this area.
>> The VTA branch was merged for GCC 4.5
>> http://gcc.gnu.org/wiki/Var_Tracking_Assignments
>> Which helps a lot with generating dwarf for previously "optimized out"
>> values. There were also a couple of papers on generating even better
>> debuginfo at the recent GCC Summit: http://gcc.gnu.org/wiki/summit2010
>>
>> Jakub Jelínek, Improving debug info for optimized away parameters
>> http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=jelinek.pdf
>> Alexandre Oliva, Consistent Views at Recommended Breakpoints
>> http://gcc.gnu.org/wiki/summit2010?action=AttachFile&do=get&target=oliva.pdf
>>
> 
> Cool! It would be much more convenient if this is solved by gcc.

Those features mentioned at the GCC summit are not real close to 
completion.  I wouldn't put off the discussion just because they're
(possibly) in the pipeline.


^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29 21:07 ` Arnaud Lacombe
@ 2010-11-30 22:40   ` Petr Hluzín
  2010-12-01 13:42     ` Hui Zhu
  2010-12-01 13:10   ` Hui Zhu
  1 sibling, 1 reply; 45+ messages in thread
From: Petr Hluzín @ 2010-11-30 22:40 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: Hui Zhu, linux-kernel, gdb, hellogcc

On 29 November 2010 22:07, Arnaud Lacombe <lacombar@gmail.com> wrote:
> Hi,
>
> On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <teawater@gmail.com> wrote:
>> Hi,
>>
>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>> qemu, kgtp or kgdb and so on.
>> But the developer more like add a printk. It have a lot of reason, a big one is:
>> (gdb) p ret
>> $3 = <value optimized out>
>> And the code execution order is not right.
>>
>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>> generate enough debug message with file with -O2.
>> So GDB cannot work very well with Linux kernel.
>>
>> So I make a patch that add a option in "Kernel hacking" called "Close
>> GCC optimization".  It will make kernel be built without -O2.
>>
> no, it does not, see below ..
>
>> I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>
>> And I will put new patch in here and
>> http://code.google.com/p/kgtp/downloads/list
>>
>> Thanks,
>> Hui
>>
>> Signed-off-by: Hui Zhu <teawater@gmail.com>
>> ---
>> [...]
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_process_$(BITS).o       += -O2
>> +CFLAGS_entry_$(BITS).o         += -O2
>> +CFLAGS_traps.o                 += -O2
>> +CFLAGS_i387.o                  += -O2
>> +CFLAGS_xsave.o                 += -O2
>> +CFLAGS_hpet.o                  += -O2
>> +endif
>>
>> [...]
>>
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
>>          - Enable verbose reporting from modpost to help solving
>>            the section mismatches reported.
>>
>> +config CC_CLOSE_OPTIMIZATION
>> +       bool "Close GCC optimization"
>> +       default n
>> +       help
>> +         Enabling this option will let gcc build kernel without "-O2".
>> +
>> +         If unsure, say N.
>> +
> You are not consistent with yourself, you add an option saying "do not
> build the kernel with -O2" and yet, you add "-O2" flags for unknown
> reason all over the tree...

The patch removes -O2 compilation flag from all files (see the
fragment below) and adds the flag to the few files that actually need
the flag. Unfortunately the patch does not explain that and the noise
of adding the flag obscures the main thing.

>> +++ b/Makefile
>> @@ -540,8 +540,10 @@ all: vmlinux
>>  ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>>  KBUILD_CFLAGS  += -Os
>>  else
>> +ifndef CONFIG_CC_CLOSE_OPTIMIZATION
>>  KBUILD_CFLAGS  += -O2
>>  endif
>> +endif

Hui, The name of the config option is close to meaningless. I suggest:

- config CONFIG_CC_CLOSE_OPTIMIZATION
-       bool "Close GCC optimization"
+ config CONFIG_CC_NO_OPTIMIZATION
+       bool "Compile with almost no optimization"
        default n
        help
-          Enabling this option will let gcc build kernel without "-O2".
+          Enabling this option will let gcc build kernel with no
optimization (where possible).
+           This makes debugging friendlier.


-- 
Petr Hluzin

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  9:44   ` Christian Borntraeger
  2010-11-29 11:12     ` Segher Boessenkool
@ 2010-12-01 12:18     ` Hui Zhu
  1 sibling, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2010-12-01 12:18 UTC (permalink / raw)
  To: Christian Borntraeger
  Cc: Américo Wang, linux-kernel, gdb, hellogcc, linux-kbuild

On Mon, Nov 29, 2010 at 17:44, Christian Borntraeger
<borntraeger@de.ibm.com> wrote:
> Am 29.11.2010 09:16, schrieb Américo Wang:
>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>> Hi,
>>>
>>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>> qemu, kgtp or kgdb and so on.
>>> But the developer more like add a printk. It have a lot of reason, a big one is:
>>> (gdb) p ret
>>> $3 = <value optimized out>
>>> And the code execution order is not right.
>>>
>>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>> generate enough debug message with file with -O2.
>>> So GDB cannot work very well with Linux kernel.
>>>
>>> So I make a patch that add a option in "Kernel hacking" called "Close
>>> GCC optimization".  It will make kernel be built without -O2.
>>>
>>> I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>>
>>
>> The problem is that some functions _have to_ be inlined and gcc without -O2
>> doesn't inline them. Have check all the cases? I doubt.
>
> In essence -O2 just tells gcc to activate a list of optimizations
> gcc  -Q -O2 --help=optimizers
> tells you what.
>
> So what about making this patch much smaller by explicitely using the optimizations
> that are absolutely necessary?
> e.g:
> -finline-small-functions -finline-functions-called-once
> (what else do we need?)
>
> We might even  be able to collapse this with the optimize for size option,
> by providing a Kconfig entry that allows to choose between
>
> -O0 -finline-small-functions -finline-functions-called-once
> -O1 -finline-small-functions -finline-functions-called-once
> -Os
> -O2
> -O3
>
> Christian
>

Hi Christian.

If we can build without any optimization options just set some file to O2.
I think keep it it will better than add some optimization options to
all files, right?

But make for this file that I add O2 to them, I can change them to to
some others options like "-O0 -finline-small-functions
-finline-functions-called-once".

Thanks,
Hui

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29  9:45         ` 乔崇
  2010-11-29 18:10           ` Valdis.Kletnieks
@ 2010-12-01 12:23           ` bekars
  2010-12-01 13:24             ` Hui Zhu
  1 sibling, 1 reply; 45+ messages in thread
From: bekars @ 2010-12-01 12:23 UTC (permalink / raw)
  To: hellogcc; +Cc: Américo Wang, linux-kernel, gdb

这个好像不行,我在2.6.35.4内核上编译,报错:

  ./mm.sh -Wp,-MD,arch/x86/kernel/.entry_32.o.d  -nostdinc -isystem
/usr/lib/gcc/i486-linux-gnu/4.3.2/include
-I/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include
-Iinclude  -include include/generated/autoconf.h -D__KERNEL__
-D__ASSEMBLY__ -m32 -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1
-DCONFIG_AS_CFI_SECTIONS=1  -gdwarf-2        -c -o
arch/x86/kernel/entry_32.o arch/x86/kernel/entry_32.S
/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
Assembler messages:
/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
Error: unknown pseudo-op: `.cfi_sections'
/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
Assembler messages:
/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
Error: unknown pseudo-op: `.cfi_sections'
/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
Assembler messages:
/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
Error: unknown pseudo-op: `.cfi_sections'
make[2]: *** [arch/x86/kernel/entry_32.o] Error 1
make[1]: *** [arch/x86/kernel] Error 2
make: *** [arch/x86] Error 2



在 2010年11月29日 下午5:45,乔崇 <qiaochong@loongson.cn> 写道:
> Hui Zhu 写道:
>> In this way, you will got a lot of error.
>>
>> Hui
>>
>> On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
>>
>>> does not need change kernel,just write a shell mycc as bellow:
>>>
>>> #!/bin/sh
>>> gcc "$@" -O0
>>>
>>>
> change mycc to this will work,:)
>
> #!/bin/sh
> gcc "$@" -O0 ||
>  gcc "$@" -O1 ||
>  gcc "$@"
>
>
>>> then
>>>
>>> make CC=./mycc vmlinux
>>>
>>> Hui Zhu said
>>>
>>> On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
>>> wrote:
>>>
>>>
>>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>>
>>>
>>> Hi,
>>>
>>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>> qemu, kgtp or kgdb and so on.
>>> But the developer more like add a printk. It have a lot of reason, a big one
>>> is:
>>> (gdb) p ret
>>> $3 = <value optimized out>
>>> And the code execution order is not right.
>>>
>>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>> generate enough debug message with file with -O2.
>>> So GDB cannot work very well with Linux kernel.
>>>
>>> So I make a patch that add a option in "Kernel hacking" called "Close
>>> GCC optimization".  It will make kernel be built without -O2.
>>>
>>> I built and use it in i386 and x86_64.  I will try to make it OK in other
>>> arch.
>>>
>>>
>>>
>>> The problem is that some functions _have to_ be inlined and gcc without -O2
>>> doesn't inline them. Have check all the cases? I doubt.
>>>
>>>
>>> If they really need O2, I set  them to O2.
>>> Actually, this is the main work, find out the file that need the O2.  :)
>>>
>>> For example:
>>> ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>>> CFLAGS_fpu.o                           += -O2
>>> CFLAGS_aesni-intel_glue.o              += -O2
>>> CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>>> endif
>>>
>>> And I will try to find more of these type files.
>>>
>>>
>>>
>>> Also, what is size of vmlinux before applying your patch and after that?
>>> Does it increase too much?
>>>
>>>
>>>
>>> Before the patch:
>>> ls -alh vmlinuz-2.6.37-rc3+
>>> -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
>>> ls -alh b26no/vmlinux
>>> -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
>>>
>>> After the patch:
>>> ls -alh vmlinuz-2.6.37-rc3debug+
>>> -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
>>> ls -alh b26/vmlinux
>>> -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
>>>
>>> Thanks,
>>> Hui
>>>
>>>
>>>
>>>
>>> --
>>>
>>> 乔崇 qiaochong@loongson.cn
>>>
>>> 2010年 11月 29日 星期一 16:35:38 CST
>>>
>>
>>
>>
>
>
> --
>
> 乔崇 qiaochong@loongson.cn
> 龙芯中科技术服务中心有限公司
> office:010-62600855-615
> mobile:13521990614
>
> 2010年 11月 29日 星期一 17:38:14 CST
>
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  9:59 ` Andi Kleen
  2010-11-29 10:12   ` Mark Wielaard
@ 2010-12-01 12:52   ` Hui Zhu
  1 sibling, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2010-12-01 12:52 UTC (permalink / raw)
  To: Andi Kleen; +Cc: linux-kernel, gdb, hellogcc

On Mon, Nov 29, 2010 at 17:59, Andi Kleen <andi@firstfloor.org> wrote:
> Hui Zhu <teawater@gmail.com> writes:
>
>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>> qemu, kgtp or kgdb and so on.
>> But the developer more like add a printk. It have a lot of reason, a big one is:
>> (gdb) p ret
>> $3 = <value optimized out>
>> And the code execution order is not right.
>
> Really the right place to fix a lot of this would be gcc (and perhaps
> gdb). I suspect with some careful work the debugging experience
> for -O2 could be improved a lot.
> I also believe the latest gccs already have improvements in this area.
>

If you think they are OK, go get a new gcc and try.  :)

>>
>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>> generate enough debug message with file with -O2.
>> So GDB cannot work very well with Linux kernel.
>>
>> So I make a patch that add a option in "Kernel hacking" called "Close
>> GCC optimization".  It will make kernel be built without -O2.
>
>
> You need to at least keep aggressive inlining for header files,
> otherwise there will be too much code bloat and bad code.
>
> Like -O1 -finline-functions ?
>

If I can build OK, why I need add some options?

Thanks,
Hui

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29 21:07 ` Arnaud Lacombe
  2010-11-30 22:40   ` Petr Hluzín
@ 2010-12-01 13:10   ` Hui Zhu
  1 sibling, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2010-12-01 13:10 UTC (permalink / raw)
  To: Arnaud Lacombe; +Cc: linux-kernel, gdb, hellogcc

On Tue, Nov 30, 2010 at 05:07, Arnaud Lacombe <lacombar@gmail.com> wrote:
> Hi,
>
> On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <teawater@gmail.com> wrote:
>> Hi,
>>
>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>> qemu, kgtp or kgdb and so on.
>> But the developer more like add a printk. It have a lot of reason, a big one is:
>> (gdb) p ret
>> $3 = <value optimized out>
>> And the code execution order is not right.
>>
>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>> generate enough debug message with file with -O2.
>> So GDB cannot work very well with Linux kernel.
>>
>> So I make a patch that add a option in "Kernel hacking" called "Close
>> GCC optimization".  It will make kernel be built without -O2.
>>
> no, it does not, see below ..
>
>> I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>
>> And I will put new patch in here and
>> http://code.google.com/p/kgtp/downloads/list
>>
>> Thanks,
>> Hui
>>
>> Signed-off-by: Hui Zhu <teawater@gmail.com>
>> ---
>> [...]
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_process_$(BITS).o       += -O2
>> +CFLAGS_entry_$(BITS).o         += -O2
>> +CFLAGS_traps.o                 += -O2
>> +CFLAGS_i387.o                  += -O2
>> +CFLAGS_xsave.o                 += -O2
>> +CFLAGS_hpet.o                  += -O2
>> +endif
>>
>> [...]
>>
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
>>          - Enable verbose reporting from modpost to help solving
>>            the section mismatches reported.
>>
>> +config CC_CLOSE_OPTIMIZATION
>> +       bool "Close GCC optimization"
>> +       default n
>> +       help
>> +         Enabling this option will let gcc build kernel without "-O2".
>> +
>> +         If unsure, say N.
>> +
> You are not consistent with yourself, you add an option saying "do not
> build the kernel with -O2" and yet, you add "-O2" flags for unknown
> reason all over the tree...
>
>  - Arnaud
>

You are really good at English.  But not mathematics.

Add -O2 to build 30 files is better than add -O2 to all files(who know
how much files in Linux Kernel?).

Thanks,
Hui

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-11-29 22:03             ` Alexey Dobriyan
@ 2010-12-01 13:21               ` Hui Zhu
  0 siblings, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2010-12-01 13:21 UTC (permalink / raw)
  To: Alexey Dobriyan
  Cc: Valdis.Kletnieks, 乔崇,
	hellogcc, Américo Wang, linux-kernel, gdb

On Tue, Nov 30, 2010 at 06:03, Alexey Dobriyan <adobriyan@gmail.com> wrote:
> On Mon, Nov 29, 2010 at 01:10:29PM -0500, Valdis.Kletnieks@vt.edu wrote:
>> That may result in issues - the problem is that there are places in the kernel
>> where 'gcc -O0' will *compile* cleanly, but not actually *run* correctly.
>
> Since nobody (no-bo-dy) runs kernel with -O0, I'd suggest original
> poster to learn how to debug kernel with constrained information.
>
> I'll be most certainly faster. :^)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

Do you know Linux kernel cannot be built with "gcc -O0" now?
I think you should said "Since nobody (no-bo-dy) don't want built
kernel with -O0".

But how you know all the people's idea?  :)

Thanks,
Hui

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-12-01 12:23           ` bekars
@ 2010-12-01 13:24             ` Hui Zhu
  2010-12-01 13:58               ` bekars
  0 siblings, 1 reply; 45+ messages in thread
From: Hui Zhu @ 2010-12-01 13:24 UTC (permalink / raw)
  To: hellogcc; +Cc: Américo Wang, linux-kernel, gdb

2.6.35.4 is a little old.

What I try is 2.6.37-rc3+ and 2.6.37-rc4+ amd64 and i386.

Thanks,
Hui

2010/12/1 bekars <bekars@gmail.com>:
> 这个好像不行,我在2.6.35.4内核上编译,报错:
>
>  ./mm.sh -Wp,-MD,arch/x86/kernel/.entry_32.o.d  -nostdinc -isystem
> /usr/lib/gcc/i486-linux-gnu/4.3.2/include
> -I/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include
> -Iinclude  -include include/generated/autoconf.h -D__KERNEL__
> -D__ASSEMBLY__ -m32 -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1
> -DCONFIG_AS_CFI_SECTIONS=1  -gdwarf-2        -c -o
> arch/x86/kernel/entry_32.o arch/x86/kernel/entry_32.S
> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
> Assembler messages:
> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
> Error: unknown pseudo-op: `.cfi_sections'
> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
> Assembler messages:
> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
> Error: unknown pseudo-op: `.cfi_sections'
> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
> Assembler messages:
> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
> Error: unknown pseudo-op: `.cfi_sections'
> make[2]: *** [arch/x86/kernel/entry_32.o] Error 1
> make[1]: *** [arch/x86/kernel] Error 2
> make: *** [arch/x86] Error 2
>
>
>
> 在 2010年11月29日 下午5:45,乔崇 <qiaochong@loongson.cn> 写道:
>> Hui Zhu 写道:
>>> In this way, you will got a lot of error.
>>>
>>> Hui
>>>
>>> On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
>>>
>>>> does not need change kernel,just write a shell mycc as bellow:
>>>>
>>>> #!/bin/sh
>>>> gcc "$@" -O0
>>>>
>>>>
>> change mycc to this will work,:)
>>
>> #!/bin/sh
>> gcc "$@" -O0 ||
>>  gcc "$@" -O1 ||
>>  gcc "$@"
>>
>>
>>>> then
>>>>
>>>> make CC=./mycc vmlinux
>>>>
>>>> Hui Zhu said
>>>>
>>>> On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
>>>> wrote:
>>>>
>>>>
>>>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>>>
>>>>
>>>> Hi,
>>>>
>>>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>>> qemu, kgtp or kgdb and so on.
>>>> But the developer more like add a printk. It have a lot of reason, a big one
>>>> is:
>>>> (gdb) p ret
>>>> $3 = <value optimized out>
>>>> And the code execution order is not right.
>>>>
>>>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>>> generate enough debug message with file with -O2.
>>>> So GDB cannot work very well with Linux kernel.
>>>>
>>>> So I make a patch that add a option in "Kernel hacking" called "Close
>>>> GCC optimization".  It will make kernel be built without -O2.
>>>>
>>>> I built and use it in i386 and x86_64.  I will try to make it OK in other
>>>> arch.
>>>>
>>>>
>>>>
>>>> The problem is that some functions _have to_ be inlined and gcc without -O2
>>>> doesn't inline them. Have check all the cases? I doubt.
>>>>
>>>>
>>>> If they really need O2, I set  them to O2.
>>>> Actually, this is the main work, find out the file that need the O2.  :)
>>>>
>>>> For example:
>>>> ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>>>> CFLAGS_fpu.o                           += -O2
>>>> CFLAGS_aesni-intel_glue.o              += -O2
>>>> CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>>>> endif
>>>>
>>>> And I will try to find more of these type files.
>>>>
>>>>
>>>>
>>>> Also, what is size of vmlinux before applying your patch and after that?
>>>> Does it increase too much?
>>>>
>>>>
>>>>
>>>> Before the patch:
>>>> ls -alh vmlinuz-2.6.37-rc3+
>>>> -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
>>>> ls -alh b26no/vmlinux
>>>> -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
>>>>
>>>> After the patch:
>>>> ls -alh vmlinuz-2.6.37-rc3debug+
>>>> -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
>>>> ls -alh b26/vmlinux
>>>> -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
>>>>
>>>> Thanks,
>>>> Hui
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> 乔崇 qiaochong@loongson.cn
>>>>
>>>> 2010年 11月 29日 星期一 16:35:38 CST
>>>>
>>>
>>>
>>>
>>
>>
>> --
>>
>> 乔崇 qiaochong@loongson.cn
>> 龙芯中科技术服务中心有限公司
>> office:010-62600855-615
>> mobile:13521990614
>>
>> 2010年 11月 29日 星期一 17:38:14 CST
>>
>>
>
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-30 22:40   ` Petr Hluzín
@ 2010-12-01 13:42     ` Hui Zhu
  0 siblings, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2010-12-01 13:42 UTC (permalink / raw)
  To: Petr Hluzín; +Cc: Arnaud Lacombe, linux-kernel, gdb, hellogcc

On Wed, Dec 1, 2010 at 06:40, Petr Hluzín <petr.hluzin@gmail.com> wrote:
> On 29 November 2010 22:07, Arnaud Lacombe <lacombar@gmail.com> wrote:
>> Hi,
>>
>> On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <teawater@gmail.com> wrote:
>>> Hi,
>>>
>>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>> qemu, kgtp or kgdb and so on.
>>> But the developer more like add a printk. It have a lot of reason, a big one is:
>>> (gdb) p ret
>>> $3 = <value optimized out>
>>> And the code execution order is not right.
>>>
>>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>> generate enough debug message with file with -O2.
>>> So GDB cannot work very well with Linux kernel.
>>>
>>> So I make a patch that add a option in "Kernel hacking" called "Close
>>> GCC optimization".  It will make kernel be built without -O2.
>>>
>> no, it does not, see below ..
>>
>>> I built and use it in i386 and x86_64.  I will try to make it OK in other arch.
>>>
>>> And I will put new patch in here and
>>> http://code.google.com/p/kgtp/downloads/list
>>>
>>> Thanks,
>>> Hui
>>>
>>> Signed-off-by: Hui Zhu <teawater@gmail.com>
>>> ---
>>> [...]
>>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>>> +CFLAGS_process_$(BITS).o       += -O2
>>> +CFLAGS_entry_$(BITS).o         += -O2
>>> +CFLAGS_traps.o                 += -O2
>>> +CFLAGS_i387.o                  += -O2
>>> +CFLAGS_xsave.o                 += -O2
>>> +CFLAGS_hpet.o                  += -O2
>>> +endif
>>>
>>> [...]
>>>
>>> --- a/lib/Kconfig.debug
>>> +++ b/lib/Kconfig.debug
>>> @@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
>>>          - Enable verbose reporting from modpost to help solving
>>>            the section mismatches reported.
>>>
>>> +config CC_CLOSE_OPTIMIZATION
>>> +       bool "Close GCC optimization"
>>> +       default n
>>> +       help
>>> +         Enabling this option will let gcc build kernel without "-O2".
>>> +
>>> +         If unsure, say N.
>>> +
>> You are not consistent with yourself, you add an option saying "do not
>> build the kernel with -O2" and yet, you add "-O2" flags for unknown
>> reason all over the tree...
>
> The patch removes -O2 compilation flag from all files (see the
> fragment below) and adds the flag to the few files that actually need
> the flag. Unfortunately the patch does not explain that and the noise
> of adding the flag obscures the main thing.
>
>>> +++ b/Makefile
>>> @@ -540,8 +540,10 @@ all: vmlinux
>>>  ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>>>  KBUILD_CFLAGS  += -Os
>>>  else
>>> +ifndef CONFIG_CC_CLOSE_OPTIMIZATION
>>>  KBUILD_CFLAGS  += -O2
>>>  endif
>>> +endif
>
> Hui, The name of the config option is close to meaningless. I suggest:
>
> - config CONFIG_CC_CLOSE_OPTIMIZATION
> -       bool "Close GCC optimization"
> + config CONFIG_CC_NO_OPTIMIZATION
> +       bool "Compile with almost no optimization"
>        default n
>        help
> -          Enabling this option will let gcc build kernel without "-O2".
> +          Enabling this option will let gcc build kernel with no
> optimization (where possible).
> +           This makes debugging friendlier.
>
>
> --
> Petr Hluzin
>

Thanks Petr.

I will fix them add try add some comments.

Thanks,
Hui

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-12-01 13:24             ` Hui Zhu
@ 2010-12-01 13:58               ` bekars
  2010-12-01 15:01                 ` Hui Zhu
  0 siblings, 1 reply; 45+ messages in thread
From: bekars @ 2010-12-01 13:58 UTC (permalink / raw)
  To: hellogcc; +Cc: Américo Wang, linux-kernel, gdb

我实验的是
>>> #!/bin/sh
>>> gcc "$@" -O0 ||
>>>  gcc "$@" -O1 ||
>>>  gcc "$@"
>>>
>>>
>>>>> then
>>>>>
>>>>> make CC=./mycc vmlinux

这个方法,感觉简单些,但是编译不过,你的patch我明天试试。

我要调试网络系统,于是修改了net/Makefile,加上KBUILD_CFLAGS  +=
-O0,编译之后能启动内核,但是一有网络通信就panic了,内核顶层的Makefile我用的是-O1优化选项

请问是不是一部分用-O0,一部分用-O2或-O1,编译出来的内核会不稳定?


在 2010年12月1日 下午9:24,Hui Zhu <teawater@gmail.com> 写道:
> 2.6.35.4 is a little old.
>
> What I try is 2.6.37-rc3+ and 2.6.37-rc4+ amd64 and i386.
>
> Thanks,
> Hui
>
> 2010/12/1 bekars <bekars@gmail.com>:
>> 这个好像不行,我在2.6.35.4内核上编译,报错:
>>
>>  ./mm.sh -Wp,-MD,arch/x86/kernel/.entry_32.o.d  -nostdinc -isystem
>> /usr/lib/gcc/i486-linux-gnu/4.3.2/include
>> -I/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include
>> -Iinclude  -include include/generated/autoconf.h -D__KERNEL__
>> -D__ASSEMBLY__ -m32 -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1
>> -DCONFIG_AS_CFI_SECTIONS=1  -gdwarf-2        -c -o
>> arch/x86/kernel/entry_32.o arch/x86/kernel/entry_32.S
>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
>> Assembler messages:
>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
>> Error: unknown pseudo-op: `.cfi_sections'
>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
>> Assembler messages:
>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
>> Error: unknown pseudo-op: `.cfi_sections'
>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
>> Assembler messages:
>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
>> Error: unknown pseudo-op: `.cfi_sections'
>> make[2]: *** [arch/x86/kernel/entry_32.o] Error 1
>> make[1]: *** [arch/x86/kernel] Error 2
>> make: *** [arch/x86] Error 2
>>
>>
>>
>> 在 2010年11月29日 下午5:45,乔崇 <qiaochong@loongson.cn> 写道:
>>> Hui Zhu 写道:
>>>> In this way, you will got a lot of error.
>>>>
>>>> Hui
>>>>
>>>> On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
>>>>
>>>>> does not need change kernel,just write a shell mycc as bellow:
>>>>>
>>>>> #!/bin/sh
>>>>> gcc "$@" -O0
>>>>>
>>>>>
>>> change mycc to this will work,:)
>>>
>>> #!/bin/sh
>>> gcc "$@" -O0 ||
>>>  gcc "$@" -O1 ||
>>>  gcc "$@"
>>>
>>>
>>>>> then
>>>>>
>>>>> make CC=./mycc vmlinux
>>>>>
>>>>> Hui Zhu said
>>>>>
>>>>> On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
>>>>> wrote:
>>>>>
>>>>>
>>>>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>>>>
>>>>>
>>>>> Hi,
>>>>>
>>>>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>>>> qemu, kgtp or kgdb and so on.
>>>>> But the developer more like add a printk. It have a lot of reason, a big one
>>>>> is:
>>>>> (gdb) p ret
>>>>> $3 = <value optimized out>
>>>>> And the code execution order is not right.
>>>>>
>>>>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>>>> generate enough debug message with file with -O2.
>>>>> So GDB cannot work very well with Linux kernel.
>>>>>
>>>>> So I make a patch that add a option in "Kernel hacking" called "Close
>>>>> GCC optimization".  It will make kernel be built without -O2.
>>>>>
>>>>> I built and use it in i386 and x86_64.  I will try to make it OK in other
>>>>> arch.
>>>>>
>>>>>
>>>>>
>>>>> The problem is that some functions _have to_ be inlined and gcc without -O2
>>>>> doesn't inline them. Have check all the cases? I doubt.
>>>>>
>>>>>
>>>>> If they really need O2, I set  them to O2.
>>>>> Actually, this is the main work, find out the file that need the O2.  :)
>>>>>
>>>>> For example:
>>>>> ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>>>>> CFLAGS_fpu.o                           += -O2
>>>>> CFLAGS_aesni-intel_glue.o              += -O2
>>>>> CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>>>>> endif
>>>>>
>>>>> And I will try to find more of these type files.
>>>>>
>>>>>
>>>>>
>>>>> Also, what is size of vmlinux before applying your patch and after that?
>>>>> Does it increase too much?
>>>>>
>>>>>
>>>>>
>>>>> Before the patch:
>>>>> ls -alh vmlinuz-2.6.37-rc3+
>>>>> -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
>>>>> ls -alh b26no/vmlinux
>>>>> -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
>>>>>
>>>>> After the patch:
>>>>> ls -alh vmlinuz-2.6.37-rc3debug+
>>>>> -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
>>>>> ls -alh b26/vmlinux
>>>>> -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
>>>>>
>>>>> Thanks,
>>>>> Hui
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> 乔崇 qiaochong@loongson.cn
>>>>>
>>>>> 2010年 11月 29日 星期一 16:35:38 CST
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>> --
>>>
>>> 乔崇 qiaochong@loongson.cn
>>> 龙芯中科技术服务中心有限公司
>>> office:010-62600855-615
>>> mobile:13521990614
>>>
>>> 2010年 11月 29日 星期一 17:38:14 CST
>>>
>>>
>>
>>
>
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-12-01 13:58               ` bekars
@ 2010-12-01 15:01                 ` Hui Zhu
  2010-12-01 15:42                   ` jovi zhang
  0 siblings, 1 reply; 45+ messages in thread
From: Hui Zhu @ 2010-12-01 15:01 UTC (permalink / raw)
  To: hellogcc; +Cc: Américo Wang, linux-kernel, gdb

2010/12/1 bekars <bekars@gmail.com>:
> 我实验的是
>>>> #!/bin/sh
>>>> gcc "$@" -O0 ||
>>>>  gcc "$@" -O1 ||
>>>>  gcc "$@"
>>>>
>>>>
>>>>>> then
>>>>>>
>>>>>> make CC=./mycc vmlinux
>
> 这个方法,感觉简单些,但是编译不过,你的patch我明天试试。
>
> 我要调试网络系统,于是修改了net/Makefile,加上KBUILD_CFLAGS  +=
> -O0,编译之后能启动内核,但是一有网络通信就panic了,内核顶层的Makefile我用的是-O1优化选项
>
> 请问是不是一部分用-O0,一部分用-O2或-O1,编译出来的内核会不稳定?
>
>

I think is because some function without -O2 will need a lot of stack
(I got some warning about it when I built).
Call this function will make kernel stack overflow.

So I add some function to -O2 and increase the stack size of amd64.

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+#define THREAD_ORDER   2
+#else
 #define THREAD_ORDER   1
+#endif
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE - 1))

Thanks,
Hui



> 在 2010年12月1日 下午9:24,Hui Zhu <teawater@gmail.com> 写道:
>> 2.6.35.4 is a little old.
>>
>> What I try is 2.6.37-rc3+ and 2.6.37-rc4+ amd64 and i386.
>>
>> Thanks,
>> Hui
>>
>> 2010/12/1 bekars <bekars@gmail.com>:
>>> 这个好像不行,我在2.6.35.4内核上编译,报错:
>>>
>>>  ./mm.sh -Wp,-MD,arch/x86/kernel/.entry_32.o.d  -nostdinc -isystem
>>> /usr/lib/gcc/i486-linux-gnu/4.3.2/include
>>> -I/home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include
>>> -Iinclude  -include include/generated/autoconf.h -D__KERNEL__
>>> -D__ASSEMBLY__ -m32 -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1
>>> -DCONFIG_AS_CFI_SECTIONS=1  -gdwarf-2        -c -o
>>> arch/x86/kernel/entry_32.o arch/x86/kernel/entry_32.S
>>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
>>> Assembler messages:
>>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
>>> Error: unknown pseudo-op: `.cfi_sections'
>>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
>>> Assembler messages:
>>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
>>> Error: unknown pseudo-op: `.cfi_sections'
>>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:
>>> Assembler messages:
>>> /home/baiyu/Melon/RSW3/base_system/linux.DEV/LKGDB/arch/x86/include/asm/dwarf2.h:46:
>>> Error: unknown pseudo-op: `.cfi_sections'
>>> make[2]: *** [arch/x86/kernel/entry_32.o] Error 1
>>> make[1]: *** [arch/x86/kernel] Error 2
>>> make: *** [arch/x86] Error 2
>>>
>>>
>>>
>>> 在 2010年11月29日 下午5:45,乔崇 <qiaochong@loongson.cn> 写道:
>>>> Hui Zhu 写道:
>>>>> In this way, you will got a lot of error.
>>>>>
>>>>> Hui
>>>>>
>>>>> On Mon, Nov 29, 2010 at 16:41, 乔崇 <qiaochong@loongson.cn> wrote:
>>>>>
>>>>>> does not need change kernel,just write a shell mycc as bellow:
>>>>>>
>>>>>> #!/bin/sh
>>>>>> gcc "$@" -O0
>>>>>>
>>>>>>
>>>> change mycc to this will work,:)
>>>>
>>>> #!/bin/sh
>>>> gcc "$@" -O0 ||
>>>>  gcc "$@" -O1 ||
>>>>  gcc "$@"
>>>>
>>>>
>>>>>> then
>>>>>>
>>>>>> make CC=./mycc vmlinux
>>>>>>
>>>>>> Hui Zhu said
>>>>>>
>>>>>> On Mon, Nov 29, 2010 at 16:16, Américo Wang <xiyou.wangcong@gmail.com>
>>>>>> wrote:
>>>>>>
>>>>>>
>>>>>> On Mon, Nov 29, 2010 at 11:56:15AM +0800, Hui Zhu wrote:
>>>>>>
>>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> Now, there are a lot of ways to debug the Linux kernel with GDB, like
>>>>>> qemu, kgtp or kgdb and so on.
>>>>>> But the developer more like add a printk. It have a lot of reason, a big one
>>>>>> is:
>>>>>> (gdb) p ret
>>>>>> $3 = <value optimized out>
>>>>>> And the code execution order is not right.
>>>>>>
>>>>>> This is becuase the Kernel is bult with gcc -O2.  Gcc will not
>>>>>> generate enough debug message with file with -O2.
>>>>>> So GDB cannot work very well with Linux kernel.
>>>>>>
>>>>>> So I make a patch that add a option in "Kernel hacking" called "Close
>>>>>> GCC optimization".  It will make kernel be built without -O2.
>>>>>>
>>>>>> I built and use it in i386 and x86_64.  I will try to make it OK in other
>>>>>> arch.
>>>>>>
>>>>>>
>>>>>>
>>>>>> The problem is that some functions _have to_ be inlined and gcc without -O2
>>>>>> doesn't inline them. Have check all the cases? I doubt.
>>>>>>
>>>>>>
>>>>>> If they really need O2, I set  them to O2.
>>>>>> Actually, this is the main work, find out the file that need the O2.  :)
>>>>>>
>>>>>> For example:
>>>>>> ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>>>>>> CFLAGS_fpu.o                           += -O2
>>>>>> CFLAGS_aesni-intel_glue.o              += -O2
>>>>>> CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>>>>>> endif
>>>>>>
>>>>>> And I will try to find more of these type files.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Also, what is size of vmlinux before applying your patch and after that?
>>>>>> Does it increase too much?
>>>>>>
>>>>>>
>>>>>>
>>>>>> Before the patch:
>>>>>> ls -alh vmlinuz-2.6.37-rc3+
>>>>>> -rw-r--r-- 1 root root 4.1M 2010-11-25 12:02 vmlinuz-2.6.37-rc3+
>>>>>> ls -alh b26no/vmlinux
>>>>>> -rwxr-xr-x 1 teawater teawater 135M 2010-11-25 13:31 b26no/vmlinux
>>>>>>
>>>>>> After the patch:
>>>>>> ls -alh vmlinuz-2.6.37-rc3debug+
>>>>>> -rw-r--r-- 1 root root 4.6M 2010-11-25 14:02 vmlinuz-2.6.37-rc3debug+
>>>>>> ls -alh b26/vmlinux
>>>>>> -rwxr-xr-x 1 teawater teawater 140M 2010-11-25 11:14 b26/vmlinux
>>>>>>
>>>>>> Thanks,
>>>>>> Hui
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>>
>>>>>> 乔崇 qiaochong@loongson.cn
>>>>>>
>>>>>> 2010年 11月 29日 星期一 16:35:38 CST
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> 乔崇 qiaochong@loongson.cn
>>>> 龙芯中科技术服务中心有限公司
>>>> office:010-62600855-615
>>>> mobile:13521990614
>>>>
>>>> 2010年 11月 29日 星期一 17:38:14 CST
>>>>
>>>>
>>>
>>>
>>
>>
>
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [hellogcc] Re: [PATCH] Built kernel without -O2 option
  2010-12-01 15:01                 ` Hui Zhu
@ 2010-12-01 15:42                   ` jovi zhang
  0 siblings, 0 replies; 45+ messages in thread
From: jovi zhang @ 2010-12-01 15:42 UTC (permalink / raw)
  To: Hui Zhu, bekars, qiaochong; +Cc: hellogcc, Américo Wang, linux-kernel, gdb

Please don't use Chinese word in this mailing list, maybe somebody
need to read LKML guideline firstly.

Does this patch have many use case upon it? if there have many use
case, maybe we can worth to do it, otherwise it maybe need to
consider..., as we known, there have many person debug kernel just
using -O2 or kdb, etc...
we need to think once bring this config option, there will have so
many maintain work on it, every maintainer need to care for their
commit file to make sure the file can work with this -O0 mode.

If there have some files missed to support with the -O0 mode, the
kernel will not stable(also it have a little hard to find which
file/function cause unstable), and the unstable kernel is not
everybody want to see.

>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_process_$(BITS).o       += -O2
>> +CFLAGS_entry_$(BITS).o         += -O2
>> +CFLAGS_traps.o                 += -O2
>> +CFLAGS_i387.o                  += -O2
>> +CFLAGS_xsave.o                 += -O2
>> +CFLAGS_hpet.o                  += -O2

CONFIG_CC_CLOSE_OPTIMIZATION really misunderstand user in here with adding -O2.

   Thanks.

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2010-11-29  3:56 [PATCH] Built kernel without -O2 option Hui Zhu
                   ` (3 preceding siblings ...)
  2010-11-29 21:07 ` Arnaud Lacombe
@ 2011-01-24  7:47 ` Hui Zhu
  2011-01-24  8:11   ` Kevin Pouget
  4 siblings, 1 reply; 45+ messages in thread
From: Hui Zhu @ 2011-01-24  7:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: gdb, hellogcc

https://lkml.org/lkml/2010/11/28/211

Update follow kernel trunk.

I built and use it in i386 and x86_64 with 2.6.38-rc2+.

And I will put new patch in here and
http://code.google.com/p/kgtp/downloads/list

Thanks,
Hui

Signed-off-by: Hui Zhu <teawater@gmail.com>
---

---
 Makefile                                        |    2 ++
 arch/x86/crypto/Makefile                        |    6 ++++++
 arch/x86/include/asm/page_64_types.h            |    4 ++++
 arch/x86/include/asm/uaccess_32.h               |    4 ++++
 arch/x86/kernel/Makefile                        |    9 +++++++++
 arch/x86/kvm/Makefile                           |    6 ++++++
 arch/x86/lib/Makefile                           |    4 ++++
 arch/x86/power/Makefile                         |    4 ++++
 crypto/Makefile                                 |    4 ++++
 drivers/char/mwave/Makefile                     |    4 ++++
 drivers/gpu/drm/i915/Makefile                   |    4 ++++
 drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
 drivers/gpu/drm/nouveau/Makefile                |    4 ++++
 drivers/gpu/drm/radeon/Makefile                 |    4 ++++
 drivers/infiniband/hw/qib/Makefile              |    4 ++++
 drivers/net/can/sja1000/Makefile                |    4 ++++
 drivers/staging/comedi/drivers/Makefile         |    4 ++++
 drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
 drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
 drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
 drivers/usb/gadget/f_loopback.c                 |    2 ++
 drivers/usb/gadget/f_sourcesink.c               |    2 ++
 drivers/usb/gadget/g_zero.h                     |    2 ++
 drivers/usb/host/Makefile                       |    4 ++++
 fs/Makefile                                     |    5 +++++
 include/linux/pagemap.h                         |    2 ++
 init/Kconfig                                    |    1 +
 kernel/Makefile                                 |    4 ++++
 kernel/kfifo.c                                  |    3 +++
 lib/Kconfig.debug                               |    8 ++++++++
 lib/raid6/Makefile                              |    6 ++++++
 mm/Makefile                                     |    6 ++++++
 mm/memory.c                                     |    6 ++++++
 mm/mincore.c                                    |    2 ++
 mm/percpu.c                                     |    4 ++++
 mm/rmap.c                                       |    2 ++
 net/mac80211/cfg.c                              |    2 ++
 net/mac80211/iface.c                            |    8 ++++++++
 net/mac80211/mesh.h                             |    2 ++
 net/mac80211/rx.c                               |    8 ++++++++
 net/mac80211/sta_info.c                         |    2 ++
 net/mac80211/status.c                           |    2 ++
 net/mac80211/tx.c                               |    4 ++++
 net/netfilter/nf_conntrack_pptp.c               |    3 ++-
 44 files changed, 188 insertions(+), 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -541,8 +541,10 @@ all: vmlinux
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os
 else
+ifndef CONFIG_CC_CLOSE_OPTIMIZATION
 KBUILD_CFLAGS	+= -O2
 endif
+endif

 include $(srctree)/arch/$(SRCARCH)/Makefile

--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -2,6 +2,12 @@
 # Arch-specific CryptoAPI modules.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_fpu.o				+= -O2
+CFLAGS_aesni-intel_glue.o		+= -O2
+CFLAGS_ghash-clmulni-intel_glue.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO_FPU) += fpu.o

 obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -1,7 +1,11 @@
 #ifndef _ASM_X86_PAGE_64_DEFS_H
 #define _ASM_X86_PAGE_64_DEFS_H

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+#define THREAD_ORDER	2
+#else
 #define THREAD_ORDER	1
+#endif
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE - 1))

--- a/arch/x86/include/asm/uaccess_32.h
+++ b/arch/x86/include/asm/uaccess_32.h
@@ -209,7 +209,11 @@ static inline unsigned long __must_check
 	if (likely(sz == -1 || sz >= n))
 		n = _copy_from_user(to, from, n);
 	else
+#ifndef CONFIG_CC_CLOSE_OPTIMIZATION
 		copy_from_user_overflow();
+#else
+		n = -EFAULT;
+#endif

 	return n;
 }
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o		:= n
 GCOV_PROFILE_tsc.o		:= n
 GCOV_PROFILE_paravirt.o		:= n

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_process_$(BITS).o	+= -O2
+CFLAGS_entry_$(BITS).o		+= -O2
+CFLAGS_traps.o			+= -O2
+CFLAGS_i387.o			+= -O2
+CFLAGS_xsave.o			+= -O2
+CFLAGS_hpet.o			+= -O2
+endif
+
 obj-y			:= process_$(BITS).o signal.o entry_$(BITS).o
 obj-y			+= traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time.o ioport.o ldt.o dumpstack.o
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -5,6 +5,12 @@ CFLAGS_x86.o := -I.
 CFLAGS_svm.o := -I.
 CFLAGS_vmx.o := -I.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_x86.o		+= -O2
+CFLAGS_emulate.o	+= -O2
+CFLAGS_svm.o		+= -O2
+endif
+
 kvm-y			+= $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
 				coalesced_mmio.o irq_comm.o eventfd.o \
 				assigned-dev.o)
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -2,6 +2,10 @@
 # Makefile for x86 specific library files.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_memmove_64.o	+= -O2
+endif
+
 inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
 inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
 quiet_cmd_inat_tables = GEN     $@
--- a/arch/x86/power/Makefile
+++ b/arch/x86/power/Makefile
@@ -3,5 +3,9 @@
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_cpu.o	:= $(nostackp)

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_cpu.o	+= -O2
+endif
+
 obj-$(CONFIG_PM_SLEEP)		+= cpu.o
 obj-$(CONFIG_HIBERNATION)	+= hibernate_$(BITS).o hibernate_asm_$(BITS).o
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -2,6 +2,10 @@
 # Cryptographic API
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_xor.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO) += crypto.o
 crypto-y := api.o cipher.o compress.o

--- a/drivers/char/mwave/Makefile
+++ b/drivers/char/mwave/Makefile
@@ -4,6 +4,10 @@
 # See the README file in this directory for more info. <paulsch@us.ibm.com>
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_smapi.o	+= -O2
+endif
+
 obj-$(CONFIG_MWAVE) += mwave.o

 mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_i915_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
 	  i915_debugfs.o \
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1221,7 +1221,11 @@ extern int intel_setup_gmbus(struct drm_
 extern void intel_teardown_gmbus(struct drm_device *dev);
 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#else
 extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#endif
 {
 	return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
 }
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_nv50_instmem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_radeon_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm

 hostprogs-y := mkregtable
--- a/drivers/infiniband/hw/qib/Makefile
+++ b/drivers/infiniband/hw/qib/Makefile
@@ -1,5 +1,9 @@
 obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_qib_iba7322.o	+= -O2
+endif
+
 ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
 	qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
 	qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
--- a/drivers/net/can/sja1000/Makefile
+++ b/drivers/net/can/sja1000/Makefile
@@ -2,6 +2,10 @@
 #  Makefile for the SJA1000 CAN controller drivers.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_kvaser_pci.o	+= -O2
+endif
+
 obj-$(CONFIG_CAN_SJA1000) += sja1000.o
 obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
 obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -1,6 +1,10 @@
 # Makefile for individual comedi drivers
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_cb_pcidas64.o	+= -O2
+endif
+
 # Comedi "helper" modules
 obj-$(CONFIG_COMEDI)			+= pcm_common.o

--- a/drivers/staging/et131x/et1310_address_map.h
+++ b/drivers/staging/et131x/et1310_address_map.h
@@ -212,12 +212,20 @@ struct global_regs {			/* Location: */
 #define INDEX10(x)	((x) & ET_DMA10_MASK)
 #define INDEX4(x)	((x) & ET_DMA4_MASK)

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void add_10bit(u32 *v, int n)
+#else
 extern inline void add_10bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void add_12bit(u32 *v, int n)
+#else
 extern inline void add_12bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
 }
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
 	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#else
 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#endif
 {
 	/* Single white space is for Linksys APs */
 	if (essid_len == 1 && essid[0] == ' ')
@@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
 	return 0;
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline int ieee80211_get_hdrlen(u16 fc)
+#else
 extern inline int ieee80211_get_hdrlen(u16 fc)
+#endif
 {
 	int hdrlen = 24;

--- a/drivers/staging/wlags49_h2/wl_internal.h
+++ b/drivers/staging/wlags49_h2/wl_internal.h
@@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
 /********************************************************************/
 /* Interrupt enable disable functions                               */
 /********************************************************************/
-
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void wl_act_int_on(struct wl_private *lp)
+#else
 extern inline void wl_act_int_on(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
@@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
 	}
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void wl_act_int_off(struct wl_private *lp)
+#else
 extern inline void wl_act_int_off(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		loopback_driver.descriptors = otg_desc;
 		loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
 }
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		sourcesink_driver.descriptors = otg_desc;
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
 }
--- a/drivers/usb/gadget/g_zero.h
+++ b/drivers/usb/gadget/g_zero.h
@@ -10,7 +10,9 @@

 /* global state */
 extern unsigned buflen;
+#ifdef CONFIG_USB_OTG
 extern const struct usb_descriptor_header *otg_desc[];
+#endif

 /* common utilities */
 struct usb_request *alloc_ep_req(struct usb_ep *ep);
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -4,6 +4,10 @@

 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_ehci-hcd.o	+= -O2
+endif
+
 isp1760-y := isp1760-hcd.o isp1760-if.o

 fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -13,6 +13,11 @@ obj-y :=	open.o read_write.o file_table.
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
 		stack.o fs_struct.o statfs.o

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_compat_ioctl.o	+= -O2
+CFLAGS_binfmt_elf.o	+= -O2
+endif
+
 ifeq ($(CONFIG_BLOCK),y)
 obj-y +=	buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
 else
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
 					unsigned long address)
 {
 	pgoff_t pgoff;
+#ifdef CONFIG_HUGETLBFS
 	if (unlikely(is_vm_hugetlb_page(vma)))
 		return linear_hugepage_index(vma, address);
+#endif
 	pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
 	pgoff += vma->vm_pgoff;
 	return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -886,6 +886,7 @@ endif

 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size"
+	depends on !CC_CLOSE_OPTIMIZATION
 	default y
 	help
 	  Enabling this option will pass "-Os" instead of "-O2" to gcc
--- a/kernel/Makefile
+++ b/kernel/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the linux kernel.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_sched.o	+= -O2
+endif
+
 obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
 	    cpu.o exit.o itimer.o time.o softirq.o resource.o \
 	    sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
 		return max;
 	return len;
 }
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+EXPORT_SYMBOL(__kfifo_max_r);
+#endif

 #define	__KFIFO_PEEK(data, out, mask) \
 	((data)[(out) & (mask)])
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
 	  - Enable verbose reporting from modpost to help solving
 	    the section mismatches reported.

+config CC_CLOSE_OPTIMIZATION
+	bool "Close GCC optimization"
+	default n
+	help
+	  Enabling this option will let gcc build kernel without "-O2".
+
+	  If unsure, say N.
+
 config DEBUG_KERNEL
 	bool "Kernel debugging"
 	help
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -1,3 +1,9 @@
+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_mmx.o	+= -O2
+CFLAGS_sse1.o	+= -O2
+CFLAGS_sse2.o	+= -O2
+endif
+
 obj-$(CONFIG_RAID6_PQ)	+= raid6_pq.o

 raid6_pq-y	+= algos.o recov.o tables.o int1.o int2.o int4.o \
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -2,6 +2,12 @@
 # Makefile for the linux memory manager.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_slob.o	+= -O2
+CFLAGS_slab.o	+= -O2
+CFLAGS_slub.o	+= -O2
+endif
+
 mmu-y			:= nommu.o
 mmu-$(CONFIG_MMU)	:= fremap.o highmem.o madvise.o memory.o mincore.o \
 			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1317,8 +1317,10 @@ struct page *follow_page(struct vm_area_
 				spin_unlock(&mm->page_table_lock);
 				wait_split_huge_page(vma->anon_vma, pmd);
 			} else {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 				page = follow_trans_huge_pmd(mm, address,
 							     pmd, flags);
+#endif
 				spin_unlock(&mm->page_table_lock);
 				goto out;
 			}
@@ -2775,7 +2777,9 @@ static int do_swap_page(struct mm_struct

 	if (ksm_might_need_to_copy(page, vma, address)) {
 		swapcache = page;
+#ifdef CONFIG_KSM
 		page = ksm_does_need_to_copy(page, vma, address);
+#endif

 		if (unlikely(!page)) {
 			ret = VM_FAULT_OOM;
@@ -3314,11 +3318,13 @@ int handle_mm_fault(struct mm_struct *mm
 		pmd_t orig_pmd = *pmd;
 		barrier();
 		if (pmd_trans_huge(orig_pmd)) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 			if (flags & FAULT_FLAG_WRITE &&
 			    !pmd_write(orig_pmd) &&
 			    !pmd_trans_splitting(orig_pmd))
 				return do_huge_pmd_wp_page(mm, vma, address,
 							   pmd, orig_pmd);
+#endif
 			return 0;
 		}
 	}
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -155,10 +155,12 @@ static void mincore_pmd_range(struct vm_
 	do {
 		next = pmd_addr_end(addr, end);
 		if (pmd_trans_huge(*pmd)) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 			if (mincore_huge_pmd(vma, pmd, addr, next, vec)) {
 				vec += (next - addr) >> PAGE_SHIFT;
 				continue;
 			}
+#endif
 			/* fall through */
 		}
 		if (pmd_none_or_clear_bad(pmd))
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1886,7 +1886,11 @@ void __init percpu_init_late(void)
 		int *map;
 		const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]);

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+		BUG_ON(size > PAGE_SIZE);
+#else
 		BUILD_BUG_ON(size > PAGE_SIZE);
+#endif

 		map = pcpu_mem_alloc(size);
 		BUG_ON(!map);
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -515,6 +515,7 @@ int page_referenced_one(struct page *pag
 		referenced++;

 	if (unlikely(PageTransHuge(page))) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		pmd_t *pmd;

 		spin_lock(&mm->page_table_lock);
@@ -524,6 +525,7 @@ int page_referenced_one(struct page *pag
 		    pmdp_clear_flush_young_notify(vma, address, pmd))
 			referenced++;
 		spin_unlock(&mm->page_table_lock);
+#endif
 	} else {
 		pte_t *pte;
 		spinlock_t *ptl;
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -699,6 +699,7 @@ static void sta_apply_parameters(struct
 						  params->ht_capa,
 						  &sta->sta.ht_cap);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
 		switch (params->plink_action) {
 		case PLINK_ACTION_OPEN:
@@ -709,6 +710,7 @@ static void sta_apply_parameters(struct
 			break;
 		}
 	}
+#endif
 }

 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -620,8 +620,10 @@ static void ieee80211_teardown_sdata(str
 		__skb_queue_purge(&sdata->fragments[i].skb_list);
 	sdata->fragment_next = 0;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_rmc_free(sdata);
+#endif

 	flushed = sta_info_flush(local, sdata);
 	WARN_ON(flushed);
@@ -797,7 +799,9 @@ static void ieee80211_iface_work(struct
 		case NL80211_IFTYPE_MESH_POINT:
 			if (!ieee80211_vif_is_mesh(&sdata->vif))
 				break;
+#ifdef CONFIG_MAC80211_MESH
 			ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+#endif
 			break;
 		default:
 			WARN(1, "frame for unexpected interface type");
@@ -818,7 +822,9 @@ static void ieee80211_iface_work(struct
 	case NL80211_IFTYPE_MESH_POINT:
 		if (!ieee80211_vif_is_mesh(&sdata->vif))
 			break;
+#ifdef CONFIG_MAC80211_MESH
 		ieee80211_mesh_work(sdata);
+#endif
 		break;
 	default:
 		break;
@@ -872,8 +878,10 @@ static void ieee80211_setup_sdata(struct
 		ieee80211_ibss_setup_sdata(sdata);
 		break;
 	case NL80211_IFTYPE_MESH_POINT:
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sdata->vif))
 			ieee80211_mesh_init_sdata(sdata);
+#endif
 		break;
 	case NL80211_IFTYPE_MONITOR:
 		sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -189,8 +189,10 @@ int ieee80211_fill_mesh_addresses(struct
 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
 		struct ieee80211_sub_if_data *sdata, char *addr4or5,
 		char *addr6);
+#ifdef CONFIG_MAC80211_MESH
 int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
 		struct ieee80211_sub_if_data *sdata);
+#endif
 bool mesh_matches_local(struct ieee802_11_elems *ie,
 		struct ieee80211_sub_if_data *sdata);
 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
 }


+#ifndef CONFIG_MAC80211_MESH
+static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
+		   struct ieee80211_sub_if_data *sdata)
+{
+	return 0;
+}
+#endif
+
 static ieee80211_rx_result
 ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
 {
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -470,8 +470,10 @@ int sta_info_insert_rcu(struct sta_info
 	rcu_read_lock();
 	mutex_unlock(&local->sta_mtx);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_accept_plinks_update(sdata);
+#endif

 	return 0;
  out_free:
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -247,8 +247,10 @@ void ieee80211_tx_status(struct ieee8021
 		}

 		rate_control_tx_status(local, sband, sta, skb);
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
 			ieee80211s_update_metric(local, sta, skb);
+#endif

 		if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
 			ieee80211_frame_acked(sta, skb);
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1638,6 +1638,7 @@ static void ieee80211_xmit(struct ieee80
 	hdr = (struct ieee80211_hdr *) skb->data;
 	info->control.vif = &sdata->vif;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) &&
 	    ieee80211_is_data(hdr->frame_control) &&
 		!is_multicast_ether_addr(hdr->addr1))
@@ -1646,6 +1647,7 @@ static void ieee80211_xmit(struct ieee80
 				rcu_read_unlock();
 				return;
 			}
+#endif

 	ieee80211_set_qos_hdr(local, skb);
 	ieee80211_tx(sdata, skb, false);
@@ -2322,7 +2324,9 @@ struct sk_buff *ieee80211_beacon_get_tim
 		*pos++ = WLAN_EID_SSID;
 		*pos++ = 0x0;

+#ifdef CONFIG_MAC80211_MESH
 		mesh_mgmt_ies_add(skb, sdata);
+#endif
 	} else {
 		WARN_ON(1);
 		goto out;
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -67,7 +67,8 @@ void
 			     struct nf_conntrack_expect *exp) __read_mostly;
 EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);

-#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
+#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) \
+    || defined(CONFIG_CC_CLOSE_OPTIMIZATION)
 /* PptpControlMessageType names */
 const char *const pptp_msg_name[] = {
 	"UNKNOWN_MESSAGE",

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2011-01-24  7:47 ` Hui Zhu
@ 2011-01-24  8:11   ` Kevin Pouget
  2011-01-24 12:42     ` Hui Zhu
  0 siblings, 1 reply; 45+ messages in thread
From: Kevin Pouget @ 2011-01-24  8:11 UTC (permalink / raw)
  Cc: linux-kernel, gdb

I'm looking forward to testing in on ARM linux once it's ready, if
it's on our roadmad :)


Kevin


(sorry if you got it twice, the first one might have been rejected
because of HTML content)

On Mon, Jan 24, 2011 at 8:47 AM, Hui Zhu <teawater@gmail.com> wrote:
>
> https://lkml.org/lkml/2010/11/28/211
>
> Update follow kernel trunk.
>
> I built and use it in i386 and x86_64 with 2.6.38-rc2+.
>
> And I will put new patch in here and
> http://code.google.com/p/kgtp/downloads/list
>
> Thanks,
> Hui
>
> Signed-off-by: Hui Zhu <teawater@gmail.com>
> ---
>
> ---
>  Makefile                                        |    2 ++
>  arch/x86/crypto/Makefile                        |    6 ++++++
>  arch/x86/include/asm/page_64_types.h            |    4 ++++
>  arch/x86/include/asm/uaccess_32.h               |    4 ++++
>  arch/x86/kernel/Makefile                        |    9 +++++++++
>  arch/x86/kvm/Makefile                           |    6 ++++++
>  arch/x86/lib/Makefile                           |    4 ++++
>  arch/x86/power/Makefile                         |    4 ++++
>  crypto/Makefile                                 |    4 ++++
>  drivers/char/mwave/Makefile                     |    4 ++++
>  drivers/gpu/drm/i915/Makefile                   |    4 ++++
>  drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
>  drivers/gpu/drm/nouveau/Makefile                |    4 ++++
>  drivers/gpu/drm/radeon/Makefile                 |    4 ++++
>  drivers/infiniband/hw/qib/Makefile              |    4 ++++
>  drivers/net/can/sja1000/Makefile                |    4 ++++
>  drivers/staging/comedi/drivers/Makefile         |    4 ++++
>  drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
>  drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
>  drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
>  drivers/usb/gadget/f_loopback.c                 |    2 ++
>  drivers/usb/gadget/f_sourcesink.c               |    2 ++
>  drivers/usb/gadget/g_zero.h                     |    2 ++
>  drivers/usb/host/Makefile                       |    4 ++++
>  fs/Makefile                                     |    5 +++++
>  include/linux/pagemap.h                         |    2 ++
>  init/Kconfig                                    |    1 +
>  kernel/Makefile                                 |    4 ++++
>  kernel/kfifo.c                                  |    3 +++
>  lib/Kconfig.debug                               |    8 ++++++++
>  lib/raid6/Makefile                              |    6 ++++++
>  mm/Makefile                                     |    6 ++++++
>  mm/memory.c                                     |    6 ++++++
>  mm/mincore.c                                    |    2 ++
>  mm/percpu.c                                     |    4 ++++
>  mm/rmap.c                                       |    2 ++
>  net/mac80211/cfg.c                              |    2 ++
>  net/mac80211/iface.c                            |    8 ++++++++
>  net/mac80211/mesh.h                             |    2 ++
>  net/mac80211/rx.c                               |    8 ++++++++
>  net/mac80211/sta_info.c                         |    2 ++
>  net/mac80211/status.c                           |    2 ++
>  net/mac80211/tx.c                               |    4 ++++
>  net/netfilter/nf_conntrack_pptp.c               |    3 ++-
>  44 files changed, 188 insertions(+), 2 deletions(-)
>
> --- a/Makefile
> +++ b/Makefile
> @@ -541,8 +541,10 @@ all: vmlinux
>  ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>  KBUILD_CFLAGS  += -Os
>  else
> +ifndef CONFIG_CC_CLOSE_OPTIMIZATION
>  KBUILD_CFLAGS  += -O2
>  endif
> +endif
>
>  include $(srctree)/arch/$(SRCARCH)/Makefile
>
> --- a/arch/x86/crypto/Makefile
> +++ b/arch/x86/crypto/Makefile
> @@ -2,6 +2,12 @@
>  # Arch-specific CryptoAPI modules.
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_fpu.o                           += -O2
> +CFLAGS_aesni-intel_glue.o              += -O2
> +CFLAGS_ghash-clmulni-intel_glue.o      += -O2
> +endif
> +
>  obj-$(CONFIG_CRYPTO_FPU) += fpu.o
>
>  obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
> --- a/arch/x86/include/asm/page_64_types.h
> +++ b/arch/x86/include/asm/page_64_types.h
> @@ -1,7 +1,11 @@
>  #ifndef _ASM_X86_PAGE_64_DEFS_H
>  #define _ASM_X86_PAGE_64_DEFS_H
>
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +#define THREAD_ORDER   2
> +#else
>  #define THREAD_ORDER   1
> +#endif
>  #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
>  #define CURRENT_MASK (~(THREAD_SIZE - 1))
>
> --- a/arch/x86/include/asm/uaccess_32.h
> +++ b/arch/x86/include/asm/uaccess_32.h
> @@ -209,7 +209,11 @@ static inline unsigned long __must_check
>        if (likely(sz == -1 || sz >= n))
>                n = _copy_from_user(to, from, n);
>        else
> +#ifndef CONFIG_CC_CLOSE_OPTIMIZATION
>                copy_from_user_overflow();
> +#else
> +               n = -EFAULT;
> +#endif
>
>        return n;
>  }
> --- a/arch/x86/kernel/Makefile
> +++ b/arch/x86/kernel/Makefile
> @@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o          := n
>  GCOV_PROFILE_tsc.o             := n
>  GCOV_PROFILE_paravirt.o                := n
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_process_$(BITS).o       += -O2
> +CFLAGS_entry_$(BITS).o         += -O2
> +CFLAGS_traps.o                 += -O2
> +CFLAGS_i387.o                  += -O2
> +CFLAGS_xsave.o                 += -O2
> +CFLAGS_hpet.o                  += -O2
> +endif
> +
>  obj-y                  := process_$(BITS).o signal.o entry_$(BITS).o
>  obj-y                  += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
>  obj-y                  += time.o ioport.o ldt.o dumpstack.o
> --- a/arch/x86/kvm/Makefile
> +++ b/arch/x86/kvm/Makefile
> @@ -5,6 +5,12 @@ CFLAGS_x86.o := -I.
>  CFLAGS_svm.o := -I.
>  CFLAGS_vmx.o := -I.
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_x86.o           += -O2
> +CFLAGS_emulate.o       += -O2
> +CFLAGS_svm.o           += -O2
> +endif
> +
>  kvm-y                  += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
>                                coalesced_mmio.o irq_comm.o eventfd.o \
>                                assigned-dev.o)
> --- a/arch/x86/lib/Makefile
> +++ b/arch/x86/lib/Makefile
> @@ -2,6 +2,10 @@
>  # Makefile for x86 specific library files.
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_memmove_64.o    += -O2
> +endif
> +
>  inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
>  inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
>  quiet_cmd_inat_tables = GEN     $@
> --- a/arch/x86/power/Makefile
> +++ b/arch/x86/power/Makefile
> @@ -3,5 +3,9 @@
>  nostackp := $(call cc-option, -fno-stack-protector)
>  CFLAGS_cpu.o   := $(nostackp)
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_cpu.o   += -O2
> +endif
> +
>  obj-$(CONFIG_PM_SLEEP)         += cpu.o
>  obj-$(CONFIG_HIBERNATION)      += hibernate_$(BITS).o hibernate_asm_$(BITS).o
> --- a/crypto/Makefile
> +++ b/crypto/Makefile
> @@ -2,6 +2,10 @@
>  # Cryptographic API
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_xor.o   += -O2
> +endif
> +
>  obj-$(CONFIG_CRYPTO) += crypto.o
>  crypto-y := api.o cipher.o compress.o
>
> --- a/drivers/char/mwave/Makefile
> +++ b/drivers/char/mwave/Makefile
> @@ -4,6 +4,10 @@
>  # See the README file in this directory for more info. <paulsch@us.ibm.com>
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_smapi.o += -O2
> +endif
> +
>  obj-$(CONFIG_MWAVE) += mwave.o
>
>  mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -2,6 +2,10 @@
>  # Makefile for the drm device driver.  This driver provides support for the
>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_i915_gem.o      += -O2
> +endif
> +
>  ccflags-y := -Iinclude/drm
>  i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
>          i915_debugfs.o \
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -1221,7 +1221,11 @@ extern int intel_setup_gmbus(struct drm_
>  extern void intel_teardown_gmbus(struct drm_device *dev);
>  extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
>  extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
> +#else
>  extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
> +#endif
>  {
>        return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
>  }
> --- a/drivers/gpu/drm/nouveau/Makefile
> +++ b/drivers/gpu/drm/nouveau/Makefile
> @@ -2,6 +2,10 @@
>  # Makefile for the drm device driver.  This driver provides support for the
>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_nv50_instmem.o  += -O2
> +endif
> +
>  ccflags-y := -Iinclude/drm
>  nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
>              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
> --- a/drivers/gpu/drm/radeon/Makefile
> +++ b/drivers/gpu/drm/radeon/Makefile
> @@ -2,6 +2,10 @@
>  # Makefile for the drm device driver.  This driver provides support for the
>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_radeon_gem.o    += -O2
> +endif
> +
>  ccflags-y := -Iinclude/drm
>
>  hostprogs-y := mkregtable
> --- a/drivers/infiniband/hw/qib/Makefile
> +++ b/drivers/infiniband/hw/qib/Makefile
> @@ -1,5 +1,9 @@
>  obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_qib_iba7322.o   += -O2
> +endif
> +
>  ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
>        qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
>        qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
> --- a/drivers/net/can/sja1000/Makefile
> +++ b/drivers/net/can/sja1000/Makefile
> @@ -2,6 +2,10 @@
>  #  Makefile for the SJA1000 CAN controller drivers.
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_kvaser_pci.o    += -O2
> +endif
> +
>  obj-$(CONFIG_CAN_SJA1000) += sja1000.o
>  obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
>  obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
> --- a/drivers/staging/comedi/drivers/Makefile
> +++ b/drivers/staging/comedi/drivers/Makefile
> @@ -1,6 +1,10 @@
>  # Makefile for individual comedi drivers
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_cb_pcidas64.o   += -O2
> +endif
> +
>  # Comedi "helper" modules
>  obj-$(CONFIG_COMEDI)                   += pcm_common.o
>
> --- a/drivers/staging/et131x/et1310_address_map.h
> +++ b/drivers/staging/et131x/et1310_address_map.h
> @@ -212,12 +212,20 @@ struct global_regs {                      /* Location: */
>  #define INDEX10(x)     ((x) & ET_DMA10_MASK)
>  #define INDEX4(x)      ((x) & ET_DMA4_MASK)
>
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +static inline void add_10bit(u32 *v, int n)
> +#else
>  extern inline void add_10bit(u32 *v, int n)
> +#endif
>  {
>        *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
>  }
>
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +static inline void add_12bit(u32 *v, int n)
> +#else
>  extern inline void add_12bit(u32 *v, int n)
> +#endif
>  {
>        *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
>  }
> --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
> +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
> @@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
>        return ((struct ieee80211_device *)netdev_priv(dev))->priv;
>  }
>
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
> +#else
>  extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
> +#endif
>  {
>        /* Single white space is for Linksys APs */
>        if (essid_len == 1 && essid[0] == ' ')
> @@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
>        return 0;
>  }
>
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +static inline int ieee80211_get_hdrlen(u16 fc)
> +#else
>  extern inline int ieee80211_get_hdrlen(u16 fc)
> +#endif
>  {
>        int hdrlen = 24;
>
> --- a/drivers/staging/wlags49_h2/wl_internal.h
> +++ b/drivers/staging/wlags49_h2/wl_internal.h
> @@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
>  /********************************************************************/
>  /* Interrupt enable disable functions                               */
>  /********************************************************************/
> -
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +static inline void wl_act_int_on(struct wl_private *lp)
> +#else
>  extern inline void wl_act_int_on(struct wl_private *lp)
> +#endif
>  {
>        /*
>         * Only do something when the driver is handling
> @@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
>        }
>  }
>
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +static inline void wl_act_int_off(struct wl_private *lp)
> +#else
>  extern inline void wl_act_int_off(struct wl_private *lp)
> +#endif
>  {
>        /*
>         * Only do something when the driver is handling
> --- a/drivers/usb/gadget/f_loopback.c
> +++ b/drivers/usb/gadget/f_loopback.c
> @@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>
>        /* support OTG systems */
> +#ifdef CONFIG_USB_OTG
>        if (gadget_is_otg(cdev->gadget)) {
>                loopback_driver.descriptors = otg_desc;
>                loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>        }
> +#endif
>
>        return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
>  }
> --- a/drivers/usb/gadget/f_sourcesink.c
> +++ b/drivers/usb/gadget/f_sourcesink.c
> @@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>
>        /* support OTG systems */
> +#ifdef CONFIG_USB_OTG
>        if (gadget_is_otg(cdev->gadget)) {
>                sourcesink_driver.descriptors = otg_desc;
>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>        }
> +#endif
>
>        return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
>  }
> --- a/drivers/usb/gadget/g_zero.h
> +++ b/drivers/usb/gadget/g_zero.h
> @@ -10,7 +10,9 @@
>
>  /* global state */
>  extern unsigned buflen;
> +#ifdef CONFIG_USB_OTG
>  extern const struct usb_descriptor_header *otg_desc[];
> +#endif
>
>  /* common utilities */
>  struct usb_request *alloc_ep_req(struct usb_ep *ep);
> --- a/drivers/usb/host/Makefile
> +++ b/drivers/usb/host/Makefile
> @@ -4,6 +4,10 @@
>
>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_ehci-hcd.o      += -O2
> +endif
> +
>  isp1760-y := isp1760-hcd.o isp1760-if.o
>
>  fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
> --- a/fs/Makefile
> +++ b/fs/Makefile
> @@ -13,6 +13,11 @@ obj-y :=     open.o read_write.o file_table.
>                pnode.o drop_caches.o splice.o sync.o utimes.o \
>                stack.o fs_struct.o statfs.o
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_compat_ioctl.o  += -O2
> +CFLAGS_binfmt_elf.o    += -O2
> +endif
> +
>  ifeq ($(CONFIG_BLOCK),y)
>  obj-y +=       buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
>  else
> --- a/include/linux/pagemap.h
> +++ b/include/linux/pagemap.h
> @@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
>                                        unsigned long address)
>  {
>        pgoff_t pgoff;
> +#ifdef CONFIG_HUGETLBFS
>        if (unlikely(is_vm_hugetlb_page(vma)))
>                return linear_hugepage_index(vma, address);
> +#endif
>        pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
>        pgoff += vma->vm_pgoff;
>        return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
> --- a/init/Kconfig
> +++ b/init/Kconfig
> @@ -886,6 +886,7 @@ endif
>
>  config CC_OPTIMIZE_FOR_SIZE
>        bool "Optimize for size"
> +       depends on !CC_CLOSE_OPTIMIZATION
>        default y
>        help
>          Enabling this option will pass "-Os" instead of "-O2" to gcc
> --- a/kernel/Makefile
> +++ b/kernel/Makefile
> @@ -2,6 +2,10 @@
>  # Makefile for the linux kernel.
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_sched.o += -O2
> +endif
> +
>  obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
>            cpu.o exit.o itimer.o time.o softirq.o resource.o \
>            sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
> --- a/kernel/kfifo.c
> +++ b/kernel/kfifo.c
> @@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
>                return max;
>        return len;
>  }
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +EXPORT_SYMBOL(__kfifo_max_r);
> +#endif
>
>  #define        __KFIFO_PEEK(data, out, mask) \
>        ((data)[(out) & (mask)])
> --- a/lib/Kconfig.debug
> +++ b/lib/Kconfig.debug
> @@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
>          - Enable verbose reporting from modpost to help solving
>            the section mismatches reported.
>
> +config CC_CLOSE_OPTIMIZATION
> +       bool "Close GCC optimization"
> +       default n
> +       help
> +         Enabling this option will let gcc build kernel without "-O2".
> +
> +         If unsure, say N.
> +
>  config DEBUG_KERNEL
>        bool "Kernel debugging"
>        help
> --- a/lib/raid6/Makefile
> +++ b/lib/raid6/Makefile
> @@ -1,3 +1,9 @@
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_mmx.o   += -O2
> +CFLAGS_sse1.o  += -O2
> +CFLAGS_sse2.o  += -O2
> +endif
> +
>  obj-$(CONFIG_RAID6_PQ) += raid6_pq.o
>
>  raid6_pq-y     += algos.o recov.o tables.o int1.o int2.o int4.o \
> --- a/mm/Makefile
> +++ b/mm/Makefile
> @@ -2,6 +2,12 @@
>  # Makefile for the linux memory manager.
>  #
>
> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +CFLAGS_slob.o  += -O2
> +CFLAGS_slab.o  += -O2
> +CFLAGS_slub.o  += -O2
> +endif
> +
>  mmu-y                  := nommu.o
>  mmu-$(CONFIG_MMU)      := fremap.o highmem.o madvise.o memory.o mincore.o \
>                           mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1317,8 +1317,10 @@ struct page *follow_page(struct vm_area_
>                                spin_unlock(&mm->page_table_lock);
>                                wait_split_huge_page(vma->anon_vma, pmd);
>                        } else {
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>                                page = follow_trans_huge_pmd(mm, address,
>                                                             pmd, flags);
> +#endif
>                                spin_unlock(&mm->page_table_lock);
>                                goto out;
>                        }
> @@ -2775,7 +2777,9 @@ static int do_swap_page(struct mm_struct
>
>        if (ksm_might_need_to_copy(page, vma, address)) {
>                swapcache = page;
> +#ifdef CONFIG_KSM
>                page = ksm_does_need_to_copy(page, vma, address);
> +#endif
>
>                if (unlikely(!page)) {
>                        ret = VM_FAULT_OOM;
> @@ -3314,11 +3318,13 @@ int handle_mm_fault(struct mm_struct *mm
>                pmd_t orig_pmd = *pmd;
>                barrier();
>                if (pmd_trans_huge(orig_pmd)) {
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>                        if (flags & FAULT_FLAG_WRITE &&
>                            !pmd_write(orig_pmd) &&
>                            !pmd_trans_splitting(orig_pmd))
>                                return do_huge_pmd_wp_page(mm, vma, address,
>                                                           pmd, orig_pmd);
> +#endif
>                        return 0;
>                }
>        }
> --- a/mm/mincore.c
> +++ b/mm/mincore.c
> @@ -155,10 +155,12 @@ static void mincore_pmd_range(struct vm_
>        do {
>                next = pmd_addr_end(addr, end);
>                if (pmd_trans_huge(*pmd)) {
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>                        if (mincore_huge_pmd(vma, pmd, addr, next, vec)) {
>                                vec += (next - addr) >> PAGE_SHIFT;
>                                continue;
>                        }
> +#endif
>                        /* fall through */
>                }
>                if (pmd_none_or_clear_bad(pmd))
> --- a/mm/percpu.c
> +++ b/mm/percpu.c
> @@ -1886,7 +1886,11 @@ void __init percpu_init_late(void)
>                int *map;
>                const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]);
>
> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
> +               BUG_ON(size > PAGE_SIZE);
> +#else
>                BUILD_BUG_ON(size > PAGE_SIZE);
> +#endif
>
>                map = pcpu_mem_alloc(size);
>                BUG_ON(!map);
> --- a/mm/rmap.c
> +++ b/mm/rmap.c
> @@ -515,6 +515,7 @@ int page_referenced_one(struct page *pag
>                referenced++;
>
>        if (unlikely(PageTransHuge(page))) {
> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>                pmd_t *pmd;
>
>                spin_lock(&mm->page_table_lock);
> @@ -524,6 +525,7 @@ int page_referenced_one(struct page *pag
>                    pmdp_clear_flush_young_notify(vma, address, pmd))
>                        referenced++;
>                spin_unlock(&mm->page_table_lock);
> +#endif
>        } else {
>                pte_t *pte;
>                spinlock_t *ptl;
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -699,6 +699,7 @@ static void sta_apply_parameters(struct
>                                                  params->ht_capa,
>                                                  &sta->sta.ht_cap);
>
> +#ifdef CONFIG_MAC80211_MESH
>        if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
>                switch (params->plink_action) {
>                case PLINK_ACTION_OPEN:
> @@ -709,6 +710,7 @@ static void sta_apply_parameters(struct
>                        break;
>                }
>        }
> +#endif
>  }
>
>  static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
> --- a/net/mac80211/iface.c
> +++ b/net/mac80211/iface.c
> @@ -620,8 +620,10 @@ static void ieee80211_teardown_sdata(str
>                __skb_queue_purge(&sdata->fragments[i].skb_list);
>        sdata->fragment_next = 0;
>
> +#ifdef CONFIG_MAC80211_MESH
>        if (ieee80211_vif_is_mesh(&sdata->vif))
>                mesh_rmc_free(sdata);
> +#endif
>
>        flushed = sta_info_flush(local, sdata);
>        WARN_ON(flushed);
> @@ -797,7 +799,9 @@ static void ieee80211_iface_work(struct
>                case NL80211_IFTYPE_MESH_POINT:
>                        if (!ieee80211_vif_is_mesh(&sdata->vif))
>                                break;
> +#ifdef CONFIG_MAC80211_MESH
>                        ieee80211_mesh_rx_queued_mgmt(sdata, skb);
> +#endif
>                        break;
>                default:
>                        WARN(1, "frame for unexpected interface type");
> @@ -818,7 +822,9 @@ static void ieee80211_iface_work(struct
>        case NL80211_IFTYPE_MESH_POINT:
>                if (!ieee80211_vif_is_mesh(&sdata->vif))
>                        break;
> +#ifdef CONFIG_MAC80211_MESH
>                ieee80211_mesh_work(sdata);
> +#endif
>                break;
>        default:
>                break;
> @@ -872,8 +878,10 @@ static void ieee80211_setup_sdata(struct
>                ieee80211_ibss_setup_sdata(sdata);
>                break;
>        case NL80211_IFTYPE_MESH_POINT:
> +#ifdef CONFIG_MAC80211_MESH
>                if (ieee80211_vif_is_mesh(&sdata->vif))
>                        ieee80211_mesh_init_sdata(sdata);
> +#endif
>                break;
>        case NL80211_IFTYPE_MONITOR:
>                sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
> --- a/net/mac80211/mesh.h
> +++ b/net/mac80211/mesh.h
> @@ -189,8 +189,10 @@ int ieee80211_fill_mesh_addresses(struct
>  int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
>                struct ieee80211_sub_if_data *sdata, char *addr4or5,
>                char *addr6);
> +#ifdef CONFIG_MAC80211_MESH
>  int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
>                struct ieee80211_sub_if_data *sdata);
> +#endif
>  bool mesh_matches_local(struct ieee802_11_elems *ie,
>                struct ieee80211_sub_if_data *sdata);
>  void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
> --- a/net/mac80211/rx.c
> +++ b/net/mac80211/rx.c
> @@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
>  }
>
>
> +#ifndef CONFIG_MAC80211_MESH
> +static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
> +                  struct ieee80211_sub_if_data *sdata)
> +{
> +       return 0;
> +}
> +#endif
> +
>  static ieee80211_rx_result
>  ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
>  {
> --- a/net/mac80211/sta_info.c
> +++ b/net/mac80211/sta_info.c
> @@ -470,8 +470,10 @@ int sta_info_insert_rcu(struct sta_info
>        rcu_read_lock();
>        mutex_unlock(&local->sta_mtx);
>
> +#ifdef CONFIG_MAC80211_MESH
>        if (ieee80211_vif_is_mesh(&sdata->vif))
>                mesh_accept_plinks_update(sdata);
> +#endif
>
>        return 0;
>  out_free:
> --- a/net/mac80211/status.c
> +++ b/net/mac80211/status.c
> @@ -247,8 +247,10 @@ void ieee80211_tx_status(struct ieee8021
>                }
>
>                rate_control_tx_status(local, sband, sta, skb);
> +#ifdef CONFIG_MAC80211_MESH
>                if (ieee80211_vif_is_mesh(&sta->sdata->vif))
>                        ieee80211s_update_metric(local, sta, skb);
> +#endif
>
>                if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
>                        ieee80211_frame_acked(sta, skb);
> --- a/net/mac80211/tx.c
> +++ b/net/mac80211/tx.c
> @@ -1638,6 +1638,7 @@ static void ieee80211_xmit(struct ieee80
>        hdr = (struct ieee80211_hdr *) skb->data;
>        info->control.vif = &sdata->vif;
>
> +#ifdef CONFIG_MAC80211_MESH
>        if (ieee80211_vif_is_mesh(&sdata->vif) &&
>            ieee80211_is_data(hdr->frame_control) &&
>                !is_multicast_ether_addr(hdr->addr1))
> @@ -1646,6 +1647,7 @@ static void ieee80211_xmit(struct ieee80
>                                rcu_read_unlock();
>                                return;
>                        }
> +#endif
>
>        ieee80211_set_qos_hdr(local, skb);
>        ieee80211_tx(sdata, skb, false);
> @@ -2322,7 +2324,9 @@ struct sk_buff *ieee80211_beacon_get_tim
>                *pos++ = WLAN_EID_SSID;
>                *pos++ = 0x0;
>
> +#ifdef CONFIG_MAC80211_MESH
>                mesh_mgmt_ies_add(skb, sdata);
> +#endif
>        } else {
>                WARN_ON(1);
>                goto out;
> --- a/net/netfilter/nf_conntrack_pptp.c
> +++ b/net/netfilter/nf_conntrack_pptp.c
> @@ -67,7 +67,8 @@ void
>                             struct nf_conntrack_expect *exp) __read_mostly;
>  EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
>
> -#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
> +#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) \
> +    || defined(CONFIG_CC_CLOSE_OPTIMIZATION)
>  /* PptpControlMessageType names */
>  const char *const pptp_msg_name[] = {
>        "UNKNOWN_MESSAGE",

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2011-01-24  8:11   ` Kevin Pouget
@ 2011-01-24 12:42     ` Hui Zhu
  2011-01-28  3:41       ` Hui Zhu
  0 siblings, 1 reply; 45+ messages in thread
From: Hui Zhu @ 2011-01-24 12:42 UTC (permalink / raw)
  To: Kevin Pouget; +Cc: linux-kernel, gdb

Great.  But I am not sure it can work OK in arm.  I will try it too.

Thanks,
Hui

On Mon, Jan 24, 2011 at 16:11, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> I'm looking forward to testing in on ARM linux once it's ready, if
> it's on our roadmad :)
>
>
> Kevin
>
>
> (sorry if you got it twice, the first one might have been rejected
> because of HTML content)
>
> On Mon, Jan 24, 2011 at 8:47 AM, Hui Zhu <teawater@gmail.com> wrote:
>>
>> https://lkml.org/lkml/2010/11/28/211
>>
>> Update follow kernel trunk.
>>
>> I built and use it in i386 and x86_64 with 2.6.38-rc2+.
>>
>> And I will put new patch in here and
>> http://code.google.com/p/kgtp/downloads/list
>>
>> Thanks,
>> Hui
>>
>> Signed-off-by: Hui Zhu <teawater@gmail.com>
>> ---
>>
>> ---
>>  Makefile                                        |    2 ++
>>  arch/x86/crypto/Makefile                        |    6 ++++++
>>  arch/x86/include/asm/page_64_types.h            |    4 ++++
>>  arch/x86/include/asm/uaccess_32.h               |    4 ++++
>>  arch/x86/kernel/Makefile                        |    9 +++++++++
>>  arch/x86/kvm/Makefile                           |    6 ++++++
>>  arch/x86/lib/Makefile                           |    4 ++++
>>  arch/x86/power/Makefile                         |    4 ++++
>>  crypto/Makefile                                 |    4 ++++
>>  drivers/char/mwave/Makefile                     |    4 ++++
>>  drivers/gpu/drm/i915/Makefile                   |    4 ++++
>>  drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
>>  drivers/gpu/drm/nouveau/Makefile                |    4 ++++
>>  drivers/gpu/drm/radeon/Makefile                 |    4 ++++
>>  drivers/infiniband/hw/qib/Makefile              |    4 ++++
>>  drivers/net/can/sja1000/Makefile                |    4 ++++
>>  drivers/staging/comedi/drivers/Makefile         |    4 ++++
>>  drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
>>  drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
>>  drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
>>  drivers/usb/gadget/f_loopback.c                 |    2 ++
>>  drivers/usb/gadget/f_sourcesink.c               |    2 ++
>>  drivers/usb/gadget/g_zero.h                     |    2 ++
>>  drivers/usb/host/Makefile                       |    4 ++++
>>  fs/Makefile                                     |    5 +++++
>>  include/linux/pagemap.h                         |    2 ++
>>  init/Kconfig                                    |    1 +
>>  kernel/Makefile                                 |    4 ++++
>>  kernel/kfifo.c                                  |    3 +++
>>  lib/Kconfig.debug                               |    8 ++++++++
>>  lib/raid6/Makefile                              |    6 ++++++
>>  mm/Makefile                                     |    6 ++++++
>>  mm/memory.c                                     |    6 ++++++
>>  mm/mincore.c                                    |    2 ++
>>  mm/percpu.c                                     |    4 ++++
>>  mm/rmap.c                                       |    2 ++
>>  net/mac80211/cfg.c                              |    2 ++
>>  net/mac80211/iface.c                            |    8 ++++++++
>>  net/mac80211/mesh.h                             |    2 ++
>>  net/mac80211/rx.c                               |    8 ++++++++
>>  net/mac80211/sta_info.c                         |    2 ++
>>  net/mac80211/status.c                           |    2 ++
>>  net/mac80211/tx.c                               |    4 ++++
>>  net/netfilter/nf_conntrack_pptp.c               |    3 ++-
>>  44 files changed, 188 insertions(+), 2 deletions(-)
>>
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -541,8 +541,10 @@ all: vmlinux
>>  ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>>  KBUILD_CFLAGS  += -Os
>>  else
>> +ifndef CONFIG_CC_CLOSE_OPTIMIZATION
>>  KBUILD_CFLAGS  += -O2
>>  endif
>> +endif
>>
>>  include $(srctree)/arch/$(SRCARCH)/Makefile
>>
>> --- a/arch/x86/crypto/Makefile
>> +++ b/arch/x86/crypto/Makefile
>> @@ -2,6 +2,12 @@
>>  # Arch-specific CryptoAPI modules.
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_fpu.o                           += -O2
>> +CFLAGS_aesni-intel_glue.o              += -O2
>> +CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CRYPTO_FPU) += fpu.o
>>
>>  obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
>> --- a/arch/x86/include/asm/page_64_types.h
>> +++ b/arch/x86/include/asm/page_64_types.h
>> @@ -1,7 +1,11 @@
>>  #ifndef _ASM_X86_PAGE_64_DEFS_H
>>  #define _ASM_X86_PAGE_64_DEFS_H
>>
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +#define THREAD_ORDER   2
>> +#else
>>  #define THREAD_ORDER   1
>> +#endif
>>  #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
>>  #define CURRENT_MASK (~(THREAD_SIZE - 1))
>>
>> --- a/arch/x86/include/asm/uaccess_32.h
>> +++ b/arch/x86/include/asm/uaccess_32.h
>> @@ -209,7 +209,11 @@ static inline unsigned long __must_check
>>        if (likely(sz == -1 || sz >= n))
>>                n = _copy_from_user(to, from, n);
>>        else
>> +#ifndef CONFIG_CC_CLOSE_OPTIMIZATION
>>                copy_from_user_overflow();
>> +#else
>> +               n = -EFAULT;
>> +#endif
>>
>>        return n;
>>  }
>> --- a/arch/x86/kernel/Makefile
>> +++ b/arch/x86/kernel/Makefile
>> @@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o          := n
>>  GCOV_PROFILE_tsc.o             := n
>>  GCOV_PROFILE_paravirt.o                := n
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_process_$(BITS).o       += -O2
>> +CFLAGS_entry_$(BITS).o         += -O2
>> +CFLAGS_traps.o                 += -O2
>> +CFLAGS_i387.o                  += -O2
>> +CFLAGS_xsave.o                 += -O2
>> +CFLAGS_hpet.o                  += -O2
>> +endif
>> +
>>  obj-y                  := process_$(BITS).o signal.o entry_$(BITS).o
>>  obj-y                  += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
>>  obj-y                  += time.o ioport.o ldt.o dumpstack.o
>> --- a/arch/x86/kvm/Makefile
>> +++ b/arch/x86/kvm/Makefile
>> @@ -5,6 +5,12 @@ CFLAGS_x86.o := -I.
>>  CFLAGS_svm.o := -I.
>>  CFLAGS_vmx.o := -I.
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_x86.o           += -O2
>> +CFLAGS_emulate.o       += -O2
>> +CFLAGS_svm.o           += -O2
>> +endif
>> +
>>  kvm-y                  += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
>>                                coalesced_mmio.o irq_comm.o eventfd.o \
>>                                assigned-dev.o)
>> --- a/arch/x86/lib/Makefile
>> +++ b/arch/x86/lib/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for x86 specific library files.
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_memmove_64.o    += -O2
>> +endif
>> +
>>  inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
>>  inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
>>  quiet_cmd_inat_tables = GEN     $@
>> --- a/arch/x86/power/Makefile
>> +++ b/arch/x86/power/Makefile
>> @@ -3,5 +3,9 @@
>>  nostackp := $(call cc-option, -fno-stack-protector)
>>  CFLAGS_cpu.o   := $(nostackp)
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_cpu.o   += -O2
>> +endif
>> +
>>  obj-$(CONFIG_PM_SLEEP)         += cpu.o
>>  obj-$(CONFIG_HIBERNATION)      += hibernate_$(BITS).o hibernate_asm_$(BITS).o
>> --- a/crypto/Makefile
>> +++ b/crypto/Makefile
>> @@ -2,6 +2,10 @@
>>  # Cryptographic API
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_xor.o   += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CRYPTO) += crypto.o
>>  crypto-y := api.o cipher.o compress.o
>>
>> --- a/drivers/char/mwave/Makefile
>> +++ b/drivers/char/mwave/Makefile
>> @@ -4,6 +4,10 @@
>>  # See the README file in this directory for more info. <paulsch@us.ibm.com>
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_smapi.o += -O2
>> +endif
>> +
>>  obj-$(CONFIG_MWAVE) += mwave.o
>>
>>  mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
>> --- a/drivers/gpu/drm/i915/Makefile
>> +++ b/drivers/gpu/drm/i915/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_i915_gem.o      += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>  i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
>>          i915_debugfs.o \
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -1221,7 +1221,11 @@ extern int intel_setup_gmbus(struct drm_
>>  extern void intel_teardown_gmbus(struct drm_device *dev);
>>  extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
>>  extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
>> +#else
>>  extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
>> +#endif
>>  {
>>        return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
>>  }
>> --- a/drivers/gpu/drm/nouveau/Makefile
>> +++ b/drivers/gpu/drm/nouveau/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_nv50_instmem.o  += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>  nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
>>              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
>> --- a/drivers/gpu/drm/radeon/Makefile
>> +++ b/drivers/gpu/drm/radeon/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_radeon_gem.o    += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>
>>  hostprogs-y := mkregtable
>> --- a/drivers/infiniband/hw/qib/Makefile
>> +++ b/drivers/infiniband/hw/qib/Makefile
>> @@ -1,5 +1,9 @@
>>  obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_qib_iba7322.o   += -O2
>> +endif
>> +
>>  ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
>>        qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
>>        qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
>> --- a/drivers/net/can/sja1000/Makefile
>> +++ b/drivers/net/can/sja1000/Makefile
>> @@ -2,6 +2,10 @@
>>  #  Makefile for the SJA1000 CAN controller drivers.
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_kvaser_pci.o    += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CAN_SJA1000) += sja1000.o
>>  obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
>>  obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
>> --- a/drivers/staging/comedi/drivers/Makefile
>> +++ b/drivers/staging/comedi/drivers/Makefile
>> @@ -1,6 +1,10 @@
>>  # Makefile for individual comedi drivers
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_cb_pcidas64.o   += -O2
>> +endif
>> +
>>  # Comedi "helper" modules
>>  obj-$(CONFIG_COMEDI)                   += pcm_common.o
>>
>> --- a/drivers/staging/et131x/et1310_address_map.h
>> +++ b/drivers/staging/et131x/et1310_address_map.h
>> @@ -212,12 +212,20 @@ struct global_regs {                      /* Location: */
>>  #define INDEX10(x)     ((x) & ET_DMA10_MASK)
>>  #define INDEX4(x)      ((x) & ET_DMA4_MASK)
>>
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +static inline void add_10bit(u32 *v, int n)
>> +#else
>>  extern inline void add_10bit(u32 *v, int n)
>> +#endif
>>  {
>>        *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
>>  }
>>
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +static inline void add_12bit(u32 *v, int n)
>> +#else
>>  extern inline void add_12bit(u32 *v, int n)
>> +#endif
>>  {
>>        *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
>>  }
>> --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
>> +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
>> @@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
>>        return ((struct ieee80211_device *)netdev_priv(dev))->priv;
>>  }
>>
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
>> +#else
>>  extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
>> +#endif
>>  {
>>        /* Single white space is for Linksys APs */
>>        if (essid_len == 1 && essid[0] == ' ')
>> @@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
>>        return 0;
>>  }
>>
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +static inline int ieee80211_get_hdrlen(u16 fc)
>> +#else
>>  extern inline int ieee80211_get_hdrlen(u16 fc)
>> +#endif
>>  {
>>        int hdrlen = 24;
>>
>> --- a/drivers/staging/wlags49_h2/wl_internal.h
>> +++ b/drivers/staging/wlags49_h2/wl_internal.h
>> @@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
>>  /********************************************************************/
>>  /* Interrupt enable disable functions                               */
>>  /********************************************************************/
>> -
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +static inline void wl_act_int_on(struct wl_private *lp)
>> +#else
>>  extern inline void wl_act_int_on(struct wl_private *lp)
>> +#endif
>>  {
>>        /*
>>         * Only do something when the driver is handling
>> @@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
>>        }
>>  }
>>
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +static inline void wl_act_int_off(struct wl_private *lp)
>> +#else
>>  extern inline void wl_act_int_off(struct wl_private *lp)
>> +#endif
>>  {
>>        /*
>>         * Only do something when the driver is handling
>> --- a/drivers/usb/gadget/f_loopback.c
>> +++ b/drivers/usb/gadget/f_loopback.c
>> @@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>
>>        /* support OTG systems */
>> +#ifdef CONFIG_USB_OTG
>>        if (gadget_is_otg(cdev->gadget)) {
>>                loopback_driver.descriptors = otg_desc;
>>                loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>        }
>> +#endif
>>
>>        return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
>>  }
>> --- a/drivers/usb/gadget/f_sourcesink.c
>> +++ b/drivers/usb/gadget/f_sourcesink.c
>> @@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>
>>        /* support OTG systems */
>> +#ifdef CONFIG_USB_OTG
>>        if (gadget_is_otg(cdev->gadget)) {
>>                sourcesink_driver.descriptors = otg_desc;
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>        }
>> +#endif
>>
>>        return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
>>  }
>> --- a/drivers/usb/gadget/g_zero.h
>> +++ b/drivers/usb/gadget/g_zero.h
>> @@ -10,7 +10,9 @@
>>
>>  /* global state */
>>  extern unsigned buflen;
>> +#ifdef CONFIG_USB_OTG
>>  extern const struct usb_descriptor_header *otg_desc[];
>> +#endif
>>
>>  /* common utilities */
>>  struct usb_request *alloc_ep_req(struct usb_ep *ep);
>> --- a/drivers/usb/host/Makefile
>> +++ b/drivers/usb/host/Makefile
>> @@ -4,6 +4,10 @@
>>
>>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_ehci-hcd.o      += -O2
>> +endif
>> +
>>  isp1760-y := isp1760-hcd.o isp1760-if.o
>>
>>  fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
>> --- a/fs/Makefile
>> +++ b/fs/Makefile
>> @@ -13,6 +13,11 @@ obj-y :=     open.o read_write.o file_table.
>>                pnode.o drop_caches.o splice.o sync.o utimes.o \
>>                stack.o fs_struct.o statfs.o
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_compat_ioctl.o  += -O2
>> +CFLAGS_binfmt_elf.o    += -O2
>> +endif
>> +
>>  ifeq ($(CONFIG_BLOCK),y)
>>  obj-y +=       buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
>>  else
>> --- a/include/linux/pagemap.h
>> +++ b/include/linux/pagemap.h
>> @@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
>>                                        unsigned long address)
>>  {
>>        pgoff_t pgoff;
>> +#ifdef CONFIG_HUGETLBFS
>>        if (unlikely(is_vm_hugetlb_page(vma)))
>>                return linear_hugepage_index(vma, address);
>> +#endif
>>        pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
>>        pgoff += vma->vm_pgoff;
>>        return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -886,6 +886,7 @@ endif
>>
>>  config CC_OPTIMIZE_FOR_SIZE
>>        bool "Optimize for size"
>> +       depends on !CC_CLOSE_OPTIMIZATION
>>        default y
>>        help
>>          Enabling this option will pass "-Os" instead of "-O2" to gcc
>> --- a/kernel/Makefile
>> +++ b/kernel/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the linux kernel.
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_sched.o += -O2
>> +endif
>> +
>>  obj-y     = sched.o fork.o exec_domain.o panic.o printk.o \
>>            cpu.o exit.o itimer.o time.o softirq.o resource.o \
>>            sysctl.o sysctl_binary.o capability.o ptrace.o timer.o user.o \
>> --- a/kernel/kfifo.c
>> +++ b/kernel/kfifo.c
>> @@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
>>                return max;
>>        return len;
>>  }
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +EXPORT_SYMBOL(__kfifo_max_r);
>> +#endif
>>
>>  #define        __KFIFO_PEEK(data, out, mask) \
>>        ((data)[(out) & (mask)])
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
>>          - Enable verbose reporting from modpost to help solving
>>            the section mismatches reported.
>>
>> +config CC_CLOSE_OPTIMIZATION
>> +       bool "Close GCC optimization"
>> +       default n
>> +       help
>> +         Enabling this option will let gcc build kernel without "-O2".
>> +
>> +         If unsure, say N.
>> +
>>  config DEBUG_KERNEL
>>        bool "Kernel debugging"
>>        help
>> --- a/lib/raid6/Makefile
>> +++ b/lib/raid6/Makefile
>> @@ -1,3 +1,9 @@
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_mmx.o   += -O2
>> +CFLAGS_sse1.o  += -O2
>> +CFLAGS_sse2.o  += -O2
>> +endif
>> +
>>  obj-$(CONFIG_RAID6_PQ) += raid6_pq.o
>>
>>  raid6_pq-y     += algos.o recov.o tables.o int1.o int2.o int4.o \
>> --- a/mm/Makefile
>> +++ b/mm/Makefile
>> @@ -2,6 +2,12 @@
>>  # Makefile for the linux memory manager.
>>  #
>>
>> +ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +CFLAGS_slob.o  += -O2
>> +CFLAGS_slab.o  += -O2
>> +CFLAGS_slub.o  += -O2
>> +endif
>> +
>>  mmu-y                  := nommu.o
>>  mmu-$(CONFIG_MMU)      := fremap.o highmem.o madvise.o memory.o mincore.o \
>>                           mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -1317,8 +1317,10 @@ struct page *follow_page(struct vm_area_
>>                                spin_unlock(&mm->page_table_lock);
>>                                wait_split_huge_page(vma->anon_vma, pmd);
>>                        } else {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                                page = follow_trans_huge_pmd(mm, address,
>>                                                             pmd, flags);
>> +#endif
>>                                spin_unlock(&mm->page_table_lock);
>>                                goto out;
>>                        }
>> @@ -2775,7 +2777,9 @@ static int do_swap_page(struct mm_struct
>>
>>        if (ksm_might_need_to_copy(page, vma, address)) {
>>                swapcache = page;
>> +#ifdef CONFIG_KSM
>>                page = ksm_does_need_to_copy(page, vma, address);
>> +#endif
>>
>>                if (unlikely(!page)) {
>>                        ret = VM_FAULT_OOM;
>> @@ -3314,11 +3318,13 @@ int handle_mm_fault(struct mm_struct *mm
>>                pmd_t orig_pmd = *pmd;
>>                barrier();
>>                if (pmd_trans_huge(orig_pmd)) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                        if (flags & FAULT_FLAG_WRITE &&
>>                            !pmd_write(orig_pmd) &&
>>                            !pmd_trans_splitting(orig_pmd))
>>                                return do_huge_pmd_wp_page(mm, vma, address,
>>                                                           pmd, orig_pmd);
>> +#endif
>>                        return 0;
>>                }
>>        }
>> --- a/mm/mincore.c
>> +++ b/mm/mincore.c
>> @@ -155,10 +155,12 @@ static void mincore_pmd_range(struct vm_
>>        do {
>>                next = pmd_addr_end(addr, end);
>>                if (pmd_trans_huge(*pmd)) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                        if (mincore_huge_pmd(vma, pmd, addr, next, vec)) {
>>                                vec += (next - addr) >> PAGE_SHIFT;
>>                                continue;
>>                        }
>> +#endif
>>                        /* fall through */
>>                }
>>                if (pmd_none_or_clear_bad(pmd))
>> --- a/mm/percpu.c
>> +++ b/mm/percpu.c
>> @@ -1886,7 +1886,11 @@ void __init percpu_init_late(void)
>>                int *map;
>>                const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]);
>>
>> +#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
>> +               BUG_ON(size > PAGE_SIZE);
>> +#else
>>                BUILD_BUG_ON(size > PAGE_SIZE);
>> +#endif
>>
>>                map = pcpu_mem_alloc(size);
>>                BUG_ON(!map);
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -515,6 +515,7 @@ int page_referenced_one(struct page *pag
>>                referenced++;
>>
>>        if (unlikely(PageTransHuge(page))) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                pmd_t *pmd;
>>
>>                spin_lock(&mm->page_table_lock);
>> @@ -524,6 +525,7 @@ int page_referenced_one(struct page *pag
>>                    pmdp_clear_flush_young_notify(vma, address, pmd))
>>                        referenced++;
>>                spin_unlock(&mm->page_table_lock);
>> +#endif
>>        } else {
>>                pte_t *pte;
>>                spinlock_t *ptl;
>> --- a/net/mac80211/cfg.c
>> +++ b/net/mac80211/cfg.c
>> @@ -699,6 +699,7 @@ static void sta_apply_parameters(struct
>>                                                  params->ht_capa,
>>                                                  &sta->sta.ht_cap);
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
>>                switch (params->plink_action) {
>>                case PLINK_ACTION_OPEN:
>> @@ -709,6 +710,7 @@ static void sta_apply_parameters(struct
>>                        break;
>>                }
>>        }
>> +#endif
>>  }
>>
>>  static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
>> --- a/net/mac80211/iface.c
>> +++ b/net/mac80211/iface.c
>> @@ -620,8 +620,10 @@ static void ieee80211_teardown_sdata(str
>>                __skb_queue_purge(&sdata->fragments[i].skb_list);
>>        sdata->fragment_next = 0;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif))
>>                mesh_rmc_free(sdata);
>> +#endif
>>
>>        flushed = sta_info_flush(local, sdata);
>>        WARN_ON(flushed);
>> @@ -797,7 +799,9 @@ static void ieee80211_iface_work(struct
>>                case NL80211_IFTYPE_MESH_POINT:
>>                        if (!ieee80211_vif_is_mesh(&sdata->vif))
>>                                break;
>> +#ifdef CONFIG_MAC80211_MESH
>>                        ieee80211_mesh_rx_queued_mgmt(sdata, skb);
>> +#endif
>>                        break;
>>                default:
>>                        WARN(1, "frame for unexpected interface type");
>> @@ -818,7 +822,9 @@ static void ieee80211_iface_work(struct
>>        case NL80211_IFTYPE_MESH_POINT:
>>                if (!ieee80211_vif_is_mesh(&sdata->vif))
>>                        break;
>> +#ifdef CONFIG_MAC80211_MESH
>>                ieee80211_mesh_work(sdata);
>> +#endif
>>                break;
>>        default:
>>                break;
>> @@ -872,8 +878,10 @@ static void ieee80211_setup_sdata(struct
>>                ieee80211_ibss_setup_sdata(sdata);
>>                break;
>>        case NL80211_IFTYPE_MESH_POINT:
>> +#ifdef CONFIG_MAC80211_MESH
>>                if (ieee80211_vif_is_mesh(&sdata->vif))
>>                        ieee80211_mesh_init_sdata(sdata);
>> +#endif
>>                break;
>>        case NL80211_IFTYPE_MONITOR:
>>                sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
>> --- a/net/mac80211/mesh.h
>> +++ b/net/mac80211/mesh.h
>> @@ -189,8 +189,10 @@ int ieee80211_fill_mesh_addresses(struct
>>  int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
>>                struct ieee80211_sub_if_data *sdata, char *addr4or5,
>>                char *addr6);
>> +#ifdef CONFIG_MAC80211_MESH
>>  int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
>>                struct ieee80211_sub_if_data *sdata);
>> +#endif
>>  bool mesh_matches_local(struct ieee802_11_elems *ie,
>>                struct ieee80211_sub_if_data *sdata);
>>  void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
>> --- a/net/mac80211/rx.c
>> +++ b/net/mac80211/rx.c
>> @@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
>>  }
>>
>>
>> +#ifndef CONFIG_MAC80211_MESH
>> +static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
>> +                  struct ieee80211_sub_if_data *sdata)
>> +{
>> +       return 0;
>> +}
>> +#endif
>> +
>>  static ieee80211_rx_result
>>  ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
>>  {
>> --- a/net/mac80211/sta_info.c
>> +++ b/net/mac80211/sta_info.c
>> @@ -470,8 +470,10 @@ int sta_info_insert_rcu(struct sta_info
>>        rcu_read_lock();
>>        mutex_unlock(&local->sta_mtx);
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif))
>>                mesh_accept_plinks_update(sdata);
>> +#endif
>>
>>        return 0;
>>  out_free:
>> --- a/net/mac80211/status.c
>> +++ b/net/mac80211/status.c
>> @@ -247,8 +247,10 @@ void ieee80211_tx_status(struct ieee8021
>>                }
>>
>>                rate_control_tx_status(local, sband, sta, skb);
>> +#ifdef CONFIG_MAC80211_MESH
>>                if (ieee80211_vif_is_mesh(&sta->sdata->vif))
>>                        ieee80211s_update_metric(local, sta, skb);
>> +#endif
>>
>>                if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
>>                        ieee80211_frame_acked(sta, skb);
>> --- a/net/mac80211/tx.c
>> +++ b/net/mac80211/tx.c
>> @@ -1638,6 +1638,7 @@ static void ieee80211_xmit(struct ieee80
>>        hdr = (struct ieee80211_hdr *) skb->data;
>>        info->control.vif = &sdata->vif;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif) &&
>>            ieee80211_is_data(hdr->frame_control) &&
>>                !is_multicast_ether_addr(hdr->addr1))
>> @@ -1646,6 +1647,7 @@ static void ieee80211_xmit(struct ieee80
>>                                rcu_read_unlock();
>>                                return;
>>                        }
>> +#endif
>>
>>        ieee80211_set_qos_hdr(local, skb);
>>        ieee80211_tx(sdata, skb, false);
>> @@ -2322,7 +2324,9 @@ struct sk_buff *ieee80211_beacon_get_tim
>>                *pos++ = WLAN_EID_SSID;
>>                *pos++ = 0x0;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>                mesh_mgmt_ies_add(skb, sdata);
>> +#endif
>>        } else {
>>                WARN_ON(1);
>>                goto out;
>> --- a/net/netfilter/nf_conntrack_pptp.c
>> +++ b/net/netfilter/nf_conntrack_pptp.c
>> @@ -67,7 +67,8 @@ void
>>                             struct nf_conntrack_expect *exp) __read_mostly;
>>  EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
>>
>> -#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
>> +#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) \
>> +    || defined(CONFIG_CC_CLOSE_OPTIMIZATION)
>>  /* PptpControlMessageType names */
>>  const char *const pptp_msg_name[] = {
>>        "UNKNOWN_MESSAGE",
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2011-01-24 12:42     ` Hui Zhu
@ 2011-01-28  3:41       ` Hui Zhu
  2011-02-17  2:43         ` Hui Zhu
  0 siblings, 1 reply; 45+ messages in thread
From: Hui Zhu @ 2011-01-28  3:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: gdb, Kevin Pouget, hellogcc

https://lkml.org/lkml/2010/11/28/211
https://lkml.org/lkml/2011/1/24/24

This version support ARM.

I built and use it in arm, i386 and x86_64 with 2.6.38-rc2+.
Please mail me if you got some error with this patch.

And I will put new patch in here and
http://code.google.com/p/kgtp/downloads/list

Thanks,
Hui

Signed-off-by: Hui Zhu <teawater@gmail.com>
---
 Makefile                                        |    2 ++
 arch/arm/include/asm/tlbflush.h                 |    4 ++++
 arch/arm/mm/dma-mapping.c                       |    2 ++
 arch/arm/mm/flush.c                             |    2 ++
 arch/x86/crypto/Makefile                        |    6 ++++++
 arch/x86/include/asm/page_64_types.h            |    4 ++++
 arch/x86/include/asm/uaccess_32.h               |    4 ++++
 arch/x86/kernel/Makefile                        |    9 +++++++++
 arch/x86/kvm/Makefile                           |    6 ++++++
 arch/x86/lib/Makefile                           |    4 ++++
 arch/x86/power/Makefile                         |    4 ++++
 crypto/Makefile                                 |    4 ++++
 drivers/char/mwave/Makefile                     |    4 ++++
 drivers/gpu/drm/i915/Makefile                   |    4 ++++
 drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
 drivers/gpu/drm/nouveau/Makefile                |    4 ++++
 drivers/gpu/drm/radeon/Makefile                 |    4 ++++
 drivers/infiniband/hw/qib/Makefile              |    4 ++++
 drivers/net/can/sja1000/Makefile                |    4 ++++
 drivers/staging/comedi/drivers/Makefile         |    4 ++++
 drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
 drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
 drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
 drivers/usb/gadget/f_loopback.c                 |    2 ++
 drivers/usb/gadget/f_sourcesink.c               |    2 ++
 drivers/usb/gadget/g_zero.h                     |    2 ++
 drivers/usb/host/Makefile                       |    4 ++++
 fs/Makefile                                     |    5 +++++
 include/asm-generic/cmpxchg-local.h             |    4 ++++
 include/linux/pagemap.h                         |    2 ++
 init/Kconfig                                    |    1 +
 kernel/kfifo.c                                  |    3 +++
 kernel/sched_autogroup.c                        |    4 ++++
 kernel/sched_autogroup.h                        |    4 ++++
 lib/Kconfig.debug                               |    8 ++++++++
 lib/raid6/Makefile                              |    6 ++++++
 mm/Makefile                                     |    6 ++++++
 mm/memory.c                                     |    6 ++++++
 mm/mincore.c                                    |    2 ++
 mm/percpu.c                                     |    4 ++++
 mm/rmap.c                                       |    2 ++
 net/mac80211/cfg.c                              |    2 ++
 net/mac80211/iface.c                            |    8 ++++++++
 net/mac80211/mesh.h                             |    2 ++
 net/mac80211/rx.c                               |    8 ++++++++
 net/mac80211/sta_info.c                         |    2 ++
 net/mac80211/status.c                           |    2 ++
 net/mac80211/tx.c                               |    4 ++++
 net/netfilter/nf_conntrack_pptp.c               |    3 ++-
 49 files changed, 204 insertions(+), 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -541,8 +541,10 @@ all: vmlinux
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os
 else
+ifndef CONFIG_CC_CLOSE_OPTIMIZATION
 KBUILD_CFLAGS	+= -O2
 endif
+endif

 include $(srctree)/arch/$(SRCARCH)/Makefile

--- a/arch/arm/include/asm/tlbflush.h
+++ b/arch/arm/include/asm/tlbflush.h
@@ -250,7 +250,11 @@ extern void __cpu_flush_kern_tlb_range(u

 extern struct cpu_tlb_fns cpu_tlb;

+#ifdef MULTI_TLB
 #define __cpu_tlb_flags			cpu_tlb.tlb_flags
+#else
+#define __cpu_tlb_flags			0
+#endif

 /*
  *	TLB Management
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -468,6 +468,7 @@ static void dma_cache_maint_page(struct
 		void *vaddr;

 		if (PageHighMem(page)) {
+#ifdef CONFIG_HIGHMEM
 			if (len + offset > PAGE_SIZE) {
 				if (offset >= PAGE_SIZE) {
 					page += offset / PAGE_SIZE;
@@ -486,6 +487,7 @@ static void dma_cache_maint_page(struct
 				op(vaddr + offset, len, dir);
 				kunmap_atomic(vaddr);
 			}
+#endif
 		} else {
 			vaddr = page_address(page) + offset;
 			op(vaddr, len, dir);
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -175,6 +175,7 @@ void __flush_dcache_page(struct address_
 	if (!PageHighMem(page)) {
 		__cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
 	} else {
+#ifdef CONFIG_HIGHMEM
 		void *addr = kmap_high_get(page);
 		if (addr) {
 			__cpuc_flush_dcache_area(addr, PAGE_SIZE);
@@ -185,6 +186,7 @@ void __flush_dcache_page(struct address_
 			__cpuc_flush_dcache_area(addr, PAGE_SIZE);
 			kunmap_atomic(addr);
 		}
+#endif
 	}

 	/*
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -2,6 +2,12 @@
 # Arch-specific CryptoAPI modules.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_fpu.o				+= -O2
+CFLAGS_aesni-intel_glue.o		+= -O2
+CFLAGS_ghash-clmulni-intel_glue.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO_FPU) += fpu.o

 obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -1,7 +1,11 @@
 #ifndef _ASM_X86_PAGE_64_DEFS_H
 #define _ASM_X86_PAGE_64_DEFS_H

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+#define THREAD_ORDER	2
+#else
 #define THREAD_ORDER	1
+#endif
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE - 1))

--- a/arch/x86/include/asm/uaccess_32.h
+++ b/arch/x86/include/asm/uaccess_32.h
@@ -209,7 +209,11 @@ static inline unsigned long __must_check
 	if (likely(sz == -1 || sz >= n))
 		n = _copy_from_user(to, from, n);
 	else
+#ifndef CONFIG_CC_CLOSE_OPTIMIZATION
 		copy_from_user_overflow();
+#else
+		n = -EFAULT;
+#endif

 	return n;
 }
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o		:= n
 GCOV_PROFILE_tsc.o		:= n
 GCOV_PROFILE_paravirt.o		:= n

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_process_$(BITS).o	+= -O2
+CFLAGS_entry_$(BITS).o		+= -O2
+CFLAGS_traps.o			+= -O2
+CFLAGS_i387.o			+= -O2
+CFLAGS_xsave.o			+= -O2
+CFLAGS_hpet.o			+= -O2
+endif
+
 obj-y			:= process_$(BITS).o signal.o entry_$(BITS).o
 obj-y			+= traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time.o ioport.o ldt.o dumpstack.o
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -5,6 +5,12 @@ CFLAGS_x86.o := -I.
 CFLAGS_svm.o := -I.
 CFLAGS_vmx.o := -I.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_x86.o		+= -O2
+CFLAGS_emulate.o	+= -O2
+CFLAGS_svm.o		+= -O2
+endif
+
 kvm-y			+= $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
 				coalesced_mmio.o irq_comm.o eventfd.o \
 				assigned-dev.o)
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -2,6 +2,10 @@
 # Makefile for x86 specific library files.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_memmove_64.o	+= -O2
+endif
+
 inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
 inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
 quiet_cmd_inat_tables = GEN     $@
--- a/arch/x86/power/Makefile
+++ b/arch/x86/power/Makefile
@@ -3,5 +3,9 @@
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_cpu.o	:= $(nostackp)

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_cpu.o	+= -O2
+endif
+
 obj-$(CONFIG_PM_SLEEP)		+= cpu.o
 obj-$(CONFIG_HIBERNATION)	+= hibernate_$(BITS).o hibernate_asm_$(BITS).o
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -2,6 +2,10 @@
 # Cryptographic API
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_xor.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO) += crypto.o
 crypto-y := api.o cipher.o compress.o

--- a/drivers/char/mwave/Makefile
+++ b/drivers/char/mwave/Makefile
@@ -4,6 +4,10 @@
 # See the README file in this directory for more info. <paulsch@us.ibm.com>
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_smapi.o	+= -O2
+endif
+
 obj-$(CONFIG_MWAVE) += mwave.o

 mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_i915_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
 	  i915_debugfs.o \
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1224,7 +1224,11 @@ extern int intel_setup_gmbus(struct drm_
 extern void intel_teardown_gmbus(struct drm_device *dev);
 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#else
 extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#endif
 {
 	return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
 }
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_nv50_instmem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_radeon_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm

 hostprogs-y := mkregtable
--- a/drivers/infiniband/hw/qib/Makefile
+++ b/drivers/infiniband/hw/qib/Makefile
@@ -1,5 +1,9 @@
 obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_qib_iba7322.o	+= -O2
+endif
+
 ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
 	qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
 	qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
--- a/drivers/net/can/sja1000/Makefile
+++ b/drivers/net/can/sja1000/Makefile
@@ -2,6 +2,10 @@
 #  Makefile for the SJA1000 CAN controller drivers.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_kvaser_pci.o	+= -O2
+endif
+
 obj-$(CONFIG_CAN_SJA1000) += sja1000.o
 obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
 obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -1,6 +1,10 @@
 # Makefile for individual comedi drivers
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_cb_pcidas64.o	+= -O2
+endif
+
 # Comedi "helper" modules
 obj-$(CONFIG_COMEDI)			+= pcm_common.o

--- a/drivers/staging/et131x/et1310_address_map.h
+++ b/drivers/staging/et131x/et1310_address_map.h
@@ -212,12 +212,20 @@ struct global_regs {			/* Location: */
 #define INDEX10(x)	((x) & ET_DMA10_MASK)
 #define INDEX4(x)	((x) & ET_DMA4_MASK)

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void add_10bit(u32 *v, int n)
+#else
 extern inline void add_10bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void add_12bit(u32 *v, int n)
+#else
 extern inline void add_12bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
 }
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
 	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#else
 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#endif
 {
 	/* Single white space is for Linksys APs */
 	if (essid_len == 1 && essid[0] == ' ')
@@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
 	return 0;
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline int ieee80211_get_hdrlen(u16 fc)
+#else
 extern inline int ieee80211_get_hdrlen(u16 fc)
+#endif
 {
 	int hdrlen = 24;

--- a/drivers/staging/wlags49_h2/wl_internal.h
+++ b/drivers/staging/wlags49_h2/wl_internal.h
@@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
 /********************************************************************/
 /* Interrupt enable disable functions                               */
 /********************************************************************/
-
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void wl_act_int_on(struct wl_private *lp)
+#else
 extern inline void wl_act_int_on(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
@@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
 	}
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+static inline void wl_act_int_off(struct wl_private *lp)
+#else
 extern inline void wl_act_int_off(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		loopback_driver.descriptors = otg_desc;
 		loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
 }
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		sourcesink_driver.descriptors = otg_desc;
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
 }
--- a/drivers/usb/gadget/g_zero.h
+++ b/drivers/usb/gadget/g_zero.h
@@ -10,7 +10,9 @@

 /* global state */
 extern unsigned buflen;
+#ifdef CONFIG_USB_OTG
 extern const struct usb_descriptor_header *otg_desc[];
+#endif

 /* common utilities */
 struct usb_request *alloc_ep_req(struct usb_ep *ep);
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -4,6 +4,10 @@

 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_ehci-hcd.o	+= -O2
+endif
+
 isp1760-y := isp1760-hcd.o isp1760-if.o

 fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -13,6 +13,11 @@ obj-y :=	open.o read_write.o file_table.
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
 		stack.o fs_struct.o statfs.o

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_compat_ioctl.o	+= -O2
+CFLAGS_binfmt_elf.o	+= -O2
+endif
+
 ifeq ($(CONFIG_BLOCK),y)
 obj-y +=	buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
 else
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -18,8 +18,10 @@ static inline unsigned long __cmpxchg_lo
 	/*
 	 * Sanity checking, compile-time.
 	 */
+#if !(defined(CONFIG_CC_CLOSE_OPTIMIZATION) && defined(CONFIG_ARM))
 	if (size == 8 && sizeof(unsigned long) != 8)
 		wrong_size_cmpxchg(ptr);
+#endif

 	local_irq_save(flags);
 	switch (size) {
@@ -39,8 +41,10 @@ static inline unsigned long __cmpxchg_lo
 		if (prev == old)
 			*(u64 *)ptr = (u64)new;
 		break;
+#if !(defined(CONFIG_CC_CLOSE_OPTIMIZATION) && defined(CONFIG_ARM))
 	default:
 		wrong_size_cmpxchg(ptr);
+#endif
 	}
 	local_irq_restore(flags);
 	return prev;
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
 					unsigned long address)
 {
 	pgoff_t pgoff;
+#ifdef CONFIG_HUGETLBFS
 	if (unlikely(is_vm_hugetlb_page(vma)))
 		return linear_hugepage_index(vma, address);
+#endif
 	pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
 	pgoff += vma->vm_pgoff;
 	return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -886,6 +886,7 @@ endif

 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size"
+	depends on !CC_CLOSE_OPTIMIZATION
 	default y
 	help
 	  Enabling this option will pass "-Os" instead of "-O2" to gcc
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
 		return max;
 	return len;
 }
+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+EXPORT_SYMBOL(__kfifo_max_r);
+#endif

 #define	__KFIFO_PEEK(data, out, mask) \
 	((data)[(out) & (mask)])
--- a/kernel/sched_autogroup.c
+++ b/kernel/sched_autogroup.c
@@ -133,7 +133,11 @@ static inline bool task_group_is_autogro
 	return tg != &root_task_group && tg->autogroup;
 }

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+struct task_group *
+#else
 static inline struct task_group *
+#endif
 autogroup_task_group(struct task_struct *p, struct task_group *tg)
 {
 	int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
--- a/kernel/sched_autogroup.h
+++ b/kernel/sched_autogroup.h
@@ -8,7 +8,11 @@ struct autogroup {
 	int			nice;
 };

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+extern struct task_group *
+#else
 static inline struct task_group *
+#endif
 autogroup_task_group(struct task_struct *p, struct task_group *tg);

 #else /* !CONFIG_SCHED_AUTOGROUP */
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -136,6 +136,14 @@ config DEBUG_SECTION_MISMATCH
 	  - Enable verbose reporting from modpost to help solving
 	    the section mismatches reported.

+config CC_CLOSE_OPTIMIZATION
+	bool "Close GCC optimization"
+	default n
+	help
+	  Enabling this option will let gcc build kernel without "-O2".
+
+	  If unsure, say N.
+
 config DEBUG_KERNEL
 	bool "Kernel debugging"
 	help
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -1,3 +1,9 @@
+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_mmx.o	+= -O2
+CFLAGS_sse1.o	+= -O2
+CFLAGS_sse2.o	+= -O2
+endif
+
 obj-$(CONFIG_RAID6_PQ)	+= raid6_pq.o

 raid6_pq-y	+= algos.o recov.o tables.o int1.o int2.o int4.o \
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -2,6 +2,12 @@
 # Makefile for the linux memory manager.
 #

+ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+CFLAGS_slob.o	+= -O2
+CFLAGS_slab.o	+= -O2
+CFLAGS_slub.o	+= -O2
+endif
+
 mmu-y			:= nommu.o
 mmu-$(CONFIG_MMU)	:= fremap.o highmem.o madvise.o memory.o mincore.o \
 			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1317,8 +1317,10 @@ struct page *follow_page(struct vm_area_
 				spin_unlock(&mm->page_table_lock);
 				wait_split_huge_page(vma->anon_vma, pmd);
 			} else {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 				page = follow_trans_huge_pmd(mm, address,
 							     pmd, flags);
+#endif
 				spin_unlock(&mm->page_table_lock);
 				goto out;
 			}
@@ -2775,7 +2777,9 @@ static int do_swap_page(struct mm_struct

 	if (ksm_might_need_to_copy(page, vma, address)) {
 		swapcache = page;
+#ifdef CONFIG_KSM
 		page = ksm_does_need_to_copy(page, vma, address);
+#endif

 		if (unlikely(!page)) {
 			ret = VM_FAULT_OOM;
@@ -3314,11 +3318,13 @@ int handle_mm_fault(struct mm_struct *mm
 		pmd_t orig_pmd = *pmd;
 		barrier();
 		if (pmd_trans_huge(orig_pmd)) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 			if (flags & FAULT_FLAG_WRITE &&
 			    !pmd_write(orig_pmd) &&
 			    !pmd_trans_splitting(orig_pmd))
 				return do_huge_pmd_wp_page(mm, vma, address,
 							   pmd, orig_pmd);
+#endif
 			return 0;
 		}
 	}
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -155,10 +155,12 @@ static void mincore_pmd_range(struct vm_
 	do {
 		next = pmd_addr_end(addr, end);
 		if (pmd_trans_huge(*pmd)) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 			if (mincore_huge_pmd(vma, pmd, addr, next, vec)) {
 				vec += (next - addr) >> PAGE_SHIFT;
 				continue;
 			}
+#endif
 			/* fall through */
 		}
 		if (pmd_none_or_clear_bad(pmd))
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1886,7 +1886,11 @@ void __init percpu_init_late(void)
 		int *map;
 		const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]);

+#ifdef CONFIG_CC_CLOSE_OPTIMIZATION
+		BUG_ON(size > PAGE_SIZE);
+#else
 		BUILD_BUG_ON(size > PAGE_SIZE);
+#endif

 		map = pcpu_mem_alloc(size);
 		BUG_ON(!map);
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -515,6 +515,7 @@ int page_referenced_one(struct page *pag
 		referenced++;

 	if (unlikely(PageTransHuge(page))) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		pmd_t *pmd;

 		spin_lock(&mm->page_table_lock);
@@ -524,6 +525,7 @@ int page_referenced_one(struct page *pag
 		    pmdp_clear_flush_young_notify(vma, address, pmd))
 			referenced++;
 		spin_unlock(&mm->page_table_lock);
+#endif
 	} else {
 		pte_t *pte;
 		spinlock_t *ptl;
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -699,6 +699,7 @@ static void sta_apply_parameters(struct
 						  params->ht_capa,
 						  &sta->sta.ht_cap);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
 		switch (params->plink_action) {
 		case PLINK_ACTION_OPEN:
@@ -709,6 +710,7 @@ static void sta_apply_parameters(struct
 			break;
 		}
 	}
+#endif
 }

 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -620,8 +620,10 @@ static void ieee80211_teardown_sdata(str
 		__skb_queue_purge(&sdata->fragments[i].skb_list);
 	sdata->fragment_next = 0;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_rmc_free(sdata);
+#endif

 	flushed = sta_info_flush(local, sdata);
 	WARN_ON(flushed);
@@ -797,7 +799,9 @@ static void ieee80211_iface_work(struct
 		case NL80211_IFTYPE_MESH_POINT:
 			if (!ieee80211_vif_is_mesh(&sdata->vif))
 				break;
+#ifdef CONFIG_MAC80211_MESH
 			ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+#endif
 			break;
 		default:
 			WARN(1, "frame for unexpected interface type");
@@ -818,7 +822,9 @@ static void ieee80211_iface_work(struct
 	case NL80211_IFTYPE_MESH_POINT:
 		if (!ieee80211_vif_is_mesh(&sdata->vif))
 			break;
+#ifdef CONFIG_MAC80211_MESH
 		ieee80211_mesh_work(sdata);
+#endif
 		break;
 	default:
 		break;
@@ -872,8 +878,10 @@ static void ieee80211_setup_sdata(struct
 		ieee80211_ibss_setup_sdata(sdata);
 		break;
 	case NL80211_IFTYPE_MESH_POINT:
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sdata->vif))
 			ieee80211_mesh_init_sdata(sdata);
+#endif
 		break;
 	case NL80211_IFTYPE_MONITOR:
 		sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -189,8 +189,10 @@ int ieee80211_fill_mesh_addresses(struct
 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
 		struct ieee80211_sub_if_data *sdata, char *addr4or5,
 		char *addr6);
+#ifdef CONFIG_MAC80211_MESH
 int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
 		struct ieee80211_sub_if_data *sdata);
+#endif
 bool mesh_matches_local(struct ieee802_11_elems *ie,
 		struct ieee80211_sub_if_data *sdata);
 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
 }


+#ifndef CONFIG_MAC80211_MESH
+static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
+		   struct ieee80211_sub_if_data *sdata)
+{
+	return 0;
+}
+#endif
+
 static ieee80211_rx_result
 ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
 {
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -470,8 +470,10 @@ int sta_info_insert_rcu(struct sta_info
 	rcu_read_lock();
 	mutex_unlock(&local->sta_mtx);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_accept_plinks_update(sdata);
+#endif

 	return 0;
  out_free:
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -247,8 +247,10 @@ void ieee80211_tx_status(struct ieee8021
 		}

 		rate_control_tx_status(local, sband, sta, skb);
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
 			ieee80211s_update_metric(local, sta, skb);
+#endif

 		if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
 			ieee80211_frame_acked(sta, skb);
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1638,6 +1638,7 @@ static void ieee80211_xmit(struct ieee80
 	hdr = (struct ieee80211_hdr *) skb->data;
 	info->control.vif = &sdata->vif;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) &&
 	    ieee80211_is_data(hdr->frame_control) &&
 		!is_multicast_ether_addr(hdr->addr1))
@@ -1646,6 +1647,7 @@ static void ieee80211_xmit(struct ieee80
 				rcu_read_unlock();
 				return;
 			}
+#endif

 	ieee80211_set_qos_hdr(local, skb);
 	ieee80211_tx(sdata, skb, false);
@@ -2322,7 +2324,9 @@ struct sk_buff *ieee80211_beacon_get_tim
 		*pos++ = WLAN_EID_SSID;
 		*pos++ = 0x0;

+#ifdef CONFIG_MAC80211_MESH
 		mesh_mgmt_ies_add(skb, sdata);
+#endif
 	} else {
 		WARN_ON(1);
 		goto out;
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -67,7 +67,8 @@ void
 			     struct nf_conntrack_expect *exp) __read_mostly;
 EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);

-#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
+#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) \
+    || defined(CONFIG_CC_CLOSE_OPTIMIZATION)
 /* PptpControlMessageType names */
 const char *const pptp_msg_name[] = {
 	"UNKNOWN_MESSAGE",

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
  2011-01-28  3:41       ` Hui Zhu
@ 2011-02-17  2:43         ` Hui Zhu
       [not found]           ` <AANLkTik+beFdZZHLyei044q8EPHwvmiKoFAvAHsNuhmw@mail.gmail.com>
  0 siblings, 1 reply; 45+ messages in thread
From: Hui Zhu @ 2011-02-17  2:43 UTC (permalink / raw)
  To: linux-kernel, Kevin Pouget, Petr Hluzín; +Cc: gdb, hellogcc

https://lkml.org/lkml/2010/11/28/211
https://lkml.org/lkml/2011/1/24/24
https://lkml.org/lkml/2011/1/27/410

Hi,

According to the comments from Petr, I make a new version that change
the options name to "Compile with almost no optimization".
Thanks for your help, Petr.

Kevin, I am not sure you have try the patch with ARM, I got thread
stack overflow in a ARM board.  I try to increase the THREAD_SIZE like
what I do in x86.  But after I try change THREAD_SIZE_ORDER of arm to
2 and update the code in entry-header.S.
But I got another crash.  Wish somebody can help me with that part.

Thanks,
Hui

Signed-off-by: Hui Zhu <teawater@gmail.com>
---
 Makefile                                        |    2 ++
 arch/arm/include/asm/tlbflush.h                 |    4 ++++
 arch/arm/mm/dma-mapping.c                       |    2 ++
 arch/arm/mm/flush.c                             |    2 ++
 arch/x86/crypto/Makefile                        |    6 ++++++
 arch/x86/include/asm/page_64_types.h            |    4 ++++
 arch/x86/include/asm/uaccess_32.h               |    4 ++++
 arch/x86/kernel/Makefile                        |    9 +++++++++
 arch/x86/kvm/Makefile                           |    6 ++++++
 arch/x86/lib/Makefile                           |    4 ++++
 arch/x86/power/Makefile                         |    4 ++++
 crypto/Makefile                                 |    4 ++++
 drivers/char/mwave/Makefile                     |    4 ++++
 drivers/gpu/drm/i915/Makefile                   |    4 ++++
 drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
 drivers/gpu/drm/nouveau/Makefile                |    4 ++++
 drivers/gpu/drm/radeon/Makefile                 |    4 ++++
 drivers/infiniband/hw/qib/Makefile              |    4 ++++
 drivers/net/can/sja1000/Makefile                |    4 ++++
 drivers/staging/comedi/drivers/Makefile         |    4 ++++
 drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
 drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
 drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
 drivers/usb/gadget/f_loopback.c                 |    2 ++
 drivers/usb/gadget/f_sourcesink.c               |    2 ++
 drivers/usb/gadget/g_zero.h                     |    2 ++
 drivers/usb/host/Makefile                       |    4 ++++
 fs/Makefile                                     |    5 +++++
 include/asm-generic/cmpxchg-local.h             |    4 ++++
 include/linux/pagemap.h                         |    2 ++
 init/Kconfig                                    |    1 +
 kernel/kfifo.c                                  |    3 +++
 kernel/sched_autogroup.c                        |    4 ++++
 kernel/sched_autogroup.h                        |    4 ++++
 lib/Kconfig.debug                               |   10 ++++++++++
 lib/raid6/Makefile                              |    6 ++++++
 mm/Makefile                                     |    6 ++++++
 mm/memory.c                                     |    6 ++++++
 mm/mincore.c                                    |    2 ++
 mm/percpu.c                                     |    4 ++++
 mm/rmap.c                                       |    2 ++
 net/mac80211/cfg.c                              |    2 ++
 net/mac80211/iface.c                            |    8 ++++++++
 net/mac80211/mesh.h                             |    2 ++
 net/mac80211/rx.c                               |    8 ++++++++
 net/mac80211/sta_info.c                         |    2 ++
 net/mac80211/status.c                           |    2 ++
 net/mac80211/tx.c                               |    4 ++++
 net/netfilter/nf_conntrack_pptp.c               |    3 ++-
 49 files changed, 206 insertions(+), 2 deletions(-)

--- a/Makefile
+++ b/Makefile
@@ -541,8 +541,10 @@ all: vmlinux
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
 KBUILD_CFLAGS	+= -Os
 else
+ifndef CONFIG_CC_NO_OPTIMIZATION
 KBUILD_CFLAGS	+= -O2
 endif
+endif

 include $(srctree)/arch/$(SRCARCH)/Makefile

--- a/arch/arm/include/asm/tlbflush.h
+++ b/arch/arm/include/asm/tlbflush.h
@@ -250,7 +250,11 @@ extern void __cpu_flush_kern_tlb_range(u

 extern struct cpu_tlb_fns cpu_tlb;

+#ifdef MULTI_TLB
 #define __cpu_tlb_flags			cpu_tlb.tlb_flags
+#else
+#define __cpu_tlb_flags			0
+#endif

 /*
  *	TLB Management
--- a/arch/arm/mm/dma-mapping.c
+++ b/arch/arm/mm/dma-mapping.c
@@ -468,6 +468,7 @@ static void dma_cache_maint_page(struct
 		void *vaddr;

 		if (PageHighMem(page)) {
+#ifdef CONFIG_HIGHMEM
 			if (len + offset > PAGE_SIZE) {
 				if (offset >= PAGE_SIZE) {
 					page += offset / PAGE_SIZE;
@@ -486,6 +487,7 @@ static void dma_cache_maint_page(struct
 				op(vaddr + offset, len, dir);
 				kunmap_atomic(vaddr);
 			}
+#endif
 		} else {
 			vaddr = page_address(page) + offset;
 			op(vaddr, len, dir);
--- a/arch/arm/mm/flush.c
+++ b/arch/arm/mm/flush.c
@@ -175,6 +175,7 @@ void __flush_dcache_page(struct address_
 	if (!PageHighMem(page)) {
 		__cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
 	} else {
+#ifdef CONFIG_HIGHMEM
 		void *addr = kmap_high_get(page);
 		if (addr) {
 			__cpuc_flush_dcache_area(addr, PAGE_SIZE);
@@ -185,6 +186,7 @@ void __flush_dcache_page(struct address_
 			__cpuc_flush_dcache_area(addr, PAGE_SIZE);
 			kunmap_atomic(addr);
 		}
+#endif
 	}

 	/*
--- a/arch/x86/crypto/Makefile
+++ b/arch/x86/crypto/Makefile
@@ -2,6 +2,12 @@
 # Arch-specific CryptoAPI modules.
 #

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_fpu.o				+= -O2
+CFLAGS_aesni-intel_glue.o		+= -O2
+CFLAGS_ghash-clmulni-intel_glue.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO_FPU) += fpu.o

 obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
--- a/arch/x86/include/asm/page_64_types.h
+++ b/arch/x86/include/asm/page_64_types.h
@@ -1,7 +1,11 @@
 #ifndef _ASM_X86_PAGE_64_DEFS_H
 #define _ASM_X86_PAGE_64_DEFS_H

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+#define THREAD_ORDER	2
+#else
 #define THREAD_ORDER	1
+#endif
 #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
 #define CURRENT_MASK (~(THREAD_SIZE - 1))

--- a/arch/x86/include/asm/uaccess_32.h
+++ b/arch/x86/include/asm/uaccess_32.h
@@ -209,7 +209,11 @@ static inline unsigned long __must_check
 	if (likely(sz == -1 || sz >= n))
 		n = _copy_from_user(to, from, n);
 	else
+#ifndef CONFIG_CC_NO_OPTIMIZATION
 		copy_from_user_overflow();
+#else
+		n = -EFAULT;
+#endif

 	return n;
 }
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o		:= n
 GCOV_PROFILE_tsc.o		:= n
 GCOV_PROFILE_paravirt.o		:= n

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_process_$(BITS).o	+= -O2
+CFLAGS_entry_$(BITS).o		+= -O2
+CFLAGS_traps.o			+= -O2
+CFLAGS_i387.o			+= -O2
+CFLAGS_xsave.o			+= -O2
+CFLAGS_hpet.o			+= -O2
+endif
+
 obj-y			:= process_$(BITS).o signal.o entry_$(BITS).o
 obj-y			+= traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
 obj-y			+= time.o ioport.o ldt.o dumpstack.o
--- a/arch/x86/kvm/Makefile
+++ b/arch/x86/kvm/Makefile
@@ -5,6 +5,12 @@ CFLAGS_x86.o := -I.
 CFLAGS_svm.o := -I.
 CFLAGS_vmx.o := -I.

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_x86.o		+= -O2
+CFLAGS_emulate.o	+= -O2
+CFLAGS_svm.o		+= -O2
+endif
+
 kvm-y			+= $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
 				coalesced_mmio.o irq_comm.o eventfd.o \
 				assigned-dev.o)
--- a/arch/x86/lib/Makefile
+++ b/arch/x86/lib/Makefile
@@ -2,6 +2,10 @@
 # Makefile for x86 specific library files.
 #

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_memmove_64.o	+= -O2
+endif
+
 inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
 inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
 quiet_cmd_inat_tables = GEN     $@
--- a/arch/x86/power/Makefile
+++ b/arch/x86/power/Makefile
@@ -3,5 +3,9 @@
 nostackp := $(call cc-option, -fno-stack-protector)
 CFLAGS_cpu.o	:= $(nostackp)

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_cpu.o	+= -O2
+endif
+
 obj-$(CONFIG_PM_SLEEP)		+= cpu.o
 obj-$(CONFIG_HIBERNATION)	+= hibernate_$(BITS).o hibernate_asm_$(BITS).o
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -2,6 +2,10 @@
 # Cryptographic API
 #

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_xor.o	+= -O2
+endif
+
 obj-$(CONFIG_CRYPTO) += crypto.o
 crypto-y := api.o cipher.o compress.o

--- a/drivers/char/mwave/Makefile
+++ b/drivers/char/mwave/Makefile
@@ -4,6 +4,10 @@
 # See the README file in this directory for more info. <paulsch@us.ibm.com>
 #

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_smapi.o	+= -O2
+endif
+
 obj-$(CONFIG_MWAVE) += mwave.o

 mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_i915_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
 	  i915_debugfs.o \
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1225,7 +1225,11 @@ extern int intel_setup_gmbus(struct drm_
 extern void intel_teardown_gmbus(struct drm_device *dev);
 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
+#ifdef CONFIG_CC_NO_OPTIMIZATION
+static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#else
 extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
+#endif
 {
 	return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
 }
--- a/drivers/gpu/drm/nouveau/Makefile
+++ b/drivers/gpu/drm/nouveau/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_nv50_instmem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm
 nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
--- a/drivers/gpu/drm/radeon/Makefile
+++ b/drivers/gpu/drm/radeon/Makefile
@@ -2,6 +2,10 @@
 # Makefile for the drm device driver.  This driver provides support for the
 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_radeon_gem.o	+= -O2
+endif
+
 ccflags-y := -Iinclude/drm

 hostprogs-y := mkregtable
--- a/drivers/infiniband/hw/qib/Makefile
+++ b/drivers/infiniband/hw/qib/Makefile
@@ -1,5 +1,9 @@
 obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_qib_iba7322.o	+= -O2
+endif
+
 ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
 	qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
 	qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
--- a/drivers/net/can/sja1000/Makefile
+++ b/drivers/net/can/sja1000/Makefile
@@ -2,6 +2,10 @@
 #  Makefile for the SJA1000 CAN controller drivers.
 #

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_kvaser_pci.o	+= -O2
+endif
+
 obj-$(CONFIG_CAN_SJA1000) += sja1000.o
 obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
 obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -1,6 +1,10 @@
 # Makefile for individual comedi drivers
 #

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_cb_pcidas64.o	+= -O2
+endif
+
 # Comedi "helper" modules
 obj-$(CONFIG_COMEDI)			+= pcm_common.o

--- a/drivers/staging/et131x/et1310_address_map.h
+++ b/drivers/staging/et131x/et1310_address_map.h
@@ -212,12 +212,20 @@ struct global_regs {			/* Location: */
 #define INDEX10(x)	((x) & ET_DMA10_MASK)
 #define INDEX4(x)	((x) & ET_DMA4_MASK)

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+static inline void add_10bit(u32 *v, int n)
+#else
 extern inline void add_10bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
 }

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+static inline void add_12bit(u32 *v, int n)
+#else
 extern inline void add_12bit(u32 *v, int n)
+#endif
 {
 	*v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
 }
--- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
@@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
 	return ((struct ieee80211_device *)netdev_priv(dev))->priv;
 }

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#else
 extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
+#endif
 {
 	/* Single white space is for Linksys APs */
 	if (essid_len == 1 && essid[0] == ' ')
@@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
 	return 0;
 }

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+static inline int ieee80211_get_hdrlen(u16 fc)
+#else
 extern inline int ieee80211_get_hdrlen(u16 fc)
+#endif
 {
 	int hdrlen = 24;

--- a/drivers/staging/wlags49_h2/wl_internal.h
+++ b/drivers/staging/wlags49_h2/wl_internal.h
@@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
 /********************************************************************/
 /* Interrupt enable disable functions                               */
 /********************************************************************/
-
+#ifdef CONFIG_CC_NO_OPTIMIZATION
+static inline void wl_act_int_on(struct wl_private *lp)
+#else
 extern inline void wl_act_int_on(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
@@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
 	}
 }

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+static inline void wl_act_int_off(struct wl_private *lp)
+#else
 extern inline void wl_act_int_off(struct wl_private *lp)
+#endif
 {
 	/*
 	 * Only do something when the driver is handling
--- a/drivers/usb/gadget/f_loopback.c
+++ b/drivers/usb/gadget/f_loopback.c
@@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		loopback_driver.descriptors = otg_desc;
 		loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
 }
--- a/drivers/usb/gadget/f_sourcesink.c
+++ b/drivers/usb/gadget/f_sourcesink.c
@@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;

 	/* support OTG systems */
+#ifdef CONFIG_USB_OTG
 	if (gadget_is_otg(cdev->gadget)) {
 		sourcesink_driver.descriptors = otg_desc;
 		sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
 	}
+#endif

 	return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
 }
--- a/drivers/usb/gadget/g_zero.h
+++ b/drivers/usb/gadget/g_zero.h
@@ -10,7 +10,9 @@

 /* global state */
 extern unsigned buflen;
+#ifdef CONFIG_USB_OTG
 extern const struct usb_descriptor_header *otg_desc[];
+#endif

 /* common utilities */
 struct usb_request *alloc_ep_req(struct usb_ep *ep);
--- a/drivers/usb/host/Makefile
+++ b/drivers/usb/host/Makefile
@@ -4,6 +4,10 @@

 ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_ehci-hcd.o	+= -O2
+endif
+
 isp1760-y := isp1760-hcd.o isp1760-if.o

 fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
--- a/fs/Makefile
+++ b/fs/Makefile
@@ -13,6 +13,11 @@ obj-y :=	open.o read_write.o file_table.
 		pnode.o drop_caches.o splice.o sync.o utimes.o \
 		stack.o fs_struct.o statfs.o

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_compat_ioctl.o	+= -O2
+CFLAGS_binfmt_elf.o	+= -O2
+endif
+
 ifeq ($(CONFIG_BLOCK),y)
 obj-y +=	buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
 else
--- a/include/asm-generic/cmpxchg-local.h
+++ b/include/asm-generic/cmpxchg-local.h
@@ -18,8 +18,10 @@ static inline unsigned long __cmpxchg_lo
 	/*
 	 * Sanity checking, compile-time.
 	 */
+#if !(defined(CONFIG_CC_NO_OPTIMIZATION) && defined(CONFIG_ARM))
 	if (size == 8 && sizeof(unsigned long) != 8)
 		wrong_size_cmpxchg(ptr);
+#endif

 	local_irq_save(flags);
 	switch (size) {
@@ -39,8 +41,10 @@ static inline unsigned long __cmpxchg_lo
 		if (prev == old)
 			*(u64 *)ptr = (u64)new;
 		break;
+#if !(defined(CONFIG_CC_NO_OPTIMIZATION) && defined(CONFIG_ARM))
 	default:
 		wrong_size_cmpxchg(ptr);
+#endif
 	}
 	local_irq_restore(flags);
 	return prev;
--- a/include/linux/pagemap.h
+++ b/include/linux/pagemap.h
@@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
 					unsigned long address)
 {
 	pgoff_t pgoff;
+#ifdef CONFIG_HUGETLBFS
 	if (unlikely(is_vm_hugetlb_page(vma)))
 		return linear_hugepage_index(vma, address);
+#endif
 	pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
 	pgoff += vma->vm_pgoff;
 	return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -886,6 +886,7 @@ endif

 config CC_OPTIMIZE_FOR_SIZE
 	bool "Optimize for size"
+	depends on !CC_NO_OPTIMIZATION
 	default y
 	help
 	  Enabling this option will pass "-Os" instead of "-O2" to gcc
--- a/kernel/kfifo.c
+++ b/kernel/kfifo.c
@@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
 		return max;
 	return len;
 }
+#ifdef CONFIG_CC_NO_OPTIMIZATION
+EXPORT_SYMBOL(__kfifo_max_r);
+#endif

 #define	__KFIFO_PEEK(data, out, mask) \
 	((data)[(out) & (mask)])
--- a/kernel/sched_autogroup.c
+++ b/kernel/sched_autogroup.c
@@ -133,7 +133,11 @@ static inline bool task_group_is_autogro
 	return tg != &root_task_group && tg->autogroup;
 }

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+struct task_group *
+#else
 static inline struct task_group *
+#endif
 autogroup_task_group(struct task_struct *p, struct task_group *tg)
 {
 	int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
--- a/kernel/sched_autogroup.h
+++ b/kernel/sched_autogroup.h
@@ -8,7 +8,11 @@ struct autogroup {
 	int			nice;
 };

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+extern struct task_group *
+#else
 static inline struct task_group *
+#endif
 autogroup_task_group(struct task_struct *p, struct task_group *tg);

 #else /* !CONFIG_SCHED_AUTOGROUP */
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -136,6 +136,16 @@ config DEBUG_SECTION_MISMATCH
 	  - Enable verbose reporting from modpost to help solving
 	    the section mismatches reported.

+config CC_NO_OPTIMIZATION
+	bool "Compile with almost no optimization"
+	default n
+	help
+	  Enabling this option will let gcc build kernel with no
+	  optimization (where possible).
+	  This makes debugging friendlier.
+
+	  If unsure, say N.
+
 config DEBUG_KERNEL
 	bool "Kernel debugging"
 	help
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -1,3 +1,9 @@
+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_mmx.o	+= -O2
+CFLAGS_sse1.o	+= -O2
+CFLAGS_sse2.o	+= -O2
+endif
+
 obj-$(CONFIG_RAID6_PQ)	+= raid6_pq.o

 raid6_pq-y	+= algos.o recov.o tables.o int1.o int2.o int4.o \
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -2,6 +2,12 @@
 # Makefile for the linux memory manager.
 #

+ifdef CONFIG_CC_NO_OPTIMIZATION
+CFLAGS_slob.o	+= -O2
+CFLAGS_slab.o	+= -O2
+CFLAGS_slub.o	+= -O2
+endif
+
 mmu-y			:= nommu.o
 mmu-$(CONFIG_MMU)	:= fremap.o highmem.o madvise.o memory.o mincore.o \
 			   mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -1317,8 +1317,10 @@ struct page *follow_page(struct vm_area_
 				spin_unlock(&mm->page_table_lock);
 				wait_split_huge_page(vma->anon_vma, pmd);
 			} else {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 				page = follow_trans_huge_pmd(mm, address,
 							     pmd, flags);
+#endif
 				spin_unlock(&mm->page_table_lock);
 				goto out;
 			}
@@ -2773,7 +2775,9 @@ static int do_swap_page(struct mm_struct

 	if (ksm_might_need_to_copy(page, vma, address)) {
 		swapcache = page;
+#ifdef CONFIG_KSM
 		page = ksm_does_need_to_copy(page, vma, address);
+#endif

 		if (unlikely(!page)) {
 			ret = VM_FAULT_OOM;
@@ -3306,11 +3310,13 @@ int handle_mm_fault(struct mm_struct *mm
 		pmd_t orig_pmd = *pmd;
 		barrier();
 		if (pmd_trans_huge(orig_pmd)) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 			if (flags & FAULT_FLAG_WRITE &&
 			    !pmd_write(orig_pmd) &&
 			    !pmd_trans_splitting(orig_pmd))
 				return do_huge_pmd_wp_page(mm, vma, address,
 							   pmd, orig_pmd);
+#endif
 			return 0;
 		}
 	}
--- a/mm/mincore.c
+++ b/mm/mincore.c
@@ -155,10 +155,12 @@ static void mincore_pmd_range(struct vm_
 	do {
 		next = pmd_addr_end(addr, end);
 		if (pmd_trans_huge(*pmd)) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 			if (mincore_huge_pmd(vma, pmd, addr, next, vec)) {
 				vec += (next - addr) >> PAGE_SHIFT;
 				continue;
 			}
+#endif
 			/* fall through */
 		}
 		if (pmd_none_or_clear_bad(pmd))
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -1886,7 +1886,11 @@ void __init percpu_init_late(void)
 		int *map;
 		const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]);

+#ifdef CONFIG_CC_NO_OPTIMIZATION
+		BUG_ON(size > PAGE_SIZE);
+#else
 		BUILD_BUG_ON(size > PAGE_SIZE);
+#endif

 		map = pcpu_mem_alloc(size);
 		BUG_ON(!map);
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -515,6 +515,7 @@ int page_referenced_one(struct page *pag
 		referenced++;

 	if (unlikely(PageTransHuge(page))) {
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
 		pmd_t *pmd;

 		spin_lock(&mm->page_table_lock);
@@ -524,6 +525,7 @@ int page_referenced_one(struct page *pag
 		    pmdp_clear_flush_young_notify(vma, address, pmd))
 			referenced++;
 		spin_unlock(&mm->page_table_lock);
+#endif
 	} else {
 		pte_t *pte;
 		spinlock_t *ptl;
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -699,6 +699,7 @@ static void sta_apply_parameters(struct
 						  params->ht_capa,
 						  &sta->sta.ht_cap);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
 		switch (params->plink_action) {
 		case PLINK_ACTION_OPEN:
@@ -709,6 +710,7 @@ static void sta_apply_parameters(struct
 			break;
 		}
 	}
+#endif
 }

 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
--- a/net/mac80211/iface.c
+++ b/net/mac80211/iface.c
@@ -620,8 +620,10 @@ static void ieee80211_teardown_sdata(str
 		__skb_queue_purge(&sdata->fragments[i].skb_list);
 	sdata->fragment_next = 0;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_rmc_free(sdata);
+#endif

 	flushed = sta_info_flush(local, sdata);
 	WARN_ON(flushed);
@@ -797,7 +799,9 @@ static void ieee80211_iface_work(struct
 		case NL80211_IFTYPE_MESH_POINT:
 			if (!ieee80211_vif_is_mesh(&sdata->vif))
 				break;
+#ifdef CONFIG_MAC80211_MESH
 			ieee80211_mesh_rx_queued_mgmt(sdata, skb);
+#endif
 			break;
 		default:
 			WARN(1, "frame for unexpected interface type");
@@ -818,7 +822,9 @@ static void ieee80211_iface_work(struct
 	case NL80211_IFTYPE_MESH_POINT:
 		if (!ieee80211_vif_is_mesh(&sdata->vif))
 			break;
+#ifdef CONFIG_MAC80211_MESH
 		ieee80211_mesh_work(sdata);
+#endif
 		break;
 	default:
 		break;
@@ -872,8 +878,10 @@ static void ieee80211_setup_sdata(struct
 		ieee80211_ibss_setup_sdata(sdata);
 		break;
 	case NL80211_IFTYPE_MESH_POINT:
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sdata->vif))
 			ieee80211_mesh_init_sdata(sdata);
+#endif
 		break;
 	case NL80211_IFTYPE_MONITOR:
 		sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
--- a/net/mac80211/mesh.h
+++ b/net/mac80211/mesh.h
@@ -189,8 +189,10 @@ int ieee80211_fill_mesh_addresses(struct
 int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
 		struct ieee80211_sub_if_data *sdata, char *addr4or5,
 		char *addr6);
+#ifdef CONFIG_MAC80211_MESH
 int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
 		struct ieee80211_sub_if_data *sdata);
+#endif
 bool mesh_matches_local(struct ieee802_11_elems *ie,
 		struct ieee80211_sub_if_data *sdata);
 void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
--- a/net/mac80211/rx.c
+++ b/net/mac80211/rx.c
@@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
 }


+#ifndef CONFIG_MAC80211_MESH
+static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
+		   struct ieee80211_sub_if_data *sdata)
+{
+	return 0;
+}
+#endif
+
 static ieee80211_rx_result
 ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
 {
--- a/net/mac80211/sta_info.c
+++ b/net/mac80211/sta_info.c
@@ -470,8 +470,10 @@ int sta_info_insert_rcu(struct sta_info
 	rcu_read_lock();
 	mutex_unlock(&local->sta_mtx);

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif))
 		mesh_accept_plinks_update(sdata);
+#endif

 	return 0;
  out_free:
--- a/net/mac80211/status.c
+++ b/net/mac80211/status.c
@@ -247,8 +247,10 @@ void ieee80211_tx_status(struct ieee8021
 		}

 		rate_control_tx_status(local, sband, sta, skb);
+#ifdef CONFIG_MAC80211_MESH
 		if (ieee80211_vif_is_mesh(&sta->sdata->vif))
 			ieee80211s_update_metric(local, sta, skb);
+#endif

 		if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
 			ieee80211_frame_acked(sta, skb);
--- a/net/mac80211/tx.c
+++ b/net/mac80211/tx.c
@@ -1638,6 +1638,7 @@ static void ieee80211_xmit(struct ieee80
 	hdr = (struct ieee80211_hdr *) skb->data;
 	info->control.vif = &sdata->vif;

+#ifdef CONFIG_MAC80211_MESH
 	if (ieee80211_vif_is_mesh(&sdata->vif) &&
 	    ieee80211_is_data(hdr->frame_control) &&
 		!is_multicast_ether_addr(hdr->addr1))
@@ -1646,6 +1647,7 @@ static void ieee80211_xmit(struct ieee80
 				rcu_read_unlock();
 				return;
 			}
+#endif

 	ieee80211_set_qos_hdr(local, skb);
 	ieee80211_tx(sdata, skb, false);
@@ -2325,7 +2327,9 @@ struct sk_buff *ieee80211_beacon_get_tim
 		*pos++ = WLAN_EID_SSID;
 		*pos++ = 0x0;

+#ifdef CONFIG_MAC80211_MESH
 		mesh_mgmt_ies_add(skb, sdata);
+#endif
 	} else {
 		WARN_ON(1);
 		goto out;
--- a/net/netfilter/nf_conntrack_pptp.c
+++ b/net/netfilter/nf_conntrack_pptp.c
@@ -67,7 +67,8 @@ void
 			     struct nf_conntrack_expect *exp) __read_mostly;
 EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);

-#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
+#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) \
+    || defined(CONFIG_CC_NO_OPTIMIZATION)
 /* PptpControlMessageType names */
 const char *const pptp_msg_name[] = {
 	"UNKNOWN_MESSAGE",

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
       [not found]           ` <AANLkTik+beFdZZHLyei044q8EPHwvmiKoFAvAHsNuhmw@mail.gmail.com>
@ 2011-02-21 12:51             ` Kevin Pouget
  2011-02-23  5:19             ` Hui Zhu
  1 sibling, 0 replies; 45+ messages in thread
From: Kevin Pouget @ 2011-02-21 12:51 UTC (permalink / raw)
  To: linux-kernel, gdb

Hello,

> Kevin, I am not sure you have try the patch with ARM

I've been using the "unoptimized" kernel since you published the ARM
patch, and although I can't say the kernel was heavily stressed,
everything has been working correctly so far, and GDB navigation is
more convenient

Thanks,

Kevin

> On Thu, Feb 17, 2011 at 3:43 AM, Hui Zhu <teawater@gmail.com> wrote:
>>
>> https://lkml.org/lkml/2010/11/28/211
>> https://lkml.org/lkml/2011/1/24/24
>> https://lkml.org/lkml/2011/1/27/410
>>
>> Hi,
>>
>> According to the comments from Petr, I make a new version that change
>> the options name to "Compile with almost no optimization".
>> Thanks for your help, Petr.
>>
>> Kevin, I am not sure you have try the patch with ARM, I got thread
>> stack overflow in a ARM board.  I try to increase the THREAD_SIZE like
>> what I do in x86.  But after I try change THREAD_SIZE_ORDER of arm to
>> 2 and update the code in entry-header.S.
>> But I got another crash.  Wish somebody can help me with that part.
>>
>> Thanks,
>> Hui
>>
>> Signed-off-by: Hui Zhu <teawater@gmail.com>
>> ---
>>  Makefile                                        |    2 ++
>>  arch/arm/include/asm/tlbflush.h                 |    4 ++++
>>  arch/arm/mm/dma-mapping.c                       |    2 ++
>>  arch/arm/mm/flush.c                             |    2 ++
>>  arch/x86/crypto/Makefile                        |    6 ++++++
>>  arch/x86/include/asm/page_64_types.h            |    4 ++++
>>  arch/x86/include/asm/uaccess_32.h               |    4 ++++
>>  arch/x86/kernel/Makefile                        |    9 +++++++++
>>  arch/x86/kvm/Makefile                           |    6 ++++++
>>  arch/x86/lib/Makefile                           |    4 ++++
>>  arch/x86/power/Makefile                         |    4 ++++
>>  crypto/Makefile                                 |    4 ++++
>>  drivers/char/mwave/Makefile                     |    4 ++++
>>  drivers/gpu/drm/i915/Makefile                   |    4 ++++
>>  drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
>>  drivers/gpu/drm/nouveau/Makefile                |    4 ++++
>>  drivers/gpu/drm/radeon/Makefile                 |    4 ++++
>>  drivers/infiniband/hw/qib/Makefile              |    4 ++++
>>  drivers/net/can/sja1000/Makefile                |    4 ++++
>>  drivers/staging/comedi/drivers/Makefile         |    4 ++++
>>  drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
>>  drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
>>  drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
>>  drivers/usb/gadget/f_loopback.c                 |    2 ++
>>  drivers/usb/gadget/f_sourcesink.c               |    2 ++
>>  drivers/usb/gadget/g_zero.h                     |    2 ++
>>  drivers/usb/host/Makefile                       |    4 ++++
>>  fs/Makefile                                     |    5 +++++
>>  include/asm-generic/cmpxchg-local.h             |    4 ++++
>>  include/linux/pagemap.h                         |    2 ++
>>  init/Kconfig                                    |    1 +
>>  kernel/kfifo.c                                  |    3 +++
>>  kernel/sched_autogroup.c                        |    4 ++++
>>  kernel/sched_autogroup.h                        |    4 ++++
>>  lib/Kconfig.debug                               |   10 ++++++++++
>>  lib/raid6/Makefile                              |    6 ++++++
>>  mm/Makefile                                     |    6 ++++++
>>  mm/memory.c                                     |    6 ++++++
>>  mm/mincore.c                                    |    2 ++
>>  mm/percpu.c                                     |    4 ++++
>>  mm/rmap.c                                       |    2 ++
>>  net/mac80211/cfg.c                              |    2 ++
>>  net/mac80211/iface.c                            |    8 ++++++++
>>  net/mac80211/mesh.h                             |    2 ++
>>  net/mac80211/rx.c                               |    8 ++++++++
>>  net/mac80211/sta_info.c                         |    2 ++
>>  net/mac80211/status.c                           |    2 ++
>>  net/mac80211/tx.c                               |    4 ++++
>>  net/netfilter/nf_conntrack_pptp.c               |    3 ++-
>>  49 files changed, 206 insertions(+), 2 deletions(-)
>>
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -541,8 +541,10 @@ all: vmlinux
>>  ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>>  KBUILD_CFLAGS  += -Os
>>  else
>> +ifndef CONFIG_CC_NO_OPTIMIZATION
>>  KBUILD_CFLAGS  += -O2
>>  endif
>> +endif
>>
>>  include $(srctree)/arch/$(SRCARCH)/Makefile
>>
>> --- a/arch/arm/include/asm/tlbflush.h
>> +++ b/arch/arm/include/asm/tlbflush.h
>> @@ -250,7 +250,11 @@ extern void __cpu_flush_kern_tlb_range(u
>>
>>  extern struct cpu_tlb_fns cpu_tlb;
>>
>> +#ifdef MULTI_TLB
>>  #define __cpu_tlb_flags                        cpu_tlb.tlb_flags
>> +#else
>> +#define __cpu_tlb_flags                        0
>> +#endif
>>
>>  /*
>>  *     TLB Management
>> --- a/arch/arm/mm/dma-mapping.c
>> +++ b/arch/arm/mm/dma-mapping.c
>> @@ -468,6 +468,7 @@ static void dma_cache_maint_page(struct
>>                void *vaddr;
>>
>>                if (PageHighMem(page)) {
>> +#ifdef CONFIG_HIGHMEM
>>                        if (len + offset > PAGE_SIZE) {
>>                                if (offset >= PAGE_SIZE) {
>>                                        page += offset / PAGE_SIZE;
>> @@ -486,6 +487,7 @@ static void dma_cache_maint_page(struct
>>                                op(vaddr + offset, len, dir);
>>                                kunmap_atomic(vaddr);
>>                        }
>> +#endif
>>                } else {
>>                        vaddr = page_address(page) + offset;
>>                        op(vaddr, len, dir);
>> --- a/arch/arm/mm/flush.c
>> +++ b/arch/arm/mm/flush.c
>> @@ -175,6 +175,7 @@ void __flush_dcache_page(struct address_
>>        if (!PageHighMem(page)) {
>>                __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
>>        } else {
>> +#ifdef CONFIG_HIGHMEM
>>                void *addr = kmap_high_get(page);
>>                if (addr) {
>>                        __cpuc_flush_dcache_area(addr, PAGE_SIZE);
>> @@ -185,6 +186,7 @@ void __flush_dcache_page(struct address_
>>                        __cpuc_flush_dcache_area(addr, PAGE_SIZE);
>>                        kunmap_atomic(addr);
>>                }
>> +#endif
>>        }
>>
>>        /*
>> --- a/arch/x86/crypto/Makefile
>> +++ b/arch/x86/crypto/Makefile
>> @@ -2,6 +2,12 @@
>>  # Arch-specific CryptoAPI modules.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_fpu.o                           += -O2
>> +CFLAGS_aesni-intel_glue.o              += -O2
>> +CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CRYPTO_FPU) += fpu.o
>>
>>  obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
>> --- a/arch/x86/include/asm/page_64_types.h
>> +++ b/arch/x86/include/asm/page_64_types.h
>> @@ -1,7 +1,11 @@
>>  #ifndef _ASM_X86_PAGE_64_DEFS_H
>>  #define _ASM_X86_PAGE_64_DEFS_H
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +#define THREAD_ORDER   2
>> +#else
>>  #define THREAD_ORDER   1
>> +#endif
>>  #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
>>  #define CURRENT_MASK (~(THREAD_SIZE - 1))
>>
>> --- a/arch/x86/include/asm/uaccess_32.h
>> +++ b/arch/x86/include/asm/uaccess_32.h
>> @@ -209,7 +209,11 @@ static inline unsigned long __must_check
>>        if (likely(sz == -1 || sz >= n))
>>                n = _copy_from_user(to, from, n);
>>        else
>> +#ifndef CONFIG_CC_NO_OPTIMIZATION
>>                copy_from_user_overflow();
>> +#else
>> +               n = -EFAULT;
>> +#endif
>>
>>        return n;
>>  }
>> --- a/arch/x86/kernel/Makefile
>> +++ b/arch/x86/kernel/Makefile
>> @@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o          := n
>>  GCOV_PROFILE_tsc.o             := n
>>  GCOV_PROFILE_paravirt.o                := n
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_process_$(BITS).o       += -O2
>> +CFLAGS_entry_$(BITS).o         += -O2
>> +CFLAGS_traps.o                 += -O2
>> +CFLAGS_i387.o                  += -O2
>> +CFLAGS_xsave.o                 += -O2
>> +CFLAGS_hpet.o                  += -O2
>> +endif
>> +
>>  obj-y                  := process_$(BITS).o signal.o entry_$(BITS).o
>>  obj-y                  += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
>>  obj-y                  += time.o ioport.o ldt.o dumpstack.o
>> --- a/arch/x86/kvm/Makefile
>> +++ b/arch/x86/kvm/Makefile
>> @@ -5,6 +5,12 @@ CFLAGS_x86.o := -I.
>>  CFLAGS_svm.o := -I.
>>  CFLAGS_vmx.o := -I.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_x86.o           += -O2
>> +CFLAGS_emulate.o       += -O2
>> +CFLAGS_svm.o           += -O2
>> +endif
>> +
>>  kvm-y                  += $(addprefix ../../../virt/kvm/, kvm_main.o ioapic.o \
>>                                coalesced_mmio.o irq_comm.o eventfd.o \
>>                                assigned-dev.o)
>> --- a/arch/x86/lib/Makefile
>> +++ b/arch/x86/lib/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for x86 specific library files.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_memmove_64.o    += -O2
>> +endif
>> +
>>  inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
>>  inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
>>  quiet_cmd_inat_tables = GEN     $@
>> --- a/arch/x86/power/Makefile
>> +++ b/arch/x86/power/Makefile
>> @@ -3,5 +3,9 @@
>>  nostackp := $(call cc-option, -fno-stack-protector)
>>  CFLAGS_cpu.o   := $(nostackp)
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_cpu.o   += -O2
>> +endif
>> +
>>  obj-$(CONFIG_PM_SLEEP)         += cpu.o
>>  obj-$(CONFIG_HIBERNATION)      += hibernate_$(BITS).o hibernate_asm_$(BITS).o
>> --- a/crypto/Makefile
>> +++ b/crypto/Makefile
>> @@ -2,6 +2,10 @@
>>  # Cryptographic API
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_xor.o   += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CRYPTO) += crypto.o
>>  crypto-y := api.o cipher.o compress.o
>>
>> --- a/drivers/char/mwave/Makefile
>> +++ b/drivers/char/mwave/Makefile
>> @@ -4,6 +4,10 @@
>>  # See the README file in this directory for more info. <paulsch@us.ibm.com>
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_smapi.o += -O2
>> +endif
>> +
>>  obj-$(CONFIG_MWAVE) += mwave.o
>>
>>  mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
>> --- a/drivers/gpu/drm/i915/Makefile
>> +++ b/drivers/gpu/drm/i915/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_i915_gem.o      += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>  i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
>>          i915_debugfs.o \
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -1225,7 +1225,11 @@ extern int intel_setup_gmbus(struct drm_
>>  extern void intel_teardown_gmbus(struct drm_device *dev);
>>  extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
>>  extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
>> +#else
>>  extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
>> +#endif
>>  {
>>        return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
>>  }
>> --- a/drivers/gpu/drm/nouveau/Makefile
>> +++ b/drivers/gpu/drm/nouveau/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_nv50_instmem.o  += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>  nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o nouveau_mem.o \
>>              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
>> --- a/drivers/gpu/drm/radeon/Makefile
>> +++ b/drivers/gpu/drm/radeon/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_radeon_gem.o    += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>
>>  hostprogs-y := mkregtable
>> --- a/drivers/infiniband/hw/qib/Makefile
>> +++ b/drivers/infiniband/hw/qib/Makefile
>> @@ -1,5 +1,9 @@
>>  obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_qib_iba7322.o   += -O2
>> +endif
>> +
>>  ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
>>        qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
>>        qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
>> --- a/drivers/net/can/sja1000/Makefile
>> +++ b/drivers/net/can/sja1000/Makefile
>> @@ -2,6 +2,10 @@
>>  #  Makefile for the SJA1000 CAN controller drivers.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_kvaser_pci.o    += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CAN_SJA1000) += sja1000.o
>>  obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
>>  obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
>> --- a/drivers/staging/comedi/drivers/Makefile
>> +++ b/drivers/staging/comedi/drivers/Makefile
>> @@ -1,6 +1,10 @@
>>  # Makefile for individual comedi drivers
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_cb_pcidas64.o   += -O2
>> +endif
>> +
>>  # Comedi "helper" modules
>>  obj-$(CONFIG_COMEDI)                   += pcm_common.o
>>
>> --- a/drivers/staging/et131x/et1310_address_map.h
>> +++ b/drivers/staging/et131x/et1310_address_map.h
>> @@ -212,12 +212,20 @@ struct global_regs {                      /* Location: */
>>  #define INDEX10(x)     ((x) & ET_DMA10_MASK)
>>  #define INDEX4(x)      ((x) & ET_DMA4_MASK)
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void add_10bit(u32 *v, int n)
>> +#else
>>  extern inline void add_10bit(u32 *v, int n)
>> +#endif
>>  {
>>        *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void add_12bit(u32 *v, int n)
>> +#else
>>  extern inline void add_12bit(u32 *v, int n)
>> +#endif
>>  {
>>        *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
>>  }
>> --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
>> +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
>> @@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
>>        return ((struct ieee80211_device *)netdev_priv(dev))->priv;
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
>> +#else
>>  extern inline int ieee80211_is_empty_essid(const char *essid, int essid_len)
>> +#endif
>>  {
>>        /* Single white space is for Linksys APs */
>>        if (essid_len == 1 && essid[0] == ' ')
>> @@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
>>        return 0;
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline int ieee80211_get_hdrlen(u16 fc)
>> +#else
>>  extern inline int ieee80211_get_hdrlen(u16 fc)
>> +#endif
>>  {
>>        int hdrlen = 24;
>>
>> --- a/drivers/staging/wlags49_h2/wl_internal.h
>> +++ b/drivers/staging/wlags49_h2/wl_internal.h
>> @@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
>>  /********************************************************************/
>>  /* Interrupt enable disable functions                               */
>>  /********************************************************************/
>> -
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void wl_act_int_on(struct wl_private *lp)
>> +#else
>>  extern inline void wl_act_int_on(struct wl_private *lp)
>> +#endif
>>  {
>>        /*
>>         * Only do something when the driver is handling
>> @@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
>>        }
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void wl_act_int_off(struct wl_private *lp)
>> +#else
>>  extern inline void wl_act_int_off(struct wl_private *lp)
>> +#endif
>>  {
>>        /*
>>         * Only do something when the driver is handling
>> --- a/drivers/usb/gadget/f_loopback.c
>> +++ b/drivers/usb/gadget/f_loopback.c
>> @@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>
>>        /* support OTG systems */
>> +#ifdef CONFIG_USB_OTG
>>        if (gadget_is_otg(cdev->gadget)) {
>>                loopback_driver.descriptors = otg_desc;
>>                loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>        }
>> +#endif
>>
>>        return usb_add_config(cdev, &loopback_driver, loopback_bind_config);
>>  }
>> --- a/drivers/usb/gadget/f_sourcesink.c
>> +++ b/drivers/usb/gadget/f_sourcesink.c
>> @@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>
>>        /* support OTG systems */
>> +#ifdef CONFIG_USB_OTG
>>        if (gadget_is_otg(cdev->gadget)) {
>>                sourcesink_driver.descriptors = otg_desc;
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>        }
>> +#endif
>>
>>        return usb_add_config(cdev, &sourcesink_driver, sourcesink_bind_config);
>>  }
>> --- a/drivers/usb/gadget/g_zero.h
>> +++ b/drivers/usb/gadget/g_zero.h
>> @@ -10,7 +10,9 @@
>>
>>  /* global state */
>>  extern unsigned buflen;
>> +#ifdef CONFIG_USB_OTG
>>  extern const struct usb_descriptor_header *otg_desc[];
>> +#endif
>>
>>  /* common utilities */
>>  struct usb_request *alloc_ep_req(struct usb_ep *ep);
>> --- a/drivers/usb/host/Makefile
>> +++ b/drivers/usb/host/Makefile
>> @@ -4,6 +4,10 @@
>>
>>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_ehci-hcd.o      += -O2
>> +endif
>> +
>>  isp1760-y := isp1760-hcd.o isp1760-if.o
>>
>>  fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
>> --- a/fs/Makefile
>> +++ b/fs/Makefile
>> @@ -13,6 +13,11 @@ obj-y :=     open.o read_write.o file_table.
>>                pnode.o drop_caches.o splice.o sync.o utimes.o \
>>                stack.o fs_struct.o statfs.o
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_compat_ioctl.o  += -O2
>> +CFLAGS_binfmt_elf.o    += -O2
>> +endif
>> +
>>  ifeq ($(CONFIG_BLOCK),y)
>>  obj-y +=       buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
>>  else
>> --- a/include/asm-generic/cmpxchg-local.h
>> +++ b/include/asm-generic/cmpxchg-local.h
>> @@ -18,8 +18,10 @@ static inline unsigned long __cmpxchg_lo
>>        /*
>>         * Sanity checking, compile-time.
>>         */
>> +#if !(defined(CONFIG_CC_NO_OPTIMIZATION) && defined(CONFIG_ARM))
>>        if (size == 8 && sizeof(unsigned long) != 8)
>>                wrong_size_cmpxchg(ptr);
>> +#endif
>>
>>        local_irq_save(flags);
>>        switch (size) {
>> @@ -39,8 +41,10 @@ static inline unsigned long __cmpxchg_lo
>>                if (prev == old)
>>                        *(u64 *)ptr = (u64)new;
>>                break;
>> +#if !(defined(CONFIG_CC_NO_OPTIMIZATION) && defined(CONFIG_ARM))
>>        default:
>>                wrong_size_cmpxchg(ptr);
>> +#endif
>>        }
>>        local_irq_restore(flags);
>>        return prev;
>> --- a/include/linux/pagemap.h
>> +++ b/include/linux/pagemap.h
>> @@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
>>                                        unsigned long address)
>>  {
>>        pgoff_t pgoff;
>> +#ifdef CONFIG_HUGETLBFS
>>        if (unlikely(is_vm_hugetlb_page(vma)))
>>                return linear_hugepage_index(vma, address);
>> +#endif
>>        pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
>>        pgoff += vma->vm_pgoff;
>>        return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -886,6 +886,7 @@ endif
>>
>>  config CC_OPTIMIZE_FOR_SIZE
>>        bool "Optimize for size"
>> +       depends on !CC_NO_OPTIMIZATION
>>        default y
>>        help
>>          Enabling this option will pass "-Os" instead of "-O2" to gcc
>> --- a/kernel/kfifo.c
>> +++ b/kernel/kfifo.c
>> @@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
>>                return max;
>>        return len;
>>  }
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +EXPORT_SYMBOL(__kfifo_max_r);
>> +#endif
>>
>>  #define        __KFIFO_PEEK(data, out, mask) \
>>        ((data)[(out) & (mask)])
>> --- a/kernel/sched_autogroup.c
>> +++ b/kernel/sched_autogroup.c
>> @@ -133,7 +133,11 @@ static inline bool task_group_is_autogro
>>        return tg != &root_task_group && tg->autogroup;
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +struct task_group *
>> +#else
>>  static inline struct task_group *
>> +#endif
>>  autogroup_task_group(struct task_struct *p, struct task_group *tg)
>>  {
>>        int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
>> --- a/kernel/sched_autogroup.h
>> +++ b/kernel/sched_autogroup.h
>> @@ -8,7 +8,11 @@ struct autogroup {
>>        int                     nice;
>>  };
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +extern struct task_group *
>> +#else
>>  static inline struct task_group *
>> +#endif
>>  autogroup_task_group(struct task_struct *p, struct task_group *tg);
>>
>>  #else /* !CONFIG_SCHED_AUTOGROUP */
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -136,6 +136,16 @@ config DEBUG_SECTION_MISMATCH
>>          - Enable verbose reporting from modpost to help solving
>>            the section mismatches reported.
>>
>> +config CC_NO_OPTIMIZATION
>> +       bool "Compile with almost no optimization"
>> +       default n
>> +       help
>> +         Enabling this option will let gcc build kernel with no
>> +         optimization (where possible).
>> +         This makes debugging friendlier.
>> +
>> +         If unsure, say N.
>> +
>>  config DEBUG_KERNEL
>>        bool "Kernel debugging"
>>        help
>> --- a/lib/raid6/Makefile
>> +++ b/lib/raid6/Makefile
>> @@ -1,3 +1,9 @@
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_mmx.o   += -O2
>> +CFLAGS_sse1.o  += -O2
>> +CFLAGS_sse2.o  += -O2
>> +endif
>> +
>>  obj-$(CONFIG_RAID6_PQ) += raid6_pq.o
>>
>>  raid6_pq-y     += algos.o recov.o tables.o int1.o int2.o int4.o \
>> --- a/mm/Makefile
>> +++ b/mm/Makefile
>> @@ -2,6 +2,12 @@
>>  # Makefile for the linux memory manager.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_slob.o  += -O2
>> +CFLAGS_slab.o  += -O2
>> +CFLAGS_slub.o  += -O2
>> +endif
>> +
>>  mmu-y                  := nommu.o
>>  mmu-$(CONFIG_MMU)      := fremap.o highmem.o madvise.o memory.o mincore.o \
>>                           mlock.o mmap.o mprotect.o mremap.o msync.o rmap.o \
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -1317,8 +1317,10 @@ struct page *follow_page(struct vm_area_
>>                                spin_unlock(&mm->page_table_lock);
>>                                wait_split_huge_page(vma->anon_vma, pmd);
>>                        } else {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                                page = follow_trans_huge_pmd(mm, address,
>>                                                             pmd, flags);
>> +#endif
>>                                spin_unlock(&mm->page_table_lock);
>>                                goto out;
>>                        }
>> @@ -2773,7 +2775,9 @@ static int do_swap_page(struct mm_struct
>>
>>        if (ksm_might_need_to_copy(page, vma, address)) {
>>                swapcache = page;
>> +#ifdef CONFIG_KSM
>>                page = ksm_does_need_to_copy(page, vma, address);
>> +#endif
>>
>>                if (unlikely(!page)) {
>>                        ret = VM_FAULT_OOM;
>> @@ -3306,11 +3310,13 @@ int handle_mm_fault(struct mm_struct *mm
>>                pmd_t orig_pmd = *pmd;
>>                barrier();
>>                if (pmd_trans_huge(orig_pmd)) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                        if (flags & FAULT_FLAG_WRITE &&
>>                            !pmd_write(orig_pmd) &&
>>                            !pmd_trans_splitting(orig_pmd))
>>                                return do_huge_pmd_wp_page(mm, vma, address,
>>                                                           pmd, orig_pmd);
>> +#endif
>>                        return 0;
>>                }
>>        }
>> --- a/mm/mincore.c
>> +++ b/mm/mincore.c
>> @@ -155,10 +155,12 @@ static void mincore_pmd_range(struct vm_
>>        do {
>>                next = pmd_addr_end(addr, end);
>>                if (pmd_trans_huge(*pmd)) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                        if (mincore_huge_pmd(vma, pmd, addr, next, vec)) {
>>                                vec += (next - addr) >> PAGE_SHIFT;
>>                                continue;
>>                        }
>> +#endif
>>                        /* fall through */
>>                }
>>                if (pmd_none_or_clear_bad(pmd))
>> --- a/mm/percpu.c
>> +++ b/mm/percpu.c
>> @@ -1886,7 +1886,11 @@ void __init percpu_init_late(void)
>>                int *map;
>>                const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]);
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +               BUG_ON(size > PAGE_SIZE);
>> +#else
>>                BUILD_BUG_ON(size > PAGE_SIZE);
>> +#endif
>>
>>                map = pcpu_mem_alloc(size);
>>                BUG_ON(!map);
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -515,6 +515,7 @@ int page_referenced_one(struct page *pag
>>                referenced++;
>>
>>        if (unlikely(PageTransHuge(page))) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                pmd_t *pmd;
>>
>>                spin_lock(&mm->page_table_lock);
>> @@ -524,6 +525,7 @@ int page_referenced_one(struct page *pag
>>                    pmdp_clear_flush_young_notify(vma, address, pmd))
>>                        referenced++;
>>                spin_unlock(&mm->page_table_lock);
>> +#endif
>>        } else {
>>                pte_t *pte;
>>                spinlock_t *ptl;
>> --- a/net/mac80211/cfg.c
>> +++ b/net/mac80211/cfg.c
>> @@ -699,6 +699,7 @@ static void sta_apply_parameters(struct
>>                                                  params->ht_capa,
>>                                                  &sta->sta.ht_cap);
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
>>                switch (params->plink_action) {
>>                case PLINK_ACTION_OPEN:
>> @@ -709,6 +710,7 @@ static void sta_apply_parameters(struct
>>                        break;
>>                }
>>        }
>> +#endif
>>  }
>>
>>  static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
>> --- a/net/mac80211/iface.c
>> +++ b/net/mac80211/iface.c
>> @@ -620,8 +620,10 @@ static void ieee80211_teardown_sdata(str
>>                __skb_queue_purge(&sdata->fragments[i].skb_list);
>>        sdata->fragment_next = 0;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif))
>>                mesh_rmc_free(sdata);
>> +#endif
>>
>>        flushed = sta_info_flush(local, sdata);
>>        WARN_ON(flushed);
>> @@ -797,7 +799,9 @@ static void ieee80211_iface_work(struct
>>                case NL80211_IFTYPE_MESH_POINT:
>>                        if (!ieee80211_vif_is_mesh(&sdata->vif))
>>                                break;
>> +#ifdef CONFIG_MAC80211_MESH
>>                        ieee80211_mesh_rx_queued_mgmt(sdata, skb);
>> +#endif
>>                        break;
>>                default:
>>                        WARN(1, "frame for unexpected interface type");
>> @@ -818,7 +822,9 @@ static void ieee80211_iface_work(struct
>>        case NL80211_IFTYPE_MESH_POINT:
>>                if (!ieee80211_vif_is_mesh(&sdata->vif))
>>                        break;
>> +#ifdef CONFIG_MAC80211_MESH
>>                ieee80211_mesh_work(sdata);
>> +#endif
>>                break;
>>        default:
>>                break;
>> @@ -872,8 +878,10 @@ static void ieee80211_setup_sdata(struct
>>                ieee80211_ibss_setup_sdata(sdata);
>>                break;
>>        case NL80211_IFTYPE_MESH_POINT:
>> +#ifdef CONFIG_MAC80211_MESH
>>                if (ieee80211_vif_is_mesh(&sdata->vif))
>>                        ieee80211_mesh_init_sdata(sdata);
>> +#endif
>>                break;
>>        case NL80211_IFTYPE_MONITOR:
>>                sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
>> --- a/net/mac80211/mesh.h
>> +++ b/net/mac80211/mesh.h
>> @@ -189,8 +189,10 @@ int ieee80211_fill_mesh_addresses(struct
>>  int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
>>                struct ieee80211_sub_if_data *sdata, char *addr4or5,
>>                char *addr6);
>> +#ifdef CONFIG_MAC80211_MESH
>>  int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
>>                struct ieee80211_sub_if_data *sdata);
>> +#endif
>>  bool mesh_matches_local(struct ieee802_11_elems *ie,
>>                struct ieee80211_sub_if_data *sdata);
>>  void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
>> --- a/net/mac80211/rx.c
>> +++ b/net/mac80211/rx.c
>> @@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
>>  }
>>
>>
>> +#ifndef CONFIG_MAC80211_MESH
>> +static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
>> +                  struct ieee80211_sub_if_data *sdata)
>> +{
>> +       return 0;
>> +}
>> +#endif
>> +
>>  static ieee80211_rx_result
>>  ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
>>  {
>> --- a/net/mac80211/sta_info.c
>> +++ b/net/mac80211/sta_info.c
>> @@ -470,8 +470,10 @@ int sta_info_insert_rcu(struct sta_info
>>        rcu_read_lock();
>>        mutex_unlock(&local->sta_mtx);
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif))
>>                mesh_accept_plinks_update(sdata);
>> +#endif
>>
>>        return 0;
>>  out_free:
>> --- a/net/mac80211/status.c
>> +++ b/net/mac80211/status.c
>> @@ -247,8 +247,10 @@ void ieee80211_tx_status(struct ieee8021
>>                }
>>
>>                rate_control_tx_status(local, sband, sta, skb);
>> +#ifdef CONFIG_MAC80211_MESH
>>                if (ieee80211_vif_is_mesh(&sta->sdata->vif))
>>                        ieee80211s_update_metric(local, sta, skb);
>> +#endif
>>
>>                if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
>>                        ieee80211_frame_acked(sta, skb);
>> --- a/net/mac80211/tx.c
>> +++ b/net/mac80211/tx.c
>> @@ -1638,6 +1638,7 @@ static void ieee80211_xmit(struct ieee80
>>        hdr = (struct ieee80211_hdr *) skb->data;
>>        info->control.vif = &sdata->vif;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif) &&
>>            ieee80211_is_data(hdr->frame_control) &&
>>                !is_multicast_ether_addr(hdr->addr1))
>> @@ -1646,6 +1647,7 @@ static void ieee80211_xmit(struct ieee80
>>                                rcu_read_unlock();
>>                                return;
>>                        }
>> +#endif
>>
>>        ieee80211_set_qos_hdr(local, skb);
>>        ieee80211_tx(sdata, skb, false);
>> @@ -2325,7 +2327,9 @@ struct sk_buff *ieee80211_beacon_get_tim
>>                *pos++ = WLAN_EID_SSID;
>>                *pos++ = 0x0;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>                mesh_mgmt_ies_add(skb, sdata);
>> +#endif
>>        } else {
>>                WARN_ON(1);
>>                goto out;
>> --- a/net/netfilter/nf_conntrack_pptp.c
>> +++ b/net/netfilter/nf_conntrack_pptp.c
>> @@ -67,7 +67,8 @@ void
>>                             struct nf_conntrack_expect *exp) __read_mostly;
>>  EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
>>
>> -#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
>> +#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) \
>> +    || defined(CONFIG_CC_NO_OPTIMIZATION)
>>  /* PptpControlMessageType names */
>>  const char *const pptp_msg_name[] = {
>>        "UNKNOWN_MESSAGE",
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

* Re: [PATCH] Built kernel without -O2 option
       [not found]           ` <AANLkTik+beFdZZHLyei044q8EPHwvmiKoFAvAHsNuhmw@mail.gmail.com>
  2011-02-21 12:51             ` Kevin Pouget
@ 2011-02-23  5:19             ` Hui Zhu
  1 sibling, 0 replies; 45+ messages in thread
From: Hui Zhu @ 2011-02-23  5:19 UTC (permalink / raw)
  To: Kevin Pouget; +Cc: linux-kernel, Petr Hluzín, gdb, hellogcc

That is cool!  Thanks for your help Kevin.

Best,
Hui

On Mon, Feb 21, 2011 at 20:47, Kevin Pouget <kevin.pouget@gmail.com> wrote:
> Hello,
>
>> Kevin, I am not sure you have try the patch with ARM
>
> I've been using the "unoptimized" kernel since you published the ARM patch,
> and although I can't say the kernel was heavily stressed, everything has
> been working correctly so far, and GDB navigation is more convenient
>
> Thanks,
>
> Kevin
>
> On Thu, Feb 17, 2011 at 3:43 AM, Hui Zhu <teawater@gmail.com> wrote:
>>
>> https://lkml.org/lkml/2010/11/28/211
>> https://lkml.org/lkml/2011/1/24/24
>> https://lkml.org/lkml/2011/1/27/410
>>
>> Hi,
>>
>> According to the comments from Petr, I make a new version that change
>> the options name to "Compile with almost no optimization".
>> Thanks for your help, Petr.
>>
>> Kevin, I am not sure you have try the patch with ARM, I got thread
>> stack overflow in a ARM board.  I try to increase the THREAD_SIZE like
>> what I do in x86.  But after I try change THREAD_SIZE_ORDER of arm to
>> 2 and update the code in entry-header.S.
>> But I got another crash.  Wish somebody can help me with that part.
>>
>> Thanks,
>> Hui
>>
>> Signed-off-by: Hui Zhu <teawater@gmail.com>
>> ---
>>  Makefile                                        |    2 ++
>>  arch/arm/include/asm/tlbflush.h                 |    4 ++++
>>  arch/arm/mm/dma-mapping.c                       |    2 ++
>>  arch/arm/mm/flush.c                             |    2 ++
>>  arch/x86/crypto/Makefile                        |    6 ++++++
>>  arch/x86/include/asm/page_64_types.h            |    4 ++++
>>  arch/x86/include/asm/uaccess_32.h               |    4 ++++
>>  arch/x86/kernel/Makefile                        |    9 +++++++++
>>  arch/x86/kvm/Makefile                           |    6 ++++++
>>  arch/x86/lib/Makefile                           |    4 ++++
>>  arch/x86/power/Makefile                         |    4 ++++
>>  crypto/Makefile                                 |    4 ++++
>>  drivers/char/mwave/Makefile                     |    4 ++++
>>  drivers/gpu/drm/i915/Makefile                   |    4 ++++
>>  drivers/gpu/drm/i915/i915_drv.h                 |    4 ++++
>>  drivers/gpu/drm/nouveau/Makefile                |    4 ++++
>>  drivers/gpu/drm/radeon/Makefile                 |    4 ++++
>>  drivers/infiniband/hw/qib/Makefile              |    4 ++++
>>  drivers/net/can/sja1000/Makefile                |    4 ++++
>>  drivers/staging/comedi/drivers/Makefile         |    4 ++++
>>  drivers/staging/et131x/et1310_address_map.h     |    8 ++++++++
>>  drivers/staging/rtl8187se/ieee80211/ieee80211.h |    8 ++++++++
>>  drivers/staging/wlags49_h2/wl_internal.h        |    9 ++++++++-
>>  drivers/usb/gadget/f_loopback.c                 |    2 ++
>>  drivers/usb/gadget/f_sourcesink.c               |    2 ++
>>  drivers/usb/gadget/g_zero.h                     |    2 ++
>>  drivers/usb/host/Makefile                       |    4 ++++
>>  fs/Makefile                                     |    5 +++++
>>  include/asm-generic/cmpxchg-local.h             |    4 ++++
>>  include/linux/pagemap.h                         |    2 ++
>>  init/Kconfig                                    |    1 +
>>  kernel/kfifo.c                                  |    3 +++
>>  kernel/sched_autogroup.c                        |    4 ++++
>>  kernel/sched_autogroup.h                        |    4 ++++
>>  lib/Kconfig.debug                               |   10 ++++++++++
>>  lib/raid6/Makefile                              |    6 ++++++
>>  mm/Makefile                                     |    6 ++++++
>>  mm/memory.c                                     |    6 ++++++
>>  mm/mincore.c                                    |    2 ++
>>  mm/percpu.c                                     |    4 ++++
>>  mm/rmap.c                                       |    2 ++
>>  net/mac80211/cfg.c                              |    2 ++
>>  net/mac80211/iface.c                            |    8 ++++++++
>>  net/mac80211/mesh.h                             |    2 ++
>>  net/mac80211/rx.c                               |    8 ++++++++
>>  net/mac80211/sta_info.c                         |    2 ++
>>  net/mac80211/status.c                           |    2 ++
>>  net/mac80211/tx.c                               |    4 ++++
>>  net/netfilter/nf_conntrack_pptp.c               |    3 ++-
>>  49 files changed, 206 insertions(+), 2 deletions(-)
>>
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -541,8 +541,10 @@ all: vmlinux
>>  ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
>>  KBUILD_CFLAGS  += -Os
>>  else
>> +ifndef CONFIG_CC_NO_OPTIMIZATION
>>  KBUILD_CFLAGS  += -O2
>>  endif
>> +endif
>>
>>  include $(srctree)/arch/$(SRCARCH)/Makefile
>>
>> --- a/arch/arm/include/asm/tlbflush.h
>> +++ b/arch/arm/include/asm/tlbflush.h
>> @@ -250,7 +250,11 @@ extern void __cpu_flush_kern_tlb_range(u
>>
>>  extern struct cpu_tlb_fns cpu_tlb;
>>
>> +#ifdef MULTI_TLB
>>  #define __cpu_tlb_flags                        cpu_tlb.tlb_flags
>> +#else
>> +#define __cpu_tlb_flags                        0
>> +#endif
>>
>>  /*
>>  *     TLB Management
>> --- a/arch/arm/mm/dma-mapping.c
>> +++ b/arch/arm/mm/dma-mapping.c
>> @@ -468,6 +468,7 @@ static void dma_cache_maint_page(struct
>>                void *vaddr;
>>
>>                if (PageHighMem(page)) {
>> +#ifdef CONFIG_HIGHMEM
>>                        if (len + offset > PAGE_SIZE) {
>>                                if (offset >= PAGE_SIZE) {
>>                                        page += offset / PAGE_SIZE;
>> @@ -486,6 +487,7 @@ static void dma_cache_maint_page(struct
>>                                op(vaddr + offset, len, dir);
>>                                kunmap_atomic(vaddr);
>>                        }
>> +#endif
>>                } else {
>>                        vaddr = page_address(page) + offset;
>>                        op(vaddr, len, dir);
>> --- a/arch/arm/mm/flush.c
>> +++ b/arch/arm/mm/flush.c
>> @@ -175,6 +175,7 @@ void __flush_dcache_page(struct address_
>>        if (!PageHighMem(page)) {
>>                __cpuc_flush_dcache_area(page_address(page), PAGE_SIZE);
>>        } else {
>> +#ifdef CONFIG_HIGHMEM
>>                void *addr = kmap_high_get(page);
>>                if (addr) {
>>                        __cpuc_flush_dcache_area(addr, PAGE_SIZE);
>> @@ -185,6 +186,7 @@ void __flush_dcache_page(struct address_
>>                        __cpuc_flush_dcache_area(addr, PAGE_SIZE);
>>                        kunmap_atomic(addr);
>>                }
>> +#endif
>>        }
>>
>>        /*
>> --- a/arch/x86/crypto/Makefile
>> +++ b/arch/x86/crypto/Makefile
>> @@ -2,6 +2,12 @@
>>  # Arch-specific CryptoAPI modules.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_fpu.o                           += -O2
>> +CFLAGS_aesni-intel_glue.o              += -O2
>> +CFLAGS_ghash-clmulni-intel_glue.o      += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CRYPTO_FPU) += fpu.o
>>
>>  obj-$(CONFIG_CRYPTO_AES_586) += aes-i586.o
>> --- a/arch/x86/include/asm/page_64_types.h
>> +++ b/arch/x86/include/asm/page_64_types.h
>> @@ -1,7 +1,11 @@
>>  #ifndef _ASM_X86_PAGE_64_DEFS_H
>>  #define _ASM_X86_PAGE_64_DEFS_H
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +#define THREAD_ORDER   2
>> +#else
>>  #define THREAD_ORDER   1
>> +#endif
>>  #define THREAD_SIZE  (PAGE_SIZE << THREAD_ORDER)
>>  #define CURRENT_MASK (~(THREAD_SIZE - 1))
>>
>> --- a/arch/x86/include/asm/uaccess_32.h
>> +++ b/arch/x86/include/asm/uaccess_32.h
>> @@ -209,7 +209,11 @@ static inline unsigned long __must_check
>>        if (likely(sz == -1 || sz >= n))
>>                n = _copy_from_user(to, from, n);
>>        else
>> +#ifndef CONFIG_CC_NO_OPTIMIZATION
>>                copy_from_user_overflow();
>> +#else
>> +               n = -EFAULT;
>> +#endif
>>
>>        return n;
>>  }
>> --- a/arch/x86/kernel/Makefile
>> +++ b/arch/x86/kernel/Makefile
>> @@ -31,6 +31,15 @@ GCOV_PROFILE_hpet.o          := n
>>  GCOV_PROFILE_tsc.o             := n
>>  GCOV_PROFILE_paravirt.o                := n
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_process_$(BITS).o       += -O2
>> +CFLAGS_entry_$(BITS).o         += -O2
>> +CFLAGS_traps.o                 += -O2
>> +CFLAGS_i387.o                  += -O2
>> +CFLAGS_xsave.o                 += -O2
>> +CFLAGS_hpet.o                  += -O2
>> +endif
>> +
>>  obj-y                  := process_$(BITS).o signal.o entry_$(BITS).o
>>  obj-y                  += traps.o irq.o irq_$(BITS).o dumpstack_$(BITS).o
>>  obj-y                  += time.o ioport.o ldt.o dumpstack.o
>> --- a/arch/x86/kvm/Makefile
>> +++ b/arch/x86/kvm/Makefile
>> @@ -5,6 +5,12 @@ CFLAGS_x86.o := -I.
>>  CFLAGS_svm.o := -I.
>>  CFLAGS_vmx.o := -I.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_x86.o           += -O2
>> +CFLAGS_emulate.o       += -O2
>> +CFLAGS_svm.o           += -O2
>> +endif
>> +
>>  kvm-y                  += $(addprefix ../../../virt/kvm/, kvm_main.o
>> ioapic.o \
>>                                coalesced_mmio.o irq_comm.o eventfd.o \
>>                                assigned-dev.o)
>> --- a/arch/x86/lib/Makefile
>> +++ b/arch/x86/lib/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for x86 specific library files.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_memmove_64.o    += -O2
>> +endif
>> +
>>  inat_tables_script = $(srctree)/arch/x86/tools/gen-insn-attr-x86.awk
>>  inat_tables_maps = $(srctree)/arch/x86/lib/x86-opcode-map.txt
>>  quiet_cmd_inat_tables = GEN     $@
>> --- a/arch/x86/power/Makefile
>> +++ b/arch/x86/power/Makefile
>> @@ -3,5 +3,9 @@
>>  nostackp := $(call cc-option, -fno-stack-protector)
>>  CFLAGS_cpu.o   := $(nostackp)
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_cpu.o   += -O2
>> +endif
>> +
>>  obj-$(CONFIG_PM_SLEEP)         += cpu.o
>>  obj-$(CONFIG_HIBERNATION)      += hibernate_$(BITS).o
>> hibernate_asm_$(BITS).o
>> --- a/crypto/Makefile
>> +++ b/crypto/Makefile
>> @@ -2,6 +2,10 @@
>>  # Cryptographic API
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_xor.o   += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CRYPTO) += crypto.o
>>  crypto-y := api.o cipher.o compress.o
>>
>> --- a/drivers/char/mwave/Makefile
>> +++ b/drivers/char/mwave/Makefile
>> @@ -4,6 +4,10 @@
>>  # See the README file in this directory for more info.
>> <paulsch@us.ibm.com>
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_smapi.o += -O2
>> +endif
>> +
>>  obj-$(CONFIG_MWAVE) += mwave.o
>>
>>  mwave-y := mwavedd.o smapi.o tp3780i.o 3780i.o
>> --- a/drivers/gpu/drm/i915/Makefile
>> +++ b/drivers/gpu/drm/i915/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for
>> the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_i915_gem.o      += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>  i915-y := i915_drv.o i915_dma.o i915_irq.o i915_mem.o \
>>          i915_debugfs.o \
>> --- a/drivers/gpu/drm/i915/i915_drv.h
>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>> @@ -1225,7 +1225,11 @@ extern int intel_setup_gmbus(struct drm_
>>  extern void intel_teardown_gmbus(struct drm_device *dev);
>>  extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int
>> speed);
>>  extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool
>> force_bit);
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
>> +#else
>>  extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
>> +#endif
>>  {
>>        return container_of(adapter, struct intel_gmbus,
>> adapter)->force_bit;
>>  }
>> --- a/drivers/gpu/drm/nouveau/Makefile
>> +++ b/drivers/gpu/drm/nouveau/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for
>> the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_nv50_instmem.o  += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>  nouveau-y := nouveau_drv.o nouveau_state.o nouveau_channel.o
>> nouveau_mem.o \
>>              nouveau_object.o nouveau_irq.o nouveau_notifier.o \
>> --- a/drivers/gpu/drm/radeon/Makefile
>> +++ b/drivers/gpu/drm/radeon/Makefile
>> @@ -2,6 +2,10 @@
>>  # Makefile for the drm device driver.  This driver provides support for
>> the
>>  # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher.
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_radeon_gem.o    += -O2
>> +endif
>> +
>>  ccflags-y := -Iinclude/drm
>>
>>  hostprogs-y := mkregtable
>> --- a/drivers/infiniband/hw/qib/Makefile
>> +++ b/drivers/infiniband/hw/qib/Makefile
>> @@ -1,5 +1,9 @@
>>  obj-$(CONFIG_INFINIBAND_QIB) += ib_qib.o
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_qib_iba7322.o   += -O2
>> +endif
>> +
>>  ib_qib-y := qib_cq.o qib_diag.o qib_dma.o qib_driver.o qib_eeprom.o \
>>        qib_file_ops.o qib_fs.o qib_init.o qib_intr.o qib_keys.o \
>>        qib_mad.o qib_mmap.o qib_mr.o qib_pcie.o qib_pio_copy.o \
>> --- a/drivers/net/can/sja1000/Makefile
>> +++ b/drivers/net/can/sja1000/Makefile
>> @@ -2,6 +2,10 @@
>>  #  Makefile for the SJA1000 CAN controller drivers.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_kvaser_pci.o    += -O2
>> +endif
>> +
>>  obj-$(CONFIG_CAN_SJA1000) += sja1000.o
>>  obj-$(CONFIG_CAN_SJA1000_ISA) += sja1000_isa.o
>>  obj-$(CONFIG_CAN_SJA1000_PLATFORM) += sja1000_platform.o
>> --- a/drivers/staging/comedi/drivers/Makefile
>> +++ b/drivers/staging/comedi/drivers/Makefile
>> @@ -1,6 +1,10 @@
>>  # Makefile for individual comedi drivers
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_cb_pcidas64.o   += -O2
>> +endif
>> +
>>  # Comedi "helper" modules
>>  obj-$(CONFIG_COMEDI)                   += pcm_common.o
>>
>> --- a/drivers/staging/et131x/et1310_address_map.h
>> +++ b/drivers/staging/et131x/et1310_address_map.h
>> @@ -212,12 +212,20 @@ struct global_regs {                      /*
>> Location: */
>>  #define INDEX10(x)     ((x) & ET_DMA10_MASK)
>>  #define INDEX4(x)      ((x) & ET_DMA4_MASK)
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void add_10bit(u32 *v, int n)
>> +#else
>>  extern inline void add_10bit(u32 *v, int n)
>> +#endif
>>  {
>>        *v = INDEX10(*v + n) | (*v & ET_DMA10_WRAP);
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void add_12bit(u32 *v, int n)
>> +#else
>>  extern inline void add_12bit(u32 *v, int n)
>> +#endif
>>  {
>>        *v = INDEX12(*v + n) | (*v & ET_DMA12_WRAP);
>>  }
>> --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h
>> +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h
>> @@ -1221,7 +1221,11 @@ static inline void *ieee80211_priv(struc
>>        return ((struct ieee80211_device *)netdev_priv(dev))->priv;
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline int ieee80211_is_empty_essid(const char *essid, int
>> essid_len)
>> +#else
>>  extern inline int ieee80211_is_empty_essid(const char *essid, int
>> essid_len)
>> +#endif
>>  {
>>        /* Single white space is for Linksys APs */
>>        if (essid_len == 1 && essid[0] == ' ')
>> @@ -1263,7 +1267,11 @@ extern inline int ieee80211_is_valid_mod
>>        return 0;
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline int ieee80211_get_hdrlen(u16 fc)
>> +#else
>>  extern inline int ieee80211_get_hdrlen(u16 fc)
>> +#endif
>>  {
>>        int hdrlen = 24;
>>
>> --- a/drivers/staging/wlags49_h2/wl_internal.h
>> +++ b/drivers/staging/wlags49_h2/wl_internal.h
>> @@ -1022,8 +1022,11 @@ static inline void wl_unlock(struct wl_p
>>  /********************************************************************/
>>  /* Interrupt enable disable functions                               */
>>  /********************************************************************/
>> -
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void wl_act_int_on(struct wl_private *lp)
>> +#else
>>  extern inline void wl_act_int_on(struct wl_private *lp)
>> +#endif
>>  {
>>        /*
>>         * Only do something when the driver is handling
>> @@ -1035,7 +1038,11 @@ extern inline void wl_act_int_on(struct
>>        }
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +static inline void wl_act_int_off(struct wl_private *lp)
>> +#else
>>  extern inline void wl_act_int_off(struct wl_private *lp)
>> +#endif
>>  {
>>        /*
>>         * Only do something when the driver is handling
>> --- a/drivers/usb/gadget/f_loopback.c
>> +++ b/drivers/usb/gadget/f_loopback.c
>> @@ -376,10 +376,12 @@ int __init loopback_add(struct usb_compo
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>
>>        /* support OTG systems */
>> +#ifdef CONFIG_USB_OTG
>>        if (gadget_is_otg(cdev->gadget)) {
>>                loopback_driver.descriptors = otg_desc;
>>                loopback_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>        }
>> +#endif
>>
>>        return usb_add_config(cdev, &loopback_driver,
>> loopback_bind_config);
>>  }
>> --- a/drivers/usb/gadget/f_sourcesink.c
>> +++ b/drivers/usb/gadget/f_sourcesink.c
>> @@ -526,10 +526,12 @@ int __init sourcesink_add(struct usb_com
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>
>>        /* support OTG systems */
>> +#ifdef CONFIG_USB_OTG
>>        if (gadget_is_otg(cdev->gadget)) {
>>                sourcesink_driver.descriptors = otg_desc;
>>                sourcesink_driver.bmAttributes |= USB_CONFIG_ATT_WAKEUP;
>>        }
>> +#endif
>>
>>        return usb_add_config(cdev, &sourcesink_driver,
>> sourcesink_bind_config);
>>  }
>> --- a/drivers/usb/gadget/g_zero.h
>> +++ b/drivers/usb/gadget/g_zero.h
>> @@ -10,7 +10,9 @@
>>
>>  /* global state */
>>  extern unsigned buflen;
>> +#ifdef CONFIG_USB_OTG
>>  extern const struct usb_descriptor_header *otg_desc[];
>> +#endif
>>
>>  /* common utilities */
>>  struct usb_request *alloc_ep_req(struct usb_ep *ep);
>> --- a/drivers/usb/host/Makefile
>> +++ b/drivers/usb/host/Makefile
>> @@ -4,6 +4,10 @@
>>
>>  ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_ehci-hcd.o      += -O2
>> +endif
>> +
>>  isp1760-y := isp1760-hcd.o isp1760-if.o
>>
>>  fhci-y := fhci-hcd.o fhci-hub.o fhci-q.o
>> --- a/fs/Makefile
>> +++ b/fs/Makefile
>> @@ -13,6 +13,11 @@ obj-y :=     open.o read_write.o file_table.
>>                pnode.o drop_caches.o splice.o sync.o utimes.o \
>>                stack.o fs_struct.o statfs.o
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_compat_ioctl.o  += -O2
>> +CFLAGS_binfmt_elf.o    += -O2
>> +endif
>> +
>>  ifeq ($(CONFIG_BLOCK),y)
>>  obj-y +=       buffer.o bio.o block_dev.o direct-io.o mpage.o ioprio.o
>>  else
>> --- a/include/asm-generic/cmpxchg-local.h
>> +++ b/include/asm-generic/cmpxchg-local.h
>> @@ -18,8 +18,10 @@ static inline unsigned long __cmpxchg_lo
>>        /*
>>         * Sanity checking, compile-time.
>>         */
>> +#if !(defined(CONFIG_CC_NO_OPTIMIZATION) && defined(CONFIG_ARM))
>>        if (size == 8 && sizeof(unsigned long) != 8)
>>                wrong_size_cmpxchg(ptr);
>> +#endif
>>
>>        local_irq_save(flags);
>>        switch (size) {
>> @@ -39,8 +41,10 @@ static inline unsigned long __cmpxchg_lo
>>                if (prev == old)
>>                        *(u64 *)ptr = (u64)new;
>>                break;
>> +#if !(defined(CONFIG_CC_NO_OPTIMIZATION) && defined(CONFIG_ARM))
>>        default:
>>                wrong_size_cmpxchg(ptr);
>> +#endif
>>        }
>>        local_irq_restore(flags);
>>        return prev;
>> --- a/include/linux/pagemap.h
>> +++ b/include/linux/pagemap.h
>> @@ -289,8 +289,10 @@ static inline pgoff_t linear_page_index(
>>                                        unsigned long address)
>>  {
>>        pgoff_t pgoff;
>> +#ifdef CONFIG_HUGETLBFS
>>        if (unlikely(is_vm_hugetlb_page(vma)))
>>                return linear_hugepage_index(vma, address);
>> +#endif
>>        pgoff = (address - vma->vm_start) >> PAGE_SHIFT;
>>        pgoff += vma->vm_pgoff;
>>        return pgoff >> (PAGE_CACHE_SHIFT - PAGE_SHIFT);
>> --- a/init/Kconfig
>> +++ b/init/Kconfig
>> @@ -886,6 +886,7 @@ endif
>>
>>  config CC_OPTIMIZE_FOR_SIZE
>>        bool "Optimize for size"
>> +       depends on !CC_NO_OPTIMIZATION
>>        default y
>>        help
>>          Enabling this option will pass "-Os" instead of "-O2" to gcc
>> --- a/kernel/kfifo.c
>> +++ b/kernel/kfifo.c
>> @@ -402,6 +402,9 @@ unsigned int __kfifo_max_r(unsigned int
>>                return max;
>>        return len;
>>  }
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +EXPORT_SYMBOL(__kfifo_max_r);
>> +#endif
>>
>>  #define        __KFIFO_PEEK(data, out, mask) \
>>        ((data)[(out) & (mask)])
>> --- a/kernel/sched_autogroup.c
>> +++ b/kernel/sched_autogroup.c
>> @@ -133,7 +133,11 @@ static inline bool task_group_is_autogro
>>        return tg != &root_task_group && tg->autogroup;
>>  }
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +struct task_group *
>> +#else
>>  static inline struct task_group *
>> +#endif
>>  autogroup_task_group(struct task_struct *p, struct task_group *tg)
>>  {
>>        int enabled = ACCESS_ONCE(sysctl_sched_autogroup_enabled);
>> --- a/kernel/sched_autogroup.h
>> +++ b/kernel/sched_autogroup.h
>> @@ -8,7 +8,11 @@ struct autogroup {
>>        int                     nice;
>>  };
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +extern struct task_group *
>> +#else
>>  static inline struct task_group *
>> +#endif
>>  autogroup_task_group(struct task_struct *p, struct task_group *tg);
>>
>>  #else /* !CONFIG_SCHED_AUTOGROUP */
>> --- a/lib/Kconfig.debug
>> +++ b/lib/Kconfig.debug
>> @@ -136,6 +136,16 @@ config DEBUG_SECTION_MISMATCH
>>          - Enable verbose reporting from modpost to help solving
>>            the section mismatches reported.
>>
>> +config CC_NO_OPTIMIZATION
>> +       bool "Compile with almost no optimization"
>> +       default n
>> +       help
>> +         Enabling this option will let gcc build kernel with no
>> +         optimization (where possible).
>> +         This makes debugging friendlier.
>> +
>> +         If unsure, say N.
>> +
>>  config DEBUG_KERNEL
>>        bool "Kernel debugging"
>>        help
>> --- a/lib/raid6/Makefile
>> +++ b/lib/raid6/Makefile
>> @@ -1,3 +1,9 @@
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_mmx.o   += -O2
>> +CFLAGS_sse1.o  += -O2
>> +CFLAGS_sse2.o  += -O2
>> +endif
>> +
>>  obj-$(CONFIG_RAID6_PQ) += raid6_pq.o
>>
>>  raid6_pq-y     += algos.o recov.o tables.o int1.o int2.o int4.o \
>> --- a/mm/Makefile
>> +++ b/mm/Makefile
>> @@ -2,6 +2,12 @@
>>  # Makefile for the linux memory manager.
>>  #
>>
>> +ifdef CONFIG_CC_NO_OPTIMIZATION
>> +CFLAGS_slob.o  += -O2
>> +CFLAGS_slab.o  += -O2
>> +CFLAGS_slub.o  += -O2
>> +endif
>> +
>>  mmu-y                  := nommu.o
>>  mmu-$(CONFIG_MMU)      := fremap.o highmem.o madvise.o memory.o mincore.o
>> \
>>                           mlock.o mmap.o mprotect.o mremap.o msync.o
>> rmap.o \
>> --- a/mm/memory.c
>> +++ b/mm/memory.c
>> @@ -1317,8 +1317,10 @@ struct page *follow_page(struct vm_area_
>>                                spin_unlock(&mm->page_table_lock);
>>                                wait_split_huge_page(vma->anon_vma, pmd);
>>                        } else {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                                page = follow_trans_huge_pmd(mm, address,
>>                                                             pmd, flags);
>> +#endif
>>                                spin_unlock(&mm->page_table_lock);
>>                                goto out;
>>                        }
>> @@ -2773,7 +2775,9 @@ static int do_swap_page(struct mm_struct
>>
>>        if (ksm_might_need_to_copy(page, vma, address)) {
>>                swapcache = page;
>> +#ifdef CONFIG_KSM
>>                page = ksm_does_need_to_copy(page, vma, address);
>> +#endif
>>
>>                if (unlikely(!page)) {
>>                        ret = VM_FAULT_OOM;
>> @@ -3306,11 +3310,13 @@ int handle_mm_fault(struct mm_struct *mm
>>                pmd_t orig_pmd = *pmd;
>>                barrier();
>>                if (pmd_trans_huge(orig_pmd)) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                        if (flags & FAULT_FLAG_WRITE &&
>>                            !pmd_write(orig_pmd) &&
>>                            !pmd_trans_splitting(orig_pmd))
>>                                return do_huge_pmd_wp_page(mm, vma,
>> address,
>>                                                           pmd, orig_pmd);
>> +#endif
>>                        return 0;
>>                }
>>        }
>> --- a/mm/mincore.c
>> +++ b/mm/mincore.c
>> @@ -155,10 +155,12 @@ static void mincore_pmd_range(struct vm_
>>        do {
>>                next = pmd_addr_end(addr, end);
>>                if (pmd_trans_huge(*pmd)) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                        if (mincore_huge_pmd(vma, pmd, addr, next, vec)) {
>>                                vec += (next - addr) >> PAGE_SHIFT;
>>                                continue;
>>                        }
>> +#endif
>>                        /* fall through */
>>                }
>>                if (pmd_none_or_clear_bad(pmd))
>> --- a/mm/percpu.c
>> +++ b/mm/percpu.c
>> @@ -1886,7 +1886,11 @@ void __init percpu_init_late(void)
>>                int *map;
>>                const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS *
>> sizeof(map[0]);
>>
>> +#ifdef CONFIG_CC_NO_OPTIMIZATION
>> +               BUG_ON(size > PAGE_SIZE);
>> +#else
>>                BUILD_BUG_ON(size > PAGE_SIZE);
>> +#endif
>>
>>                map = pcpu_mem_alloc(size);
>>                BUG_ON(!map);
>> --- a/mm/rmap.c
>> +++ b/mm/rmap.c
>> @@ -515,6 +515,7 @@ int page_referenced_one(struct page *pag
>>                referenced++;
>>
>>        if (unlikely(PageTransHuge(page))) {
>> +#ifdef CONFIG_TRANSPARENT_HUGEPAGE
>>                pmd_t *pmd;
>>
>>                spin_lock(&mm->page_table_lock);
>> @@ -524,6 +525,7 @@ int page_referenced_one(struct page *pag
>>                    pmdp_clear_flush_young_notify(vma, address, pmd))
>>                        referenced++;
>>                spin_unlock(&mm->page_table_lock);
>> +#endif
>>        } else {
>>                pte_t *pte;
>>                spinlock_t *ptl;
>> --- a/net/mac80211/cfg.c
>> +++ b/net/mac80211/cfg.c
>> @@ -699,6 +699,7 @@ static void sta_apply_parameters(struct
>>                                                  params->ht_capa,
>>                                                  &sta->sta.ht_cap);
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif) && params->plink_action) {
>>                switch (params->plink_action) {
>>                case PLINK_ACTION_OPEN:
>> @@ -709,6 +710,7 @@ static void sta_apply_parameters(struct
>>                        break;
>>                }
>>        }
>> +#endif
>>  }
>>
>>  static int ieee80211_add_station(struct wiphy *wiphy, struct net_device
>> *dev,
>> --- a/net/mac80211/iface.c
>> +++ b/net/mac80211/iface.c
>> @@ -620,8 +620,10 @@ static void ieee80211_teardown_sdata(str
>>                __skb_queue_purge(&sdata->fragments[i].skb_list);
>>        sdata->fragment_next = 0;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif))
>>                mesh_rmc_free(sdata);
>> +#endif
>>
>>        flushed = sta_info_flush(local, sdata);
>>        WARN_ON(flushed);
>> @@ -797,7 +799,9 @@ static void ieee80211_iface_work(struct
>>                case NL80211_IFTYPE_MESH_POINT:
>>                        if (!ieee80211_vif_is_mesh(&sdata->vif))
>>                                break;
>> +#ifdef CONFIG_MAC80211_MESH
>>                        ieee80211_mesh_rx_queued_mgmt(sdata, skb);
>> +#endif
>>                        break;
>>                default:
>>                        WARN(1, "frame for unexpected interface type");
>> @@ -818,7 +822,9 @@ static void ieee80211_iface_work(struct
>>        case NL80211_IFTYPE_MESH_POINT:
>>                if (!ieee80211_vif_is_mesh(&sdata->vif))
>>                        break;
>> +#ifdef CONFIG_MAC80211_MESH
>>                ieee80211_mesh_work(sdata);
>> +#endif
>>                break;
>>        default:
>>                break;
>> @@ -872,8 +878,10 @@ static void ieee80211_setup_sdata(struct
>>                ieee80211_ibss_setup_sdata(sdata);
>>                break;
>>        case NL80211_IFTYPE_MESH_POINT:
>> +#ifdef CONFIG_MAC80211_MESH
>>                if (ieee80211_vif_is_mesh(&sdata->vif))
>>                        ieee80211_mesh_init_sdata(sdata);
>> +#endif
>>                break;
>>        case NL80211_IFTYPE_MONITOR:
>>                sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
>> --- a/net/mac80211/mesh.h
>> +++ b/net/mac80211/mesh.h
>> @@ -189,8 +189,10 @@ int ieee80211_fill_mesh_addresses(struct
>>  int ieee80211_new_mesh_header(struct ieee80211s_hdr *meshhdr,
>>                struct ieee80211_sub_if_data *sdata, char *addr4or5,
>>                char *addr6);
>> +#ifdef CONFIG_MAC80211_MESH
>>  int mesh_rmc_check(u8 *addr, struct ieee80211s_hdr *mesh_hdr,
>>                struct ieee80211_sub_if_data *sdata);
>> +#endif
>>  bool mesh_matches_local(struct ieee802_11_elems *ie,
>>                struct ieee80211_sub_if_data *sdata);
>>  void mesh_ids_set_default(struct ieee80211_if_mesh *mesh);
>> --- a/net/mac80211/rx.c
>> +++ b/net/mac80211/rx.c
>> @@ -453,6 +453,14 @@ static int ieee80211_get_mmie_keyidx(str
>>  }
>>
>>
>> +#ifndef CONFIG_MAC80211_MESH
>> +static int mesh_rmc_check(u8 *sa, struct ieee80211s_hdr *mesh_hdr,
>> +                  struct ieee80211_sub_if_data *sdata)
>> +{
>> +       return 0;
>> +}
>> +#endif
>> +
>>  static ieee80211_rx_result
>>  ieee80211_rx_mesh_check(struct ieee80211_rx_data *rx)
>>  {
>> --- a/net/mac80211/sta_info.c
>> +++ b/net/mac80211/sta_info.c
>> @@ -470,8 +470,10 @@ int sta_info_insert_rcu(struct sta_info
>>        rcu_read_lock();
>>        mutex_unlock(&local->sta_mtx);
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif))
>>                mesh_accept_plinks_update(sdata);
>> +#endif
>>
>>        return 0;
>>  out_free:
>> --- a/net/mac80211/status.c
>> +++ b/net/mac80211/status.c
>> @@ -247,8 +247,10 @@ void ieee80211_tx_status(struct ieee8021
>>                }
>>
>>                rate_control_tx_status(local, sband, sta, skb);
>> +#ifdef CONFIG_MAC80211_MESH
>>                if (ieee80211_vif_is_mesh(&sta->sdata->vif))
>>                        ieee80211s_update_metric(local, sta, skb);
>> +#endif
>>
>>                if (!(info->flags & IEEE80211_TX_CTL_INJECTED) && acked)
>>                        ieee80211_frame_acked(sta, skb);
>> --- a/net/mac80211/tx.c
>> +++ b/net/mac80211/tx.c
>> @@ -1638,6 +1638,7 @@ static void ieee80211_xmit(struct ieee80
>>        hdr = (struct ieee80211_hdr *) skb->data;
>>        info->control.vif = &sdata->vif;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>        if (ieee80211_vif_is_mesh(&sdata->vif) &&
>>            ieee80211_is_data(hdr->frame_control) &&
>>                !is_multicast_ether_addr(hdr->addr1))
>> @@ -1646,6 +1647,7 @@ static void ieee80211_xmit(struct ieee80
>>                                rcu_read_unlock();
>>                                return;
>>                        }
>> +#endif
>>
>>        ieee80211_set_qos_hdr(local, skb);
>>        ieee80211_tx(sdata, skb, false);
>> @@ -2325,7 +2327,9 @@ struct sk_buff *ieee80211_beacon_get_tim
>>                *pos++ = WLAN_EID_SSID;
>>                *pos++ = 0x0;
>>
>> +#ifdef CONFIG_MAC80211_MESH
>>                mesh_mgmt_ies_add(skb, sdata);
>> +#endif
>>        } else {
>>                WARN_ON(1);
>>                goto out;
>> --- a/net/netfilter/nf_conntrack_pptp.c
>> +++ b/net/netfilter/nf_conntrack_pptp.c
>> @@ -67,7 +67,8 @@ void
>>                             struct nf_conntrack_expect *exp)
>> __read_mostly;
>>  EXPORT_SYMBOL_GPL(nf_nat_pptp_hook_expectfn);
>>
>> -#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG)
>> +#if defined(DEBUG) || defined(CONFIG_DYNAMIC_DEBUG) \
>> +    || defined(CONFIG_CC_NO_OPTIMIZATION)
>>  /* PptpControlMessageType names */
>>  const char *const pptp_msg_name[] = {
>>        "UNKNOWN_MESSAGE",
>
>

^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2011-02-23  5:20 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-29  3:56 [PATCH] Built kernel without -O2 option Hui Zhu
2010-11-29  8:16 ` Américo Wang
2010-11-29  8:18   ` microcai
2010-11-29  8:24   ` Hui Zhu
     [not found]     ` <4CF36741.9000808@loongson.cn>
2010-11-29  8:47       ` [hellogcc] " Hui Zhu
2010-11-29  8:55         ` Steven
2010-11-29  8:57           ` Hui Zhu
2010-11-29  9:45         ` 乔崇
2010-11-29 18:10           ` Valdis.Kletnieks
2010-11-29 18:34             ` Steven J. Magnani
2010-11-29 22:03             ` Alexey Dobriyan
2010-12-01 13:21               ` Hui Zhu
2010-12-01 12:23           ` bekars
2010-12-01 13:24             ` Hui Zhu
2010-12-01 13:58               ` bekars
2010-12-01 15:01                 ` Hui Zhu
2010-12-01 15:42                   ` jovi zhang
2010-11-29  8:52     ` Américo Wang
2010-11-29  9:11       ` Hui Zhu
2010-11-29 18:03       ` Valdis.Kletnieks
2010-11-29 20:51       ` richard -rw- weinberger
2010-11-29 21:00         ` Arnaud Lacombe
2010-11-29 21:07           ` richard -rw- weinberger
2010-11-29  9:44   ` Christian Borntraeger
2010-11-29 11:12     ` Segher Boessenkool
2010-11-29 11:17       ` Christian Borntraeger
2010-11-29 11:57         ` Nicholas Mc Guire
2010-12-01 12:18     ` Hui Zhu
2010-11-29  9:59 ` Andi Kleen
2010-11-29 10:12   ` Mark Wielaard
2010-11-30  9:31     ` Américo Wang
2010-11-30 18:40       ` Michael Snyder
2010-12-01 12:52   ` Hui Zhu
2010-11-29 19:05 ` Jan Kratochvil
2010-11-29 21:07 ` Arnaud Lacombe
2010-11-30 22:40   ` Petr Hluzín
2010-12-01 13:42     ` Hui Zhu
2010-12-01 13:10   ` Hui Zhu
2011-01-24  7:47 ` Hui Zhu
2011-01-24  8:11   ` Kevin Pouget
2011-01-24 12:42     ` Hui Zhu
2011-01-28  3:41       ` Hui Zhu
2011-02-17  2:43         ` Hui Zhu
     [not found]           ` <AANLkTik+beFdZZHLyei044q8EPHwvmiKoFAvAHsNuhmw@mail.gmail.com>
2011-02-21 12:51             ` Kevin Pouget
2011-02-23  5:19             ` Hui Zhu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.