Print this page
6583 remove whole-process swapping


  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  28 /*        All Rights Reserved   */
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"        /* from SVr4.0 1.12 */
  31 
  32 #include <sys/types.h>
  33 #include <sys/param.h>
  34 #include <sys/sysmacros.h>
  35 #include <sys/signal.h>
  36 #include <sys/pcb.h>
  37 #include <sys/user.h>
  38 #include <sys/systm.h>
  39 #include <sys/sysinfo.h>
  40 #include <sys/var.h>
  41 #include <sys/errno.h>
  42 #include <sys/cmn_err.h>
  43 #include <sys/proc.h>
  44 #include <sys/debug.h>
  45 #include <sys/inline.h>
  46 #include <sys/disp.h>
  47 #include <sys/class.h>
  48 #include <sys/kmem.h>
  49 #include <sys/cpuvar.h>
  50 #include <sys/priocntl.h>
  51 
  52 /*
  53  * Class specific code for the sys class. There are no
  54  * class specific data structures associated with
  55  * the sys class and the scheduling policy is trivially
  56  * simple. There is no time slicing.
  57  */
  58 
  59 pri_t           sys_init(id_t, int, classfuncs_t **);
  60 static int      sys_getclpri(pcpri_t *);
  61 static int      sys_fork(kthread_t *, kthread_t *, void *);
  62 static int      sys_enterclass(kthread_t *, id_t, void *, cred_t *, void *);
  63 static int      sys_canexit(kthread_t *, cred_t *);
  64 static int      sys_nosys();
  65 static int      sys_donice(kthread_t *, cred_t *, int, int *);
  66 static int      sys_doprio(kthread_t *, cred_t *, int, int *);
  67 static void     sys_forkret(kthread_t *, kthread_t *);
  68 static void     sys_nullsys();
  69 static pri_t    sys_swappri(kthread_t *, int);
  70 static int      sys_alloc(void **, int);
  71 
  72 struct classfuncs sys_classfuncs = {
  73         /* messages to class manager */
  74         {
  75                 sys_nosys,      /* admin */
  76                 sys_nosys,      /* getclinfo */
  77                 sys_nosys,      /* parmsin */
  78                 sys_nosys,      /* parmsout */
  79                 sys_nosys,      /* vaparmsin */
  80                 sys_nosys,      /* vaparmsout */
  81                 sys_getclpri,   /* getclpri */
  82                 sys_alloc,
  83                 sys_nullsys,    /* free */
  84         },
  85         /* operations on threads */
  86         {
  87                 sys_enterclass, /* enterclass */
  88                 sys_nullsys,    /* exitclass */
  89                 sys_canexit,
  90                 sys_fork,
  91                 sys_forkret,    /* forkret */
  92                 sys_nullsys,    /* parmsget */
  93                 sys_nosys,      /* parmsset */
  94                 sys_nullsys,    /* stop */
  95                 sys_nullsys,    /* exit */
  96                 sys_nullsys,    /* active */
  97                 sys_nullsys,    /* inactive */
  98                 sys_swappri,    /* swapin */
  99                 sys_swappri,    /* swapout */
 100                 sys_nullsys,    /* trapret */
 101                 setfrontdq,     /* preempt */
 102                 setbackdq,      /* setrun */
 103                 sys_nullsys,    /* sleep */
 104                 sys_nullsys,    /* tick */
 105                 setbackdq,      /* wakeup */
 106                 sys_donice,
 107                 (pri_t (*)())sys_nosys, /* globpri */
 108                 sys_nullsys,    /* set_process_group */
 109                 sys_nullsys,    /* yield */
 110                 sys_doprio,
 111         }
 112 
 113 };
 114 
 115 
 116 /* ARGSUSED */
 117 pri_t
 118 sys_init(cid, clparmsz, clfuncspp)
 119         id_t            cid;


 175         kthread_t *ct;
 176 {
 177         register proc_t *pp = ttoproc(t);
 178         register proc_t *cp = ttoproc(ct);
 179 
 180         ASSERT(t == curthread);
 181         ASSERT(MUTEX_HELD(&pidlock));
 182 
 183         /*
 184          * Grab the child's p_lock before dropping pidlock to ensure
 185          * the process does not disappear before we set it running.
 186          */
 187         mutex_enter(&cp->p_lock);
 188         mutex_exit(&pidlock);
 189         continuelwps(cp);
 190         mutex_exit(&cp->p_lock);
 191 
 192         mutex_enter(&pp->p_lock);
 193         continuelwps(pp);
 194         mutex_exit(&pp->p_lock);
 195 }
 196 
 197 /* ARGSUSED */
 198 static pri_t
 199 sys_swappri(t, flags)
 200         kthread_t       *t;
 201         int             flags;
 202 {
 203         return (-1);
 204 }
 205 
 206 static int
 207 sys_nosys()
 208 {
 209         return (ENOSYS);
 210 }
 211 
 212 
 213 static void
 214 sys_nullsys()
 215 {
 216 }
 217 
 218 /* ARGSUSED */
 219 static int
 220 sys_donice(kthread_t *t, cred_t *cr, int incr, int *retvalp)
 221 {
 222         return (EINVAL);
 223 }


  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 
  27 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  28 /*        All Rights Reserved   */
  29 


  30 #include <sys/types.h>
  31 #include <sys/param.h>
  32 #include <sys/sysmacros.h>
  33 #include <sys/signal.h>
  34 #include <sys/pcb.h>
  35 #include <sys/user.h>
  36 #include <sys/systm.h>
  37 #include <sys/sysinfo.h>
  38 #include <sys/var.h>
  39 #include <sys/errno.h>
  40 #include <sys/cmn_err.h>
  41 #include <sys/proc.h>
  42 #include <sys/debug.h>
  43 #include <sys/inline.h>
  44 #include <sys/disp.h>
  45 #include <sys/class.h>
  46 #include <sys/kmem.h>
  47 #include <sys/cpuvar.h>
  48 #include <sys/priocntl.h>
  49 
  50 /*
  51  * Class specific code for the sys class. There are no
  52  * class specific data structures associated with
  53  * the sys class and the scheduling policy is trivially
  54  * simple. There is no time slicing.
  55  */
  56 
  57 pri_t           sys_init(id_t, int, classfuncs_t **);
  58 static int      sys_getclpri(pcpri_t *);
  59 static int      sys_fork(kthread_t *, kthread_t *, void *);
  60 static int      sys_enterclass(kthread_t *, id_t, void *, cred_t *, void *);
  61 static int      sys_canexit(kthread_t *, cred_t *);
  62 static int      sys_nosys();
  63 static int      sys_donice(kthread_t *, cred_t *, int, int *);
  64 static int      sys_doprio(kthread_t *, cred_t *, int, int *);
  65 static void     sys_forkret(kthread_t *, kthread_t *);
  66 static void     sys_nullsys();

  67 static int      sys_alloc(void **, int);
  68 
  69 struct classfuncs sys_classfuncs = {
  70         /* messages to class manager */
  71         {
  72                 sys_nosys,      /* admin */
  73                 sys_nosys,      /* getclinfo */
  74                 sys_nosys,      /* parmsin */
  75                 sys_nosys,      /* parmsout */
  76                 sys_nosys,      /* vaparmsin */
  77                 sys_nosys,      /* vaparmsout */
  78                 sys_getclpri,   /* getclpri */
  79                 sys_alloc,
  80                 sys_nullsys,    /* free */
  81         },
  82         /* operations on threads */
  83         {
  84                 sys_enterclass, /* enterclass */
  85                 sys_nullsys,    /* exitclass */
  86                 sys_canexit,
  87                 sys_fork,
  88                 sys_forkret,    /* forkret */
  89                 sys_nullsys,    /* parmsget */
  90                 sys_nosys,      /* parmsset */
  91                 sys_nullsys,    /* stop */
  92                 sys_nullsys,    /* exit */
  93                 sys_nullsys,    /* active */
  94                 sys_nullsys,    /* inactive */


  95                 sys_nullsys,    /* trapret */
  96                 setfrontdq,     /* preempt */
  97                 setbackdq,      /* setrun */
  98                 sys_nullsys,    /* sleep */
  99                 sys_nullsys,    /* tick */
 100                 setbackdq,      /* wakeup */
 101                 sys_donice,
 102                 (pri_t (*)())sys_nosys, /* globpri */
 103                 sys_nullsys,    /* set_process_group */
 104                 sys_nullsys,    /* yield */
 105                 sys_doprio,
 106         }
 107 
 108 };
 109 
 110 
 111 /* ARGSUSED */
 112 pri_t
 113 sys_init(cid, clparmsz, clfuncspp)
 114         id_t            cid;


 170         kthread_t *ct;
 171 {
 172         register proc_t *pp = ttoproc(t);
 173         register proc_t *cp = ttoproc(ct);
 174 
 175         ASSERT(t == curthread);
 176         ASSERT(MUTEX_HELD(&pidlock));
 177 
 178         /*
 179          * Grab the child's p_lock before dropping pidlock to ensure
 180          * the process does not disappear before we set it running.
 181          */
 182         mutex_enter(&cp->p_lock);
 183         mutex_exit(&pidlock);
 184         continuelwps(cp);
 185         mutex_exit(&cp->p_lock);
 186 
 187         mutex_enter(&pp->p_lock);
 188         continuelwps(pp);
 189         mutex_exit(&pp->p_lock);









 190 }
 191 
 192 static int
 193 sys_nosys()
 194 {
 195         return (ENOSYS);
 196 }
 197 
 198 
 199 static void
 200 sys_nullsys()
 201 {
 202 }
 203 
 204 /* ARGSUSED */
 205 static int
 206 sys_donice(kthread_t *t, cred_t *cr, int incr, int *retvalp)
 207 {
 208         return (EINVAL);
 209 }