Print this page
5508 move segvn #defines into seg_vn.c
Reviewed by: Marcel Telka <marcel@telka.sk>


   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  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  * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved.

  23  */
  24 
  25 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  26 /*        All Rights Reserved   */
  27 
  28 /*
  29  * University Copyright- Copyright (c) 1982, 1986, 1988
  30  * The Regents of the University of California
  31  * All Rights Reserved
  32  *
  33  * University Acknowledgment- Portions of this document are derived from
  34  * software developed by the University of California, Berkeley, and its
  35  * contributors.
  36  */
  37 
  38 /*
  39  * VM - shared or copy-on-write from a vnode/anonymous memory.
  40  */
  41 
  42 #include <sys/types.h>


  56 #include <sys/vtrace.h>
  57 #include <sys/cmn_err.h>
  58 #include <sys/callb.h>
  59 #include <sys/vm.h>
  60 #include <sys/dumphdr.h>
  61 #include <sys/lgrp.h>
  62 
  63 #include <vm/hat.h>
  64 #include <vm/as.h>
  65 #include <vm/seg.h>
  66 #include <vm/seg_vn.h>
  67 #include <vm/pvn.h>
  68 #include <vm/anon.h>
  69 #include <vm/page.h>
  70 #include <vm/vpage.h>
  71 #include <sys/proc.h>
  72 #include <sys/task.h>
  73 #include <sys/project.h>
  74 #include <sys/zone.h>
  75 #include <sys/shm_impl.h>





















  76 /*
  77  * Private seg op routines.
  78  */
  79 static int      segvn_dup(struct seg *seg, struct seg *newseg);
  80 static int      segvn_unmap(struct seg *seg, caddr_t addr, size_t len);
  81 static void     segvn_free(struct seg *seg);
  82 static faultcode_t segvn_fault(struct hat *hat, struct seg *seg,
  83                     caddr_t addr, size_t len, enum fault_type type,
  84                     enum seg_rw rw);
  85 static faultcode_t segvn_faulta(struct seg *seg, caddr_t addr);
  86 static int      segvn_setprot(struct seg *seg, caddr_t addr,
  87                     size_t len, uint_t prot);
  88 static int      segvn_checkprot(struct seg *seg, caddr_t addr,
  89                     size_t len, uint_t prot);
  90 static int      segvn_kluster(struct seg *seg, caddr_t addr, ssize_t delta);
  91 static size_t   segvn_swapout(struct seg *seg);
  92 static int      segvn_sync(struct seg *seg, caddr_t addr, size_t len,
  93                     int attr, uint_t flags);
  94 static size_t   segvn_incore(struct seg *seg, caddr_t addr, size_t len,
  95                     char *vec);




   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  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  * Copyright (c) 1986, 2010, Oracle and/or its affiliates. All rights reserved.
  23  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 
  26 /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T     */
  27 /*        All Rights Reserved   */
  28 
  29 /*
  30  * University Copyright- Copyright (c) 1982, 1986, 1988
  31  * The Regents of the University of California
  32  * All Rights Reserved
  33  *
  34  * University Acknowledgment- Portions of this document are derived from
  35  * software developed by the University of California, Berkeley, and its
  36  * contributors.
  37  */
  38 
  39 /*
  40  * VM - shared or copy-on-write from a vnode/anonymous memory.
  41  */
  42 
  43 #include <sys/types.h>


  57 #include <sys/vtrace.h>
  58 #include <sys/cmn_err.h>
  59 #include <sys/callb.h>
  60 #include <sys/vm.h>
  61 #include <sys/dumphdr.h>
  62 #include <sys/lgrp.h>
  63 
  64 #include <vm/hat.h>
  65 #include <vm/as.h>
  66 #include <vm/seg.h>
  67 #include <vm/seg_vn.h>
  68 #include <vm/pvn.h>
  69 #include <vm/anon.h>
  70 #include <vm/page.h>
  71 #include <vm/vpage.h>
  72 #include <sys/proc.h>
  73 #include <sys/task.h>
  74 #include <sys/project.h>
  75 #include <sys/zone.h>
  76 #include <sys/shm_impl.h>
  77 
  78 /*
  79  * segvn_fault needs a temporary page list array.  To avoid calling kmem all
  80  * the time, it creates a small (PVN_GETPAGE_NUM entry) array and uses it if
  81  * it can.  In the rare case when this page list is not large enough, it
  82  * goes and gets a large enough array from kmem.
  83  *
  84  * This small page list array covers either 8 pages or 64kB worth of pages -
  85  * whichever is smaller.
  86  */
  87 #define PVN_MAX_GETPAGE_SZ      0x10000
  88 #define PVN_MAX_GETPAGE_NUM     0x8
  89 
  90 #if PVN_MAX_GETPAGE_SZ > PVN_MAX_GETPAGE_NUM * PAGESIZE
  91 #define PVN_GETPAGE_SZ  ptob(PVN_MAX_GETPAGE_NUM)
  92 #define PVN_GETPAGE_NUM PVN_MAX_GETPAGE_NUM
  93 #else
  94 #define PVN_GETPAGE_SZ  PVN_MAX_GETPAGE_SZ
  95 #define PVN_GETPAGE_NUM btop(PVN_MAX_GETPAGE_SZ)
  96 #endif
  97 
  98 /*
  99  * Private seg op routines.
 100  */
 101 static int      segvn_dup(struct seg *seg, struct seg *newseg);
 102 static int      segvn_unmap(struct seg *seg, caddr_t addr, size_t len);
 103 static void     segvn_free(struct seg *seg);
 104 static faultcode_t segvn_fault(struct hat *hat, struct seg *seg,
 105                     caddr_t addr, size_t len, enum fault_type type,
 106                     enum seg_rw rw);
 107 static faultcode_t segvn_faulta(struct seg *seg, caddr_t addr);
 108 static int      segvn_setprot(struct seg *seg, caddr_t addr,
 109                     size_t len, uint_t prot);
 110 static int      segvn_checkprot(struct seg *seg, caddr_t addr,
 111                     size_t len, uint_t prot);
 112 static int      segvn_kluster(struct seg *seg, caddr_t addr, ssize_t delta);
 113 static size_t   segvn_swapout(struct seg *seg);
 114 static int      segvn_sync(struct seg *seg, caddr_t addr, size_t len,
 115                     int attr, uint_t flags);
 116 static size_t   segvn_incore(struct seg *seg, caddr_t addr, size_t len,
 117                     char *vec);