From owner-p4-projects@FreeBSD.ORG Mon Apr 7 21:24:18 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 8A90D106566C; Mon, 7 Apr 2008 21:24:18 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D0041065672 for ; Mon, 7 Apr 2008 21:24:18 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 354708FC1D for ; Mon, 7 Apr 2008 21:24:18 +0000 (UTC) (envelope-from sam@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m37LOIlt096103 for ; Mon, 7 Apr 2008 21:24:18 GMT (envelope-from sam@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m37LOIlL096101 for perforce@freebsd.org; Mon, 7 Apr 2008 21:24:18 GMT (envelope-from sam@freebsd.org) Date: Mon, 7 Apr 2008 21:24:18 GMT Message-Id: <200804072124.m37LOIlL096101@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to sam@freebsd.org using -f From: Sam Leffler To: Perforce Change Reviews Cc: Subject: PERFORCE change 139544 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Apr 2008 21:24:18 -0000 http://perforce.freebsd.org/chv.cgi?CH=139544 Change 139544 by sam@sam_ebb on 2008/04/07 21:23:17 change taskqueue_start_threads to create threads of proc0 instead of procs; note this means these are no longer visible (by default) in ps, top, etc. Affected files ... .. //depot/projects/vap/sys/kern/subr_taskqueue.c#7 edit Differences ... ==== //depot/projects/vap/sys/kern/subr_taskqueue.c#7 (text+ko) ==== @@ -56,8 +56,8 @@ void *tq_context; struct task *tq_running; struct mtx tq_mutex; - struct proc **tq_pproc; - int tq_pcount; + struct thread **tq_threads; + int tq_tcount; int tq_spin; int tq_flags; }; @@ -143,10 +143,10 @@ * Signal a taskqueue thread to terminate. */ static void -taskqueue_terminate(struct proc **pp, struct taskqueue *tq) +taskqueue_terminate(struct thread **pp, struct taskqueue *tq) { - while (tq->tq_pcount > 0) { + while (tq->tq_tcount > 0) { wakeup(tq); TQ_SLEEP(tq, pp, &tq->tq_mutex, PWAIT, "taskqueue_destroy", 0); } @@ -163,9 +163,9 @@ TQ_LOCK(queue); queue->tq_flags &= ~TQ_FLAGS_ACTIVE; taskqueue_run(queue); - taskqueue_terminate(queue->tq_pproc, queue); + taskqueue_terminate(queue->tq_threads, queue); mtx_destroy(&queue->tq_mutex); - free(queue->tq_pproc, M_TASKQUEUE); + free(queue->tq_threads, M_TASKQUEUE); free(queue, M_TASKQUEUE); } @@ -341,45 +341,47 @@ const char *name, ...) { va_list ap; + struct thread *td; struct taskqueue *tq; - struct thread *td; + int i, error; char ktname[MAXCOMLEN]; - int i, error; if (count <= 0) return (EINVAL); + tq = *tqp; va_start(ap, name); vsnprintf(ktname, MAXCOMLEN, name, ap); va_end(ap); - tq->tq_pproc = malloc(sizeof(struct proc *) * count, M_TASKQUEUE, + tq->tq_threads = malloc(sizeof(struct thread *) * count, M_TASKQUEUE, M_NOWAIT | M_ZERO); - if (tq->tq_pproc == NULL) { + if (tq->tq_threads == NULL) { printf("%s: no memory for %s threads\n", __func__, ktname); return (ENOMEM); } for (i = 0; i < count; i++) { if (count == 1) - error = kproc_create(taskqueue_thread_loop, tqp, - &tq->tq_pproc[i], RFSTOPPED, 0, ktname); + error = kthread_add(taskqueue_thread_loop, tqp, NULL, + &tq->tq_threads[i], RFSTOPPED, 0, ktname); else - error = kproc_create(taskqueue_thread_loop, tqp, - &tq->tq_pproc[i], RFSTOPPED, 0, "%s_%d", ktname, i); + error = kthread_add(taskqueue_thread_loop, tqp, NULL, + &tq->tq_threads[i], RFSTOPPED, 0, + "%s_%d", ktname, i); if (error) { /* should be ok to continue, taskqueue_free will dtrt */ - printf("%s: kproc_create(%s): error %d", - __func__, ktname, error); - tq->tq_pproc[i] = NULL; /* paranoid */ + printf("%s: kthread_add(%s): error %d", __func__, + ktname, error); + tq->tq_threads[i] = NULL; /* paranoid */ } else - tq->tq_pcount++; + tq->tq_tcount++; } for (i = 0; i < count; i++) { - if (tq->tq_pproc[i] == NULL) + if (tq->tq_threads[i] == NULL) continue; - td = FIRST_THREAD_IN_PROC(tq->tq_pproc[i]); + td = tq->tq_threads[i]; thread_lock(td); sched_prio(td, pri); sched_add(td, SRQ_BORING); @@ -403,8 +405,8 @@ } while ((tq->tq_flags & TQ_FLAGS_ACTIVE) != 0); /* rendezvous with thread that asked us to terminate */ - tq->tq_pcount--; - wakeup_one(tq->tq_pproc); + tq->tq_tcount--; + wakeup_one(tq->tq_threads); TQ_UNLOCK(tq); kproc_exit(0); }