The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/savar.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*      $NetBSD: savar.h,v 1.20.8.1 2008/09/16 18:49:34 bouyer Exp $    */
    2 
    3 /*-
    4  * Copyright (c) 2001 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Nathan J. Williams.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  * 3. All advertising materials mentioning features or use of this software
   19  *    must display the following acknowledgement:
   20  *        This product includes software developed by the NetBSD
   21  *        Foundation, Inc. and its contributors.
   22  * 4. Neither the name of The NetBSD Foundation nor the names of its
   23  *    contributors may be used to endorse or promote products derived
   24  *    from this software without specific prior written permission.
   25  *
   26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   36  * POSSIBILITY OF SUCH DAMAGE.
   37  */
   38 
   39 /*
   40  * Internal data usd by the scheduler activation implementation
   41  */
   42 
   43 #ifndef _SYS_SAVAR_H_
   44 #define _SYS_SAVAR_H_
   45 
   46 #include <sys/lock.h>
   47 #include <sys/tree.h>
   48 #include <sys/queue.h>
   49 
   50 union sau_state {
   51         struct {
   52                 ucontext_t      ss_ctx;
   53                 struct sa_t     ss_sa;
   54         } ss_captured;
   55         struct {
   56                 struct lwp      *ss_lwp;
   57         } ss_deferred;
   58 };
   59 
   60 struct sa_emul {
   61         size_t          sae_ucsize;     /* Size of ucontext_t */
   62         size_t          sae_sasize;     /* Size of sa_t */
   63         size_t          sae_sapsize;    /* Size of (sa_t *) */
   64         int             (*sae_sacopyout)(int, const void *, void *);
   65         int             (*sae_upcallconv)(struct lwp *, int, size_t *, void **,
   66                             void (**)(void *));
   67         void            (*sae_upcall)(struct lwp *, int, int, int, void *,
   68                             void *, void *, sa_upcall_t);
   69         void            (*sae_getucontext)(struct lwp *, void *);
   70         void            *(*sae_ucsp)(void *); /* Stack ptr from an ucontext_t */
   71 };
   72 
   73 struct sadata_upcall {
   74         SIMPLEQ_ENTRY(sadata_upcall)    sau_next;
   75         int     sau_flags;
   76         int     sau_type;
   77         size_t  sau_argsize;
   78         void    *sau_arg;
   79         void    (*sau_argfreefunc)(void *);
   80         stack_t sau_stack;
   81         union sau_state sau_event;
   82         union sau_state sau_interrupted;
   83 };
   84 
   85 #define SAU_FLAG_DEFERRED_EVENT         0x1
   86 #define SAU_FLAG_DEFERRED_INTERRUPTED   0x2
   87 
   88 #define SA_UPCALL_TYPE_MASK             0x00FF
   89 
   90 #define SA_UPCALL_DEFER_EVENT           0x1000
   91 #define SA_UPCALL_DEFER_INTERRUPTED     0x2000
   92 #define SA_UPCALL_DEFER                 (SA_UPCALL_DEFER_EVENT | \
   93                                          SA_UPCALL_DEFER_INTERRUPTED)
   94 
   95 struct sastack {
   96         stack_t                 sast_stack;
   97         SPLAY_ENTRY(sastack)    sast_node;
   98         unsigned int            sast_gen;
   99 };
  100 
  101 struct sadata_vp {
  102         int     savp_id;                /* "virtual processor" identifier */
  103         SLIST_ENTRY(sadata_vp)  savp_next; /* link to next sadata_vp */
  104         struct simplelock       savp_lock; /* lock on these fields */
  105         struct lwp      *savp_lwp;      /* lwp on "virtual processor" */
  106         struct lwp      *savp_blocker;  /* recently blocked lwp */
  107         struct lwp      *savp_wokenq_head; /* list of woken lwps */
  108         struct lwp      **savp_wokenq_tailp; /* list of woken lwps */
  109         vaddr_t savp_faultaddr;         /* page fault address */
  110         vaddr_t savp_ofaultaddr;        /* old page fault address */
  111         LIST_HEAD(, lwp)        savp_lwpcache; /* list of available lwps */
  112         int     savp_ncached;           /* list length */
  113         struct sadata_upcall    *savp_sleeper_upcall; /* cached upcall data */
  114         SIMPLEQ_HEAD(, sadata_upcall)   savp_upcalls; /* pending upcalls */
  115 };
  116 
  117 struct sadata {
  118         struct simplelock sa_lock;      /* lock on these fields */
  119         int     sa_flag;                /* SA_* flags */
  120         sa_upcall_t     sa_upcall;      /* upcall entry point */
  121         int     sa_concurrency;         /* current concurrency */
  122         int     sa_maxconcurrency;      /* requested concurrency */
  123         SPLAY_HEAD(sasttree, sastack) sa_stackstree; /* tree of upcall stacks */
  124         struct sastack  *sa_stacknext;  /* next free stack */
  125         ssize_t sa_stackinfo_offset;    /* offset from ss_sp to stackinfo data */
  126         int     sa_nstacks;             /* number of upcall stacks */
  127         SLIST_HEAD(, sadata_vp) sa_vps; /* list of "virtual processors" */
  128 };
  129 
  130 #define SA_FLAG_ALL     SA_FLAG_PREEMPT
  131 
  132 #define SA_MAXNUMSTACKS 16              /* Maximum number of upcall stacks per VP. */
  133 
  134 struct sadata_upcall *sadata_upcall_alloc(int);
  135 void    sadata_upcall_free(struct sadata_upcall *);
  136 
  137 void    sa_release(struct proc *);
  138 void    sa_switch(struct lwp *, int);
  139 void    sa_preempt(struct lwp *);
  140 void    sa_yield(struct lwp *);
  141 int     sa_upcall(struct lwp *, int, struct lwp *, struct lwp *, size_t, void *,
  142                   void (*)(void *));
  143 
  144 void    sa_putcachelwp(struct proc *, struct lwp *);
  145 struct lwp *sa_getcachelwp(struct sadata_vp *);
  146 
  147 /*
  148  * API permitting other parts of the kernel to indicate that they
  149  * are entering code paths in which blocking events should NOT generate
  150  * upcalls to an SA process. These routines should ONLY be used by code
  151  * involved in scheduling or process/thread initialization (such as
  152  * stack copying). These calls must be balanced. They may be nested, but
  153  * MUST be released in a LIFO order. These calls assume that the lwp is
  154  * locked.
  155  */
  156 typedef int sa_critpath_t;
  157 void    sa_critpath_enter(struct lwp *, sa_critpath_t *);
  158 void    sa_critpath_exit(struct lwp *, sa_critpath_t *);
  159 
  160 
  161 void    sa_unblock_userret(struct lwp *);
  162 void    sa_upcall_userret(struct lwp *);
  163 void    cpu_upcall(struct lwp *, int, int, int, void *, void *, void *, sa_upcall_t);
  164 
  165 typedef int (*sa_copyin_stack_t)(stack_t *, int, stack_t *);
  166 int     sa_stacks1(struct lwp *, register_t *, int, stack_t *,
  167     sa_copyin_stack_t);
  168 int     dosa_register(struct lwp *, sa_upcall_t, sa_upcall_t *, int, ssize_t);
  169 
  170 void    *sa_ucsp(void *);
  171 
  172 #define SAOUT_UCONTEXT  0
  173 #define SAOUT_SA_T      1
  174 #define SAOUT_SAP_T     2
  175 
  176 #endif /* !_SYS_SAVAR_H_ */

Cache object: a3a7ce7e96ea63288b9d94f230e645eb


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.