Skip to contentSkip to conversation

epoll cleanups - epoll include diet ...

PATCH In review Davide Libenzi 2 participants 5 messages Apr 4, 2007 – Apr 6, 2007 VFS

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 epoll cleanups - epoll include diet ...

Remove some unneeded include files from epoll code.

- Davide

fs/eventpoll.c +2 -11
Index: linux-2.6.21-rc5.mm4/fs/eventpoll.c
===================================================================
@@ -1,6 +1,6 @@
 /*
- *  fs/eventpoll.c ( Efficent event polling implementation )
- *  Copyright (C) 2001,...,2006	 Davide Libenzi
+ *  fs/eventpoll.c (Efficent event notification implementation)
+ *  Copyright (C) 2001,...,2007	 Davide Libenzi
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -17,30 +17,21 @@
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/file.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/string.h>
 #include <linux/list.h>
 #include <linux/hash.h>
 #include <linux/spinlock.h>
-#include <linux/syscalls.h>
 #include <linux/rwsem.h>
 #include <linux/rbtree.h>
 #include <linux/wait.h>
 #include <linux/eventpoll.h>
-#include <linux/mount.h>
-#include <linux/bitops.h>
 #include <linux/mutex.h>
 #include <linux/anon_inodes.h>
 #include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/mman.h>
 #include <asm/atomic.h>
-#include <asm/semaphore.h>
 
 
 /*
#1 lore raw
Quoted 2 lines · On Tue, 03 Apr 2007 18:35:06 -0700 Davide Libenzi <[email protected]>…

Remove some unneeded include files from epoll code.

Our definitions of "unneeded" might differ.

Quoted 39 lines

- Davide

Index: linux-2.6.21-rc5.mm4/fs/eventpoll.c
===================================================================

fs/eventpoll.c +2 -5
@@ -1,6 +1,6 @@
 /*
- *  fs/eventpoll.c ( Efficent event polling implementation )
- *  Copyright (C) 2001,...,2006	 Davide Libenzi
+ *  fs/eventpoll.c (Efficent event notification implementation)
+ *  Copyright (C) 2001,...,2007	 Davide Libenzi
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -17,30 +17,21 @@
 #include <linux/sched.h>
 #include <linux/fs.h>
 #include <linux/file.h>
-#include <linux/signal.h>
 #include <linux/errno.h>
-#include <linux/mm.h>
 #include <linux/slab.h>
 #include <linux/poll.h>
 #include <linux/string.h>
 #include <linux/list.h>
 #include <linux/hash.h>
 #include <linux/spinlock.h>
-#include <linux/syscalls.h>
 #include <linux/rwsem.h>
 #include <linux/rbtree.h>
 #include <linux/wait.h>
 #include <linux/eventpoll.h>

fs/eventpoll.c line 43

Quoted 10 lines
fs/eventpoll.c +0 -6
-#include <linux/mount.h>
-#include <linux/bitops.h>
 #include <linux/mutex.h>
 #include <linux/anon_inodes.h>
 #include <asm/uaccess.h>
-#include <asm/system.h>
-#include <asm/io.h>
-#include <asm/mman.h>
 #include <asm/atomic.h>
-#include <asm/semaphore.h>

epoll uses signal stuff and might need signal.h. It implements syscalls and it certainly needs to have those syscall's prototypes in scope. It surely uses stuff from mm.h (doesn't everything??)

I am suspecting that this patch relies upon accidental nested inclusions from within other headers. But that is super-fragile: change a config item, switch to a different architecture and whoops, it doesn't compile any more.

Maybe I'm wrong, and you somehow worked out that none of these things which these headers define, and none the things which these headers' includees define is used in epoll.c or in the headers which are included after these headers, or in those headers' includees. If so, how the heck did you do that?

#2 lore raw
Quoted 3 lines · Andrew Morton

epoll uses signal stuff and might need signal.h. It implements syscalls and it certainly needs to have those syscall's prototypes in scope. It surely uses stuff from mm.h (doesn't everything??)

Ack about signal.h, I forgot about the pwait code :(
Why syscalls.h? The eventpoll.c file expots syscalls, but it doesn't use anything declared in there.
What does eventpoll.c use *directly* from mm.h? If eventpoll.c uses, let's say sched.h, and sched.h needs mm.h, it is sched.h responsibility to include the mm.h file not eventpoll.c one.

- Davide

#3 lore raw
Quoted 9 lines · On Thu, 5 Apr 2007 18:12:58 -0700 (PDT) Davide Libenzi…
Quoted 3 lines · Andrew Morton

epoll uses signal stuff and might need signal.h. It implements syscalls and it certainly needs to have those syscall's prototypes in scope. It surely uses stuff from mm.h (doesn't everything??)

Ack about signal.h, I forgot about the pwait code :(
Why syscalls.h? The eventpoll.c file expots syscalls, but it doesn't use anything declared in there.

So that the compiler can verify that our declarations of sys_epoll_foo() match our definitions of them.

Quoted 4 lines

What does eventpoll.c use *directly* from mm.h? If eventpoll.c uses, let's say sched.h, and sched.h needs mm.h, it is sched.h responsibility to include the mm.h file not eventpoll.c one.

Sure. But if epoll.c _does_ use something from mm.h (or uses something from a header which mm.h includes) then if we later remove the #include mm.h from sched.h, eventpoll.c will break.

The general rule is: include in .c the header files which provide the stuff which that .c file uses. Now, it maybe that eventpoll.c indeed uses nothing which mm.h provides, and nothing which mm.h's includees provide. But it is non-trivial to prove that. Once added, includes are hard to remove :(

#4 lore raw
Quoted 9 lines · Andrew Morton
Quoted 6 lines · On Thu, 5 Apr 2007 18:12:58 -0700 (PDT) Davide Libenzi…
Quoted 3 lines · Andrew Morton

epoll uses signal stuff and might need signal.h. It implements syscalls and it certainly needs to have those syscall's prototypes in scope. It surely uses stuff from mm.h (doesn't everything??)

Quoted 6 lines
Quoted 3 lines

Ack about signal.h, I forgot about the pwait code :(
Why syscalls.h? The eventpoll.c file expots syscalls, but it doesn't use anything declared in there.

So that the compiler can verify that our declarations of sys_epoll_foo() match our definitions of them.

Right. Just drop that patch then.

- Davide