lkml.org 
[lkml]   [1996]   [Dec]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectPatch: speed up getname()

Hello hackers,

Here is a patch to speed up getname(), which is used by sys_open()
and lots of other system calls that take file names. It speeds up
sys_open() by about 20% on my system.

It's based on a suggestion from Linus Torvalds to have a single-page
cache in order to avoid calling __get_free_page() and free_page() on
every getname() and putname() pair.

I believe this code is correct and I'm running it on my system.
I'd like some more people to try it out, especially on an SMP system
with lots of concurrent accesses. Then I'll submit it for 2.1.X.

Regards,

Michael Chastain
mec@shout.net

--- linux-2.1.13/fs/namei.c Mon Oct 28 12:21:41 1996
+++ linux/fs/namei.c Sun Dec 1 08:55:09 1996
@@ -48,25 +48,42 @@
return retval;
}

+/*
+ * This is a single page for faster getname.
+ * If the page is available when entering getname, use it.
+ * If the page is not available, call __get_free_page instead.
+ * This works even though do_getname can block (think about it).
+ * -- Michael Chastain, based on idea of Linus Torvalds, 1 Dec 1996.
+ */
+static unsigned long name_page_cache = 0;
+
int getname(const char * filename, char **result)
{
unsigned long page;
int retval;

- page = __get_free_page(GFP_KERNEL);
- retval = -ENOMEM;
- if (page) {
- *result = (char *)page;
- retval = do_getname(filename, (char *) page);
- if (retval < 0)
- free_page(page);
+ page = name_page_cache;
+ name_page_cache = 0;
+ if (!page) {
+ page = __get_free_page(GFP_KERNEL);
+ if (!page)
+ return -ENOMEM;
}
+
+ retval = do_getname(filename, (char *) page);
+ if (retval < 0)
+ putname( (char *) page );
+ else
+ *result = (char *) page;
return retval;
}

void putname(char * name)
{
- free_page((unsigned long) name);
+ if (name_page_cache == 0)
+ name_page_cache = (unsigned long) name;
+ else
+ free_page((unsigned long) name);
}

/*

\
 
 \ /
  Last update: 2005-03-22 13:37    [W:0.039 / U:1.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site