Module Name:    src
Committed By:   rmind
Date:           Sun May  1 00:11:52 UTC 2011

Modified Files:
        src/sys/kern: kern_exit.c kern_proc.c kern_resource.c
        src/sys/sys: resourcevar.h

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


To generate a diff of this commit:
cvs rdiff -u -r1.232 -r1.233 src/sys/kern/kern_exit.c
cvs rdiff -u -r1.176 -r1.177 src/sys/kern/kern_proc.c
cvs rdiff -u -r1.158 -r1.159 src/sys/kern/kern_resource.c
cvs rdiff -u -r1.48 -r1.49 src/sys/sys/resourcevar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_exit.c
diff -u src/sys/kern/kern_exit.c:1.232 src/sys/kern/kern_exit.c:1.233
--- src/sys/kern/kern_exit.c:1.232	Mon Feb 21 20:23:28 2011
+++ src/sys/kern/kern_exit.c	Sun May  1 00:11:52 2011
@@ -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);

Index: src/sys/kern/kern_proc.c
diff -u src/sys/kern/kern_proc.c:1.176 src/sys/kern/kern_proc.c:1.177
--- src/sys/kern/kern_proc.c:1.176	Wed Apr 27 00:36:47 2011
+++ src/sys/kern/kern_proc.c	Sun May  1 00:11:52 2011
@@ -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;
-
-	limit0.pl_rlimit[RLIMIT_NPROC].rlim_max = maxproc;
-	limit0.pl_rlimit[RLIMIT_NPROC].rlim_cur =
-	    maxproc < maxuprc ? maxproc : maxuprc;
+
+	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;
+	}
+
+	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);
 	}
-
 }
 
 /*

Index: src/sys/kern/kern_resource.c
diff -u src/sys/kern/kern_resource.c:1.158 src/sys/kern/kern_resource.c:1.159
--- src/sys/kern/kern_resource.c:1.158	Sat Apr 30 23:41:17 2011
+++ src/sys/kern/kern_resource.c	Sun May  1 00:11:52 2011
@@ -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);

Index: src/sys/sys/resourcevar.h
diff -u src/sys/sys/resourcevar.h:1.48 src/sys/sys/resourcevar.h:1.49
--- src/sys/sys/resourcevar.h:1.48	Sun Jan 11 02:45:55 2009
+++ src/sys/sys/resourcevar.h	Sun May  1 00:11:52 2011
@@ -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_ */

Reply via email to