Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Feb 2008 13:29:51 GMT
From:      Maxim Zhuravlev <thioretic@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 134837 for review
Message-ID:  <200802051329.m15DTp3P052736@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=134837

Change 134837 by thioretic@thioretic on 2008/02/05 13:29:02

	Some minor fixes

Affected files ...

.. //depot/projects/soc2007/thioretic_gidl2/kern/subr_busio.c#7 edit
.. //depot/projects/soc2007/thioretic_gidl2/sys/ior_types.h#1 add

Differences ...

==== //depot/projects/soc2007/thioretic_gidl2/kern/subr_busio.c#7 (text+ko) ====

@@ -10,6 +10,7 @@
 #include <sys/systm.h>
 #include <sys/proc.h>
 #include <sys/bus.h>
+#include <sys/ior_types.h>
 
 static MALLOC_DEFINE(M_BUS_IO, "bus_io", "Bus io subsystem data structures");
 
@@ -29,20 +30,7 @@
 int work_kthreads_to_wait_on;
 
 struct ior {
-#define OPEN	1
-#define FDOPEN	2
-#define CLOSE	3
-#define READ	4
-#define WRITE	5
-#define IOCTL	6
-#define POLL	7
-#define MMAP	8
-#define STRATEGY	9
-#define DUMP	10
-#define KQFILTER	11
-#define PURGE	12
-#define SPARE2	13
-	u_int32_t type;
+	u_int32_t type;	//see sys/ior_types.h
 	void* data;
 #define IORS_NONE	0
 #define IORS_ENQUEUED	1<<0
@@ -79,7 +67,7 @@
 	ior_t todo;
 	int flags;
 
-	struct mtx guard_spin_mtx;
+	struct mtx guard_mtx;
 };
 
 static ior_queue ior_queues[IOR_QUEUES_NUM];
@@ -155,10 +143,10 @@
 				break;
 			}
 			TAILQ_INSERT_TAIL(&work_kthreads, pwk, link);
-		}while (work_kthreads_num < ++cur_work_kthreads_num);
+		}while (work_kthreads_num > ++cur_work_kthreads_num);
 	}
 	else{
-		cur_work_kthreads_num = work_kthreads_num;
+		cur_work_kthreads_num = work_kthreads_num - old_work_kthreads_num;
 		TAILQ_FOREACH(pwk, &work_kthreads, link){
 			if(cur_work_kthreads_num)
 				cur_work_kthreads_num--;
@@ -179,7 +167,7 @@
 	error = sysctl_handle_int(oidp, &value, sizeof(value), req);
 	if (!error && req->newptr){
 		if (value > 0){
-			old_work_kthreads_num = work_kthreds_num;
+			old_work_kthreads_num = work_kthreads_num;
 			work_kthreads_num = value;
 			reset_work_kthreads ();
 		}else
@@ -199,9 +187,9 @@
 
 	for (i = 0; i < IOR_QUEUES_NUM; i++){
 		ior_queues[i]->iors = TAILQ_HEAD_INITIALIZER(ior_queues[i]->iors);
-		mtx_init (&ior_queues[i]->guard_spin_mtx,
+		mtx_init (&ior_queues[i]->guard_mtx,
 			"ior_queue_mtx",
-			NULL, MTX_SPIN);
+			NULL, MTX_DEF);
 	}
 
 	reset_work_kthreads();
@@ -216,23 +204,23 @@
 retry:
 	for (qid; qid < IOR_QUEUES_NUM; qid++){
 		q = ior_queues[qid];
-		if (r = q.todo)
+		if (r = q.todo){
+			ior_lock (r);
+			mtx_lock (&q.guard_mtx);
 			break;
+		}
 	}
 	if (qid == IOR_QUEUES_NUM)
 		return (1);
 	
-	ior_lock (r);
-	mtx_lock_spin(&q.guard_spin_mtx);
-
 	if (r->state != IORS_ENQUEUED){
-		mtx_unlock_spin (&q.guard_spin_mtx);
+		mtx_unlock (&q.guard_mtx);
 		ior_unlock (r);
 		goto retry;
 	}
 
 	q.todo = TAILQ_NEXT(r, link);
-	mtx_unlock_spin (&q.guard_spin_mtx);
+	mtx_unlock (&q.guard_mtx);
 
 	r->state = IORS_OWNED;
 	ior_unlock (r);
@@ -386,13 +374,13 @@
 		return ();
 	}
 
-	mtx_lock_spin (&q.guard_spin_mtx);
+	mtx_lock (&q.guard_mtx);
 
 	TAILQ_INSERT_TAIL (&q.iors, r, link);
 	if (q.todo == NULL) 
 		q.todo = r;
 	
-	mtx_unlock_spin (&q.guard_spin_mtx);
+	mtx_unlock (&q.guard_mtx);
 
 	r->queue_id = queue_id + 1;
 	r->state = IORS_ENQUEUED;
@@ -414,18 +402,18 @@
 
 	ior_lock (r);
 	
-	if (r->state != IOR_ENQUEUED  || r->children){
+	if (r->state != IORS_ENQUEUED  || r->children){
 			ior_unlock (r);
 			return (1);
 	}
 	
-	mtx_lock_spin (&q.guard_spin_mtx);
+	mtx_lock (&q.guard_mtx);
 	
 	if (q.todo == r)
 		q.todo = TAILQ_NEXT (r, link);
 	TAILQ_REMOVE (&q.iors, r, link);
 
-	mtx_unlock_spin (&q.quard_spin_mtx);
+	mtx_unlock (&q.quard_mtx);
 
 	r->state = IORS_NONE;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200802051329.m15DTp3P052736>