Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys count executable image pages as executable for vm-usage ...



details:   https://anonhg.NetBSD.org/src/rev/d4350a96da13
branches:  trunk
changeset: 537802:d4350a96da13
user:      chs <chs%NetBSD.org@localhost>
date:      Sat Oct 05 22:34:02 2002 +0000

description:
count executable image pages as executable for vm-usage purposes.
also, always do the VTEXT vs. v_writecount mutual exclusion
(which we previously skipped if the text or data segment was empty).

diffstat:

 sys/arch/mips/mips/cpu_exec.c             |  43 +++++++-----------------------
 sys/arch/sh3/sh3/coff_exec.c              |  19 ++----------
 sys/compat/common/compat_exec.c           |  22 ++++-----------
 sys/compat/hpux/hpux_exec_aout.c          |  17 ++++-------
 sys/compat/ibcs2/ibcs2_exec_coff.c        |  25 ++++-------------
 sys/compat/linux/common/linux_exec_aout.c |  22 ++++-----------
 sys/compat/linux/common/linux_uselib.c    |  12 +++-----
 sys/compat/m68k4k/m68k4k_exec.c           |  22 ++++-----------
 sys/compat/netbsd32/netbsd32_exec_aout.c  |  22 ++++-----------
 sys/compat/sunos/sunos_exec_aout.c        |  22 ++++-----------
 sys/kern/exec_aout.c                      |  22 ++++-----------
 sys/kern/exec_ecoff.c                     |  22 ++++-----------
 sys/kern/exec_elf32.c                     |  38 ++++++++++++---------------
 sys/kern/exec_macho.c                     |  36 +++++--------------------
 sys/kern/exec_subr.c                      |   7 +---
 sys/kern/vfs_vnops.c                      |  22 ++++++++++++++-
 sys/sys/vnode.h                           |   5 ++-
 17 files changed, 123 insertions(+), 255 deletions(-)

diffs (truncated from 849 to 300 lines):

diff -r 6ed1270dfeff -r d4350a96da13 sys/arch/mips/mips/cpu_exec.c
--- a/sys/arch/mips/mips/cpu_exec.c     Sat Oct 05 21:30:42 2002 +0000
+++ b/sys/arch/mips/mips/cpu_exec.c     Sat Oct 05 22:34:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpu_exec.c,v 1.33 2002/09/27 15:36:23 provos Exp $     */
+/*     $NetBSD: cpu_exec.c,v 1.34 2002/10/05 22:34:02 chs Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -94,30 +94,17 @@
                return error;
        }
 
-
+#ifdef COMPAT_09
+       error = vn_marktext(epp->ep_vp);
+       if (error)
+               return (error);
 
-#ifdef COMPAT_09
        epp->ep_taddr = 0x1000;
        epp->ep_entry = hdr->a_entry;
        epp->ep_tsize = hdr->a_text;
        epp->ep_daddr = epp->ep_taddr + hdr->a_text;
        epp->ep_dsize = hdr->a_data + hdr->a_bss;
 
-       /*
-        * check if vnode is in open for writing, because we want to
-        * demand-page out of it.  if it is, don't do it, for various
-        * reasons
-        */
-       if ((hdr->a_text != 0 || hdr->a_data != 0)
-           && epp->ep_vp->v_writecount != 0) {
-#ifdef DIAGNOSTIC
-               if (epp->ep_vp->v_flag & VTEXT)
-                       panic("exec: a VTEXT vnode has writecount != 0");
-#endif
-               return ETXTBSY;
-       }
-       epp->ep_vp->v_flag |= VTEXT;
-
        /* set up command for text segment */
        NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, hdr->a_text,
            epp->ep_taddr, epp->ep_vp, 0, VM_PROT_READ|VM_PROT_EXECUTE);
@@ -202,27 +189,17 @@
                return ENOEXEC;
        }
 
-               /* See if we got any program header information... */
+       /* See if we got any program header information... */
        if (!ex->e_phoff || !ex->e_phnum) {
                return ENOEXEC;
        }
 
+       error = vn_marktext(epp->ep_vp);
+       if (error)
+               return (error);
+
        /* Set the entry point... */
        epp->ep_entry = ex->e_entry;
-
-       /*
-        * Check if vnode is open for writing, because we want to
-        * demand-page out of it.  If it is, don't do it.
-        */
-       if (epp->ep_vp->v_writecount != 0) {
-#ifdef DIAGNOSTIC
-               if (epp->ep_vp->v_flag & VTEXT)
-                       panic("exec: a VTEXT vnode has writecount != 0");
-#endif
-               return ETXTBSY;
-       }
-       epp->ep_vp->v_flag |= VTEXT;
-
        epp->ep_taddr = 0;
        epp->ep_tsize = 0;
        epp->ep_daddr = 0;
