lkml.org 
[lkml]   [2003]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectRe: [PATCH] 2.4: Restore current->files in flush_old_exec
From
On Sat, Aug 09, 2003 at 11:11:16AM +1000, herbert wrote:
>
> At this point, I believe the unshare_files stuff should be fine from
> a correctness point of view. However, there is still a performance
> problem as every ELF exec call ends up dupliating the files structure
> as well as walking through all file locks.

Here is the patch that ensures files is only duplicated when necessary.
--
Debian GNU/Linux 3.0 is out! ( http://www.debian.org/ )
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt--- kernel-source-2.4/fs/binfmt_elf.c.orig 2003-08-09 11:28:18.000000000 +1000
+++ kernel-source-2.4/fs/binfmt_elf.c 2003-08-09 11:32:13.000000000 +1000
@@ -480,6 +480,10 @@
files = current->files; /* Refcounted so ok */
if(unshare_files() < 0)
goto out_free_ph;
+ if (files == current->files) {
+ put_files_struct(files);
+ files = NULL;
+ }

/* exec will make our files private anyway, but for the a.out
loader stuff we need to do it earlier */
@@ -602,8 +606,10 @@
goto out_free_dentry;

/* Discard our unneeded old files struct */
- steal_locks(files, current->files);
- put_files_struct(files);
+ if (files) {
+ steal_locks(files, current->files);
+ put_files_struct(files);
+ }

/* OK, This is the point of no return */
current->mm->start_data = 0;
@@ -811,9 +817,11 @@
out_free_file:
sys_close(elf_exec_fileno);
out_free_fh:
- ftmp = current->files;
- current->files = files;
- put_files_struct(ftmp);
+ if (files) {
+ ftmp = current->files;
+ current->files = files;
+ put_files_struct(ftmp);
+ }
out_free_ph:
kfree(elf_phdata);
goto out;
\
 
 \ /
  Last update: 2005-03-22 13:47    [from the cache]
©2003-2014 Jasper Spaans. Advertise on this site