Source-Changes-HG archive

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

[src/trunk]: src/sys Rename limfree() to lim_free(), misc clean up. No funct...



details:   https://anonhg.NetBSD.org/src/rev/ddbcaf019a45
branches:  trunk
changeset: 764686:ddbcaf019a45
user:      rmind <rmind%NetBSD.org@localhost>
date:      Sun May 01 00:11:52 2011 +0000

description:
Rename limfree() to lim_free(), misc clean up.  No functional change.

diffstat:

 sys/kern/kern_exit.c     |   6 +++---
 sys/kern/kern_proc.c     |  36 +++++++++++++++++++-----------------
 sys/kern/kern_resource.c |  14 ++++++++------
 sys/sys/resourcevar.h    |  21 ++++++++++++---------
 4 files changed, 42 insertions(+), 35 deletions(-)

diffs (214 lines):

diff -r e4e670211a13 -r ddbcaf019a45 sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Sat Apr 30 23:41:17 2011 +0000
+++ b/sys/kern/kern_exit.c      Sun May 01 00:11:52 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.232 2011/02/21 20:23:28 pooka Exp $    */
+/*     $NetBSD: kern_exit.c,v 1.233 2011/05/01 00:11:52 rmind Exp $    */
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.232 2011/02/21 20:23:28 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.233 2011/05/01 00:11:52 rmind Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_perfctrs.h"
@@ -970,7 +970,7 @@
         * Release substructures.
         */
 
-       limfree(p->p_limit);
+       lim_free(p->p_limit);
        pstatsfree(p->p_stats);
        kauth_cred_free(cred1);
        kauth_cred_free(cred2);
diff -r e4e670211a13 -r ddbcaf019a45 sys/kern/kern_proc.c
--- a/sys/kern/kern_proc.c      Sat Apr 30 23:41:17 2011 +0000
+++ b/sys/kern/kern_proc.c      Sun May 01 00:11:52 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_proc.c,v 1.176 2011/04/27 00:36:47 rmind Exp $    */
+/*     $NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $    */
 
 /*-
  * Copyright (c) 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.176 2011/04/27 00:36:47 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_proc.c,v 1.177 2011/05/01 00:11:52 rmind Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_kstack.h"
@@ -399,6 +399,7 @@
 {
        struct proc *p;
        struct pgrp *pg;
+       struct rlimit *rlim;
        rlim_t lim;
        int i;
 
@@ -434,24 +435,26 @@
 
        /* Create the limits structures. */
        mutex_init(&limit0.pl_lock, MUTEX_DEFAULT, IPL_NONE);
-       for (i = 0; i < __arraycount(limit0.pl_rlimit); i++)
-               limit0.pl_rlimit[i].rlim_cur =   
-                   limit0.pl_rlimit[i].rlim_max = RLIM_INFINITY;
 
-       limit0.pl_rlimit[RLIMIT_NOFILE].rlim_max = maxfiles;
-       limit0.pl_rlimit[RLIMIT_NOFILE].rlim_cur =
-           maxfiles < nofile ? maxfiles : nofile;
+       rlim = limit0.pl_rlimit;
+       for (i = 0; i < __arraycount(limit0.pl_rlimit); i++) {
+               rlim[i].rlim_cur = RLIM_INFINITY;
+               rlim[i].rlim_max = RLIM_INFINITY;
+       }
 
-       limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc;
-       limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur =
-           maxproc < maxuprc ? maxproc : maxuprc;
+       rlim[RLIMIT_NOFILE].rlim_max = maxfiles;
+       rlim[RLIMIT_NOFILE].rlim_cur = maxfiles < nofile ? maxfiles : nofile;
+
+       rlim[RLIMIT_NPROC].rlim_max = maxproc;
+       rlim[RLIMIT_NPROC].rlim_cur = maxproc < maxuprc ? maxproc : maxuprc;
 
        lim = MIN(VM_MAXUSER_ADDRESS, ctob((rlim_t)uvmexp.free));
-       limit0.pl_rlimit[RLIMIT_RSS].rlim_max = lim;
-       limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_max = lim;
-       limit0.pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
-       limit0.pl_corename = defcorename;        
-       limit0.pl_refcnt = 1;    
+       rlim[RLIMIT_RSS].rlim_max = lim;
+       rlim[RLIMIT_MEMLOCK].rlim_max = lim;
+       rlim[RLIMIT_MEMLOCK].rlim_cur = lim / 3;
+
+       limit0.pl_corename = defcorename;
+       limit0.pl_refcnt = 1;
        limit0.pl_sv_limit = NULL;
 
        /* Configure virtual memory system, set vm rlimits. */
