Messages in this thread Patch in this message | | | Date | Thu, 27 Jul 2000 23:27:51 +0100 (BST) | From | Tigran Aivazian <> | Subject | [patch] Re: recent names_cachep change |
| |
On Thu, 27 Jul 2000, Linus Torvalds wrote: > Just put it in fs/dcache.c, then dcache_init() can be static. And move > filescache_init() there too from kernel/fork.c (and files_cachep should > probably be declared somewhere in a header file). The kernel/fork.c > location happens to be where it is allocated/de-allocated, but > conceptually it's a VFS data structure. Oh, and file_table_init() and > dquot_init_hash should be there too..
ok, done this part and called it vfs_cache_init(). See patch below. bh_cachep belongs there as well since buffer cache is really a part of VFS (ok it isn't but it is in fs/*.c and therefore it is).
> The vma_init/buffer_init/page_cache_init/kiobuf_setup/ipc_init stuff > should probably be done as a "mm_init()" or something.
not done this part yet (intentionally, because this is quite unrelated to the patch below and I know concatenation of patches is a no-no)
> And fork_init/signals_init is probably kernel/fork.c, as "process_init()". > So that init/main.c looks a bit cleaner.
No, I disagree because then one would have to have DEBUG_SIG in two (or in zero) places or put it in the header which is not-nice.
Also, I paid more attention to putting same-subsystem SLAB caches together rather than reducing the number of lines in init/main.c
Regards, Tigran
diff -urN -X dontdiff linux/fs/buffer.c vfscache/fs/buffer.c --- linux/fs/buffer.c Thu Jul 27 07:31:19 2000 +++ vfscache/fs/buffer.c Thu Jul 27 23:09:40 2000 @@ -92,8 +92,6 @@ }; static struct bh_free_head free_list[NR_SIZES]; -kmem_cache_t *bh_cachep; - static int grow_buffers(int size); static void __refile_buffer(struct buffer_head *); @@ -2302,12 +2300,6 @@ for(i = 0; i < NR_LIST; i++) lru_list[i] = NULL; - bh_cachep = kmem_cache_create("buffer_head", - sizeof(struct buffer_head), - 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if(!bh_cachep) - panic("Cannot create buffer head SLAB cache\n"); } diff -urN -X dontdiff linux/fs/dcache.c vfscache/fs/dcache.c --- linux/fs/dcache.c Fri Jul 14 20:52:15 2000 +++ vfscache/fs/dcache.c Thu Jul 27 23:16:20 2000 @@ -1168,7 +1168,7 @@ return ino; } -void __init dcache_init(unsigned long mempages) +static void __init dcache_init(unsigned long mempages) { struct list_head *d; unsigned long order; @@ -1225,4 +1225,56 @@ d++; i--; } while (i); +} + +/* SLAB cache for __getname() consumers */ +kmem_cache_t *names_cachep; + +/* SLAB cache for files_struct structures */ +kmem_cache_t *files_cachep; + +/* SLAB cache for file structures */ +kmem_cache_t *filp_cachep; + +/* SLAB cache for dquot structures */ +kmem_cache_t *dquot_cachep; + +/* SLAB cache for buffer_head structures */ +kmem_cache_t *bh_cachep; + +void __init vfs_caches_init(unsigned long mempages) +{ + bh_cachep = kmem_cache_create("buffer_head", + sizeof(struct buffer_head), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if(!bh_cachep) + panic("Cannot create buffer head SLAB cache\n"); + + names_cachep = kmem_cache_create("names_cache", + PAGE_SIZE, 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!names_cachep) + panic("Cannot create names SLAB cache"); + + files_cachep = kmem_cache_create("files_cache", + sizeof(struct files_struct), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!files_cachep) + panic("Cannot create files SLAB cache"); + + filp_cachep = kmem_cache_create("filp", + sizeof(struct file), 0, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if(!filp_cachep) + panic("Cannot create filp SLAB cache"); + +#if defined (CONFIG_QUOTA) + dquot_cachep = kmem_cache_create("dquot", + sizeof(struct dquot), sizeof(unsigned long) * 4, + SLAB_HWCACHE_ALIGN, NULL, NULL); + if (!dquot_cachep) + panic("Cannot create dquot SLAB cache"); +#endif + + dcache_init(mempages); } diff -urN -X dontdiff linux/fs/dquot.c vfscache/fs/dquot.c --- linux/fs/dquot.c Thu Jul 27 07:31:19 2000 +++ vfscache/fs/dquot.c Thu Jul 27 22:55:48 2000 @@ -64,8 +64,6 @@ static char quotamessage[MAX_QUOTA_MESSAGE]; static char *quotatypes[] = INITQFNAMES; -static kmem_cache_t *dquot_cachep; - static inline struct quota_mount_options *sb_dqopt(struct super_block *sb) { return &sb->s_dquot; @@ -1344,13 +1342,6 @@ void __init dquot_init_hash(void) { printk(KERN_NOTICE "VFS: Diskquotas version %s initialized\n", __DQUOT_VERSION__); - - dquot_cachep = kmem_cache_create("dquot", sizeof(struct dquot), - sizeof(unsigned long) * 4, - SLAB_HWCACHE_ALIGN, NULL, NULL); - - if (!dquot_cachep) - panic("Cannot create dquot SLAB cache\n"); memset(dquot_hash, 0, sizeof(dquot_hash)); memset((caddr_t)&dqstats, 0, sizeof(dqstats)); diff -urN -X dontdiff linux/fs/file_table.c vfscache/fs/file_table.c --- linux/fs/file_table.c Thu Jul 27 07:31:19 2000 +++ vfscache/fs/file_table.c Thu Jul 27 23:15:52 2000 @@ -12,9 +12,6 @@ #include <linux/module.h> #include <linux/smp_lock.h> -/* SLAB cache for filp's. */ -static kmem_cache_t *filp_cache; - /* sysctl tunables... */ struct files_stat_struct files_stat = {0, 0, NR_FILE}; @@ -25,20 +22,6 @@ /* public *and* exported. Not pretty! */ spinlock_t files_lock = SPIN_LOCK_UNLOCKED; -void __init file_table_init(void) -{ - filp_cache = kmem_cache_create("filp", sizeof(struct file), - 0, - SLAB_HWCACHE_ALIGN, NULL, NULL); - if(!filp_cache) - panic("VFS: Cannot alloc filp SLAB cache."); - /* - * We could allocate the reserved files here, but really - * shouldn't need to: the normal boot process will create - * plenty of free files. - */ -} - /* Find an unused file structure and return a pointer to it. * Returns NULL, if there are no more free file structures or * we run out of memory. @@ -78,7 +61,7 @@ */ if (files_stat.nr_files < files_stat.max_files) { file_list_unlock(); - f = kmem_cache_alloc(filp_cache, SLAB_KERNEL); + f = kmem_cache_alloc(filp_cachep, SLAB_KERNEL); file_list_lock(); if (f) { files_stat.nr_files++; diff -urN -X dontdiff linux/fs/namei.c vfscache/fs/namei.c --- linux/fs/namei.c Thu Jul 27 07:31:19 2000 +++ vfscache/fs/namei.c Thu Jul 27 22:41:14 2000 @@ -1954,20 +1954,3 @@ readlink: page_readlink, follow_link: page_follow_link, }; - -/* SLAB cache for name blocks */ -kmem_cache_t *names_cachep; - -static int __init namecache_init(void) -{ - names_cachep = kmem_cache_create("names_cache", - PAGE_SIZE, - 0, - SLAB_HWCACHE_ALIGN, - NULL, NULL); - if (!names_cachep) - panic("Cannot create names cache"); - return 0; -} - -module_init(namecache_init) diff -urN -X dontdiff linux/include/linux/fs.h vfscache/include/linux/fs.h --- linux/include/linux/fs.h Thu Jul 27 07:31:21 2000 +++ vfscache/include/linux/fs.h Thu Jul 27 23:11:42 2000 @@ -193,8 +193,6 @@ extern void buffer_init(unsigned long); extern void inode_init(unsigned long); -extern void file_table_init(void); -extern void dcache_init(unsigned long); /* bh state bits */ #define BH_Uptodate 0 /* 1 if the buffer contains valid data */ @@ -881,6 +879,9 @@ extern struct file * dentry_open(struct dentry *, struct vfsmount *, int); extern int filp_close(struct file *, fl_owner_t id); extern char * getname(const char *); + +/* fs/dcache.c */ +extern void vfs_caches_init(unsigned long); #define __getname() kmem_cache_alloc(names_cachep, SLAB_KERNEL) #define putname(name) kmem_cache_free(names_cachep, (void *)(name)) diff -urN -X dontdiff linux/include/linux/slab.h vfscache/include/linux/slab.h --- linux/include/linux/slab.h Thu Jul 27 07:31:21 2000 +++ vfscache/include/linux/slab.h Thu Jul 27 23:11:44 2000 @@ -69,6 +69,10 @@ extern kmem_cache_t *vm_area_cachep; extern kmem_cache_t *mm_cachep; extern kmem_cache_t *names_cachep; +extern kmem_cache_t *files_cachep; +extern kmem_cache_t *filp_cachep; +extern kmem_cache_t *dquot_cachep; +extern kmem_cache_t *bh_cachep; #endif /* __KERNEL__ */ diff -urN -X dontdiff linux/init/main.c vfscache/init/main.c --- linux/init/main.c Thu Jul 27 07:31:21 2000 +++ vfscache/init/main.c Thu Jul 27 23:04:19 2000 @@ -92,7 +92,6 @@ extern void sbus_init(void); extern void ppc_init(void); extern void sysctl_init(void); -extern void filescache_init(void); extern void signals_init(void); extern void bdev_init(void); extern int init_pcmcia_ds(void); @@ -563,8 +562,7 @@ mempages = num_physpages; fork_init(mempages); - filescache_init(); - dcache_init(mempages); + vfs_caches_init(mempages); vma_init(); buffer_init(mempages); page_cache_init(mempages); @@ -572,12 +570,8 @@ signals_init(); bdev_init(); inode_init(mempages); - file_table_init(); #if defined(CONFIG_SYSVIPC) ipc_init(); -#endif -#if defined(CONFIG_QUOTA) - dquot_init_hash(); #endif check_bugs(); printk("POSIX conformance testing by UNIFIX\n"); diff -urN -X dontdiff linux/kernel/exit.c vfscache/kernel/exit.c --- linux/kernel/exit.c Tue Jul 11 19:26:51 2000 +++ vfscache/kernel/exit.c Thu Jul 27 22:46:23 2000 @@ -180,8 +180,6 @@ } } -extern kmem_cache_t *files_cachep; - void put_files_struct(struct files_struct *files) { if (atomic_dec_and_test(&files->count)) { diff -urN -X dontdiff linux/kernel/fork.c vfscache/kernel/fork.c --- linux/kernel/fork.c Thu Jul 27 07:31:21 2000 +++ vfscache/kernel/fork.c Thu Jul 27 22:46:47 2000 @@ -35,9 +35,6 @@ /* SLAB cache for mm_struct's. */ kmem_cache_t *mm_cachep; -/* SLAB cache for files structs */ -kmem_cache_t *files_cachep; - struct task_struct *pidhash[PIDHASH_SZ]; /* UID task count cache, to prevent walking entire process list every @@ -809,15 +806,4 @@ bad_fork_free: free_task_struct(p); goto bad_fork; -} - -void __init filescache_init(void) -{ - files_cachep = kmem_cache_create("files_cache", - sizeof(struct files_struct), - 0, - SLAB_HWCACHE_ALIGN, - NULL, NULL); - if (!files_cachep) - panic("Cannot create files cache"); } diff -urN -X dontdiff linux/mm/highmem.c vfscache/mm/highmem.c --- linux/mm/highmem.c Thu Jul 27 07:31:21 2000 +++ vfscache/mm/highmem.c Thu Jul 27 23:07:44 2000 @@ -240,8 +240,6 @@ * This will be moved to the block layer in 2.5. */ -extern kmem_cache_t *bh_cachep; - static inline void copy_from_high_bh (struct buffer_head *to, struct buffer_head *from) {
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/
| |