diff -r 6ed1270dfeff -r d4350a96da13 sys/arch/sh3/sh3/coff_exec.c
--- a/sys/arch/sh3/sh3/coff_exec.c      Sat Oct 05 21:30:42 2002 +0000
+++ b/sys/arch/sh3/sh3/coff_exec.c      Sat Oct 05 22:34:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: coff_exec.c,v 1.16 2002/09/27 15:36:42 provos Exp $    */
+/*     $NetBSD: coff_exec.c,v 1.17 2002/10/05 22:34:03 chs Exp $       */
 
 /*
  * Copyright (c) 1994, 1995 Scott Bartram
@@ -299,20 +299,9 @@
        offset = sh.s_scnptr - (sh.s_vaddr - epp->ep_taddr);
        epp->ep_tsize = sh.s_size + (sh.s_vaddr - epp->ep_taddr);
 
-       /*
-        * check if vnode is in open for writing, because we want to
-        * demand-page out of it.  if it is, don't do it, for various
-        * reasons
-        */
-       if ((ap->a_tsize != 0 || ap->a_dsize != 0) &&
-           epp->ep_vp->v_writecount != 0) {
-#ifdef DIAGNOSTIC
-               if (epp->ep_vp->v_flag & VTEXT)
-                       panic("exec: a VTEXT vnode has writecount != 0");
-#endif
-               return ETXTBSY;
-       }
-       epp->ep_vp->v_flag |= VTEXT;
+       error = vn_marktext(epp->ep_vp);
+       if (error)
+               return (error);
 
        DPRINTF(("VMCMD: addr %lx size %lx offset %lx\n", epp->ep_taddr,
            epp->ep_tsize, offset));
diff -r 6ed1270dfeff -r d4350a96da13 sys/compat/common/compat_exec.c
--- a/sys/compat/common/compat_exec.c   Sat Oct 05 21:30:42 2002 +0000
+++ b/sys/compat/common/compat_exec.c   Sat Oct 05 22:34:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: compat_exec.c,v 1.6 2002/09/27 15:37:03 provos Exp $   */
+/*     $NetBSD: compat_exec.c,v 1.7 2002/10/05 22:34:03 chs Exp $      */
 
 /*
  * Copyright (c) 1993, 1994 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: compat_exec.c,v 1.6 2002/09/27 15:37:03 provos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_exec.c,v 1.7 2002/10/05 22:34:03 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -56,6 +56,7 @@
        struct exec_package *epp;
 {
        struct exec *execp = epp->ep_hdr;
+       int error;
 
        epp->ep_taddr = 0;
        epp->ep_tsize = execp->a_text;
@@ -63,20 +64,9 @@
        epp->ep_dsize = execp->a_data + execp->a_bss;
        epp->ep_entry = execp->a_entry;
 
-       /*
-        * check if vnode is in open for writing, because we want to
-        * demand-page out of it.  if it is, don't do it, for various
-        * reasons
-        */
-       if ((execp->a_text != 0 || execp->a_data != 0) &&
-           epp->ep_vp->v_writecount != 0) {
-#ifdef DIAGNOSTIC
-               if (epp->ep_vp->v_flag & VTEXT)
-                       panic("exec: a VTEXT vnode has writecount != 0");
-#endif
-               return ETXTBSY;
-       }
-       epp->ep_vp->v_flag |= VTEXT;
+       error = vn_marktext(epp->ep_vp);
+       if (error)
+               return (error);
 
        /* set up command for text segment */
        NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text,
diff -r 6ed1270dfeff -r d4350a96da13 sys/compat/hpux/hpux_exec_aout.c
--- a/sys/compat/hpux/hpux_exec_aout.c  Sat Oct 05 21:30:42 2002 +0000
+++ b/sys/compat/hpux/hpux_exec_aout.c  Sat Oct 05 22:34:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpux_exec_aout.c,v 1.3 2001/11/13 02:08:14 lukem Exp $ */
+/*     $NetBSD: hpux_exec_aout.c,v 1.4 2002/10/05 22:34:04 chs Exp $   */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpux_exec_aout.c,v 1.3 2001/11/13 02:08:14 lukem Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpux_exec_aout.c,v 1.4 2002/10/05 22:34:04 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -188,16 +188,11 @@
        struct hpux_exec *execp = epp->ep_hdr;
        long bsize, baddr;
        long nontext;
+       int error;
 
