diff -urpN --exclude-from=/home/davej/.exclude bk-linus/arch/x86_64/kernel/traps.c linux-2.5/arch/x86_64/kernel/traps.c --- bk-linus/arch/x86_64/kernel/traps.c 2002-11-21 02:13:00.000000000 +0000 +++ linux-2.5/arch/x86_64/kernel/traps.c 2002-11-21 17:57:06.000000000 +0000 @@ -353,11 +353,6 @@ void handle_BUG(struct pt_regs *regs) printk("Kernel BUG at %.50s:%d\n", f.filename, f.line); } -void out_of_line_bug(void) -{ - BUG(); -} - spinlock_t die_lock = SPIN_LOCK_UNLOCKED; int die_owner = -1; diff -urpN --exclude-from=/home/davej/.exclude bk-linus/arch/x86_64/kernel/x8664_ksyms.c linux-2.5/arch/x86_64/kernel/x8664_ksyms.c --- bk-linus/arch/x86_64/kernel/x8664_ksyms.c 2002-11-21 02:13:00.000000000 +0000 +++ linux-2.5/arch/x86_64/kernel/x8664_ksyms.c 2002-11-21 17:57:06.000000000 +0000 @@ -195,7 +195,4 @@ EXPORT_SYMBOL(die_chain); extern void do_softirq_thunk(void); EXPORT_SYMBOL_NOVERS(do_softirq_thunk); -void out_of_line_bug(void); -EXPORT_SYMBOL(out_of_line_bug); - EXPORT_SYMBOL(init_level4_pgt); Binary files bk-linus/core and linux-2.5/core differ diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/asm-i386/mmu_context.h linux-2.5/include/asm-i386/mmu_context.h --- bk-linus/include/asm-i386/mmu_context.h 2002-11-21 02:21:51.000000000 +0000 +++ linux-2.5/include/asm-i386/mmu_context.h 2002-11-21 18:03:23.000000000 +0000 @@ -50,7 +50,7 @@ static inline void switch_mm(struct mm_s else { cpu_tlbstate[cpu].state = TLBSTATE_OK; if (cpu_tlbstate[cpu].active_mm != next) - BUG(); + out_of_line_bug(); if (!test_and_set_bit(cpu, &next->cpu_vm_mask)) { /* We were in lazy tlb mode and leave_mm disabled * tlb flush IPI delivery. We must reload %cr3. diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/asm-i386/pci.h linux-2.5/include/asm-i386/pci.h --- bk-linus/include/asm-i386/pci.h 2002-11-21 02:21:51.000000000 +0000 +++ linux-2.5/include/asm-i386/pci.h 2002-11-21 18:03:23.000000000 +0000 @@ -77,7 +77,7 @@ static inline dma_addr_t pci_map_single( size_t size, int direction) { if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); flush_write_buffers(); return virt_to_phys(ptr); } @@ -93,7 +93,7 @@ static inline void pci_unmap_single(stru size_t size, int direction) { if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); /* Nothing to do */ } @@ -105,7 +105,7 @@ static inline dma_addr_t pci_map_page(st unsigned long offset, size_t size, int direction) { if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); return (dma_addr_t)(page_to_pfn(page)) * PAGE_SIZE + offset; } @@ -114,7 +114,7 @@ static inline void pci_unmap_page(struct size_t size, int direction) { if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); /* Nothing to do */ } @@ -147,11 +147,11 @@ static inline int pci_map_sg(struct pci_ int i; if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); for (i = 0; i < nents; i++ ) { if (!sg[i].page) - BUG(); + out_of_line_bug(); sg[i].dma_address = page_to_phys(sg[i].page) + sg[i].offset; } @@ -168,7 +168,7 @@ static inline void pci_unmap_sg(struct p int nents, int direction) { if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); /* Nothing to do */ } @@ -186,7 +186,7 @@ static inline void pci_dma_sync_single(s size_t size, int direction) { if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); flush_write_buffers(); } @@ -201,7 +201,7 @@ static inline void pci_dma_sync_sg(struc int nelems, int direction) { if (direction == PCI_DMA_NONE) - BUG(); + out_of_line_bug(); flush_write_buffers(); } diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/asm-x86_64/page.h linux-2.5/include/asm-x86_64/page.h --- bk-linus/include/asm-x86_64/page.h 2002-11-21 02:23:41.000000000 +0000 +++ linux-2.5/include/asm-x86_64/page.h 2002-11-21 18:04:35.000000000 +0000 @@ -78,7 +78,6 @@ struct bug_frame { asm volatile("ud2 ; .quad %c1 ; .short %c0" :: \ "i"(__LINE__), "i" (__stringify(KBUILD_BASENAME))) #define PAGE_BUG(page) BUG() -void out_of_line_bug(void); /* Pure 2^n version of get_order */ extern __inline__ int get_order(unsigned long size) diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/linux/dcache.h linux-2.5/include/linux/dcache.h --- bk-linus/include/linux/dcache.h 2002-11-21 02:23:47.000000000 +0000 +++ linux-2.5/include/linux/dcache.h 2002-11-21 18:04:40.000000000 +0000 @@ -255,7 +255,7 @@ static __inline__ struct dentry * dget(s { if (dentry) { if (!atomic_read(&dentry->d_count)) - BUG(); + out_of_line_bug(); atomic_inc(&dentry->d_count); } return dentry; diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/linux/highmem.h linux-2.5/include/linux/highmem.h --- bk-linus/include/linux/highmem.h 2002-11-21 02:23:51.000000000 +0000 +++ linux-2.5/include/linux/highmem.h 2002-11-21 18:04:42.000000000 +0000 @@ -53,7 +53,7 @@ static inline void memclear_highpage_flu void *kaddr; if (offset + size > PAGE_SIZE) - BUG(); + out_of_line_bug(); kaddr = kmap_atomic(page, KM_USER0); memset((char *)kaddr + offset, 0, size); diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/linux/kernel.h linux-2.5/include/linux/kernel.h --- bk-linus/include/linux/kernel.h 2002-11-21 02:23:56.000000000 +0000 +++ linux-2.5/include/linux/kernel.h 2002-11-21 18:04:46.000000000 +0000 @@ -180,6 +180,9 @@ extern void dump_stack(void); const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) +extern void __out_of_line_bug(int line) ATTRIB_NORET; +#define out_of_line_bug() __out_of_line_bug(__LINE__) + #endif /* __KERNEL__ */ #define SI_LOAD_SHIFT 16 diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/linux/quotaops.h linux-2.5/include/linux/quotaops.h --- bk-linus/include/linux/quotaops.h 2002-11-21 02:24:04.000000000 +0000 +++ linux-2.5/include/linux/quotaops.h 2002-11-21 18:04:51.000000000 +0000 @@ -45,7 +45,7 @@ extern struct quotactl_ops vfs_quotactl_ static __inline__ void DQUOT_INIT(struct inode *inode) { if (!inode->i_sb) - BUG(); + out_of_line_bug(); lock_kernel(); if (sb_any_quota_enabled(inode->i_sb) && !IS_NOQUOTA(inode)) inode->i_sb->dq_op->initialize(inode, -1); @@ -57,7 +57,7 @@ static __inline__ void DQUOT_DROP(struct lock_kernel(); if (IS_QUOTAINIT(inode)) { if (!inode->i_sb) - BUG(); + out_of_line_bug(); inode->i_sb->dq_op->drop(inode); /* Ops must be set when there's any quota... */ } unlock_kernel(); diff -urpN --exclude-from=/home/davej/.exclude bk-linus/include/linux/skbuff.h linux-2.5/include/linux/skbuff.h --- bk-linus/include/linux/skbuff.h 2002-11-21 02:24:06.000000000 +0000 +++ linux-2.5/include/linux/skbuff.h 2002-11-21 18:04:53.000000000 +0000 @@ -858,7 +858,7 @@ static inline char *__skb_pull(struct sk { skb->len -= len; if (skb->len < skb->data_len) - BUG(); + out_of_line_bug(); return skb->data += len; } @@ -1101,7 +1101,7 @@ static inline void *kmap_skb_frag(const { #ifdef CONFIG_HIGHMEM if (in_irq()) - BUG(); + out_of_line_bug(); local_bh_disable(); #endif diff -urpN --exclude-from=/home/davej/.exclude bk-linus/kernel/ksyms.c linux-2.5/kernel/ksyms.c --- bk-linus/kernel/ksyms.c 2002-11-21 02:24:37.000000000 +0000 +++ linux-2.5/kernel/ksyms.c 2002-11-21 18:05:17.000000000 +0000 @@ -491,6 +491,7 @@ EXPORT_SYMBOL(loops_per_jiffy); /* misc */ EXPORT_SYMBOL(panic); +EXPORT_SYMBOL(__out_of_line_bug); EXPORT_SYMBOL(sprintf); EXPORT_SYMBOL(snprintf); EXPORT_SYMBOL(sscanf); diff -urpN --exclude-from=/home/davej/.exclude bk-linus/kernel/panic.c linux-2.5/kernel/panic.c --- bk-linus/kernel/panic.c 2002-11-21 02:24:37.000000000 +0000 +++ linux-2.5/kernel/panic.c 2002-11-21 18:05:17.000000000 +0000 @@ -125,3 +129,23 @@ const char *print_tainted() } int tainted = 0; + +/* + * A BUG() call in an inline function in a header should be avoided, + * because it can seriously bloat the kernel. So here we have + * helper functions. + * We lose the BUG()-time file-and-line info this way, but it's + * usually not very useful from an inline anyway. The backtrace + * tells us what we want to know. + */ + +void __out_of_line_bug(int line) +{ + printk("kernel BUG in header file at line %d\n", line); + + BUG(); + + /* Satisfy __attribute__((noreturn)) */ + for ( ; ; ) + ; +}