Skip to contentSkip to conversation

include file cleanup

RFC In review Manfred Spraul 3 participants 5 messages Dec 29, 2001

Subsystems (18)
lore
Share & tools
lore
#0 lore raw

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
diff -urN 2.5/fs/autofs/inode.c build-2.5/fs/autofs/inode.c
@@ -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
diff -urN 2.5/fs/char_dev.c build-2.5/fs/char_dev.c
@@ -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
diff -urN 2.5/fs/isofs/joliet.c build-2.5/fs/isofs/joliet.c
@@ -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
diff -urN 2.5/fs/isofs/namei.c build-2.5/fs/isofs/namei.c
@@ -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
diff -urN 2.5/fs/namespace.c build-2.5/fs/namespace.c
@@ -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
diff -urN 2.5/fs/nfs/write.c build-2.5/fs/nfs/write.c
@@ -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
diff -urN 2.5/fs/nfsd/export.c build-2.5/fs/nfsd/export.c
@@ -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
diff -urN 2.5/fs/proc/base.c build-2.5/fs/proc/base.c
@@ -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
diff -urN 2.5/fs/qnx4/inode.c build-2.5/fs/qnx4/inode.c
@@ -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
diff -urN 2.5/fs/qnx4/truncate.c build-2.5/fs/qnx4/truncate.c
@@ -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
diff -urN 2.5/include/linux/file.h build-2.5/include/linux/file.h
@@ -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
diff -urN 2.5/include/linux/interrupt.h build-2.5/include/linux/interrupt.h
@@ -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
diff -urN 2.5/include/linux/kernel.h build-2.5/include/linux/kernel.h
@@ -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
diff -urN 2.5/include/linux/linkage.h build-2.5/include/linux/linkage.h
@@ -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
diff -urN 2.5/include/linux/parport.h build-2.5/include/linux/parport.h
@@ -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
diff -urN 2.5/include/linux/proc_fs.h build-2.5/include/linux/proc_fs.h
@@ -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
diff -urN 2.5/include/linux/reiserfs_fs.h build-2.5/include/linux/reiserfs_fs.h
@@ -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
diff -urN 2.5/include/linux/shm.h build-2.5/include/linux/shm.h
@@ -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
diff -urN 2.5/include/linux/slab.h build-2.5/include/linux/slab.h
@@ -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
diff -urN 2.5/include/linux/sunrpc/clnt.h build-2.5/include/linux/sunrpc/clnt.h
@@ -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
diff -urN 2.5/ipc/shm.c build-2.5/ipc/shm.c
@@ -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
diff -urN 2.5/kernel/exit.c build-2.5/kernel/exit.c
@@ -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
diff -urN 2.5/kernel/pm.c build-2.5/kernel/pm.c
@@ -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
diff -urN 2.5/kernel/sysctl.c build-2.5/kernel/sysctl.c
@@ -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
diff -urN 2.5/mm/mempool.c build-2.5/mm/mempool.c
@@ -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
diff -urN 2.5/mm/mprotect.c build-2.5/mm/mprotect.c
@@ -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
diff -urN 2.5/mm/mremap.c build-2.5/mm/mremap.c
@@ -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
diff -urN 2.5/mm/slab.c build-2.5/mm/slab.c
@@ -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
diff -urN 2.5/mm/swapfile.c build-2.5/mm/swapfile.c
@@ -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
diff -urN 2.5/mm/vmscan.c build-2.5/mm/vmscan.c
@@ -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
diff -urN 2.5/net/sunrpc/auth_null.c build-2.5/net/sunrpc/auth_null.c
@@ -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
diff -urN 2.5/net/sunrpc/auth_unix.c build-2.5/net/sunrpc/auth_unix.c
@@ -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"
#1 lore raw
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

#2 lore raw
In reply to Manfred Spraul
Quoted 8 lines · Manfred Spraul

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?

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 of sched.h into a seperate <linux/current.h>:
some source files only include sched.h because 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.."
#3 lore raw
Quoted 4 lines · Oliver Xymoron

Maybe. You might want to pull the rest of the get_free_page functions 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 of sched.h into a seperate <linux/current.h>:
some source files only include sched.h because 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.

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

#4 lore raw
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.."