xref: /titanic_53/usr/src/uts/i86pc/vm/htable.h (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate  *
4*7c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate  * with the License.
8*7c478bd9Sstevel@tonic-gate  *
9*7c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate  * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate  *
14*7c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate  *
20*7c478bd9Sstevel@tonic-gate  * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate  */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
25*7c478bd9Sstevel@tonic-gate  */
26*7c478bd9Sstevel@tonic-gate 
27*7c478bd9Sstevel@tonic-gate #ifndef	_VM_HTABLE_H
28*7c478bd9Sstevel@tonic-gate #define	_VM_HTABLE_H
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*7c478bd9Sstevel@tonic-gate 
32*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
33*7c478bd9Sstevel@tonic-gate extern "C" {
34*7c478bd9Sstevel@tonic-gate #endif
35*7c478bd9Sstevel@tonic-gate 
36*7c478bd9Sstevel@tonic-gate #if defined(__GNUC__) && defined(_ASM_INLINES) && defined(_KERNEL)
37*7c478bd9Sstevel@tonic-gate #include <asm/htable.h>
38*7c478bd9Sstevel@tonic-gate #endif
39*7c478bd9Sstevel@tonic-gate 
40*7c478bd9Sstevel@tonic-gate extern void atomic_andb(uint8_t *addr, uint8_t value);
41*7c478bd9Sstevel@tonic-gate extern void atomic_orb(uint8_t *addr, uint8_t value);
42*7c478bd9Sstevel@tonic-gate extern void atomic_inc16(uint16_t *addr);
43*7c478bd9Sstevel@tonic-gate extern void atomic_dec16(uint16_t *addr);
44*7c478bd9Sstevel@tonic-gate extern void mmu_tlbflush_entry(caddr_t addr);
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate /*
47*7c478bd9Sstevel@tonic-gate  * Each hardware page table has an htable_t describing it.
48*7c478bd9Sstevel@tonic-gate  *
49*7c478bd9Sstevel@tonic-gate  * We use a reference counter mechanism to detect when we can free an htable.
50*7c478bd9Sstevel@tonic-gate  * In the implmentation the reference count is split into 2 separate counters:
51*7c478bd9Sstevel@tonic-gate  *
52*7c478bd9Sstevel@tonic-gate  *	ht_busy is a traditional reference count of uses of the htable pointer
53*7c478bd9Sstevel@tonic-gate  *
54*7c478bd9Sstevel@tonic-gate  *	ht_valid_cnt is a count of how references are implied by valid PTE/PTP
55*7c478bd9Sstevel@tonic-gate  *	         entries in the pagetable
56*7c478bd9Sstevel@tonic-gate  *
57*7c478bd9Sstevel@tonic-gate  * ht_busy is only incremented by htable_lookup() or htable_create()
58*7c478bd9Sstevel@tonic-gate  * while holding the appropriate hash_table mutex. While installing a new
59*7c478bd9Sstevel@tonic-gate  * valid PTE or PTP, in order to increment ht_valid_cnt a thread must have
60*7c478bd9Sstevel@tonic-gate  * done an htable_lookup() or htable_create() but not the htable_release yet.
61*7c478bd9Sstevel@tonic-gate  *
62*7c478bd9Sstevel@tonic-gate  * htable_release(), while holding the mutex, can know that if
63*7c478bd9Sstevel@tonic-gate  * busy == 1 and valid_cnt == 0, the htable can be free'd.
64*7c478bd9Sstevel@tonic-gate  *
65*7c478bd9Sstevel@tonic-gate  * The fields have been ordered to make htable_lookup() fast. Hence,
66*7c478bd9Sstevel@tonic-gate  * ht_hat, ht_vaddr, ht_level and ht_next need to be clustered together.
67*7c478bd9Sstevel@tonic-gate  */
68*7c478bd9Sstevel@tonic-gate struct htable {
69*7c478bd9Sstevel@tonic-gate 	struct htable	*ht_next;	/* forward link for hash table */
70*7c478bd9Sstevel@tonic-gate 	struct hat	*ht_hat;	/* hat this mapping comes from */
71*7c478bd9Sstevel@tonic-gate 	uintptr_t	ht_vaddr;	/* virt addr at start of this table */
72*7c478bd9Sstevel@tonic-gate 	level_t		ht_level;	/* page table level: 0=4K, 1=2M, ... */
73*7c478bd9Sstevel@tonic-gate 	uint16_t	ht_flags;	/* see below */
74*7c478bd9Sstevel@tonic-gate 	int16_t		ht_busy;	/* implements locking protocol */
75*7c478bd9Sstevel@tonic-gate 	uint16_t	ht_num_ptes;	/* # of PTEs in page table */
76*7c478bd9Sstevel@tonic-gate 	int16_t		ht_valid_cnt;	/* # of valid entries in this table */
77*7c478bd9Sstevel@tonic-gate 	uint32_t	ht_lock_cnt;	/* # of locked entries in this table */
78*7c478bd9Sstevel@tonic-gate 					/* never used for kernel hat */
79*7c478bd9Sstevel@tonic-gate 	pfn_t		ht_pfn;		/* pfn of page of the pagetable */
80*7c478bd9Sstevel@tonic-gate 	struct htable	*ht_prev;	/* backward link for hash table */
81*7c478bd9Sstevel@tonic-gate 	struct htable	*ht_parent;	/* htable that points to this htable */
82*7c478bd9Sstevel@tonic-gate 	struct htable	*ht_shares;	/* for HTABLE_SHARED_PFN only */
83*7c478bd9Sstevel@tonic-gate };
84*7c478bd9Sstevel@tonic-gate typedef struct htable htable_t;
85*7c478bd9Sstevel@tonic-gate 
86*7c478bd9Sstevel@tonic-gate /*
87*7c478bd9Sstevel@tonic-gate  * Flags values for htable ht_flags field:
88*7c478bd9Sstevel@tonic-gate  *
89*7c478bd9Sstevel@tonic-gate  * HTABLE_VLP - this is the top level htable of a VLP HAT.
90*7c478bd9Sstevel@tonic-gate  *
91*7c478bd9Sstevel@tonic-gate  * HTABLE_SHARED_PFN - this htable had it's PFN assigned from sharing another
92*7c478bd9Sstevel@tonic-gate  * 	htable. Used by hat_share() for ISM.
93*7c478bd9Sstevel@tonic-gate  */
94*7c478bd9Sstevel@tonic-gate #define	HTABLE_VLP		(0x0001)
95*7c478bd9Sstevel@tonic-gate #define	HTABLE_SHARED_PFN	(0x0002)
96*7c478bd9Sstevel@tonic-gate 
97*7c478bd9Sstevel@tonic-gate /*
98*7c478bd9Sstevel@tonic-gate  * The htable hash table hashing function.  The 28 is so that high
99*7c478bd9Sstevel@tonic-gate  * order bits are include in the hash index to skew the wrap
100*7c478bd9Sstevel@tonic-gate  * around of addresses.
101*7c478bd9Sstevel@tonic-gate  */
102*7c478bd9Sstevel@tonic-gate #define	HTABLE_HASH(hat, va, lvl)					\
103*7c478bd9Sstevel@tonic-gate 	((((va) >> LEVEL_SHIFT(1)) + ((va) >> 28) + (lvl)) &		\
104*7c478bd9Sstevel@tonic-gate 	((hat)->hat_num_hash - 1))
105*7c478bd9Sstevel@tonic-gate 
106*7c478bd9Sstevel@tonic-gate /*
107*7c478bd9Sstevel@tonic-gate  * For 32 bit, access to page table entries is done via the page table's PFN and
108*7c478bd9Sstevel@tonic-gate  * the index of the PTE. We use a CPU specific mapping (a la ppcopy) to map
109*7c478bd9Sstevel@tonic-gate  * in page tables on an "as needed" basis.
110*7c478bd9Sstevel@tonic-gate  *
111*7c478bd9Sstevel@tonic-gate  * 64 bit kernels will use seg_kpm style mappings and avoid any overhead.
112*7c478bd9Sstevel@tonic-gate  *
113*7c478bd9Sstevel@tonic-gate  * The code uses compare and swap instructions to read/write PTE's to
114*7c478bd9Sstevel@tonic-gate  * avoid atomicity problems, since PTEs can be 8 bytes on 32 bit systems.
115*7c478bd9Sstevel@tonic-gate  * Again this can be optimized on 64 bit systems, since aligned load/store
116*7c478bd9Sstevel@tonic-gate  * will naturally be atomic.
117*7c478bd9Sstevel@tonic-gate  *
118*7c478bd9Sstevel@tonic-gate  * Each CPU gets a unique hat_cpu_info structure in cpu_hat_info.
119*7c478bd9Sstevel@tonic-gate  */
120*7c478bd9Sstevel@tonic-gate struct hat_cpu_info {
121*7c478bd9Sstevel@tonic-gate 	pfn_t hci_mapped_pfn;		/* pfn of currently mapped page table */
122*7c478bd9Sstevel@tonic-gate 	x86pte_t *hci_pagetable_va;	/* VA to use for mappings */
123*7c478bd9Sstevel@tonic-gate 	x86pte_t *hci_kernel_pte;	/* kernel PTE for cpu_pagetable_va */
124*7c478bd9Sstevel@tonic-gate 	kmutex_t hci_mutex;		/* mutex to ensure sequential usage */
125*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
126*7c478bd9Sstevel@tonic-gate 	pfn_t	hci_vlp_pfn;		/* pfn of hci_vlp_l3ptes */
127*7c478bd9Sstevel@tonic-gate 	x86pte_t *hci_vlp_l3ptes;	/* VLP Level==3 pagetable (top) */
128*7c478bd9Sstevel@tonic-gate 	x86pte_t *hci_vlp_l2ptes;	/* VLP Level==2 pagetable */
129*7c478bd9Sstevel@tonic-gate #endif	/* __amd64 */
130*7c478bd9Sstevel@tonic-gate };
131*7c478bd9Sstevel@tonic-gate 
132*7c478bd9Sstevel@tonic-gate 
133*7c478bd9Sstevel@tonic-gate /*
134*7c478bd9Sstevel@tonic-gate  * Compute the last page aligned VA mapped by an htable.
135*7c478bd9Sstevel@tonic-gate  *
136*7c478bd9Sstevel@tonic-gate  * Given a va and a level, compute the virtual address of the start of the
137*7c478bd9Sstevel@tonic-gate  * next page at that level.
138*7c478bd9Sstevel@tonic-gate  *
139*7c478bd9Sstevel@tonic-gate  * XX64 - The check for the VA hole needs to be better generalized.
140*7c478bd9Sstevel@tonic-gate  */
141*7c478bd9Sstevel@tonic-gate #if defined(__amd64)
142*7c478bd9Sstevel@tonic-gate 
143*7c478bd9Sstevel@tonic-gate #define	HTABLE_LAST_PAGE(ht)						\
144*7c478bd9Sstevel@tonic-gate 	((ht)->ht_level == mmu.max_level ? ((uintptr_t)0UL - MMU_PAGESIZE) :\
145*7c478bd9Sstevel@tonic-gate 	((ht)->ht_vaddr - MMU_PAGESIZE +				\
146*7c478bd9Sstevel@tonic-gate 	((uintptr_t)((ht)->ht_num_ptes) << LEVEL_SHIFT((ht)->ht_level))))
147*7c478bd9Sstevel@tonic-gate 
148*7c478bd9Sstevel@tonic-gate #define	NEXT_ENTRY_VA(va, l)	\
149*7c478bd9Sstevel@tonic-gate 	((va & LEVEL_MASK(l)) + LEVEL_SIZE(l) == mmu.hole_start ?	\
150*7c478bd9Sstevel@tonic-gate 	mmu.hole_end : (va & LEVEL_MASK(l)) + LEVEL_SIZE(l))
151*7c478bd9Sstevel@tonic-gate 
152*7c478bd9Sstevel@tonic-gate #elif defined(__i386)
153*7c478bd9Sstevel@tonic-gate 
154*7c478bd9Sstevel@tonic-gate #define	HTABLE_LAST_PAGE(ht)	((ht)->ht_vaddr - MMU_PAGESIZE + \
155*7c478bd9Sstevel@tonic-gate 	((uintptr_t)((ht)->ht_num_ptes) << LEVEL_SHIFT((ht)->ht_level)))
156*7c478bd9Sstevel@tonic-gate 
157*7c478bd9Sstevel@tonic-gate #define	NEXT_ENTRY_VA(va, l) ((va & LEVEL_MASK(l)) + LEVEL_SIZE(l))
158*7c478bd9Sstevel@tonic-gate 
159*7c478bd9Sstevel@tonic-gate #endif
160*7c478bd9Sstevel@tonic-gate 
161*7c478bd9Sstevel@tonic-gate #if defined(_KERNEL)
162*7c478bd9Sstevel@tonic-gate 
163*7c478bd9Sstevel@tonic-gate /*
164*7c478bd9Sstevel@tonic-gate  * initialization function called from hat_init()
165*7c478bd9Sstevel@tonic-gate  */
166*7c478bd9Sstevel@tonic-gate extern void htable_init(void);
167*7c478bd9Sstevel@tonic-gate 
168*7c478bd9Sstevel@tonic-gate /*
169*7c478bd9Sstevel@tonic-gate  * Functions to lookup, or "lookup and create", the htable corresponding
170*7c478bd9Sstevel@tonic-gate  * to the virtual address "vaddr"  in the "hat" at the given "level" of
171*7c478bd9Sstevel@tonic-gate  * page tables. htable_lookup() may return NULL if no such entry exists.
172*7c478bd9Sstevel@tonic-gate  *
173*7c478bd9Sstevel@tonic-gate  * On return the given htable is marked busy (a shared lock) - this prevents
174*7c478bd9Sstevel@tonic-gate  * the htable from being stolen or freed) until htable_release() is called.
175*7c478bd9Sstevel@tonic-gate  *
176*7c478bd9Sstevel@tonic-gate  * If kalloc_flag is set on an htable_create() we can't call kmem allocation
177*7c478bd9Sstevel@tonic-gate  * routines for this htable, since it's for the kernel hat itself.
178*7c478bd9Sstevel@tonic-gate  *
179*7c478bd9Sstevel@tonic-gate  * htable_acquire() is used when an htable pointer has been extracted from
180*7c478bd9Sstevel@tonic-gate  * an hment and we need to get a reference to the htable.
181*7c478bd9Sstevel@tonic-gate  */
182*7c478bd9Sstevel@tonic-gate extern htable_t *htable_lookup(struct hat *hat, uintptr_t vaddr, level_t level);
183*7c478bd9Sstevel@tonic-gate extern htable_t *htable_create(struct hat *hat, uintptr_t vaddr, level_t level,
184*7c478bd9Sstevel@tonic-gate 	htable_t *shared);
185*7c478bd9Sstevel@tonic-gate extern void htable_acquire(htable_t *);
186*7c478bd9Sstevel@tonic-gate 
187*7c478bd9Sstevel@tonic-gate extern void htable_release(htable_t *ht);
188*7c478bd9Sstevel@tonic-gate 
189*7c478bd9Sstevel@tonic-gate /*
190*7c478bd9Sstevel@tonic-gate  * Code to free all remaining htables for a hat. Called after the hat is no
191*7c478bd9Sstevel@tonic-gate  * longer in use by any thread.
192*7c478bd9Sstevel@tonic-gate  */
193*7c478bd9Sstevel@tonic-gate extern void htable_purge_hat(struct hat *hat);
194*7c478bd9Sstevel@tonic-gate 
195*7c478bd9Sstevel@tonic-gate /*
196*7c478bd9Sstevel@tonic-gate  * Find the htable, page table entry index, and PTE of the given virtual
197*7c478bd9Sstevel@tonic-gate  * address.  If not found returns NULL. When found, returns the htable_t *,
198*7c478bd9Sstevel@tonic-gate  * sets entry, and has a hold on the htable.
199*7c478bd9Sstevel@tonic-gate  */
200*7c478bd9Sstevel@tonic-gate extern htable_t *htable_getpte(struct hat *, uintptr_t, uint_t *, x86pte_t *,
201*7c478bd9Sstevel@tonic-gate 	level_t);
202*7c478bd9Sstevel@tonic-gate 
203*7c478bd9Sstevel@tonic-gate /*
204*7c478bd9Sstevel@tonic-gate  * Similar to hat_getpte(), except that this only succeeds if a valid
205*7c478bd9Sstevel@tonic-gate  * page mapping is present.
206*7c478bd9Sstevel@tonic-gate  */
207*7c478bd9Sstevel@tonic-gate extern htable_t *htable_getpage(struct hat *hat, uintptr_t va, uint_t *entry);
208*7c478bd9Sstevel@tonic-gate 
209*7c478bd9Sstevel@tonic-gate /*
210*7c478bd9Sstevel@tonic-gate  * Called to allocate initial/additional htables for reserve.
211*7c478bd9Sstevel@tonic-gate  */
212*7c478bd9Sstevel@tonic-gate extern void htable_initial_reserve(uint_t);
213*7c478bd9Sstevel@tonic-gate extern void htable_reserve(uint_t);
214*7c478bd9Sstevel@tonic-gate 
215*7c478bd9Sstevel@tonic-gate /*
216*7c478bd9Sstevel@tonic-gate  * Used to readjust the htable reserve after the reserve list has been used.
217*7c478bd9Sstevel@tonic-gate  * Also called after boot to release left over boot reserves.
218*7c478bd9Sstevel@tonic-gate  */
219*7c478bd9Sstevel@tonic-gate extern void htable_adjust_reserve(void);
220*7c478bd9Sstevel@tonic-gate 
221*7c478bd9Sstevel@tonic-gate /*
222*7c478bd9Sstevel@tonic-gate  * Routine to find the next populated htable at or above a given virtual
223*7c478bd9Sstevel@tonic-gate  * address. Can specify an upper limit, or HTABLE_WALK_TO_END to indicate
224*7c478bd9Sstevel@tonic-gate  * that it should search the entire address space.  Similar to
225*7c478bd9Sstevel@tonic-gate  * hat_getpte(), but used for walking through address ranges. It can be
226*7c478bd9Sstevel@tonic-gate  * used like this:
227*7c478bd9Sstevel@tonic-gate  *
228*7c478bd9Sstevel@tonic-gate  *	va = ...
229*7c478bd9Sstevel@tonic-gate  *	ht = NULL;
230*7c478bd9Sstevel@tonic-gate  *	while (va < end_va) {
231*7c478bd9Sstevel@tonic-gate  *		pte = htable_walk(hat, &ht, &va, end_va);
232*7c478bd9Sstevel@tonic-gate  *		if (!pte)
233*7c478bd9Sstevel@tonic-gate  *			break;
234*7c478bd9Sstevel@tonic-gate  *
235*7c478bd9Sstevel@tonic-gate  *		... code to operate on page at va ...
236*7c478bd9Sstevel@tonic-gate  *
237*7c478bd9Sstevel@tonic-gate  *		va += LEVEL_SIZE(ht->ht_level);
238*7c478bd9Sstevel@tonic-gate  *	}
239*7c478bd9Sstevel@tonic-gate  *	if (ht)
240*7c478bd9Sstevel@tonic-gate  *		htable_release(ht);
241*7c478bd9Sstevel@tonic-gate  *
242*7c478bd9Sstevel@tonic-gate  */
243*7c478bd9Sstevel@tonic-gate extern x86pte_t htable_walk(struct hat *hat, htable_t **ht, uintptr_t *va,
244*7c478bd9Sstevel@tonic-gate 	uintptr_t eaddr);
245*7c478bd9Sstevel@tonic-gate 
246*7c478bd9Sstevel@tonic-gate #define	HTABLE_WALK_TO_END ((uintptr_t)-1)
247*7c478bd9Sstevel@tonic-gate 
248*7c478bd9Sstevel@tonic-gate /*
249*7c478bd9Sstevel@tonic-gate  * Utilities convert between virtual addresses and page table entry indeces.
250*7c478bd9Sstevel@tonic-gate  */
251*7c478bd9Sstevel@tonic-gate extern uint_t htable_va2entry(uintptr_t va, htable_t *ht);
252*7c478bd9Sstevel@tonic-gate extern uintptr_t htable_e2va(htable_t *ht, uint_t entry);
253*7c478bd9Sstevel@tonic-gate 
254*7c478bd9Sstevel@tonic-gate /*
255*7c478bd9Sstevel@tonic-gate  * Interfaces that provide access to page table entries via the htable.
256*7c478bd9Sstevel@tonic-gate  *
257*7c478bd9Sstevel@tonic-gate  * Note that all accesses except x86pte_copy() and x86pte_zero() are atomic.
258*7c478bd9Sstevel@tonic-gate  */
259*7c478bd9Sstevel@tonic-gate extern void	x86pte_cpu_init(cpu_t *, void *);
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate extern x86pte_t	x86pte_get(htable_t *, uint_t entry);
262*7c478bd9Sstevel@tonic-gate 
263*7c478bd9Sstevel@tonic-gate extern x86pte_t	x86pte_set(htable_t *, uint_t entry, x86pte_t new, void *);
264*7c478bd9Sstevel@tonic-gate 
265*7c478bd9Sstevel@tonic-gate extern x86pte_t x86pte_invalidate_pfn(htable_t *ht, uint_t entry, pfn_t pfn,
266*7c478bd9Sstevel@tonic-gate 	void *pte_ptr);
267*7c478bd9Sstevel@tonic-gate 
268*7c478bd9Sstevel@tonic-gate extern x86pte_t x86pte_update(htable_t *ht, uint_t entry,
269*7c478bd9Sstevel@tonic-gate 	x86pte_t old, x86pte_t new);
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate extern void	x86pte_copy(htable_t *src, htable_t *dest, uint_t entry,
272*7c478bd9Sstevel@tonic-gate 	uint_t cnt);
273*7c478bd9Sstevel@tonic-gate 
274*7c478bd9Sstevel@tonic-gate extern void	x86pte_zero(htable_t *ht, uint_t entry, uint_t cnt);
275*7c478bd9Sstevel@tonic-gate 
276*7c478bd9Sstevel@tonic-gate 
277*7c478bd9Sstevel@tonic-gate /*
278*7c478bd9Sstevel@tonic-gate  * these are actually inlines for "lock; incw", "lock; decw", etc. instructions.
279*7c478bd9Sstevel@tonic-gate  */
280*7c478bd9Sstevel@tonic-gate #define	HTABLE_INC(x)	atomic_inc16((uint16_t *)&x)
281*7c478bd9Sstevel@tonic-gate #define	HTABLE_DEC(x)	atomic_dec16((uint16_t *)&x)
282*7c478bd9Sstevel@tonic-gate #define	HTABLE_LOCK_INC(ht)	atomic_add_32(&(ht)->ht_lock_cnt, 1)
283*7c478bd9Sstevel@tonic-gate #define	HTABLE_LOCK_DEC(ht)	atomic_add_32(&(ht)->ht_lock_cnt, -1)
284*7c478bd9Sstevel@tonic-gate 
285*7c478bd9Sstevel@tonic-gate #endif	/* _KERNEL */
286*7c478bd9Sstevel@tonic-gate 
287*7c478bd9Sstevel@tonic-gate 
288*7c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
289*7c478bd9Sstevel@tonic-gate }
290*7c478bd9Sstevel@tonic-gate #endif
291*7c478bd9Sstevel@tonic-gate 
292*7c478bd9Sstevel@tonic-gate #endif	/* _VM_HTABLE_H */
293