Home | History | Annotate | Line # | Download | only in rumpkern
t_threadpool.c revision 1.2.2.2
      1  1.2.2.2  christos /*	$NetBSD: t_threadpool.c,v 1.2.2.2 2019/06/10 22:10:11 christos Exp $	*/
      2  1.2.2.2  christos 
      3  1.2.2.2  christos /*-
      4  1.2.2.2  christos  * Copyright (c) 2018 The NetBSD Foundation, Inc.
      5  1.2.2.2  christos  * All rights reserved.
      6  1.2.2.2  christos  *
      7  1.2.2.2  christos  * Redistribution and use in source and binary forms, with or without
      8  1.2.2.2  christos  * modification, are permitted provided that the following conditions
      9  1.2.2.2  christos  * are met:
     10  1.2.2.2  christos  * 1. Redistributions of source code must retain the above copyright
     11  1.2.2.2  christos  *    notice, this list of conditions and the following disclaimer.
     12  1.2.2.2  christos  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.2.2.2  christos  *    notice, this list of conditions and the following disclaimer in the
     14  1.2.2.2  christos  *    documentation and/or other materials provided with the distribution.
     15  1.2.2.2  christos  *
     16  1.2.2.2  christos  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
     17  1.2.2.2  christos  * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
     18  1.2.2.2  christos  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     19  1.2.2.2  christos  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     20  1.2.2.2  christos  * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
     21  1.2.2.2  christos  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     22  1.2.2.2  christos  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
     23  1.2.2.2  christos  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     24  1.2.2.2  christos  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
     25  1.2.2.2  christos  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     26  1.2.2.2  christos  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
     27  1.2.2.2  christos  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     28  1.2.2.2  christos  */
     29  1.2.2.2  christos 
     30  1.2.2.2  christos #include <sys/types.h>
     31  1.2.2.2  christos #include <sys/mount.h>
     32  1.2.2.2  christos #include <sys/sysctl.h>
     33  1.2.2.2  christos 
     34  1.2.2.2  christos #include <rump/rump.h>
     35  1.2.2.2  christos 
     36  1.2.2.2  christos #include <atf-c.h>
     37  1.2.2.2  christos 
     38  1.2.2.2  christos #include "h_macros.h"
     39  1.2.2.2  christos #include "../kernspace/kernspace.h"
     40  1.2.2.2  christos 
     41  1.2.2.2  christos ATF_TC(threadpool_unbound_lifecycle);
     42  1.2.2.2  christos ATF_TC_HEAD(threadpool_unbound_lifecycle, tc)
     43  1.2.2.2  christos {
     44  1.2.2.2  christos 
     45  1.2.2.2  christos 	atf_tc_set_md_var(tc, "descr", "Tests unbound threadpool lifecycle");
     46  1.2.2.2  christos }
     47  1.2.2.2  christos 
     48  1.2.2.2  christos ATF_TC_BODY(threadpool_unbound_lifecycle, tc)
     49  1.2.2.2  christos {
     50  1.2.2.2  christos 
     51  1.2.2.2  christos 	rump_init();
     52  1.2.2.2  christos 
     53  1.2.2.2  christos 	rump_schedule();
     54  1.2.2.2  christos 	rumptest_threadpool_unbound_lifecycle(); /* panics if fails */
     55  1.2.2.2  christos 	rump_unschedule();
     56  1.2.2.2  christos }
     57  1.2.2.2  christos 
     58  1.2.2.2  christos ATF_TC(threadpool_percpu_lifecycle);
     59  1.2.2.2  christos ATF_TC_HEAD(threadpool_percpu_lifecycle, tc)
     60  1.2.2.2  christos {
     61  1.2.2.2  christos 
     62  1.2.2.2  christos 	atf_tc_set_md_var(tc, "descr", "Tests percpu threadpool lifecycle");
     63  1.2.2.2  christos }
     64  1.2.2.2  christos 
     65  1.2.2.2  christos ATF_TC_BODY(threadpool_percpu_lifecycle, tc)
     66  1.2.2.2  christos {
     67  1.2.2.2  christos 
     68  1.2.2.2  christos 	rump_init();
     69  1.2.2.2  christos 
     70  1.2.2.2  christos 	rump_schedule();
     71  1.2.2.2  christos 	rumptest_threadpool_percpu_lifecycle(); /* panics if fails */
     72  1.2.2.2  christos 	rump_unschedule();
     73  1.2.2.2  christos }
     74  1.2.2.2  christos 
     75  1.2.2.2  christos ATF_TC(threadpool_unbound_schedule);
     76  1.2.2.2  christos ATF_TC_HEAD(threadpool_unbound_schedule, tc)
     77  1.2.2.2  christos {
     78  1.2.2.2  christos 
     79  1.2.2.2  christos 	atf_tc_set_md_var(tc, "descr",
     80  1.2.2.2  christos 	    "Tests scheduling on unbound threadpools");
     81  1.2.2.2  christos }
     82  1.2.2.2  christos 
     83  1.2.2.2  christos ATF_TC_BODY(threadpool_unbound_schedule, tc)
     84  1.2.2.2  christos {
     85  1.2.2.2  christos 
     86  1.2.2.2  christos 	rump_init();
     87  1.2.2.2  christos 
     88  1.2.2.2  christos 	rump_schedule();
     89  1.2.2.2  christos 	rumptest_threadpool_unbound_schedule(); /* panics if fails */
     90  1.2.2.2  christos 	rump_unschedule();
     91  1.2.2.2  christos }
     92  1.2.2.2  christos 
     93  1.2.2.2  christos ATF_TC(threadpool_percpu_schedule);
     94  1.2.2.2  christos ATF_TC_HEAD(threadpool_percpu_schedule, tc)
     95  1.2.2.2  christos {
     96  1.2.2.2  christos 
     97  1.2.2.2  christos 	atf_tc_set_md_var(tc, "descr",
     98  1.2.2.2  christos 	    "Tests scheduling on percpu threadpools");
     99  1.2.2.2  christos }
    100  1.2.2.2  christos 
    101  1.2.2.2  christos ATF_TC_BODY(threadpool_percpu_schedule, tc)
    102  1.2.2.2  christos {
    103  1.2.2.2  christos 
    104  1.2.2.2  christos 	rump_init();
    105  1.2.2.2  christos 
    106  1.2.2.2  christos 	rump_schedule();
    107  1.2.2.2  christos 	rumptest_threadpool_percpu_schedule(); /* panics if fails */
    108  1.2.2.2  christos 	rump_unschedule();
    109  1.2.2.2  christos }
    110  1.2.2.2  christos 
    111  1.2.2.2  christos ATF_TC(threadpool_job_cancel);
    112  1.2.2.2  christos ATF_TC_HEAD(threadpool_job_cancel, tc)
    113  1.2.2.2  christos {
    114  1.2.2.2  christos 
    115  1.2.2.2  christos 	atf_tc_set_md_var(tc, "descr",
    116  1.2.2.2  christos 	    "Tests synchronizing with job cancellation");
    117  1.2.2.2  christos }
    118  1.2.2.2  christos 
    119  1.2.2.2  christos ATF_TC_BODY(threadpool_job_cancel, tc)
    120  1.2.2.2  christos {
    121  1.2.2.2  christos 
    122  1.2.2.2  christos 	rump_init();
    123  1.2.2.2  christos 
    124  1.2.2.2  christos 	rump_schedule();
    125  1.2.2.2  christos 	rumptest_threadpool_job_cancel(); /* panics if fails */
    126  1.2.2.2  christos 	rump_unschedule();
    127  1.2.2.2  christos }
    128  1.2.2.2  christos 
    129  1.2.2.2  christos ATF_TC(threadpool_job_cancelthrash);
    130  1.2.2.2  christos ATF_TC_HEAD(threadpool_job_cancelthrash, tc)
    131  1.2.2.2  christos {
    132  1.2.2.2  christos 
    133  1.2.2.2  christos 	atf_tc_set_md_var(tc, "descr",
    134  1.2.2.2  christos 	    "Tests thrashing job scheduling / cancellation");
    135  1.2.2.2  christos }
    136  1.2.2.2  christos 
    137  1.2.2.2  christos ATF_TC_BODY(threadpool_job_cancelthrash, tc)
    138  1.2.2.2  christos {
    139  1.2.2.2  christos 
    140  1.2.2.2  christos 	rump_init();
    141  1.2.2.2  christos 
    142  1.2.2.2  christos 	rump_schedule();
    143  1.2.2.2  christos 	rumptest_threadpool_job_cancelthrash(); /* panics if fails */
    144  1.2.2.2  christos 	rump_unschedule();
    145  1.2.2.2  christos }
    146  1.2.2.2  christos 
    147  1.2.2.2  christos ATF_TP_ADD_TCS(tp)
    148  1.2.2.2  christos {
    149  1.2.2.2  christos 	ATF_TP_ADD_TC(tp, threadpool_unbound_lifecycle);
    150  1.2.2.2  christos 	ATF_TP_ADD_TC(tp, threadpool_percpu_lifecycle);
    151  1.2.2.2  christos 	ATF_TP_ADD_TC(tp, threadpool_unbound_schedule);
    152  1.2.2.2  christos 	ATF_TP_ADD_TC(tp, threadpool_percpu_schedule);
    153  1.2.2.2  christos 	ATF_TP_ADD_TC(tp, threadpool_job_cancel);
    154  1.2.2.2  christos 	ATF_TP_ADD_TC(tp, threadpool_job_cancelthrash);
    155  1.2.2.2  christos 
    156  1.2.2.2  christos 	return atf_no_error();
    157  1.2.2.2  christos }
    158