Re: [PATCH] Built kernel without -O2 option

From: Kevin Pouget
Date: Mon Feb 21 2011 - 07:52:08 EST


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@xxxxxxxxx> 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@xxxxxxxxx>
>> ---
>>  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@xxxxxxxxxx>
>>  #
>>
>> +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",
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/