xref: /titanic_51/usr/src/lib/libumem/common/umem_base.h (revision 749f21d359d8fbd020c974a1a5227316221bfc9c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_UMEM_BASE_H
28 #define	_UMEM_BASE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <umem_impl.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #include "misc.h"
39 
40 extern size_t pagesize;
41 #undef PAGESIZE
42 #define	PAGESIZE	pagesize
43 
44 /*
45  * umem.c: non-tunables
46  */
47 extern vmem_t		*umem_memalign_arena;
48 
49 extern int umem_ready;
50 extern thread_t umem_init_thr;		/* the thread doing the init */
51 
52 extern int umem_init(void);		/* do umem's initialization */
53 #pragma rarely_called(umem_init)
54 
55 extern umem_log_header_t *umem_transaction_log;
56 extern umem_log_header_t *umem_content_log;
57 extern umem_log_header_t *umem_failure_log;
58 extern umem_log_header_t *umem_slab_log;
59 
60 extern mutex_t umem_init_lock;
61 
62 extern mutex_t umem_cache_lock;
63 extern umem_cache_t umem_null_cache;
64 
65 extern mutex_t umem_flags_lock;
66 
67 extern mutex_t umem_update_lock;
68 extern cond_t umem_update_cv;
69 extern volatile thread_t umem_st_update_thr;
70 extern thread_t umem_update_thr;
71 extern struct timeval	umem_update_next;
72 
73 extern volatile hrtime_t umem_reap_next;
74 extern volatile uint32_t umem_reaping;
75 #define	UMEM_REAP_DONE		0x00000000	/* inactive */
76 #define	UMEM_REAP_ADDING	0x00000001	/* umem_reap() is active */
77 #define	UMEM_REAP_ACTIVE	0x00000002	/* update thread is reaping */
78 
79 /*
80  * umem.c: tunables
81  */
82 extern uint32_t umem_max_ncpus;
83 
84 extern uint32_t umem_stack_depth;
85 extern uint32_t umem_reap_interval;
86 extern uint32_t umem_update_interval;
87 extern uint32_t umem_depot_contention;
88 extern uint32_t umem_abort;
89 extern uint32_t umem_output;
90 extern uint32_t umem_logging;
91 extern uint32_t umem_mtbf;
92 extern size_t umem_transaction_log_size;
93 extern size_t umem_content_log_size;
94 extern size_t umem_failure_log_size;
95 extern size_t umem_slab_log_size;
96 extern size_t umem_content_maxsave;
97 extern size_t umem_lite_minsize;
98 extern size_t umem_lite_maxalign;
99 extern size_t umem_maxverify;
100 extern size_t umem_minfirewall;
101 
102 extern uint32_t umem_flags;
103 
104 /*
105  * umem.c: Internal aliases (to avoid PLTs)
106  */
107 extern void *_umem_alloc(size_t size, int umflags);
108 extern void *_umem_zalloc(size_t size, int umflags);
109 extern void _umem_free(void *buf, size_t size);
110 
111 extern void *_umem_cache_alloc(umem_cache_t *cache, int flags);
112 extern void _umem_cache_free(umem_cache_t *cache, void *buffer);
113 
114 /*
115  * umem.c: private interfaces
116  */
117 extern void umem_type_init(caddr_t, size_t, size_t);
118 extern int umem_get_max_ncpus(void);
119 extern void umem_process_updates(void);
120 extern void umem_cache_applyall(void (*)(umem_cache_t *));
121 extern void umem_cache_update(umem_cache_t *);
122 
123 /*
124  * umem_fork.c: private interfaces
125  */
126 extern void umem_forkhandler_init(void);
127 
128 /*
129  * umem_update_thread.c
130  */
131 extern int umem_create_update_thread(void);
132 
133 /*
134  * envvar.c:
135  */
136 void umem_setup_envvars(int);
137 void umem_process_envvars(void);
138 
139 #ifdef	__cplusplus
140 }
141 #endif
142 
143 #endif	/* _UMEM_BASE_H */
144