consolidation of BUG support code.
Subsystems (45)
cover consolidation of BUG support code.
The changes shown here are to unify linux's BUG support under the one <linux/bug.h> file. Due to historical reasons, we have some BUG code in bug.h and some in kernel.h -- i.e. the support for BUILD_BUG in linux/kernel.h predates the addition of linux/bug.h, but old code in kernel.h wasn't moved to bug.h at that time. As a band-aid, kernel.h was including <asm/bug.h> to pseudo link them.
This has caused confusion[1] and general yuck/WTF[2] reactions. Here is an example that violates the principle of least surprise:
CC lib/string.o
lib/string.c: In function 'strlcat':
lib/string.c:225:2: error: implicit declaration of function 'BUILD_BUG_ON'
make[2]: *** [lib/string.o] Error 1
$
$ grep linux/bug.h lib/string.c
#include <linux/bug.h>
$We've included <linux/bug.h> for the BUG infrastructure and yet we still get a compile fail! [We've not kernel.h for BUILD_BUG_ON.] Ugh - very confusing for someone who is new to kernel development.
With the above in mind, the goals of this changeset are:
1) find and fix any include/*.h files that were relying on the implicit presence of BUG code.
2) find and fix any C files that were consuming kernel.h and hence relying on implicitly getting some/all BUG code.
3) Move the BUG related code living in kernel.h to <linux/bug.h>
4) remove the asm/bug.h from kernel.h to finally break the chain.
During development, the order was more like 3-4, build-test, 1-2. But to ensure that git history for bisect doesn't get needless build failures introduced, the commits have been reorderd to fix the problem areas in advance.
With respect to #1 -- I was wanting to avoid putting bug.h into high usage header files. So you will see processor.h and the spinlock.h getting special treatment. Others who might(?) be considered high usage and hence maybe needing special treatment are called out via a cmdline filter in the commit message.
Unlike the module.h cleanup[3], I've made no attempt to separate the changes along maintainer/arch lines -- I'm assuming that if this seems OK to folks, then it will be pulled all at once. The separation I did for module.h was costly and not really required.
Testing so far has been on i386, x86-64, mips, arm, powerpc,
alpha, sparc, ... If nobody has any fundamental problems
with the underlying concept here, I'd like to put it into the linux-next pool for 3.4 sometime soon.
Thanks,
Paul
[1] https://lkml.org/lkml/2012/1/3/90
[2] https://lkml.org/lkml/2012/1/17/414
[3] http://lwn.net/Articles/453517/
---
Paul Gortmaker (7):
x86: relocate get/set debugreg fcns to include/asm/debugreg.
spinlock: macroize assert_spin_locked to avoid bug.h dependency
lib: fix implicit users of kernel.h for TAINT_WARN bug.h: add include of it to various implicit C users
BUG: headers with BUG/BUG_ON etc. need linux/bug.h bug: consolidate BUILD_BUG_ON with other bug code kernel.h: doesn't explicitly use bug.h, so don't include it.
arch/arm/mach-ux500/board-mop500-pins.c | 1 + arch/mips/fw/arc/cmdline.c | 1 + arch/mips/fw/arc/identify.c | 1 + arch/powerpc/kernel/pmc.c | 1 + arch/powerpc/xmon/ppc-opc.c | 1 + arch/powerpc/xmon/spu-opc.c | 1 + arch/x86/include/asm/debugreg.h | 67 +++++++++++++++++++++++ arch/x86/include/asm/paravirt.h | 1 + arch/x86/include/asm/processor.h | 63 --------------------- arch/x86/kernel/cpu/common.c | 1 + arch/x86/kernel/paravirt.c | 1 + arch/x86/mm/kmemcheck/selftest.c | 1 + drivers/gpu/drm/radeon/cayman_blit_shaders.c | 1 + drivers/gpu/drm/radeon/evergreen_blit_shaders.c | 1 + drivers/gpu/drm/radeon/r600_blit_shaders.c | 1 + include/asm-generic/dma-mapping-common.h | 1 + include/asm-generic/pgtable.h | 1 + include/asm-generic/tlbflush.h | 2 + include/drm/ttm/ttm_memory.h | 1 + include/linux/atmdev.h | 1 + include/linux/bio.h | 1 + include/linux/bit_spinlock.h | 1 + include/linux/bug.h | 61 +++++++++++++++++++++ include/linux/ceph/decode.h | 3 +- include/linux/ceph/libceph.h | 1 + include/linux/ceph/mdsmap.h | 1 + include/linux/cpumask.h | 1 + include/linux/crypto.h | 1 + include/linux/debug_locks.h | 1 + include/linux/dmaengine.h | 1 + include/linux/elfcore.h | 1 + include/linux/ext3_fs.h | 1 + include/linux/fs.h | 1 + include/linux/fsnotify.h | 1 + include/linux/gpio.h | 1 + include/linux/highmem.h | 1 + include/linux/i2o.h | 1 + include/linux/if_vlan.h | 1 + include/linux/io-mapping.h | 1 + include/linux/kernel.h | 62 --------------------- include/linux/kprobes.h | 1 + include/linux/kvm_host.h | 1 + include/linux/memory_hotplug.h | 1 + include/linux/mm.h | 1 + include/linux/mtd/cfi.h | 1 + include/linux/netdevice.h | 1 + include/linux/nilfs2_fs.h | 1 + include/linux/page-flags.h | 1 + include/linux/pid_namespace.h | 1 + include/linux/posix_acl.h | 1 + include/linux/ptrace.h | 1 + include/linux/radix-tree.h | 1 + include/linux/rcupdate.h | 1 + include/linux/regset.h | 1 + include/linux/reiserfs_fs.h | 1 + include/linux/relay.h | 1 + include/linux/scatterlist.h | 6 ++- include/linux/seq_file.h | 1 + include/linux/skbuff.h | 1 + include/linux/slub_def.h | 1 + include/linux/spinlock.h | 5 +-- include/linux/ssb/ssb_driver_gige.h | 1 + include/linux/swapops.h | 1 + include/linux/syscalls.h | 1 + include/linux/transport_class.h | 1 + include/linux/virtio_config.h | 1 + include/net/cfg80211.h | 1 + include/net/dst.h | 1 + include/net/ip_vs.h | 1 + include/net/mac80211.h | 1 + include/net/netns/generic.h | 1 + include/net/red.h | 1 + include/net/tcp.h | 1 + include/net/timewait_sock.h | 1 + include/net/udp.h | 1 + include/net/wpan-phy.h | 1 + include/scsi/osd_ore.h | 1 + include/scsi/scsi_transport.h | 1 + lib/average.c | 1 + lib/bitmap.c | 1 + lib/iommu-helper.c | 1 + lib/list_debug.c | 2 + lib/plist.c | 1 + lib/string.c | 1 + lib/timerqueue.c | 1 + 85 files changed, 215 insertions(+), 132 deletions(-)
Signature · 1 line
1.7.7.2
PATCH 1/7 x86: relocate get/set debugreg fcns to include/asm/debugreg.
Since we already have a debugreg.h header file, move the assoc. get/set functions to it. In addition to it being the logical home for them, it has a secondary advantage. The functions that are moved use BUG(). So we really need to have linux/bug.h in scope. But asm/processor.h is used about 600 times, vs. only about 15 for debugreg.h -- so adding bug.h to the latter reduces the amount of time we'll be processing it during a compile.
--- arch/x86/include/asm/debugreg.h | 67 ++++++++++++++++++++++++++++++++++++++ arch/x86/include/asm/processor.h | 63 ----------------------------------- arch/x86/kernel/cpu/common.c | 1 + 3 files changed, 68 insertions(+), 63 deletions(-)
arch/x86/include/asm/debugreg.h +67 -0
@@ -78,8 +78,75 @@*/ #ifdef __KERNEL__ +#include <linux/bug.h> + DECLARE_PER_CPU(unsigned long, cpu_dr7); +#ifndef CONFIG_PARAVIRT +/* +* These special macros can be used to get or set a debugging register +*/ +#define get_debugreg (var, register) \ + (var) = native_get_debugreg(register) +#define set_debugreg (value, register) \ + native_set_debugreg(register, value) +#endif + +static inline unsigned long native_get_debugreg (int regno) +{ +unsigned long val =0 ;/* Damn you, gcc! */ + +switch (regno) { +case 0 : + asm("mov %%db0, %0" :"=r" (val)); +break ; +case 1 : + asm("mov %%db1, %0" :"=r" (val)); +break ; +case 2 : + asm("mov %%db2, %0" :"=r" (val)); +break ; +case 3 : + asm("mov %%db3, %0" :"=r" (val)); +break ; +case 6 : + asm("mov %%db6, %0" :"=r" (val)); +break ; +case 7 : + asm("mov %%db7, %0" :"=r" (val)); +break ; +default : +BUG (); + } +return val; +} + +static inline void native_set_debugreg (int regno,unsigned long value) +{ +switch (regno) { +case 0 : + asm("mov %0, %%db0" ::"r" (value)); +break ; +case 1 : + asm("mov %0, %%db1" ::"r" (value)); +break ; +case 2 : + asm("mov %0, %%db2" ::"r" (value)); +break ; +case 3 : + asm("mov %0, %%db3" ::"r" (value)); +break ; +case 6 : + asm("mov %0, %%db6" ::"r" (value)); +break ; +case 7 : + asm("mov %0, %%db7" ::"r" (value)); +break ; +default : +BUG (); + } +} +static inline void hw_breakpoint_disable (void ) {/* Zero the control register for HW Breakpoint */
arch/x86/include/asm/processor.h +0 -63
75 lines not on this page · raw message
arch/x86/kernel/cpu/common.c +1 -0
@@ -18,6 +18,7 @@#include <asm/archrandom.h> #include <asm/hypervisor.h> #include <asm/processor.h> +#include <asm/debugreg.h> #include <asm/sections.h> #include <linux/topology.h> #include <linux/cpumask.h>
Signature · 1 line
1.7.7.2
PATCH 2/7 spinlock: macroize assert_spin_locked to avoid bug.h dependency
In reply to Paul GortmakerIn spinlock_api_smp.h we find a define for assert_raw_spin_locked
[which uses BUG_ON]. Then assert_spin_locked (as an inline) uses
it, meaning we need bug.h But rather than put linux/bug.h in such a highly used file like spinlock.h, we can just make the un-raw version also a macro. Then the required bug.h presence is limited just to those few files who are actually doing the assert testing.
--- include/linux/spinlock.h | 5 +---- 1 files changed, 1 insertions(+), 4 deletions(-)
include/linux/spinlock.h +1 -4
@@ -375,10 +375,7 @@ static inline int spin_can_lock(spinlock_t *lock)return raw_spin_can_lock (&lock->rlock); } -static inline void assert_spin_locked (spinlock_t *lock) -{ -assert_raw_spin_locked (&lock->rlock); -} +#define assert_spin_locked (lock) assert_raw_spin_locked(&(lock)->rlock)/* * Pull the atomic_t declaration:
Signature · 1 line
1.7.7.2
PATCH 3/7 lib: fix implicit users of kernel.h for TAINT_WARN
In reply to Paul GortmakerA pending header cleanup will cause this to show up as:
lib/average.c:38: error: 'TAINT_WARN' undeclared (first use in this function) lib/list_debug.c:24: error: 'TAINT_WARN' undeclared (first use in this function)
and TAINT_WARN comes from include/linux/kernel.h file.
--- lib/average.c | 1 + lib/list_debug.c | 1 + 2 files changed, 2 insertions(+), 0 deletions(-)
lib/average.c +1 -0
@@ -7,6 +7,7 @@#include <linux/module.h> #include <linux/average.h> +#include <linux/kernel.h> #include <linux/bug.h> #include <linux/log2.h>
lib/list_debug.c +1 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/list.h> +#include <linux/kernel.h> /* * Insert a new entry between two known consecutive entries.
Signature · 1 line
1.7.7.2
PATCH 6/7 bug: consolidate BUILD_BUG_ON with other bug code
In reply to Paul GortmakerThe support for BUILD_BUG in linux/kernel.h predates the addition of linux/bug.h -- with this chunk off separate, you can run into situations where a person gets a compile fail even when they've included linux/bug.h, like this:
CC lib/string.o
lib/string.c: In function 'strlcat':
lib/string.c:225:2: error: implicit declaration of function 'BUILD_BUG_ON' make[2]: *** [lib/string.o] Error 1
$
$ grep linux/bug.h lib/string.c #include <linux/bug.h> $
Since the above violates the principle of least surprise, move the BUG chunks from kernel.h to bug.h so it is all together.
--- include/linux/bug.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/kernel.h | 61 ------------------------------------------------ 2 files changed, 61 insertions(+), 61 deletions(-)
include/linux/bug.h +61 -0
@@ -11,6 +11,67 @@ enum bug_trap_type {struct pt_regs ; +#ifdef __CHECKER__ +#define BUILD_BUG_ON_NOT_POWER_OF_2 (n) +#define BUILD_BUG_ON_ZERO (e) (0) +#define BUILD_BUG_ON_NULL (e) ((void*)0) +#define BUILD_BUG_ON (condition) +#define BUILD_BUG () (0) +#else /* __CHECKER__ */ + +/* Force a compilation error if a constant expression is not a power of 2 */ +#define BUILD_BUG_ON_NOT_POWER_OF_2 (n) \ + BUILD_BUG_ON((n) == 0 || (((n) & ((n) - 1)) != 0)) + +/* Force a compilation error if condition is true, but also produce a +result (of value 0 and type size_t), so the expression can be used +e.g. in a structure initializer (or where-ever else comma expressions +aren't permitted). */ +#define BUILD_BUG_ON_ZERO (e) (sizeof(struct { int:-!!(e); })) +#define BUILD_BUG_ON_NULL (e) ((void *)sizeof(struct { int:-!!(e); })) + +/** +* BUILD_BUG_ON - break compile if a condition is true. +* @condition: the condition which the compiler should know is false. +* +* If you have some code which relies on certain constants being equal, or +* other compile-time-evaluated condition, you should use BUILD_BUG_ON to +* detect if someone changes it. +* +* The implementation uses gcc's reluctance to create a negative array, but +* gcc (as of 4.4) only emits that error for obvious cases (eg. not arguments +* to inline functions). So as a fallback we use the optimizer; if it can't +* prove the condition is false, it will cause a link error on the undefined +* "__build_bug_on_failed". This error message can be harder to track down +* though, hence the two different methods. +*/ +#ifndef __OPTIMIZE__ +#define BUILD_BUG_ON (condition) ((void)sizeof(char[1 - 2*!!(condition)])) +#else +extern int __build_bug_on_failed; +#define BUILD_BUG_ON (condition) \ + do { \ + ((void)sizeof(char[1 - 2*!!(condition)])); \ + if (condition) __build_bug_on_failed = 1; \ + } while(0) +#endif + +/** +* BUILD_BUG - break compile if used. +* +* If you have some code that you expect the compiler to eliminate at +* build time, you should use BUILD_BUG to detect if it is +* unexpectedly used. +*/ +#define BUILD_BUG () \ + do { \ + extern void __build_bug_failed(void) \ + __linktime_error("BUILD_BUG failed"); \ + __build_bug_failed(); \ + } while (0) + +#endif /* __CHECKER__ */ +#ifdef CONFIG_GENERIC_BUG #include <asm-generic/bug.h>
include/linux/kernel.h +0 -61
67 lines not on this page · raw message
Signature · 1 line
1.7.7.2
PATCH 7/7 kernel.h: doesn't explicitly use bug.h, so don't include it.
In reply to Paul GortmakerThis header isn't using bug.h infrastructure, but due to historical reasons, it was including it. Removing it revealed several implicit dependencies (since kernel.h is everywhere) so we've fixed those 1st before deploying this change.
--- include/linux/kernel.h | 1 - 1 files changed, 0 insertions(+), 1 deletions(-)
include/linux/kernel.h +0 -1
@@ -20,7 +20,6 @@#include <linux/printk.h> #include <linux/dynamic_debug.h> #include <asm/byteorder.h> -#include <asm/bug.h> #define USHRT_MAX ((u16)(~0U))#define SHRT_MAX ((s16)(USHRT_MAX>>1))
Signature · 1 line
1.7.7.2
PATCH 4/7 bug.h: add include of it to various implicit C users
In reply to Paul GortmakerWith bug.h currently living right in linux/kernel.h there are files that use BUG_ON and friends but are not including the header explicitly. Fix them up so we can remove the presence in kernel.h file.
--- arch/arm/mach-ux500/board-mop500-pins.c | 1 + arch/mips/fw/arc/cmdline.c | 1 + arch/mips/fw/arc/identify.c | 1 + arch/powerpc/kernel/pmc.c | 1 + arch/powerpc/xmon/ppc-opc.c | 1 + arch/powerpc/xmon/spu-opc.c | 1 + arch/x86/kernel/paravirt.c | 1 + arch/x86/mm/kmemcheck/selftest.c | 1 + drivers/gpu/drm/radeon/cayman_blit_shaders.c | 1 + drivers/gpu/drm/radeon/evergreen_blit_shaders.c | 1 + drivers/gpu/drm/radeon/r600_blit_shaders.c | 1 + lib/bitmap.c | 1 + lib/iommu-helper.c | 1 + lib/list_debug.c | 1 + lib/plist.c | 1 + lib/string.c | 1 + lib/timerqueue.c | 1 + 17 files changed, 17 insertions(+), 0 deletions(-)
arch/arm/mach-ux500/board-mop500-pins.c +1 -0
@@ -6,6 +6,7 @@#include <linux/kernel.h> #include <linux/init.h> +#include <linux/bug.h> #include <asm/mach-types.h> #include <plat/pincfg.h>
arch/mips/fw/arc/cmdline.c +1 -0
@@ -7,6 +7,7 @@* * Copyright (C) 1996 David S. Miller ([email protected]) */ +#include <linux/bug.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/string.h>
arch/mips/fw/arc/identify.c +1 -0
@@ -11,6 +11,7 @@* * Copyright (C) 1996 David S. Miller ([email protected]) */ +#include <linux/bug.h> #include <linux/init.h> #include <linux/kernel.h> #include <linux/types.h>
arch/powerpc/kernel/pmc.c +1 -0
@@ -13,6 +13,7 @@*/ #include <linux/errno.h> +#include <linux/bug.h> #include <linux/spinlock.h> #include <linux/export.h>
arch/powerpc/xmon/ppc-opc.c +1 -0
@@ -22,6 +22,7 @@#include <linux/stddef.h> #include <linux/kernel.h> +#include <linux/bug.h> #include "nonstdio.h" #include "ppc.h"
arch/powerpc/xmon/spu-opc.c +1 -0
@@ -19,6 +19,7 @@51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ #include <linux/kernel.h> +#include <linux/bug.h> #include "spu.h" /* This file holds the Spu opcode table */
arch/x86/kernel/paravirt.c +1 -0
@@ -26,6 +26,7 @@#include <asm/bug.h> #include <asm/paravirt.h> +#include <asm/debugreg.h> #include <asm/desc.h> #include <asm/setup.h> #include <asm/pgtable.h>
arch/x86/mm/kmemcheck/selftest.c +1 -0
@@ -1,3 +1,4 @@ +#include <linux/bug.h> #include <linux/kernel.h> #include "opcode.h"
drivers/gpu/drm/radeon/cayman_blit_shaders.c +1 -0
@@ -24,6 +24,7 @@* Alex Deucher <[email protected]> */ +#include <linux/bug.h> #include <linux/types.h> #include <linux/kernel.h>
drivers/gpu/drm/radeon/evergreen_blit_shaders.c +1 -0
@@ -24,6 +24,7 @@* Alex Deucher <[email protected]> */ +#include <linux/bug.h> #include <linux/types.h> #include <linux/kernel.h>
drivers/gpu/drm/radeon/r600_blit_shaders.c +1 -0
@@ -24,6 +24,7 @@* Alex Deucher <[email protected]> */ +#include <linux/bug.h> #include <linux/types.h> #include <linux/kernel.h>
lib/bitmap.c +1 -0
@@ -10,6 +10,7 @@#include <linux/errno.h> #include <linux/bitmap.h> #include <linux/bitops.h> +#include <linux/bug.h> #include <asm/uaccess.h> /*
lib/iommu-helper.c +1 -0
@@ -4,6 +4,7 @@#include <linux/module.h> #include <linux/bitmap.h> +#include <linux/bug.h> int iommu_is_span_boundary(unsigned int index, unsigned int nr, unsigned long shift,
lib/list_debug.c +1 -0
@@ -8,6 +8,7 @@#include <linux/module.h> #include <linux/list.h> +#include <linux/bug.h> #include <linux/kernel.h> /*
lib/plist.c +1 -0
@@ -23,6 +23,7 @@* information. */ +#include <linux/bug.h> #include <linux/plist.h> #include <linux/spinlock.h>
lib/string.c +1 -0
@@ -22,6 +22,7 @@#include <linux/types.h> #include <linux/string.h> #include <linux/ctype.h> +#include <linux/bug.h> #include <linux/module.h> #ifndef __HAVE_ARCH_STRNICMP
lib/timerqueue.c +1 -0
@@ -25,6 +25,7 @@#include <linux/timerqueue.h> #include <linux/rbtree.h> #include <linux/module.h> +#include <linux/bug.h> /** * timerqueue_add - Adds timer to timerqueue.
Signature · 1 line
1.7.7.2
PATCH 5/7 BUG: headers with BUG/BUG_ON etc. need linux/bug.h
In reply to Paul GortmakerIf a header file is making use of BUG, BUG_ON, BUILD_BUG_ON, or any other BUG variant in a static inline (i.e. not in a #define) then that header really should be including <linux/bug.h> and not just expecting it to be implicitly present.
We can make this change risk-free, since if the files using these headers didn't have exposure to linux/bug.h already, they would have been causing compile failures/warnings.
We might want to revisit some of these "high use" files and see if we can avoid the bug.h include in a "clean" way, via a simple define instead of an inline if possible.
Top ten "high use" candidates at the moment are as follows:
$ for i in `git diff --name-only ^HEAD~ HEAD|sed 's,include/,,'`; do echo $i ; C=`git grep -l $i include|wc -l` ; echo $C $i ; done |sort -n -k1 -r|head 72 linux/skbuff.h 59 linux/fs.h 50 linux/netdevice.h 40 linux/rcupdate.h 33 linux/mm.h 24 linux/scatterlist.h 20 linux/cpumask.h 15 linux/seq_file.h 14 linux/crypto.h 12 linux/dmaengine.h $
Note that the above stats can be misleading, in that it doesn't factor in whether one of the "includers" itself is high use. For example, if foo.h is only used once, but the user is kernel.h, then foo.h will be largely everywhere.
--- arch/x86/include/asm/paravirt.h | 1 + include/asm-generic/dma-mapping-common.h | 1 + include/asm-generic/pgtable.h | 1 + include/asm-generic/tlbflush.h | 2 ++ include/drm/ttm/ttm_memory.h | 1 + include/linux/atmdev.h | 1 + include/linux/bio.h | 1 + include/linux/bit_spinlock.h | 1 + include/linux/ceph/decode.h | 3 ++- include/linux/ceph/libceph.h | 1 + include/linux/ceph/mdsmap.h | 1 + include/linux/cpumask.h | 1 + include/linux/crypto.h | 1 + include/linux/debug_locks.h | 1 + include/linux/dmaengine.h | 1 + include/linux/elfcore.h | 1 + include/linux/ext3_fs.h | 1 + include/linux/fs.h | 1 + include/linux/fsnotify.h | 1 + include/linux/gpio.h | 1 + include/linux/highmem.h | 1 + include/linux/i2o.h | 1 + include/linux/if_vlan.h | 1 + include/linux/io-mapping.h | 1 + include/linux/kprobes.h | 1 + include/linux/kvm_host.h | 1 + include/linux/memory_hotplug.h | 1 + include/linux/mm.h | 1 + include/linux/mtd/cfi.h | 1 + include/linux/netdevice.h | 1 + include/linux/nilfs2_fs.h | 1 + include/linux/page-flags.h | 1 + include/linux/pid_namespace.h | 1 + include/linux/posix_acl.h | 1 + include/linux/ptrace.h | 1 + include/linux/radix-tree.h | 1 + include/linux/rcupdate.h | 1 + include/linux/regset.h | 1 + include/linux/reiserfs_fs.h | 1 + include/linux/relay.h | 1 + include/linux/scatterlist.h | 6 ++++-- include/linux/seq_file.h | 1 + include/linux/skbuff.h | 1 + include/linux/slub_def.h | 1 + include/linux/ssb/ssb_driver_gige.h | 1 + include/linux/swapops.h | 1 + include/linux/syscalls.h | 1 + include/linux/transport_class.h | 1 + include/linux/virtio_config.h | 1 + include/net/cfg80211.h | 1 + include/net/dst.h | 1 + include/net/ip_vs.h | 1 + include/net/mac80211.h | 1 + include/net/netns/generic.h | 1 + include/net/red.h | 1 + include/net/tcp.h | 1 + include/net/timewait_sock.h | 1 + include/net/udp.h | 1 + include/net/wpan-phy.h | 1 + include/scsi/osd_ore.h | 1 + include/scsi/scsi_transport.h | 1 + 61 files changed, 66 insertions(+), 3 deletions(-)
arch/x86/include/asm/paravirt.h +1 -0
@@ -10,6 +10,7 @@#include <asm/paravirt_types.h> #ifndef __ASSEMBLY__ +#include <linux/bug.h> #include <linux/types.h> #include <linux/cpumask.h>
include/asm-generic/dma-mapping-common.h +1 -0
@@ -2,6 +2,7 @@#define _ASM_GENERIC_DMA_MAPPING_H#include <linux/kmemcheck.h> +#include <linux/bug.h> #include <linux/scatterlist.h> #include <linux/dma-debug.h> #include <linux/dma-attrs.h>
include/asm-generic/pgtable.h +1 -0
@@ -5,6 +5,7 @@#ifdef CONFIG_MMU #include <linux/mm_types.h> +#include <linux/bug.h> #ifndef __HAVE_ARCH_PTEP_SET_ACCESS_FLAGS extern int ptep_set_access_flags(struct vm_area_struct *vma,
include/asm-generic/tlbflush.h +2 -0
@@ -9,6 +9,8 @@#error need to implement an architecture specific asm/tlbflush.h#endif +#include <linux/bug.h> +static inline void flush_tlb_mm (struct mm_struct *mm) {BUG ();
include/drm/ttm/ttm_memory.h +1 -0
@@ -30,6 +30,7 @@#include <linux/workqueue.h> #include <linux/spinlock.h> +#include <linux/bug.h> #include <linux/wait.h> #include <linux/errno.h> #include <linux/kobject.h>
include/linux/atmdev.h +1 -0
@@ -217,6 +217,7 @@ struct atm_cirange {#include <linux/wait.h> /* wait_queue_head_t */ #include <linux/time.h> /* struct timeval */ #include <linux/net.h> +#include <linux/bug.h> #include <linux/skbuff.h> /* struct sk_buff */ #include <linux/uio.h> #include <net/sock.h>
include/linux/bio.h +1 -0
@@ -23,6 +23,7 @@#include <linux/highmem.h> #include <linux/mempool.h> #include <linux/ioprio.h> +#include <linux/bug.h> #ifdef CONFIG_BLOCK
include/linux/bit_spinlock.h +1 -0
@@ -4,6 +4,7 @@#include <linux/kernel.h> #include <linux/preempt.h> #include <linux/atomic.h> +#include <linux/bug.h> /* * bit-based spin_lock()
include/linux/ceph/decode.h +2 -1
@@ -1,8 +1,9 @@#ifndef __CEPH_DECODE_H#define __CEPH_DECODE_H -#include <asm/unaligned.h> +#include <linux/bug.h> #include <linux/time.h> +#include <asm/unaligned.h> #include "types.h"
include/linux/ceph/libceph.h +1 -0
@@ -7,6 +7,7 @@#include <linux/backing-dev.h> #include <linux/completion.h> #include <linux/exportfs.h> +#include <linux/bug.h> #include <linux/fs.h> #include <linux/mempool.h> #include <linux/pagemap.h>
include/linux/ceph/mdsmap.h +1 -0
@@ -1,6 +1,7 @@#ifndef _FS_CEPH_MDSMAP_H#define _FS_CEPH_MDSMAP_H +#include <linux/bug.h> #include "types.h" /*
include/linux/cpumask.h +1 -0
@@ -9,6 +9,7 @@#include <linux/kernel.h> #include <linux/threads.h> #include <linux/bitmap.h> +#include <linux/bug.h> typedef struct cpumask { DECLARE_BITMAP(bits, NR_CPUS); } cpumask_t;
include/linux/crypto.h +1 -0
@@ -20,6 +20,7 @@#include <linux/atomic.h> #include <linux/kernel.h> #include <linux/list.h> +#include <linux/bug.h> #include <linux/slab.h> #include <linux/string.h> #include <linux/uaccess.h>
include/linux/debug_locks.h +1 -0
@@ -3,6 +3,7 @@#include <linux/kernel.h> #include <linux/atomic.h> +#include <linux/bug.h> #include <asm/system.h> struct task_struct ;
include/linux/dmaengine.h +1 -0
@@ -23,6 +23,7 @@#include <linux/device.h> #include <linux/uio.h> +#include <linux/bug.h> #include <linux/scatterlist.h> #include <linux/bitmap.h> #include <asm/page.h>
include/linux/elfcore.h +1 -0
@@ -6,6 +6,7 @@#include <linux/time.h> #ifdef __KERNEL__#include <linux/user.h> +#include <linux/bug.h> #endif #include <linux/ptrace.h> #include <linux/elf.h>
include/linux/ext3_fs.h +1 -0
@@ -18,6 +18,7 @@#include <linux/types.h> #include <linux/magic.h> +#include <linux/bug.h> /* * The second extended filesystem constants/structures
include/linux/fs.h +1 -0
@@ -389,6 +389,7 @@ struct inodes_stat_t {#include <linux/prio_tree.h> #include <linux/init.h> #include <linux/pid.h> +#include <linux/bug.h> #include <linux/mutex.h> #include <linux/capability.h> #include <linux/semaphore.h>
include/linux/fsnotify.h +1 -0
@@ -14,6 +14,7 @@#include <linux/fsnotify_backend.h> #include <linux/audit.h> #include <linux/slab.h> +#include <linux/bug.h> /* * fsnotify_d_instantiate - instantiate a dentry for inode
include/linux/gpio.h +1 -0
@@ -34,6 +34,7 @@ struct gpio {#include <linux/kernel.h> #include <linux/types.h> #include <linux/errno.h> +#include <linux/bug.h> struct device ;struct gpio_chip ;
include/linux/highmem.h +1 -0
@@ -3,6 +3,7 @@#include <linux/fs.h> #include <linux/kernel.h> +#include <linux/bug.h> #include <linux/mm.h> #include <linux/uaccess.h> #include <linux/hardirq.h>
include/linux/i2o.h +1 -0
@@ -24,6 +24,7 @@#define I2O_MAX_DRIVERS 8#include <linux/pci.h> +#include <linux/bug.h> #include <linux/dma-mapping.h> #include <linux/string.h> #include <linux/slab.h>
include/linux/if_vlan.h +1 -0
@@ -17,6 +17,7 @@#include <linux/netdevice.h> #include <linux/etherdevice.h> #include <linux/rtnetlink.h> +#include <linux/bug.h> #define VLAN_HLEN 4/* The additional bytes (on top of the Ethernet header) * that VLAN requires.
include/linux/io-mapping.h +1 -0
@@ -20,6 +20,7 @@#include <linux/types.h> #include <linux/slab.h> +#include <linux/bug.h> #include <asm/io.h> #include <asm/page.h>
include/linux/kprobes.h +1 -0
@@ -33,6 +33,7 @@#include <linux/list.h> #include <linux/notifier.h> #include <linux/smp.h> +#include <linux/bug.h> #include <linux/percpu.h> #include <linux/spinlock.h> #include <linux/rcupdate.h>
include/linux/kvm_host.h +1 -0
@@ -13,6 +13,7 @@#include <linux/spinlock.h> #include <linux/signal.h> #include <linux/sched.h> +#include <linux/bug.h> #include <linux/mm.h> #include <linux/mmu_notifier.h> #include <linux/preempt.h>
include/linux/memory_hotplug.h +1 -0
@@ -4,6 +4,7 @@#include <linux/mmzone.h> #include <linux/spinlock.h> #include <linux/notifier.h> +#include <linux/bug.h> struct page ;struct zone ;
include/linux/mm.h +1 -0
@@ -6,6 +6,7 @@#ifdef __KERNEL__#include <linux/gfp.h> +#include <linux/bug.h> #include <linux/list.h> #include <linux/mmzone.h> #include <linux/rbtree.h>
include/linux/mtd/cfi.h +1 -0
@@ -22,6 +22,7 @@#include <linux/delay.h> #include <linux/types.h> +#include <linux/bug.h> #include <linux/interrupt.h> #include <linux/mtd/flashchip.h> #include <linux/mtd/map.h>
include/linux/netdevice.h +1 -0
@@ -33,6 +33,7 @@#ifdef __KERNEL__#include <linux/pm_qos.h> #include <linux/timer.h> +#include <linux/bug.h> #include <linux/delay.h> #include <linux/atomic.h> #include <asm/cache.h>
include/linux/nilfs2_fs.h +1 -0
@@ -41,6 +41,7 @@#include <linux/types.h> #include <linux/ioctl.h> #include <linux/magic.h> +#include <linux/bug.h> #define NILFS_INODE_BMAP_SIZE 7
include/linux/page-flags.h +1 -0
@@ -6,6 +6,7 @@#define PAGE_FLAGS_H #include <linux/types.h> +#include <linux/bug.h> #ifndef __GENERATING_BOUNDS_H#include <linux/mm_types.h> #include <generated/bounds.h>
include/linux/pid_namespace.h +1 -0
@@ -2,6 +2,7 @@#define _LINUX_PID_NS_H#include <linux/sched.h> +#include <linux/bug.h> #include <linux/mm.h> #include <linux/threads.h> #include <linux/nsproxy.h>
include/linux/posix_acl.h +1 -0
@@ -8,6 +8,7 @@#ifndef __LINUX_POSIX_ACL_H#define __LINUX_POSIX_ACL_H +#include <linux/bug.h> #include <linux/slab.h> #include <linux/rcupdate.h>
include/linux/ptrace.h +1 -0
@@ -113,6 +113,7 @@#include <linux/compiler.h> /* For unlikely. */ #include <linux/sched.h> /* For struct task_struct. */ #include <linux/err.h> /* for IS_ERR_VALUE */ +#include <linux/bug.h> /* For BUG_ON. */ extern long arch_ptrace(struct task_struct *child, long request,
include/linux/radix-tree.h +1 -0
@@ -22,6 +22,7 @@#include <linux/preempt.h> #include <linux/types.h> +#include <linux/bug.h> #include <linux/kernel.h> #include <linux/rcupdate.h>
include/linux/rcupdate.h +1 -0
@@ -42,6 +42,7 @@#include <linux/lockdep.h> #include <linux/completion.h> #include <linux/debugobjects.h> +#include <linux/bug.h> #include <linux/compiler.h> #ifdef CONFIG_RCU_TORTURE_TEST
include/linux/regset.h +1 -0
@@ -15,6 +15,7 @@#include <linux/compiler.h> #include <linux/types.h> +#include <linux/bug.h> #include <linux/uaccess.h> struct task_struct ;struct user_regset ;
include/linux/reiserfs_fs.h +1 -0
@@ -18,6 +18,7 @@#include <linux/slab.h> #include <linux/interrupt.h> #include <linux/sched.h> +#include <linux/bug.h> #include <linux/workqueue.h> #include <asm/unaligned.h> #include <linux/bitops.h>
include/linux/relay.h +1 -0
@@ -15,6 +15,7 @@#include <linux/timer.h> #include <linux/wait.h> #include <linux/list.h> +#include <linux/bug.h> #include <linux/fs.h> #include <linux/poll.h> #include <linux/kref.h>
include/linux/scatterlist.h +4 -2
@@ -1,10 +1,12 @@#ifndef _LINUX_SCATTERLIST_H#define _LINUX_SCATTERLIST_H +#include <linux/string.h> +#include <linux/bug.h> +#include <linux/mm.h> +#include <asm/types.h> #include <asm/scatterlist.h> -#include <linux/mm.h> -#include <linux/string.h> #include <asm/io.h> struct sg_table {
include/linux/seq_file.h +1 -0
@@ -3,6 +3,7 @@#include <linux/types.h> #include <linux/string.h> +#include <linux/bug.h> #include <linux/mutex.h> #include <linux/cpumask.h> #include <linux/nodemask.h>
include/linux/skbuff.h +1 -0
@@ -18,6 +18,7 @@#include <linux/kmemcheck.h> #include <linux/compiler.h> #include <linux/time.h> +#include <linux/bug.h> #include <linux/cache.h> #include <linux/atomic.h>
include/linux/slub_def.h +1 -0
@@ -8,6 +8,7 @@*/ #include <linux/types.h> #include <linux/gfp.h> +#include <linux/bug.h> #include <linux/workqueue.h> #include <linux/kobject.h>
include/linux/ssb/ssb_driver_gige.h +1 -0
@@ -2,6 +2,7 @@#define LINUX_SSB_DRIVER_GIGE_H_ #include <linux/ssb/ssb.h> +#include <linux/bug.h> #include <linux/pci.h> #include <linux/spinlock.h>
include/linux/swapops.h +1 -0
@@ -2,6 +2,7 @@#define _LINUX_SWAPOPS_H#include <linux/radix-tree.h> +#include <linux/bug.h> /* * swapcache pages are stored in the swapper_space radix tree. We want to
include/linux/syscalls.h +1 -0
@@ -68,6 +68,7 @@ struct file_handle;#include <linux/aio_abi.h> #include <linux/capability.h> #include <linux/list.h> +#include <linux/bug.h> #include <linux/sem.h> #include <asm/siginfo.h> #include <asm/signal.h>
include/linux/transport_class.h +1 -0
@@ -10,6 +10,7 @@#define _TRANSPORT_CLASS_H_#include <linux/device.h> +#include <linux/bug.h> #include <linux/attribute_container.h> struct transport_container ;
include/linux/virtio_config.h +1 -0
@@ -53,6 +53,7 @@#ifdef __KERNEL__#include <linux/err.h> +#include <linux/bug.h> #include <linux/virtio.h> /**
include/net/cfg80211.h +1 -0
@@ -13,6 +13,7 @@#include <linux/netdevice.h> #include <linux/debugfs.h> #include <linux/list.h> +#include <linux/bug.h> #include <linux/netlink.h> #include <linux/skbuff.h> #include <linux/nl80211.h>
include/net/dst.h +1 -0
@@ -12,6 +12,7 @@#include <linux/netdevice.h> #include <linux/rtnetlink.h> #include <linux/rcupdate.h> +#include <linux/bug.h> #include <linux/jiffies.h> #include <net/neighbour.h> #include <asm/processor.h>
include/net/ip_vs.h +1 -0
@@ -16,6 +16,7 @@#include <linux/atomic.h> /* for struct atomic_t */ #include <linux/compiler.h> #include <linux/timer.h> +#include <linux/bug.h> #include <net/checksum.h> #include <linux/netfilter.h> /* for union nf_inet_addr */
include/net/mac80211.h +1 -0
@@ -17,6 +17,7 @@#include <linux/if_ether.h> #include <linux/skbuff.h> #include <linux/device.h> +#include <linux/bug.h> #include <linux/ieee80211.h> #include <net/cfg80211.h> #include <asm/unaligned.h>
include/net/netns/generic.h +1 -0
@@ -5,6 +5,7 @@#ifndef __NET_GENERIC_H__#define __NET_GENERIC_H__ +#include <linux/bug.h> #include <linux/rcupdate.h> /*
include/net/red.h +1 -0
@@ -2,6 +2,7 @@#define __NET_SCHED_RED_H#include <linux/types.h> +#include <linux/bug.h> #include <net/pkt_sched.h> #include <net/inet_ecn.h> #include <net/dsfield.h>
include/net/tcp.h +1 -0
@@ -22,6 +22,7 @@#include <linux/list.h> #include <linux/tcp.h> +#include <linux/bug.h> #include <linux/slab.h> #include <linux/cache.h> #include <linux/percpu.h>
include/net/timewait_sock.h +1 -0
@@ -12,6 +12,7 @@#define _TIMEWAIT_SOCK_H#include <linux/slab.h> +#include <linux/bug.h> #include <net/sock.h> struct timewait_sock_ops {
include/net/udp.h +1 -0
@@ -23,6 +23,7 @@#define _UDP_H#include <linux/list.h> +#include <linux/bug.h> #include <net/inet_sock.h> #include <net/sock.h> #include <net/snmp.h>
include/net/wpan-phy.h +1 -0
@@ -23,6 +23,7 @@#include <linux/netdevice.h> #include <linux/mutex.h> +#include <linux/bug.h> struct wpan_phy {struct mutex pib_lock;
include/scsi/osd_ore.h +1 -0
@@ -26,6 +26,7 @@#include <scsi/osd_attributes.h> #include <scsi/osd_sec.h> #include <linux/pnfs_osd_xdr.h> +#include <linux/bug.h> struct ore_comp {struct osd_obj_id obj;
include/scsi/scsi_transport.h +1 -0
@@ -22,6 +22,7 @@#include <linux/transport_class.h> #include <linux/blkdev.h> +#include <linux/bug.h> #include <scsi/scsi_host.h> #include <scsi/scsi_device.h>
Signature · 1 line
1.7.7.2
Hi Paul,
Quoted 16 lines · On Thu, 26 Jan 2012 21:44:25 -0500 Paul Gortmaker…
The changes shown here are to unify linux's BUG support under the one <
linux/bug.h> file. Due to historical reasons, we have some BUG code inbug.hand some inkernel.h-- i.e. the support forBUILD_BUGinlinux/kernel.hpredates the addition oflinux/bug.h, but old code inkernel.hwasn't moved tobug.hat that time. As a band-aid,kernel.hwas including <asm/bug.h> to pseudo link them. With the above in mind, the goals of this changeset are:1) find and fix any
include/*.hfiles that were relying on the implicit presence of BUG code.
2) find and fix any C files that were consumingkernel.hand hence relying on implicitly getting some/all BUG code.
3) Move the BUG related code living inkernel.hto <linux/bug.h>
4) remove theasm/bug.hfromkernel.hto finally break the chain.
Quoted 4 lines
During development, the order was more like 3-4, build-test, 1-2. But to ensure that git history for bisect doesn't get needless build failures introduced, the commits have been reorderd to fix the problem areas in advance.
I have expressed reservations with these tree wide include file cleanups in the past (there was going pain for me and others during the module.h split up for example). So, have you considered the following alternate method of achieving most (if not all) of the gains:
First a patch that moves the BUG related stuff from kernel.h to linux/bug.h and replacing the include of asm/bug.h with linux/bug.h in kernel.h. This should essentially be a noop (bar some strange interesting bugs).
The trick is to convince Linus that this patch is OK for the current RC series ...
Then you can (at your leisure) fix all the files that need linux/bug.h included - farming them out as required. And we could add a check in checkpatch.pl.
Then (either after 3.4-rc1 or in the 3.5 merge window) we can remove the include of linux/bug.h from linux/kernel.h and fix any left over build problems.
I have not thought about this too hard, so there may be large holes in this plan.
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
Re: [PATCH 1/7] x86: relocate get/set debugreg fcns to include/asm/debugreg.
In reply to Paul GortmakerQuoted 13 lines · Paul Gortmaker
Since we already have a
debugreg.hheader file, move the assoc. get/set functions to it. In addition to it being the logical home for them, it has a secondary advantage. The functions that are moved useBUG(). So we really need to havelinux/bug.hin scope. Butasm/processor.his used about 600 times, vs. only about 15 fordebugreg.h-- so addingbug.hto the latter reduces the amount of time we'll be processing it during a compile.Signed-off-by Paul Gortmaker <[email protected]>CC Thomas Gleixner <[email protected]>CC Ingo Molnar <[email protected]>CC "H. Peter Anvin" <[email protected]>
Quoted 5 lines
--- arch/x86/include/asm/debugreg.h | 67 ++++++++++++++++++++++++++++++++++++++ arch/x86/include/asm/processor.h | 63 ----------------------------------- arch/x86/kernel/cpu/common.c | 1 + 3 files changed, 68 insertions(+), 63 deletions(-)
I suspect you'd like to carry this in your tree, so that all these patches are together?
Thanks,
Ingo
Quoted 19 lines · [Re: [RFC - PATCH 0/7] consolidation of BUG support code.] On 27/01/2012 (Fri…
Hi Paul,
Quoted 16 lines · On Thu, 26 Jan 2012 21:44:25 -0500 Paul Gortmaker…
The changes shown here are to unify linux's BUG support under the one <
linux/bug.h> file. Due to historical reasons, we have some BUG code inbug.hand some inkernel.h-- i.e. the support forBUILD_BUGinlinux/kernel.hpredates the addition oflinux/bug.h, but old code inkernel.hwasn't moved tobug.hat that time. As a band-aid,kernel.hwas including <asm/bug.h> to pseudo link them. With the above in mind, the goals of this changeset are:1) find and fix any
include/*.hfiles that were relying on the implicit presence of BUG code.
2) find and fix any C files that were consumingkernel.hand hence relying on implicitly getting some/all BUG code.
3) Move the BUG related code living inkernel.hto <linux/bug.h>
4) remove theasm/bug.hfromkernel.hto finally break the chain.
Quoted 7 lines
Quoted 4 lines
During development, the order was more like 3-4, build-test, 1-2. But to ensure that git history for bisect doesn't get needless build failures introduced, the commits have been reorderd to fix the problem areas in advance.
I have expressed reservations with these tree wide include file cleanups in the past (there was going pain for me and others during the
module.h
Well, I thought module.h went reasonably OK for something that touched close to 2500 files. I don't recall getting a lot of scorn and flame. In any case, this is nowhere near that size or scope of the module.h work, so I'll go out on a limb and say it should be nearly "pain free".
Quoted 8 lines
split up for example). So, have you considered the following alternate
method of achieving most (if not all) of the gains:
First a patch that moves the BUG related stuff from
kernel.htolinux/bug.hand replacing the include ofasm/bug.hwithlinux/bug.hinkernel.h. This should essentially be a noop (bar some strange interesting bugs).
You don't even really need the above as a prerequisite in order to start adding bug.h to all the places that are using it. As I noted in one of the commit logs, things are compiling today, so files using BUG are already getting it one way or another -- just implicitly.
Quoted 6 lines
The trick is to convince Linus that this patch is OK for the current RC series ...
Then you can (at your leisure) fix all the files that need
linux/bug.hincluded - farming them out as required. And we could add a check in checkpatch.pl.
I originally had the module.h stuff broken across maintainer lines, as I was assuming they would need to be farmed out as chunks, when Ingo suggested to just lump it all into one pull request and have it go at once (and I was fine with that). So this time I didn't bother making things like the one include/* commit into 60-odd separate commits.
I'm not really inclined to greatly favour one way over the other. Tracking all the one line commits to make sure they make it through the various sub-maintainers will take a bit more effort, but if that is what folks *really* want me to do, I'm OK with that. It is just that your feedback here is the 1st I've heard favouring that method so far.
Thanks,
Paul.
Quoted 11 lines
Then (either after 3.4-rc1 or in the 3.5 merge window) we can remove the include of
linux/bug.hfromlinux/kernel.hand fix any left over build problems.I have not thought about this too hard, so there may be large holes in this plan.
Signature · 2 lines
Cheers, Stephen Rothwell [email protected]
Re: [PATCH 1/7] x86: relocate get/set debugreg fcns to include/asm/debugreg.
In reply to Ingo MolnarQuoted 22 lines · [Re: [PATCH 1/7] x86: relocate get/set debugreg fcns to include/asm/debugreg.]…
Quoted 13 lines · Paul Gortmaker
Since we already have a
debugreg.hheader file, move the assoc. get/set functions to it. In addition to it being the logical home for them, it has a secondary advantage. The functions that are moved useBUG(). So we really need to havelinux/bug.hin scope. Butasm/processor.his used about 600 times, vs. only about 15 fordebugreg.h-- so addingbug.hto the latter reduces the amount of time we'll be processing it during a compile.Signed-off-by Paul Gortmaker <[email protected]>CC Thomas Gleixner <[email protected]>CC Ingo Molnar <[email protected]>CC "H. Peter Anvin" <[email protected]>Quoted 5 lines
--- arch/x86/include/asm/debugreg.h | 67 ++++++++++++++++++++++++++++++++++++++ arch/x86/include/asm/processor.h | 63 ----------------------------------- arch/x86/kernel/cpu/common.c | 1 + 3 files changed, 68 insertions(+), 63 deletions(-)
Quoted 4 lines
Acked-by Ingo Molnar <[email protected]>I suspect you'd like to carry this in your tree, so that all these patches are together?
Yes, that was my original intent, unless there is a consensus from people indicating that they'd really rather not see such standalone cleanup trees exist at all.
Thanks,
Paul.
Quoted 4 lines
Thanks,
Ingo