cleanup file.h and INIT_TASK a bit
Subsystems (14)
RFC PATCH 1/1 cleanup file.h and INIT_TASK a bit
This patches does a couple of things: first off, it removes the sched.h include from file.h that was added recently, as we really don't need yet another include file chain mess. To make this a bit more palatable, a few of the inlines are moved out of file.h and into fcntl.c, plus the files_struct is moved to file.h from sched.h. Since this meant adding file.h to the various arch/*/kernel/init_task.c files, I took the time to move the INIT_* bits for initializing the init task out of sched.h and into init_task.h. If this is okay, please apply the patch. There are other cleanups to do if people are interested: the #define for init_task is currently duplicated in *all* asm-*/processor.h files to be exactly the same thing... This is a way of testing the waters on include file cleanups. Done properly, they shave ~10-15% off of the kernel compile time on my machine.
Oh, the file.h cleanup exposed a mess (bug): usb.c was duplicating code from daemonize().
-ben
Signature · 1 line
Fish.
Quoted 1 line · Jeff Garzik
I don't see a patch attached to your message...
Doh! Here it is... (also on kernel.org)
-ben
:r ~/patches/v2.5.2-pre11-file_init.diff
arch/arm/kernel/init_task.c +1 -0
@@ -5,6 +5,7 @@#include <linux/fs.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/i386/kernel/init_task.c +1 -0
@@ -1,6 +1,7 @@#include <linux/mm.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/ia64/kernel/init_task.c +1 -0
@@ -9,6 +9,7 @@#include <linux/init.h> #include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/mips/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/mips64/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/parisc/kernel/init_task.c +1 -0
@@ -1,6 +1,7 @@#include <linux/mm.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/s390/kernel/init_task.c +1 -0
@@ -8,6 +8,7 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/s390x/kernel/init_task.c +1 -0
@@ -8,6 +8,7 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/sh/kernel/init_task.c +1 -0
@@ -1,6 +1,7 @@#include <linux/mm.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/sparc/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/pgtable.h> #include <asm/uaccess.h>
arch/sparc64/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/pgtable.h> #include <asm/uaccess.h>
drivers/usb/storage/usb.c +0 -3
@@ -314,9 +314,6 @@* This thread doesn't need any user-level access, * so get rid of all our resources.. */ -exit_files (current); - current->files = init_task.files; -atomic_inc (¤t->files->count);daemonize ();/* set our name for identification purposes */
fs/fcntl.c +22 -0
@@ -20,6 +20,28 @@extern int fcntl_setlease (unsigned int fd,struct file *filp,long arg);extern int fcntl_getlease (struct file *filp); +void set_close_on_exec (unsigned int fd,int flag) +{ +struct files_struct *files = current->files; +write_lock (&files->file_lock); +if (flag) +FD_SET (fd, files->close_on_exec); +else +FD_CLR (fd, files->close_on_exec); +write_unlock (&files->file_lock); +} + +static inline int get_close_on_exec (unsigned int fd) +{ +struct files_struct *files = current->files; +int res; +read_lock (&files->file_lock); + res =FD_ISSET (fd, files->close_on_exec); +read_unlock (&files->file_lock); +return res; +} + +/* Expand files. Return <0 on error; 0 nothing done; 1 files expanded, * we may have blocked. *
fs/file.c +1 -0
@@ -11,6 +11,7 @@#include <linux/sched.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <linux/file.h> #include <asm/bitops.h>
fs/proc/array.c +1 -0
@@ -70,6 +70,7 @@#include <linux/smp.h> #include <linux/signal.h> #include <linux/highmem.h> +#include <linux/file.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
include/linux/file.h +38 -39
119 lines not on this page · raw message
include/linux/init_task.h +88 -0
88 lines not on this page · raw message
include/linux/sched.h +0 -101
126 lines not on this page · raw message
kernel/exit.c +1 -0
@@ -17,6 +17,7 @@#ifdef CONFIG_BSD_PROCESS_ACCT #include <linux/acct.h> #endif +#include <linux/file.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
kernel/fork.c +1 -0
@@ -21,6 +21,7 @@#include <linux/completion.h> #include <linux/namespace.h> #include <linux/personality.h> +#include <linux/file.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
kernel/kmod.c +1 -0
@@ -27,6 +27,7 @@#include <linux/slab.h> #include <linux/namespace.h> #include <linux/completion.h> +#include <linux/file.h> #include <asm/uaccess.h>
Quoted 3 lines · Benjamin LaHaise
Oh, the
file.hcleanup exposed a mess (bug):usb.cwas duplicating code fromdaemonize().
That's drivers/usb/storage/usb.c, the usb-storage driver's file. Which should not be confused with drivers/usb/usb.c :)
greg k-h
Resend. Several people pointed out they like the cleanup, nobody complained.
Quoted 14 lines · Benjamin LaHaise
This patches does a couple of things: first off, it removes the
sched.hinclude fromfile.hthat was added recently, as we really don't need yet another include file chain mess. To make this a bit more palatable, a few of the inlines are moved out offile.hand intofcntl.c, plus thefiles_structis moved tofile.hfromsched.h. Since this meant addingfile.hto the variousarch/*/kernel/init_task.cfiles, I took the time to move the INIT_* bits for initializing the init task out ofsched.hand intoinit_task.h. If this is okay, please apply the patch. There are other cleanups to do if people are interested: the #define forinit_taskis currently duplicated in *all*asm-*/processor.hfiles to be exactly the same thing... This is a way of testing the waters on include file cleanups. Done properly, they shave ~10-15% off of the kernel compile time on my machine.
Quoted 2 lines
Oh, the
file.hcleanup exposed a mess (bug):usb.cwas duplicating code fromdaemonize().
-ben
:r ~/patches/v2.5.2-pre11-file_init.diff
arch/arm/kernel/init_task.c +1 -0
@@ -5,6 +5,7 @@#include <linux/fs.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/i386/kernel/init_task.c +1 -0
@@ -1,6 +1,7 @@#include <linux/mm.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/ia64/kernel/init_task.c +1 -0
@@ -9,6 +9,7 @@#include <linux/init.h> #include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/mips/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/mips64/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/parisc/kernel/init_task.c +1 -0
@@ -1,6 +1,7 @@#include <linux/mm.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/s390/kernel/init_task.c +1 -0
@@ -8,6 +8,7 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/s390x/kernel/init_task.c +1 -0
@@ -8,6 +8,7 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/sh/kernel/init_task.c +1 -0
@@ -1,6 +1,7 @@#include <linux/mm.h> #include <linux/sched.h> #include <linux/init.h> +#include <linux/init_task.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
arch/sparc/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/pgtable.h> #include <asm/uaccess.h>
arch/sparc64/kernel/init_task.c +1 -0
@@ -1,5 +1,6 @@#include <linux/mm.h> #include <linux/sched.h> +#include <linux/init_task.h> #include <asm/pgtable.h> #include <asm/uaccess.h>
drivers/usb/storage/usb.c +0 -3
@@ -314,9 +314,6 @@* This thread doesn't need any user-level access, * so get rid of all our resources.. */ -exit_files (current); - current->files = init_task.files; -atomic_inc (¤t->files->count);daemonize ();/* set our name for identification purposes */
fs/fcntl.c +22 -0
@@ -20,6 +20,28 @@extern int fcntl_setlease (unsigned int fd,struct file *filp,long arg);extern int fcntl_getlease (struct file *filp); +void set_close_on_exec (unsigned int fd,int flag) +{ +struct files_struct *files = current->files; +write_lock (&files->file_lock); +if (flag) +FD_SET (fd, files->close_on_exec); +else +FD_CLR (fd, files->close_on_exec); +write_unlock (&files->file_lock); +} + +static inline int get_close_on_exec (unsigned int fd) +{ +struct files_struct *files = current->files; +int res; +read_lock (&files->file_lock); + res =FD_ISSET (fd, files->close_on_exec); +read_unlock (&files->file_lock); +return res; +} + +/* Expand files. Return <0 on error; 0 nothing done; 1 files expanded, * we may have blocked. *
fs/file.c +1 -0
@@ -11,6 +11,7 @@#include <linux/sched.h> #include <linux/slab.h> #include <linux/vmalloc.h> +#include <linux/file.h> #include <asm/bitops.h>
fs/proc/array.c +1 -0
@@ -70,6 +70,7 @@#include <linux/smp.h> #include <linux/signal.h> #include <linux/highmem.h> +#include <linux/file.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
include/linux/file.h +38 -39
119 lines not on this page · raw message
include/linux/init_task.h +88 -0
88 lines not on this page · raw message
include/linux/sched.h +0 -101
126 lines not on this page · raw message
kernel/exit.c +1 -0
@@ -17,6 +17,7 @@#ifdef CONFIG_BSD_PROCESS_ACCT #include <linux/acct.h> #endif +#include <linux/file.h> #include <asm/uaccess.h> #include <asm/pgtable.h>
kernel/fork.c +1 -0
@@ -21,6 +21,7 @@#include <linux/completion.h> #include <linux/namespace.h> #include <linux/personality.h> +#include <linux/file.h> #include <asm/pgtable.h> #include <asm/pgalloc.h>
kernel/kmod.c +1 -0
@@ -27,6 +27,7 @@#include <linux/slab.h> #include <linux/namespace.h> #include <linux/completion.h> +#include <linux/file.h> #include <asm/uaccess.h>
Quoted 19 lines · Benjamin LaHaise
Resend. Several people pointed out they like the cleanup, nobody complained.
Quoted 16 lines · Benjamin LaHaise
This patches does a couple of things: first off, it removes the
sched.hinclude fromfile.hthat was added recently, as we really don't need yet another include file chain mess. To make this a bit more palatable, a few of the inlines are moved out offile.hand intofcntl.c, plus thefiles_structis moved tofile.hfromsched.h. Since this meant addingfile.hto the variousarch/*/kernel/init_task.cfiles, I took the time to move the INIT_* bits for initializing the init task out ofsched.hand intoinit_task.h. If this is okay, please apply the patch. There are other cleanups to do if people are interested: the #define forinit_taskis currently duplicated in *all*asm-*/processor.hfiles to be exactly the same thing... This is a way of testing the waters on include file cleanups. Done properly, they shave ~10-15% off of the kernel compile time on my machine.Oh, the
file.hcleanup exposed a mess (bug):usb.cwas duplicating code fromdaemonize().
Please, split it in two chunks - init_task.h stuff and everything else. The former is obviously good thing, the latter may need more - I understand why you do the #define tricks, but I'm less than sure that it's the best way.
As for the USB... There is a bunch of other places that should do daemonize() - I'll dig the patch out and send it.