@@ -1358,7 +1361,6 @@
                l->l_cred = p->p_cred;
                kauth_cred_free(oc);
        }
-
 }
 
 /*
diff -r e4e670211a13 -r ddbcaf019a45 sys/kern/kern_resource.c
--- a/sys/kern/kern_resource.c  Sat Apr 30 23:41:17 2011 +0000
+++ b/sys/kern/kern_resource.c  Sun May 01 00:11:52 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_resource.c,v 1.158 2011/04/30 23:41:17 rmind Exp $        */
+/*     $NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $        */
 
 /*-
  * Copyright (c) 1982, 1986, 1991, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.158 2011/04/30 23:41:17 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_resource.c,v 1.159 2011/05/01 00:11:52 rmind Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -680,7 +680,7 @@
        if (p->p_limit->pl_flags & PL_WRITEABLE) {
                /* Someone crept in while we were busy */
                mutex_exit(p->p_lock);
-               limfree(newlim);
+               lim_free(newlim);
                if (set_shared)
                        p->p_limit->pl_flags |= PL_SHAREMOD;
                return;
@@ -699,15 +699,17 @@
 }
 
 void
-limfree(struct plimit *lim)
+lim_free(struct plimit *lim)
 {
        struct plimit *sv_lim;
 
        do {
-               if (atomic_dec_uint_nv(&lim->pl_refcnt) > 0)
+               if (atomic_dec_uint_nv(&lim->pl_refcnt) > 0) {
                        return;
-               if (lim->pl_corename != defcorename)
+               }
+               if (lim->pl_corename != defcorename) {
                        free(lim->pl_corename, M_TEMP);
+               }
                sv_lim = lim->pl_sv_limit;
                mutex_destroy(&lim->pl_lock);
                pool_cache_put(plimit_cache, lim);
diff -r e4e670211a13 -r ddbcaf019a45 sys/sys/resourcevar.h
--- a/sys/sys/resourcevar.h     Sat Apr 30 23:41:17 2011 +0000
+++ b/sys/sys/resourcevar.h     Sun May 01 00:11:52 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: resourcevar.h,v 1.48 2009/01/11 02:45:55 christos Exp $        */
+/*     $NetBSD: resourcevar.h,v 1.49 2011/05/01 00:11:52 rmind Exp $   */
 
 /*
  * Copyright (c) 1991, 1993
@@ -60,6 +60,8 @@
        struct  timeval p_start;        /* starting time */
 };
 
+#ifdef _KERNEL
+
 /*
  * Kernel shareable process resource limits.  Because this structure
  * is moderately large but changes infrequently, it is normally
@@ -72,14 +74,14 @@
  * will never be changed again.
  */
 struct plimit {
-       struct  rlimit pl_rlimit[RLIM_NLIMITS];
-       char    *pl_corename;
+       struct rlimit   pl_rlimit[RLIM_NLIMITS];
+       char *          pl_corename;
 #define        PL_SHAREMOD     0x01            /* modifications are shared */
 #define        PL_WRITEABLE    0x02            /* private to this process */
-       int     pl_flags;
-       int     pl_refcnt;              /* number of references */
-       kmutex_t pl_lock;               /* mutex for pl_refcnt */
-       struct plimit *pl_sv_limit;     /* saved when PL_WRITEABLE set */
+       int             pl_flags;
+       int             pl_refcnt;      /* number of references */
+       kmutex_t        pl_lock;        /* mutex for pl_refcnt */
+       struct plimit * pl_sv_limit;    /* saved when PL_WRITEABLE set */
 };
 
 /* add user profiling from AST XXXSMP */
@@ -92,7 +94,6 @@
                _p->p_stats->p_prof.pr_ticks = 0;                       \
        } while (/* CONSTCOND */ 0)
 
-#ifdef _KERNEL
 extern char defcorename[];
 
 extern int security_setidcore_dump;
@@ -109,7 +110,7 @@
 struct plimit *lim_copy(struct plimit *lim);
 void   lim_addref(struct plimit *lim);
 void   lim_privatise(struct proc *p, bool set_shared);
-void   limfree(struct plimit *);
+void   lim_free(struct plimit *);
 
 void   resource_init(void);
 void   ruadd(struct rusage *, struct rusage *);
@@ -118,5 +119,7 @@
 void   pstatsfree(struct pstats *);
 extern rlim_t maxdmap;
 extern rlim_t maxsmap;
+
 #endif
+
 #endif /* !_SYS_RESOURCEVAR_H_ */



Home | Main Index | Thread Index | Old Index