Messages in this thread Patch in this message | | | Date | Fri, 8 Jan 1999 13:43:06 +0100 (CET) | From | Andrea Arcangeli <> | Subject | [patch] getname buffer moved to slab cache |
| |
This my patch improve fs performances a bit.
Here the timings before the patch:
Script started on Fri Jan 8 13:01:53 1999 root@laser:~# time find / >/dev/null
real 0m1.523s user 0m0.420s sys 0m1.100s root@laser:~# time find / >/dev/null
real 0m1.532s user 0m0.500s sys 0m1.050s root@laser:~# time find / >/dev/null
real 0m1.534s user 0m0.390s sys 0m1.140s root@laser:~# /usr/bin/time find / >/dev/null 0.50user 1.04system 0:01.54elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (83major+32minor)pagefaults 0swaps root@laser:~# /usr/bin/time find / >/dev/null 0.43user 1.11system 0:01.54elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (83major+32minor)pagefaults 0swaps root@laser:~# time (find / >/dev/null & find / >/dev/null )
real 0m1.849s user 0m0.800s sys 0m2.900s root@laser:~# time (find / >/dev/null & find / >/dev/null )
real 0m1.807s user 0m0.870s sys 0m2.750s root@laser:~# exit
Script done on Fri Jan 8 13:02:48 1999
Here with the getname-slab-cache patch applyed:
Script started on Fri Jan 8 12:54:55 1999 root@laser:~# time find / >/dev/null
real 0m1.479s user 0m0.400s sys 0m1.080s root@laser:~# time find / >/dev/null
real 0m1.481s user 0m0.460s sys 0m1.030s root@laser:~# time find / >/dev/null
real 0m1.480s user 0m0.370s sys 0m1.110s root@laser:~# /usr/bin/time find / >/dev/null 0.61user 0.87system 0:01.47elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (83major+32minor)pagefaults 0swaps root@laser:~# /usr/bin/time find / >/dev/null 0.43user 1.05system 0:01.48elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (83major+32minor)pagefaults 0swaps root@laser:~# /usr/bin/time find / >/dev/null 0.46user 1.02system 0:01.47elapsed 100%CPU (0avgtext+0avgdata 0maxresident)k 0inputs+0outputs (83major+32minor)pagefaults 0swaps root@laser:~# time (find / >/dev/null & find / >/dev/null )
real 0m1.746s user 0m0.980s sys 0m2.510s root@laser:~# time (find / >/dev/null & find / >/dev/null )
real 0m1.748s user 0m0.800s sys 0m2.700s Script done on Fri Jan 8 12:56:14 1999
Under normal usage the slabstats looks like this:
caandrea@laser:~$ cat /proc/slabinfo *snip* getname_cache 0 6 *snip*
And finally here the patch against 2.2.0-pre5:
Index: fs/namei.c =================================================================== RCS file: /var/cvs/linux/fs/namei.c,v retrieving revision 1.1.1.1.2.8 diff -u -r1.1.1.1.2.8 namei.c --- namei.c 1998/12/29 01:19:03 1.1.1.1.2.8 +++ linux/fs/namei.c 1999/01/08 12:00:55 @@ -16,6 +16,7 @@ #include <linux/proc_fs.h> #include <linux/smp_lock.h> #include <linux/quotaops.h> +#include <linux/init.h> #include <asm/uaccess.h> #include <asm/unaligned.h> @@ -101,6 +102,21 @@ * * POSIX.1 2.4: an empty pathname is invalid (ENOENT). */ + +/* + * Cache the getname buffer in the slab cache to improve performances. + * Copyright (C) 1999 Andrea Arcangeli + */ + +static kmem_cache_t * getname_cache; + +#define __getname() kmem_cache_alloc(getname_cache, GFP_KERNEL) + +void putname(char * name) +{ + kmem_cache_free(getname_cache, name); +} + static inline int do_getname(const char *filename, char *page) { int retval; @@ -1303,4 +1319,15 @@ } unlock_kernel(); return error; +} + +void __init namei_init(void) +{ + getname_cache = kmem_cache_create("getname_cache", + PAGE_SIZE, + 0, + SLAB_HWCACHE_ALIGN, + NULL, NULL); + if (!getname_cache) + panic("cannot create getname cache"); } Index: include/linux/fs.h =================================================================== RCS file: /var/cvs/linux/include/linux/fs.h,v retrieving revision 1.1.1.1.2.11 diff -u -r1.1.1.1.2.11 fs.h --- fs.h 1999/01/03 19:51:15 1.1.1.1.2.11 +++ linux/include/linux/fs.h 1999/01/08 11:37:09 @@ -168,6 +168,7 @@ extern void inode_init(void); extern void file_table_init(void); extern void dcache_init(void); +extern void namei_init(void); typedef char buffer_block[BLOCK_SIZE]; @@ -697,8 +698,7 @@ extern struct file *filp_open(const char *, int, int); extern char * getname(const char * filename); -#define __getname() ((char *) __get_free_page(GFP_KERNEL)) -#define putname(name) free_page((unsigned long)(name)) +extern void FASTCALL(putname(char * name)); extern void kill_fasync(struct fasync_struct *fa, int sig); extern int register_blkdev(unsigned int, const char *, struct file_operations *); Index: init/main.c =================================================================== RCS file: /var/cvs/linux/init/main.c,v retrieving revision 1.1.1.1.2.10 diff -u -r1.1.1.1.2.10 main.c --- main.c 1999/01/05 00:18:33 1.1.1.1.2.10 +++ linux/init/main.c 1999/01/08 11:31:13 @@ -1160,6 +1160,7 @@ buffer_init(); signals_init(); inode_init(); + namei_init(); file_table_init(); #if defined(CONFIG_SYSVIPC) ipc_init();
Ah and I don't know what does it mean SLAB_RED_ZONE and SLAB_POISON...
- 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/
| |