DragonFly kernel List (threaded) for 2008-03
DragonFly BSD
DragonFly kernel List (threaded) for 2008-03
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

migrating proc from zone to objcache


From: "Nicolas Thery" <nthery@xxxxxxxxx>
Date: Mon, 31 Mar 2008 20:26:34 +0200

Hello,

Now that the release is over, I'll try to get rid of zones and migrate
allocations to objcache.

Here is a 1st patch that migrate struct proc.  I'll commit it in a
couple of days if nobody objects.

I'm also implementing a way to monitor objcache statistics.  So far,
I've hacked sth similar to
sysctl vm.zone: stats are returned in one giant string, one line per
cache.  That's simple but ugly and hard to read because there are
quite a few stats per cache.

So I'm thinking about implementing a small tool, ocstat, that extracts
stats from sysctl the way ps(1) does (thru libkvm iirc) and formats it
in various ways.  What do you think?

Cheers,
Nicolas

Index: src2/sys/kern/kern_exit.c
===================================================================
--- src2.orig/sys/kern/kern_exit.c	2008-03-31 08:05:59.139796000 +0200
+++ src2/sys/kern/kern_exit.c	2008-03-31 10:31:39.000000000 +0200
@@ -834,7 +834,7 @@ loop:
 			}

 			vm_waitproc(p);
-			zfree(proc_zone, p);
+			objcache_put(proc_cache, p);
 			nprocs--;
 			return (0);
 		}
Index: src2/sys/kern/kern_proc.c
===================================================================
--- src2.orig/sys/kern/kern_proc.c	2008-03-31 08:05:59.139918000 +0200
+++ src2/sys/kern/kern_proc.c	2008-03-31 10:31:39.000000000 +0200
@@ -84,7 +84,7 @@ u_long pgrphash;
 struct proclist allproc;
 struct proclist zombproc;
 struct spinlock allproc_spin;
-vm_zone_t proc_zone;
+struct objcache* proc_cache;
 vm_zone_t lwp_zone;
 vm_zone_t thread_zone;

@@ -131,7 +131,7 @@ procinit(void)
 	spin_init(&allproc_spin);
 	pidhashtbl = hashinit(maxproc / 4, M_PROC, &pidhash);
 	pgrphashtbl = hashinit(maxproc / 4, M_PROC, &pgrphash);
-	proc_zone = zinit("PROC", sizeof (struct proc), 0, 0, 5);
+	proc_cache = objcache_create_simple(M_PROC, sizeof(struct proc));
 	lwp_zone = zinit("LWP", sizeof (struct lwp), 0, 0, 5);
 	thread_zone = zinit("THREAD", sizeof (struct thread), 0, 0, 5);
 	uihashinit();
Index: src2/sys/sys/proc.h
===================================================================
--- src2.orig/sys/sys/proc.h	2008-03-31 08:05:59.140325000 +0200
+++ src2/sys/sys/proc.h	2008-03-31 10:31:39.000000000 +0200
@@ -473,7 +473,7 @@ struct proc *zpfind (pid_t);	/* Find zom
 struct vm_zone;
 struct globaldata;
 struct lwp_params;
-extern struct vm_zone *proc_zone;
+extern struct objcache *proc_cache;
 extern struct vm_zone *lwp_zone;

 int	enterpgrp (struct proc *p, pid_t pgid, int mksess);
Index: src2/sys/kern/kern_fork.c
===================================================================
--- src2.orig/sys/kern/kern_fork.c	2008-03-31 08:05:59.140042000 +0200
+++ src2/sys/kern/kern_fork.c	2008-03-31 10:31:39.000000000 +0200
@@ -332,7 +332,7 @@ fork1(struct lwp *lp1, int flags, struct
 	}

 	/* Allocate new proc. */
-	p2 = zalloc(proc_zone);
+	p2 = objcache_get(proc_cache, M_WAITOK);
 	bzero(p2, sizeof(*p2));

 	/*



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