2010-11-29 03:56:39

by Hui Zhu

[permalink] [raw]
Subject: [PATCH] Built kernel without -O2 option

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 <[email protected]>
---
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. <[email protected]>
#

+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;


2010-11-29 08:11:32

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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?

2010-11-29 08:18:31

by microcai

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

2010/11/29 Américo Wang <[email protected]>:
> 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 [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>

2010-11-29 08:25:06

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, Nov 29, 2010 at 16:16, Am?rico Wang <[email protected]> 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

2010-11-29 08:48:05

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, Nov 29, 2010 at 04:24:42PM +0800, Hui Zhu wrote:
>On Mon, Nov 29, 2010 at 16:16, Américo Wang <[email protected]> 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.

2010-11-29 09:11:46

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, Nov 29, 2010 at 16:52, Am?rico Wang <[email protected]> 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 <[email protected]> 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

2010-11-29 09:44:40

by Christian Borntraeger

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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

2010-11-29 09:59:45

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

Hui Zhu <[email protected]> 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

--
[email protected] -- Speaking for myself only.

2010-11-29 10:12:31

by Mark Wielaard

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, 2010-11-29 at 10:59 +0100, Andi Kleen wrote:
> Hui Zhu <[email protected]> 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

2010-11-29 11:12:56

by Segher Boessenkool

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

> 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

2010-11-29 11:17:20

by Christian Borntraeger

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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.

2010-11-29 12:07:09

by Nicholas Mc Guire

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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

2010-11-29 18:05:01

by Valdis Klētnieks

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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.


Attachments:
(No filename) (227.00 B)

2010-11-29 19:06:16

by Jan Kratochvil

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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

2010-11-29 20:51:51

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, Nov 29, 2010 at 9:52 AM, Am?rico Wang <[email protected]> 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 <[email protected]> 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 [email protected]
> More majordomo info at ?http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at ?http://www.tux.org/lkml/
>

--
Thanks,
//richard

2010-11-29 21:00:20

by Arnaud Lacombe

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

Hi,

On Mon, Nov 29, 2010 at 3:51 PM, richard -rw- weinberger
<[email protected]> wrote:
> On Mon, Nov 29, 2010 at 9:52 AM, Am?rico Wang <[email protected]> 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

2010-11-29 21:07:22

by Arnaud Lacombe

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

Hi,

On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <[email protected]> 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 <[email protected]>
> ---
> [...]
> +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

2010-11-29 21:07:29

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, Nov 29, 2010 at 10:00 PM, Arnaud Lacombe <[email protected]> wrote:
> Hi,
>
> On Mon, Nov 29, 2010 at 3:51 PM, richard -rw- weinberger
> <[email protected]> wrote:
>> On Mon, Nov 29, 2010 at 9:52 AM, Am?rico Wang <[email protected]> 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

2010-11-30 09:26:23

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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 <[email protected]> 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.

2010-11-30 18:40:41

by Michael Snyder

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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 <[email protected]> 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.

2010-11-30 22:40:23

by Petr Hluzín

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On 29 November 2010 22:07, Arnaud Lacombe <[email protected]> wrote:
> Hi,
>
> On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <[email protected]> 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 <[email protected]>
>> ---
>> [...]
>> +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

2010-12-01 12:18:48

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, Nov 29, 2010 at 17:44, Christian Borntraeger
<[email protected]> 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

2010-12-01 12:52:47

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Mon, Nov 29, 2010 at 17:59, Andi Kleen <[email protected]> wrote:
> Hui Zhu <[email protected]> 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

2010-12-01 13:11:14

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Tue, Nov 30, 2010 at 05:07, Arnaud Lacombe <[email protected]> wrote:
> Hi,
>
> On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <[email protected]> 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 <[email protected]>
>> ---
>> [...]
>> +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

2010-12-01 13:42:41

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

On Wed, Dec 1, 2010 at 06:40, Petr Hluz?n <[email protected]> wrote:
> On 29 November 2010 22:07, Arnaud Lacombe <[email protected]> wrote:
>> Hi,
>>
>> On Sun, Nov 28, 2010 at 10:56 PM, Hui Zhu <[email protected]> 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 <[email protected]>
>>> ---
>>> [...]
>>> +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

2011-02-17 02:43:56

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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 <[email protected]>
---
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. <[email protected]>
#

+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",

2011-02-21 12:52:05

by Kevin Pouget

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

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 <[email protected]> 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 <[email protected]>
>> ---
>> ?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. <[email protected]>
>> ?#
>>
>> +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",
>

2011-02-23 05:20:19

by Hui Zhu

[permalink] [raw]
Subject: Re: [PATCH] Built kernel without -O2 option

That is cool! Thanks for your help Kevin.

Best,
Hui

On Mon, Feb 21, 2011 at 20:47, Kevin Pouget <[email protected]> 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 <[email protected]> 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 <[email protected]>
>> ---
>> ?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.
>> <[email protected]>
>> ?#
>>
>> +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",
>
>