-       /*
-        * Check if vnode is in open for writing, because we want to
-        * demand-page out of it.  If it is, don't do it, for various
-        * reasons.
-        */
-       if ((execp->ha_text != 0 || execp->ha_data != 0) &&
-           epp->ep_vp->v_writecount != 0)
-               return (ETXTBSY);
-       epp->ep_vp->v_flag |= VTEXT;
+       error = vn_marktext(epp->ep_vp);
+       if (error)
+               return (error);
 
        /*
         * HP-UX ZMAGIC executables need to have their segment
diff -r 6ed1270dfeff -r d4350a96da13 sys/compat/ibcs2/ibcs2_exec_coff.c
--- a/sys/compat/ibcs2/ibcs2_exec_coff.c        Sat Oct 05 21:30:42 2002 +0000
+++ b/sys/compat/ibcs2/ibcs2_exec_coff.c        Sat Oct 05 22:34:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ibcs2_exec_coff.c,v 1.4 2002/09/27 15:37:04 provos Exp $       */
+/*     $NetBSD: ibcs2_exec_coff.c,v 1.5 2002/10/05 22:34:04 chs Exp $  */
 
 /*
  * Copyright (c) 1994, 1995, 1998 Scott Bartram
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec_coff.c,v 1.4 2002/09/27 15:37:04 provos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ibcs2_exec_coff.c,v 1.5 2002/10/05 22:34:04 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -440,26 +440,13 @@
        offset = sh.s_scnptr - (sh.s_vaddr - epp->ep_taddr);
        epp->ep_tsize = sh.s_size + (sh.s_vaddr - epp->ep_taddr);
 
-#ifdef notyet
-       /*
-        * check if vnode is in open for writing, because we want to
-        * demand-page out of it.  if it is, don't do it, for various
-        * reasons
-n       */
-       if ((ap->a_tsize != 0 || ap->a_dsize != 0) &&
-           epp->ep_vp->v_writecount != 0) {
-#ifdef DIAGNOSTIC
-               if (epp->ep_vp->v_flag & VTEXT)
-                       panic("exec: a VTEXT vnode has writecount != 0");
-#endif
-               return ETXTBSY;
-       }
-       epp->ep_vp->v_flag |= VTEXT;
-#endif
-       
        /* DPRINTF(("VMCMD: addr %x size %d offset %d\n", epp->ep_taddr,
                 epp->ep_tsize, offset)); */
 #ifdef notyet
+       error = vn_marktext(epp->ep_vp);
+       if (error)
+               return (error);
+       
        NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, epp->ep_tsize,
                  epp->ep_taddr, epp->ep_vp, offset,
                  VM_PROT_READ|VM_PROT_EXECUTE);
diff -r 6ed1270dfeff -r d4350a96da13 sys/compat/linux/common/linux_exec_aout.c
--- a/sys/compat/linux/common/linux_exec_aout.c Sat Oct 05 21:30:42 2002 +0000
+++ b/sys/compat/linux/common/linux_exec_aout.c Sat Oct 05 22:34:02 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: linux_exec_aout.c,v 1.49 2002/09/27 15:37:05 provos Exp $      */
+/*     $NetBSD: linux_exec_aout.c,v 1.50 2002/10/05 22:34:04 chs Exp $ */
 
 /*-
  * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_exec_aout.c,v 1.49 2002/09/27 15:37:05 provos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_exec_aout.c,v 1.50 2002/10/05 22:34:04 chs Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -296,6 +296,7 @@
        struct exec_package *epp;
 {
        struct exec *execp = epp->ep_hdr;
+       int error;
 
        epp->ep_taddr = LINUX_N_TXTADDR(*execp, QMAGIC);
        epp->ep_tsize = execp->a_text;
@@ -303,20 +304,9 @@
        epp->ep_dsize = execp->a_data + execp->a_bss;
        epp->ep_entry = execp->a_entry;
 
-       /*
-        * check if vnode is in open for writing, because we want to
-        * demand-page out of it.  if it is, don't do it, for various
-        * reasons
-        */
-       if ((execp->a_text != 0 || execp->a_data != 0) &&
-           epp->ep_vp->v_writecount != 0) {
-#ifdef DIAGNOSTIC
-               if (epp->ep_vp->v_flag & VTEXT)
-                       panic("exec: a VTEXT vnode has writecount != 0");
-#endif
-               return ETXTBSY;
-       }
-       epp->ep_vp->v_flag |= VTEXT;
+       error = vn_marktext(epp->ep_vp);
+       if (error)
+               return (error);
 
        /* set up command for text segment */
        NEW_VMCMD(&epp->ep_vmcmds, vmcmd_map_pagedvn, execp->a_text,
diff -r 6ed1270dfeff -r d4350a96da13 sys/compat/linux/common/linux_uselib.c
--- a/sys/compat/linux/common/linux_uselib.c    Sat Oct 05 21:30:42 2002 +0000



Home | Main Index | Thread Index | Old Index