Print this page
6583 remove whole-process swapping
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/vm/seg_kp.h
+++ new/usr/src/uts/common/vm/seg_kp.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 19 *
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 #ifndef _VM_SEG_KP_H
28 28 #define _VM_SEG_KP_H
29 29
30 -#pragma ident "%Z%%M% %I% %E% SMI"
31 -
32 30 /*
33 31 * segkp (as in kernel pageable) is a segment driver that supports allocation
34 32 * of page-aligned variable size of vm resources.
35 33 *
36 34 * Each vm resource represents a page-aligned range of virtual addresses.
37 35 * The caller may specify whether the resource should include a redzone,
38 36 * be locked down, or be zero initialized.
39 37 */
40 38
41 39 #include <vm/seg.h>
42 40 #include <sys/vmem.h>
43 41
44 42 #ifdef __cplusplus
45 43 extern "C" {
46 44 #endif
47 45
48 46 #ifdef _KERNEL
49 47
50 48 /*
51 49 * Private information per overall segkp segment (as opposed
52 50 * to per resource within segment). There are as many anon slots
53 51 * allocated as there there are pages in the segment.
54 52 */
55 53 struct segkp_segdata {
56 54 struct anon_hdr *kpsd_anon; /* anon structs */
57 55 vmem_t *kpsd_arena; /* virtual memory descriptor */
58 56 struct segkp_data **kpsd_hash; /* Hash table for lookups */
59 57 };
60 58
61 59 #define SEGKP_VMEM(seg) (((struct segkp_segdata *)(seg)->s_data)->kpsd_arena)
62 60
63 61 /*
64 62 * A hash table is used to aid in the lookup of a kpd's based on vaddr.
65 63 * Since the heaviest use of segkp occurs from segkp_*get and segkp_*release,
66 64 * the hashing is based on the vaddr used by these routines.
67 65 */
68 66 #define SEGKP_HASHSZ 256 /* power of two */
69 67 #define SEGKP_HASHMASK (SEGKP_HASHSZ - 1)
70 68 #define SEGKP_HASH(vaddr) \
71 69 ((int)(((uintptr_t)vaddr >> PAGESHIFT) & SEGKP_HASHMASK))
72 70
73 71 struct segkp_data {
74 72 kmutex_t kp_lock; /* per resource lock */
75 73 caddr_t kp_base; /* starting addr of chunk */
76 74 size_t kp_len; /* # of bytes */
77 75 uint_t kp_flags; /* state info */
78 76 int kp_cookie; /* index into cache array */
79 77 ulong_t kp_anon_idx; /* index into main anon array */
80 78 /* in segkp_segdata */
81 79 struct anon_hdr *kp_anon; /* anon structs */
82 80 struct segkp_data *kp_next; /* ptr to next in hash chain */
83 81 };
84 82
85 83 /*
86 84 * Flag bits
87 85 *
88 86 */
89 87 #define KPD_ZERO 0x01 /* initialize resource with 0 */
90 88 #define KPD_LOCKED 0x02 /* resources locked */
91 89 #define KPD_NO_ANON 0x04 /* no swap resources required */
92 90 #define KPD_HASREDZONE 0x08 /* include a redzone */
93 91 #define KPD_NOWAIT 0x10 /* do not wait for res. if unavail. */
94 92 #define KPD_WRITEDIRTY 0x20 /* dirty pages should be flushed */
95 93 #define KPD_HASAMP 0x40 /* anon_hdr managed by caller */
96 94
97 95 /*
98 96 * A cache of segkp elements may be created via segkp_cache_init().
99 97 * The elements on the freelist all have the same len and flags value.
100 98 * The cookie passed to the client is an index into the freelist array.
101 99 */
102 100 struct segkp_cache {
103 101 int kpf_max; /* max # of elements allowed */
104 102 int kpf_count; /* current no. of elments */
105 103 int kpf_inuse; /* list inuse */
106 104 uint_t kpf_flags; /* seg_kp flag value */
107 105 size_t kpf_len; /* len of resource */
108 106 struct seg *kpf_seg; /* segment */
109 107 struct segkp_data *kpf_list; /* list of kpd's */
110 108 };
111 109 #define SEGKP_MAX_CACHE 4 /* Number of caches maintained */
112 110
113 111 /*
114 112 * Define redzone, and stack_to_memory macros.
115 113 * The redzone is PAGESIZE bytes.
116 114 */
117 115 #ifdef STACK_GROWTH_DOWN
118 116 #define KPD_REDZONE(kpd) (0)
119 117 #define stom(v, flags) (((flags) & KPD_HASREDZONE) ? (v) + PAGESIZE : (v))
120 118
121 119 #else /* STACK_GROWTH_DOWN */
122 120
123 121 #define KPD_REDZONE(kpd) (btop(kpd->kp_len) - 1)
124 122 #define stom(v) (v)
125 123 #endif /* STACK_GROWTH_DOWN */
126 124
127 125 #define SEGKP_MAPLEN(len, flags) \
128 126 (((flags) & KPD_HASREDZONE) ? (len) - PAGESIZE : (len))
129 127
130 128 extern struct seg *segkp;
131 129 /* If segkp becomes more than one seg this test will need changing. */
132 130 #define SEG_IS_SEGKP(SEG) ((SEG) == segkp)
133 131
134 132 /*
135 133 * Public routine declarations not part of the segment ops vector go here.
↓ open down ↓ |
94 lines elided |
↑ open up ↑ |
136 134 */
137 135 int segkp_create(struct seg *seg);
138 136 caddr_t segkp_get(struct seg *seg, size_t len, uint_t flags);
139 137 void segkp_release(struct seg *seg, caddr_t vaddr);
140 138 void * segkp_cache_init(struct seg *seg, int maxsize, size_t len,
141 139 uint_t flags);
142 140 void segkp_cache_free();
143 141 caddr_t segkp_cache_get(void *cookie);
144 142 int segkp_map_red(void);
145 143 void segkp_unmap_red(void);
146 -size_t swapsize(caddr_t v);
147 144
148 145 /* Special currently only used by schedctl. */
149 146 struct anon_map; /* Make the compiler happy about the next line. */
150 147 caddr_t segkp_get_withanonmap(struct seg *, size_t, uint_t, struct anon_map *);
151 148
152 149 /*
153 150 * We allow explicit calls to segkp_fault, even though it's part
154 151 * of the segkp ops vector.
155 152 */
156 153 faultcode_t segkp_fault(struct hat *hat, struct seg *seg, caddr_t addr,
157 154 size_t len, enum fault_type type, enum seg_rw rw);
158 155
159 156 #endif /* _KERNEL */
160 157
161 158 #ifdef __cplusplus
162 159 }
163 160 #endif
164 161
165 162 #endif /* _VM_SEG_KP_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX