include file cleanup
Subsystems (18)
RFC 1/1 include file cleanup
slab.h is currently one of the worst include files:
it includes <mm.h>, that one <sched.h>, that one <fs.h>, just because it needs the GFP_ defines.
I've split the gfp functions out of mm.h into a seperate <gfp.h> header file.
Is that a step in the right direction?
Another similar cleanup would be splitting the 'struct task_struct' definition out of sched.h into a seperate <linux/current.h>:
some source files only include sched.h because they dereference one field within current.
Any comments?
The patch is against 2.5.1-dj6, but also applies to 2.5.2-pre3 with some minor line shifts.
--
Manfred
<<<<<<<<<<<< PATCH:
fs/autofs/inode.c +1 -0
@@ -11,6 +11,7 @@* ------------------------------------------------------------------------- */ #include <linux/kernel.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/file.h> #include <linux/locks.h>
fs/char_dev.c +1 -0
@@ -6,6 +6,7 @@#include <linux/config.h> #include <linux/init.h> +#include <linux/fs.h> #include <linux/slab.h> #define HASH_BITS 6
fs/isofs/joliet.c +1 -1
@@ -8,7 +8,7 @@#include <linux/string.h> #include <linux/nls.h> -#include <linux/slab.h> +#include <linux/mm.h> #include <linux/iso_fs.h> #include <asm/unaligned.h>
fs/isofs/namei.c +1 -1
@@ -12,7 +12,7 @@#include <linux/string.h> #include <linux/stat.h> #include <linux/fcntl.h> -#include <linux/slab.h> +#include <linux/mm.h> #include <linux/errno.h> #include <linux/config.h> /* Joliet? */
fs/namespace.c +1 -0
@@ -10,6 +10,7 @@#include <linux/config.h> #include <linux/slab.h> +#include <linux/sched.h> #include <linux/smp_lock.h> #include <linux/init.h> #include <linux/quotaops.h>
fs/nfs/write.c +1 -1
@@ -49,7 +49,7 @@#include <linux/config.h> #include <linux/types.h> #include <linux/slab.h> -#include <linux/swap.h> +#include <linux/mm.h> #include <linux/pagemap.h> #include <linux/file.h>
fs/nfsd/export.c +1 -0
@@ -16,6 +16,7 @@#include <linux/unistd.h> #include <linux/slab.h> +#include <linux/sched.h> #include <linux/stat.h> #include <linux/in.h>
fs/proc/base.c +1 -0
@@ -25,6 +25,7 @@#include <linux/string.h> #include <linux/seq_file.h> #include <linux/namespace.h> +#include <linux/mm.h> /* * For hysterical raisins we keep the same inumbers as in the old procfs.
fs/qnx4/inode.c +1 -1
@@ -18,8 +18,8 @@#include <linux/string.h> #include <linux/errno.h> #include <linux/slab.h> -#include <linux/qnx4_fs.h> #include <linux/fs.h> +#include <linux/qnx4_fs.h> #include <linux/locks.h> #include <linux/init.h> #include <linux/highuid.h>
fs/qnx4/truncate.c +1 -2
@@ -13,9 +13,8 @@#include <linux/config.h> #include <linux/types.h> #include <linux/errno.h> -#include <linux/slab.h> -#include <linux/qnx4_fs.h> #include <linux/fs.h> +#include <linux/qnx4_fs.h> #include <linux/locks.h> #include <asm/uaccess.h>
include/linux/file.h +2 -0
@@ -5,6 +5,8 @@#ifndef __LINUX_FILE_H#define __LINUX_FILE_H +#include <linux/sched.h> +extern void FASTCALL (fput (struct file *));extern struct file *FASTCALL (fget (unsigned int fd));
include/linux/gfp.h +81 -0
81 lines not on this page · raw message
include/linux/interrupt.h +1 -0
@@ -9,6 +9,7 @@#include <asm/bitops.h> #include <asm/atomic.h> +#include <asm/system.h> #include <asm/ptrace.h> struct irqaction {
include/linux/kernel.h +0 -10
@@ -44,16 +44,6 @@#define minimum_console_loglevel (console_printk[2])#define default_console_loglevel (console_printk[3]) -# define NORET_TYPE /**/ -# define ATTRIB_NORET __attribute__((noreturn)) -# define NORET_AND noreturn, - -#ifdef __i386__ -#define FASTCALL (x) x __attribute__((regparm(3))) -#else -#define FASTCALL (x) x -#endif -struct completion ;extern struct notifier_block *panic_notifier_list;
include/linux/linkage.h +10 -0
@@ -60,4 +60,14 @@#endif +# define NORET_TYPE /**/ +# define ATTRIB_NORET __attribute__((noreturn)) +# define NORET_AND noreturn, + +#ifdef __i386__ +#define FASTCALL (x) x __attribute__((regparm(3))) +#else +#define FASTCALL (x) x +#endif +#endif
include/linux/mm.h +1 -74
93 lines not on this page · raw message
include/linux/parport.h +1 -0
@@ -8,6 +8,7 @@#ifndef _PARPORT_H_#define _PARPORT_H_ +#include <linux/sched.h> /* Start off with user-visible constants */
include/linux/proc_fs.h +2 -0
@@ -3,6 +3,8 @@#include <linux/config.h> #include <linux/slab.h> +#include <linux/fs.h> +#include <asm/atomic.h> /* * The proc filesystem constants/structures
include/linux/reiserfs_fs.h +1 -1
@@ -15,10 +15,10 @@#include <linux/types.h> #ifdef __KERNEL__#include <linux/slab.h> +#include <linux/interrupt.h> #include <linux/tqueue.h> #include <asm/unaligned.h> #include <linux/bitops.h> -#include <asm/hardirq.h> #include <linux/proc_fs.h> #endif
include/linux/shm.h +0 -1
@@ -80,7 +80,6 @@asmlinkage long sys_shmat (int shmid,char *shmaddr,int shmflg,unsigned long *addr);asmlinkage long sys_shmdt (char *shmaddr);asmlinkage long sys_shmctl (int shmid,int cmd,struct shmid_ds *buf); -extern void shm_unuse (swp_entry_t entry,struct page *page);#endif /* __KERNEL__ */
include/linux/slab.h +3 -2
@@ -11,8 +11,8 @@typedef struct kmem_cache_s kmem_cache_t ; -#include <linux/mm.h> -#include <linux/cache.h> +#include <linux/gfp.h> +#include <linux/types.h> /* flags for kmem_cache_alloc() */ #define SLAB_NOFS GFP_NOFS
@@ -64,6 +64,7 @@extern int FASTCALL (kmem_cache_reap (int ));extern int slabinfo_read_proc (char *page,char **start,off_t off,int count,int *eof,void *data); +struct file ;extern int slabinfo_write_proc (struct file *file,const char *buffer,unsigned long count,void *data);
include/linux/sunrpc/clnt.h +1 -0
@@ -15,6 +15,7 @@#include <linux/sunrpc/auth.h> #include <linux/sunrpc/stats.h> #include <linux/sunrpc/xdr.h> +#include <asm/signal.h> /* * This defines an RPC port mapping
ipc/shm.c +1 -0
@@ -17,6 +17,7 @@#include <linux/config.h> #include <linux/slab.h> +#include <linux/mm.h> #include <linux/shm.h> #include <linux/init.h> #include <linux/file.h>
kernel/exit.c +1 -0
@@ -5,6 +5,7 @@*/ #include <linux/config.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/interrupt.h> #include <linux/smp_lock.h>
kernel/pm.c +1 -0
@@ -20,6 +20,7 @@#include <linux/module.h> #include <linux/spinlock.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/pm.h> #include <linux/interrupt.h>
kernel/sysctl.c +1 -0
@@ -19,6 +19,7 @@*/ #include <linux/config.h> +#include <linux/mm.h> #include <linux/slab.h> #include <linux/sysctl.h> #include <linux/swapctl.h>
mm/mempool.c +1 -0
@@ -8,6 +8,7 @@* started by Ingo Molnar, Copyright (C) 2001 */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/mempool.h>
mm/mprotect.c +1 -0
@@ -3,6 +3,7 @@* * (C) Copyright 1994 Linus Torvalds */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/smp_lock.h> #include <linux/shm.h>
mm/mremap.c +1 -0
@@ -4,6 +4,7 @@* (C) Copyright 1996 Linus Torvalds */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/smp_lock.h> #include <linux/shm.h>
mm/slab.c +2 -0
@@ -70,6 +70,8 @@#include <linux/config.h> #include <linux/slab.h> +#include <linux/mm.h> +#include <linux/cache.h> #include <linux/interrupt.h> #include <linux/init.h> #include <linux/compiler.h>
mm/swapfile.c +1 -0
@@ -5,6 +5,7 @@* Swap reorganised 29.12.95, Stephen Tweedie */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/smp_lock.h> #include <linux/kernel_stat.h>
mm/vmscan.c +1 -0
@@ -11,6 +11,7 @@* Multiqueue VM started 5.8.00, Rik van Riel. */ +#include <linux/mm.h> #include <linux/slab.h> #include <linux/kernel_stat.h> #include <linux/swap.h>
net/sunrpc/auth_null.c +1 -1
@@ -7,11 +7,11 @@*/ #include <linux/types.h> -#include <linux/slab.h> #include <linux/socket.h> #include <linux/in.h> #include <linux/utsname.h> #include <linux/sunrpc/clnt.h> +#include <linux/sched.h> #ifdef RPC_DEBUG # define RPCDBG_FACILITY RPCDBG_AUTH
net/sunrpc/auth_unix.c +1 -1
@@ -7,7 +7,7 @@*/ #include <linux/types.h> -#include <linux/slab.h> +#include <linux/sched.h> #include <linux/socket.h> #include <linux/in.h> #include <linux/sunrpc/clnt.h>
fs/nls/nls_base.c +1 -1
@@ -13,7 +13,7 @@#include <linux/string.h> #include <linux/config.h> #include <linux/nls.h> -#include <linux/slab.h> +#include <linux/kernel.h> #include <linux/errno.h> #ifdef CONFIG_KMOD #include <linux/kmod.h>
fs/freevxfs/vxfs_inode.c +1 -0
@@ -35,6 +35,7 @@#include <linux/fs.h> #include <linux/kernel.h> #include <linux/slab.h> +#include <linux/pagemap.h> #include "vxfs.h" #include "vxfs_inode.h"
Quoted 3 lines · Manfred Spraul
Any comments?
The patch is against 2.5.1-dj6, but also applies to 2.5.2-pre3 with some minor line shifts.
I love it. Here's to hoping the powers that be decide to accept it.
-ben
Quoted 8 lines · Manfred Spraul
slab.his currently one of the worst include files:
it includes <mm.h>, that one <sched.h>, that one <fs.h>, just because it needs theGFP_defines.I've split the gfp functions out of
mm.hinto a seperate <gfp.h> header file.Is that a step in the right direction?
Maybe. You might want to pull the rest of the get_free_page functions out with it.
Quoted 4 lines
Another similar cleanup would be splitting the 'struct
task_struct' definition out ofsched.hinto a seperate <linux/current.h>:
some source files only includesched.hbecause they dereference one field within current.
Tried it yet? I think you'll find this very difficult because of all the things task_struct references.
Signature · 1 line
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."
Quoted 4 lines · Oliver Xymoron
Maybe. You might want to pull the rest of the
get_free_pagefunctions out with it.
Yes, I overlooked them. Thanks.
Quoted 9 lines
Quoted 5 lines
Another similar cleanup would be splitting the 'struct
task_struct' definition out ofsched.hinto a seperate <linux/current.h>:
some source files only includesched.hbecause they dereference one field within current.Tried it yet? I think you'll find this very difficult because of all the things
task_structreferences.
It wasn't that difficult: only these includes are needed to pull in all substructures ;-)
<<<<<<<
#include <linux/config.h>
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/timer.h>
#include <linux/times.h>
#include <linux/capability.h>
#include <linux/resource.h>
#include <linux/signal.h>
#include <asm/param.h>
#include <asm/signal.h>
#include <asm/processor.h>
#include <asm/resource.h>
<<<<<<<<<
Another target is IS_ERR: several header files include fs.h because they need it.
--
Manfred
Quoted 19 lines · Manfred Spraul
It wasn't that difficult: only these includes are needed to pull in all substructures ;-)
<<<<<<<
#include <linux/config.h>
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/list.h>
#include <linux/wait.h>
#include <linux/timer.h>
#include <linux/times.h>
#include <linux/capability.h>
#include <linux/resource.h>
#include <linux/signal.h>
#include <asm/param.h>
#include <asm/signal.h>
#include <asm/processor.h>
#include <asm/resource.h>
<<<<<<<<<
Indeed. Recently I wanted to stash current->pid inside a spinlock for debugging purposes and discovered it was a nightmare because of all the forward references that'd be needed.
Signature · 1 line
"Love the dolphins," she advised him. "Write by W.A.S.T.E.."