xref: /titanic_52/usr/src/lib/libumem/common/umem_base.h (revision e5815e7afac983d9ae9b2316e5056c8401cf7e5e)
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 (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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 /*
26  * Copyright (c) 2012, Joyent, Inc.  All rights reserved.
27  */
28 
29 #ifndef	_UMEM_BASE_H
30 #define	_UMEM_BASE_H
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 extern uintptr_t umem_tmem_off;
80 
81 /*
82  * umem.c: tunables
83  */
84 extern uint32_t umem_max_ncpus;
85 
86 extern uint32_t umem_stack_depth;
87 extern uint32_t umem_reap_interval;
88 extern uint32_t umem_update_interval;
89 extern uint32_t umem_depot_contention;
90 extern uint32_t umem_abort;
91 extern uint32_t umem_output;
92 extern uint32_t umem_logging;
93 extern uint32_t umem_mtbf;
94 extern size_t umem_transaction_log_size;
95 extern size_t umem_content_log_size;
96 extern size_t umem_failure_log_size;
97 extern size_t umem_slab_log_size;
98 extern size_t umem_content_maxsave;
99 extern size_t umem_lite_minsize;
100 extern size_t umem_lite_maxalign;
101 extern size_t umem_maxverify;
102 extern size_t umem_minfirewall;
103 extern size_t umem_ptc_size;
104 
105 extern uint32_t umem_flags;
106 
107 /*
108  * umem.c: Internal aliases (to avoid PLTs)
109  */
110 extern void *_umem_alloc(size_t size, int umflags);
111 extern void *_umem_zalloc(size_t size, int umflags);
112 extern void _umem_free(void *buf, size_t size);
113 
114 extern void *_umem_cache_alloc(umem_cache_t *cache, int flags);
115 extern void _umem_cache_free(umem_cache_t *cache, void *buffer);
116 
117 /*
118  * umem.c: private interfaces
119  */
120 extern void umem_type_init(caddr_t, size_t, size_t);
121 extern int umem_get_max_ncpus(void);
122 extern void umem_process_updates(void);
123 extern void umem_cache_applyall(void (*)(umem_cache_t *));
124 extern void umem_cache_update(umem_cache_t *);
125 
126 extern void umem_alloc_sizes_add(size_t);
127 extern void umem_alloc_sizes_clear(void);
128 extern void umem_alloc_sizes_remove(size_t);
129 
130 /*
131  * umem_fork.c: private interfaces
132  */
133 extern void umem_forkhandler_init(void);
134 
135 /*
136  * umem_update_thread.c
137  */
138 extern int umem_create_update_thread(void);
139 
140 /*
141  * envvar.c:
142  */
143 void umem_setup_envvars(int);
144 void umem_process_envvars(void);
145 
146 /*
147  * umem_genasm.c: private interfaces
148  */
149 extern const int umem_genasm_supported;
150 extern int umem_genasm(int *, umem_cache_t **, int);
151 
152 /*
153  * malloc.c: traditional malloc/free interface for genasm
154  */
155 extern void *umem_malloc(size_t);
156 extern void umem_malloc_free(void *);
157 extern void *_malloc(size_t);
158 extern void _free(void *);
159 
160 #ifdef	__cplusplus
161 }
162 #endif
163 
164 #endif	/* _UMEM_BASE_H */
165