Date: Wed, 2 Jan 2008 17:05:14 GMT From: John Baldwin <jhb@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 132307 for review Message-ID: <200801021705.m02H5EfC050275@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=132307 Change 132307 by jhb@jhb_mutex on 2008/01/02 17:04:49 Catch up to kthread API changes. Affected files ... .. //depot/projects/smpng/sys/modules/crash/crash.c#40 edit .. //depot/projects/smpng/sys/modules/crash2/crash2.c#22 edit .. //depot/projects/smpng/sys/modules/evtest/evtest.c#24 edit Differences ... ==== //depot/projects/smpng/sys/modules/crash/crash.c#40 (text+ko) ==== @@ -75,7 +75,7 @@ static struct sx foo, bar, bar2, qux; static struct cv event_cv; static struct mtx event_mtx, test_mtx, test1_mtx, test2_mtx; -static struct proc *kthread; +static struct thread *kthread; static int event; static int mod_event(struct module *module, int cmd, void *arg); @@ -794,7 +794,7 @@ mtx_init(&test1_mtx, "test1", NULL, MTX_DEF); mtx_lock(&test1_mtx); printf("Locking test1 and then exiting, should get a witness panic.\n"); - kthread_exit(0); + kthread_exit(); } CRASH_EVENT("exit a thread while holding a mutex", test_thread_exit); @@ -900,7 +900,7 @@ event = 0; mtx_unlock(&event_mtx); if (ev == -1) { - kthread_exit(0); + kthread_exit(); break; } /* Give sysctl time to finish. */ @@ -919,10 +919,10 @@ load(void *arg) { struct thread *td; - struct proc *p; int error; - error = kthread_create(crash_thread, NULL, &p, RFSTOPPED, 0, "crash"); + error = kthread_add(crash_thread, NULL, NULL, &td, RFSTOPPED, 0, + "crash"); if (error) return (error); sx_init(&foo, "foo"); @@ -932,13 +932,12 @@ event = 0; mtx_init(&event_mtx, "crash event", NULL, MTX_DEF); cv_init(&event_cv, "crash"); - td = FIRST_THREAD_IN_PROC(p); - mtx_lock_spin(&sched_lock); + thread_lock(td); sched_prio(td, PRI_MIN_IDLE); TD_SET_CAN_RUN(td); sched_add(td, SRQ_BORING); - mtx_unlock_spin(&sched_lock); - kthread = p; + thread_unlock(td); + kthread = td; return (0); } ==== //depot/projects/smpng/sys/modules/crash2/crash2.c#22 (text+ko) ==== @@ -86,7 +86,8 @@ static struct crash2_event **event_start, **event_stop; static struct cv event_cv; static struct mtx event_mtx; -static struct proc *kthread[NTHREADS]; +static struct proc *kproc; +static struct thread *kthread[NTHREADS]; static int event[NTHREADS]; static struct rwlock foo; static struct mtx bar; @@ -467,7 +468,7 @@ mtx_unlock(&event_mtx); if (ev == -1) { printf("crash2[%d]: exiting\n", i); - kthread_exit(0); + kthread_exit(); break; } /* Give sysctl time to finish. */ @@ -522,18 +523,19 @@ mtx_init(&event_mtx, "crash2 event", NULL, MTX_DEF); cv_init(&event_cv, "crash2"); for (i = 0; i < NTHREADS; i++) { - error = kthread_create(crash_thread, (void *)(intptr_t)i, - &kthread[i], RFSTOPPED, 0, "crash2: %d", i); + error = kproc_kthread_add(crash_thread, (void *)(intptr_t)i, + &kproc, &kthread[i], RFSTOPPED, 0, "crash2", "crash2: %d", + i); if (error) { unload(NULL); return (error); } - td = FIRST_THREAD_IN_PROC(kthread[i]); - mtx_lock_spin(&sched_lock); + td = kthread[i]; + thread_lock(td); sched_prio(td, PRI_MIN_IDLE); TD_SET_CAN_RUN(td); sched_add(td, SRQ_BORING); - mtx_unlock_spin(&sched_lock); + thread_unlock(td); } return (0); } ==== //depot/projects/smpng/sys/modules/evtest/evtest.c#24 (text+ko) ==== @@ -67,10 +67,12 @@ static int event, broadcast_count, num_threads, sync_threads; struct thread_info { - struct proc *ti_p; + struct thread *ti_td; int ti_event; } threads[NUM_THREADS]; +struct proc *kproc; + struct event_info { const char *ei_help; int ei_flags; @@ -136,7 +138,7 @@ KASSERT(event == 0, ("event %d was unhandled", event)); if (ei->ei_flags & EVENT_TYPE_BROADCAST) { for (i = 0; i < NUM_THREADS; i++) { - if (threads[i].ti_p != NULL) + if (threads[i].ti_td != NULL) threads[i].ti_event = new_event; broadcast_count++; } @@ -170,7 +172,7 @@ int i; for (i = 0; i < NUM_THREADS; i++) - if (threads[i].ti_p == curthread->td_proc) + if (threads[i].ti_td == curthread) return (i); return (-1); } @@ -316,7 +318,7 @@ mtx_unlock(&event_mtx); printf("%s: thread %d dying\n", __func__, evtest_lookupthread()); - kthread_exit(0); + kthread_exit(); break; case 0: printf("%s: thread %d doing nothing\n", @@ -382,18 +384,18 @@ struct thread *td; int error; - if (i < 0 || i >= NUM_THREADS || threads[i].ti_p != NULL) + if (i < 0 || i >= NUM_THREADS || threads[i].ti_td != NULL) return (EINVAL); - error = kthread_create(event_thread, &threads[i].ti_event, - &threads[i].ti_p, RFSTOPPED, 0, name); + error = kproc_kthread_add(event_thread, &threads[i].ti_event, &kproc, + &threads[i].ti_td, RFSTOPPED, 0, "evtest", name); if (error) return (error); - td = FIRST_THREAD_IN_PROC(threads[i].ti_p); - mtx_lock_spin(&sched_lock); + td = threads[i].ti_td; + thread_lock(td); sched_prio(td, PRI_MIN_IDLE); TD_SET_CAN_RUN(td); sched_add(td, SRQ_BORING); - mtx_unlock_spin(&sched_lock); + thread_unlock(td); mtx_lock(&event_mtx); num_threads++; mtx_unlock(&event_mtx); @@ -404,7 +406,7 @@ thread_destroy(int i) { - if (i < 0 || i >= NUM_THREADS || threads[i].ti_p == NULL) + if (i < 0 || i >= NUM_THREADS || threads[i].ti_td == NULL) return; mtx_assert(&event_mtx, MA_OWNED); printf("%s: killing thread %d\n", __func__, i); @@ -412,8 +414,8 @@ broadcast_count = num_threads; event = -1; cv_broadcast(&event_cv); - msleep(threads[i].ti_p, &event_mtx, PWAIT, "evtstun", 0); - threads[i].ti_p = NULL; + msleep(threads[i].ti_td, &event_mtx, PWAIT, "evtstun", 0); + threads[i].ti_td = NULL; num_threads--; if (event != 0 && num_threads > 0) cv_wait(&event_recvd, &event_mtx);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801021705.m02H5EfC050275>