seg_vn.h revision 05d3dc4b6755c54754109ffbe7e792f4e5b7c7c9
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * CDDL HEADER START
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * The contents of this file are subject to the terms of the
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * Common Development and Distribution License (the "License").
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * You may not use this file except in compliance with the License.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * See the License for the specific language governing permissions
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * and limitations under the License.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * When distributing Covered Code, include this CDDL HEADER in each
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * If applicable, add the following below this CDDL HEADER, with the
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * fields enclosed by brackets "[]" replaced with your own identifying
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * information: Portions Copyright [yyyy] [name of copyright owner]
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * CDDL HEADER END
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * Use is subject to license terms.
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka/* All Rights Reserved */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * University Copyright- Copyright (c) 1982, 1986, 1988
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * The Regents of the University of California
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * All Rights Reserved
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * University Acknowledgment- Portions of this document are derived from
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * software developed by the University of California, Berkeley, and its
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * contributors.
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka#pragma ident "%Z%%M% %I% %E% SMI"
1cc553493b17fa6a6770261bbfeb258f354ebf48rmestaextern "C" {
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka * A pointer to this structure is passed to segvn_create().
1cc553493b17fa6a6770261bbfeb258f354ebf48rmestatypedef struct segvn_crargs {
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta u_offset_t offset; /* starting offset of vnode for mapping */
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka struct anon_map *amp; /* anon mapping to map to */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * (Semi) private data maintained by the seg_vn driver per segment mapping.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * The read/write segment lock protects all of segvn_data including the
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * vpage array. All fields in segvn_data are treated as read-only when
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka * the "read" version of the address space and the segment locks are held.
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka * The "write" version of the segment lock, however, is required in order to
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * update the following fields:
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * softlockcnt
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * is written by acquiring either the readers lock on the segment and
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * freemem lock, or any lock combination which guarantees exclusive use
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * of this segment (e.g., adress space writers lock,
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * address space readers lock + segment writers lock).
1cc553493b17fa6a6770261bbfeb258f354ebf48rmestatypedef struct segvn_data {
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta krwlock_t lock; /* protect segvn_data and vpage array */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta kmutex_t segp_slock; /* serialize insertions into seg_pcache */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta uchar_t pageprot; /* true if per page protections present */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta uchar_t prot; /* current segment prot if pageprot == 0 */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta u_offset_t offset; /* starting offset of vnode for mapping */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta struct vnode *vp; /* vnode that segment mapping is to */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta ulong_t anon_index; /* starting index into anon_map anon array */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta struct anon_map *amp; /* pointer to anon share structure, if needed */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta struct vpage *vpage; /* per-page information, if needed */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta size_t swresv; /* swap space reserved for this segment */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta uchar_t pageadvice; /* true if per page advice set */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta ssize_t softlockcnt; /* # of pages SOFTLOCKED in seg */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta lgrp_mem_policy_info_t policy_info; /* memory allocation policy */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta hat_region_cookie_t rcookie; /* region for hat calls */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta lgrp_mem_policy_info_t tr_policy_info; /* memory allocation for TR */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta struct segvn_data *svn_trnext; /* textrepl list next link */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta struct segvn_data *svn_trprev; /* textrepl list prev link */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * segment text replication states.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_TR_INIT (0) /* Check if text replication can be enabled */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_TR_ON (1) /* Text replication is enabled */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_TR_OFF (2) /* Text replication is disabled */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * Macros for segvn segment driver locking.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_LOCK_ENTER(as, lock, type) rw_enter((lock), (type))
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_LOCK_DOWNGRADE(as, lock) rw_downgrade((lock))
5cb0d67909d9970a3e7adbea9422ca3fc88000bfMarcel Telka#define SEGVN_LOCK_TRYENTER(as, lock, type) rw_tryenter((lock), (type))
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * Macros to test lock states.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_LOCK_HELD(as, lock) RW_LOCK_HELD((lock))
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_READ_HELD(as, lock) RW_READ_HELD((lock))
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SEGVN_WRITE_HELD(as, lock) RW_WRITE_HELD((lock))
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * Macro used to detect the need to Break the sharing of COW pages
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * The rw == S_WRITE is for the COW case
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * rw == S_READ and type == SOFTLOCK is for the physio case
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * We don't want to share a softlocked page because it can cause problems
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * with multithreaded apps but if rw == S_READ_NOCOW it's ok to not break
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * sharing of COW pages even in SOFTLOCK case.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define BREAK_COW_SHARE(rw, type, seg_type) ((rw == S_WRITE || \
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta { NULL, NULL, 0, MAP_PRIVATE, prot, max, 0, NULL, 0, 0 }
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta ((struct segvn_crargs *)(argsp))->szc == AS_MAP_HEAP || \
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta ((struct segvn_crargs *)(argsp))->szc == AS_MAP_STACK) && \
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta#define SVNTR_HASH_FUNC(vp) (((((uintptr_t)(vp)) >> 4) ^ \
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * A hash table entry looked up by vnode, off/eoff and szc to find anon map to
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta * use for text replication based on main thread's (t_tid = 1) lgrp.
1cc553493b17fa6a6770261bbfeb258f354ebf48rmestatypedef struct svntr {
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta struct svntr *tr_next; /* next svntr in this hash bucket */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta ulong_t tr_refcnt; /* number of segs sharing this entry */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta segvn_data_t *tr_svnhead; /* list of segs sharing this entry */
1cc553493b17fa6a6770261bbfeb258f354ebf48rmesta struct anon_map *tr_amp[NLGRPS_MAX]; /* per lgrp anon maps */
typedef struct svntr_bucket {
typedef struct svntr_stats {
extern void segvn_init(void);
#ifdef __cplusplus