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/uvm/uvm_object.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 /*      $OpenBSD: uvm_object.h,v 1.30 2022/09/04 06:49:11 jsg Exp $     */
    2 /*      $NetBSD: uvm_object.h,v 1.11 2001/03/09 01:02:12 chs Exp $      */
    3 
    4 /*
    5  * Copyright (c) 1997 Charles D. Cranor and Washington University.
    6  * All rights reserved.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   27  *
   28  * from: Id: uvm_object.h,v 1.1.2.2 1998/01/04 22:44:51 chuck Exp
   29  */
   30 
   31 #ifndef _UVM_UVM_OBJECT_H_
   32 #define _UVM_UVM_OBJECT_H_
   33 
   34 /*
   35  * The UVM memory object interface.  Notes:
   36  *
   37  * A UVM memory object represents a list of pages, which are managed by
   38  * the object's pager operations (uvm_object::pgops).  All pages belonging
   39  * to an object are owned by it and thus protected by the object lock.
   40  *
   41  * The lock (uvm_object::vmobjlock) may be shared amongst the UVM objects.
   42  * By default, the lock is allocated dynamically using rw_obj_init() cache.
   43  * Lock sharing is normally used when there is an underlying object.  For
   44  * example, vnode representing a file may have an underlying node, which
   45  * is the case for tmpfs and layered file systems.  In such case, vnode's
   46  * UVM object and the underlying UVM object shares the lock.
   47  *
   48  * The reference count is managed atomically for the anonymous UVM objects.
   49  * For other objects, it is arbitrary (may use the lock or atomics).
   50  */
   51 
   52 struct uvm_object {
   53         struct rwlock                   *vmobjlock;     /* lock on object */
   54         const struct uvm_pagerops       *pgops;         /* pager ops */
   55         RBT_HEAD(uvm_objtree, vm_page)   memt;          /* pages in object */
   56         int                              uo_npages;     /* # of pages in memt */
   57         int                              uo_refs;       /* reference count */
   58 };
   59 
   60 /*
   61  * UVM_OBJ_KERN is a 'special' uo_refs value which indicates that the
   62  * object is a kernel memory object rather than a normal one (kernel
   63  * memory objects don't have reference counts -- they never die).
   64  *
   65  * this value is used to detected kernel object mappings at uvm_unmap()
   66  * time.   normally when an object is unmapped its pages eventually become
   67  * deactivated and then paged out and/or freed.    this is not useful
   68  * for kernel objects... when a kernel object is unmapped we always want
   69  * to free the resources associated with the mapping.   UVM_OBJ_KERN
   70  * allows us to decide which type of unmapping we want to do.
   71  *
   72  * in addition, we have kernel objects which may be used in an
   73  * interrupt context.  these objects get their mappings entered
   74  * with pmap_kenter*() and removed with pmap_kremove(), which
   75  * are safe to call in interrupt context, and must be used ONLY
   76  * for wired kernel mappings in these objects and their associated
   77  * maps.
   78  */
   79 #define UVM_OBJ_KERN            (-2)
   80 
   81 #define UVM_OBJ_IS_KERN_OBJECT(uobj)                                    \
   82         ((uobj)->uo_refs == UVM_OBJ_KERN)
   83 
   84 #ifdef _KERNEL
   85 
   86 extern const struct uvm_pagerops uvm_vnodeops;
   87 extern const struct uvm_pagerops uvm_deviceops;
   88 extern const struct uvm_pagerops pmap_pager;
   89 extern const struct uvm_pagerops bufcache_pager;
   90 
   91 /* For object trees */
   92 int     uvm_pagecmp(const struct vm_page *, const struct vm_page *);
   93 RBT_PROTOTYPE(uvm_objtree, vm_page, objt, uvm_pagecmp)
   94 
   95 #define UVM_OBJ_IS_VNODE(uobj)                                          \
   96         ((uobj)->pgops == &uvm_vnodeops)
   97 
   98 #define UVM_OBJ_IS_DEVICE(uobj)                                         \
   99         ((uobj)->pgops == &uvm_deviceops)
  100 
  101 #define UVM_OBJ_IS_VTEXT(uobj)                                          \
  102         ((uobj)->pgops == &uvm_vnodeops &&                              \
  103          ((struct vnode *)uobj)->v_flag & VTEXT)
  104 
  105 #define UVM_OBJ_IS_AOBJ(uobj)                                           \
  106         ((uobj)->pgops == &aobj_pager)
  107 
  108 #define UVM_OBJ_IS_PMAP(uobj)                                           \
  109         ((uobj)->pgops == &pmap_pager)
  110 
  111 #define UVM_OBJ_IS_BUFCACHE(uobj)                                       \
  112         ((uobj)->pgops == &bufcache_pager)
  113 
  114 #define UVM_OBJ_IS_DUMMY(uobj)                                          \
  115         (UVM_OBJ_IS_PMAP(uobj) || UVM_OBJ_IS_BUFCACHE(uobj))
  116 
  117 void    uvm_obj_init(struct uvm_object *, const struct uvm_pagerops *, int);
  118 void    uvm_obj_destroy(struct uvm_object *);
  119 void    uvm_obj_setlock(struct uvm_object *, struct rwlock *);
  120 int     uvm_obj_wire(struct uvm_object *, voff_t, voff_t, struct pglist *);
  121 void    uvm_obj_unwire(struct uvm_object *, voff_t, voff_t);
  122 void    uvm_obj_free(struct uvm_object *);
  123 
  124 #endif /* _KERNEL */
  125 
  126 #endif /* _UVM_UVM_OBJECT_H_ */

Cache object: 8e5d700d5327a2bb5da6ec24e8764e3b


[ 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.