lkml.org 
[lkml]   [1996]   [Jul]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subjectpatch....
Date
From
Tiny patch to hopefully speed up get_empty_filp().

I claim this has an average running time of N/M where N is the number
of allocated structs, and M is the number of free structs. It's also
just plain faster which is actually find a struct because it doesn't
mess around with re-writing all the pointers, and zero'ing the entire
structure. It only zero's the parts that aren't going to get
overwritten, and saves 3 function calls to boot.

basic idea is, starting searching from the struct after the last free
struct that was found to be free.

Anyone see any hugely obvious errors?

Michael.

--- linux/fs/file_table.c.old Tue Jul 30 19:47:35 1996
+++ linux/fs/file_table.c Tue Jul 30 19:59:41 1996
@@ -102,7 +102,7 @@
{
int i;
int max = max_files;
- struct file * f;
+ static struct file * f = NULL;

/*
* Reserve a few files for the super-user..
@@ -111,15 +111,25 @@
max -= 10;

/* if the return is taken, we are in deep trouble */
- if (!first_file && !grow_files())
- return NULL;
+ if (!first_file) {
+ if (!grow_files())
+ return NULL;
+ f = first_file;
+ }

do {
- for (f = first_file, i=0; i < nr_files; i++, f = f->f_next)
+ for (f = f->f_next, i=0; i < nr_files; i++, f = f->f_next)
if (!f->f_count) {
+#if 1
+ f->f_mode = f->f_pos = f->f_flags = f->f_count =
+ f->f_reada = f->f_ramax = f->f_raend = f->f_ralen =
+ f->f_rawin = f->f_owner = 0;
+ f->private_data = f->f_op = f->f_inode = NULL;
+#else
remove_file_free(f);
memset(f,0,sizeof(*f));
put_last_free(f);
+#endif
f->f_count = 1;
f->f_version = ++event;
return f;


--
Mean people suck. Nice people swallow.
Which is worse: ignorance or apathy? Who knows? Who cares?
The notorious A.F.T.
Most of your faults are not your fault.

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