xref: /illumos-gate/usr/src/lib/libumem/common/umem_base.h (revision fcdb3229a31dd4ff700c69238814e326aad49098)
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) 2019, Joyent, Inc.
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 
54 extern umem_log_header_t *umem_transaction_log;
55 extern umem_log_header_t *umem_content_log;
56 extern umem_log_header_t *umem_failure_log;
57 extern umem_log_header_t *umem_slab_log;
58 
59 extern mutex_t umem_init_lock;
60 
61 extern mutex_t umem_cache_lock;
62 extern umem_cache_t umem_null_cache;
63 
64 extern mutex_t umem_flags_lock;
65 
66 extern mutex_t umem_update_lock;
67 extern cond_t umem_update_cv;
68 extern volatile thread_t umem_st_update_thr;
69 extern thread_t umem_update_thr;
70 extern struct timeval	umem_update_next;
71 
72 extern volatile hrtime_t umem_reap_next;
73 extern volatile uint32_t umem_reaping;
74 #define	UMEM_REAP_DONE		0x00000000	/* inactive */
75 #define	UMEM_REAP_ADDING	0x00000001	/* umem_reap() is active */
76 #define	UMEM_REAP_ACTIVE	0x00000002	/* update thread is reaping */
77 
78 extern uintptr_t umem_tmem_off;
79 
80 /*
81  * umem.c: tunables
82  */
83 extern uint32_t umem_max_ncpus;
84 
85 extern uint32_t umem_stack_depth;
86 extern uint32_t umem_reap_interval;
87 extern uint32_t umem_update_interval;
88 extern uint32_t umem_depot_contention;
89 extern uint32_t umem_abort;
90 extern uint32_t umem_output;
91 extern uint32_t umem_logging;
92 extern uint32_t umem_mtbf;
93 extern size_t umem_transaction_log_size;
94 extern size_t umem_content_log_size;
95 extern size_t umem_failure_log_size;
96 extern size_t umem_slab_log_size;
97 extern size_t umem_content_maxsave;
98 extern size_t umem_lite_minsize;
99 extern size_t umem_lite_maxalign;
100 extern size_t umem_maxverify;
101 extern size_t umem_minfirewall;
102 extern size_t umem_ptc_size;
103 
104 extern uint32_t umem_flags;
105 
106 /*
107  * umem.c: Internal aliases (to avoid PLTs)
108  */
109 extern void *_umem_alloc(size_t size, int umflags);
110 extern void *_umem_zalloc(size_t size, int umflags);
111 extern void _umem_free(void *buf, size_t size);
112 
113 extern void *_umem_cache_alloc(umem_cache_t *cache, int flags);
114 extern void _umem_cache_free(umem_cache_t *cache, void *buffer);
115 
116 /*
117  * umem.c: private interfaces
118  */
119 extern void umem_type_init(caddr_t, size_t, size_t);
120 extern int umem_get_max_ncpus(void);
121 extern void umem_process_updates(void);
122 extern void umem_cache_applyall(void (*)(umem_cache_t *));
123 extern void umem_cache_update(umem_cache_t *);
124 
125 extern void umem_alloc_sizes_add(size_t);
126 extern void umem_alloc_sizes_clear(void);
127 extern void umem_alloc_sizes_remove(size_t);
128 
129 /*
130  * umem_fork.c: private interfaces
131  */
132 extern void umem_forkhandler_init(void);
133 
134 /*
135  * umem_update_thread.c
136  */
137 extern int umem_create_update_thread(void);
138 
139 /*
140  * envvar.c:
141  */
142 void umem_setup_envvars(int);
143 void umem_process_envvars(void);
144 
145 /*
146  * umem_genasm.c: private interfaces
147  */
148 extern const int umem_genasm_supported;
149 extern boolean_t umem_genasm(int *, umem_cache_t **, int);
150 
151 /*
152  * malloc.c: traditional malloc/free interface for genasm
153  */
154 extern void *umem_malloc(size_t);
155 extern void umem_malloc_free(void *);
156 extern void *_malloc(size_t);
157 extern void _free(void *);
158 
159 #ifdef	__cplusplus
160 }
161 #endif
162 
163 #endif	/* _UMEM_BASE_H */
164