xref: /titanic_51/usr/src/lib/libumem/common/umem_base.h (revision 1e49577a7fcde812700ded04431b49d67cc57d6d)
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 #ifndef	_UMEM_BASE_H
27 #define	_UMEM_BASE_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <umem_impl.h>
32 
33 #ifdef	__cplusplus
34 extern "C" {
35 #endif
36 
37 #include "misc.h"
38 
39 extern size_t pagesize;
40 #undef PAGESIZE
41 #define	PAGESIZE	pagesize
42 
43 /*
44  * umem.c: non-tunables
45  */
46 extern vmem_t		*umem_memalign_arena;
47 
48 extern int umem_ready;
49 extern thread_t umem_init_thr;		/* the thread doing the init */
50 
51 extern int umem_init(void);		/* do umem's initialization */
52 #pragma rarely_called(umem_init)
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 /*
79  * umem.c: tunables
80  */
81 extern uint32_t umem_max_ncpus;
82 
83 extern uint32_t umem_stack_depth;
84 extern uint32_t umem_reap_interval;
85 extern uint32_t umem_update_interval;
86 extern uint32_t umem_depot_contention;
87 extern uint32_t umem_abort;
88 extern uint32_t umem_output;
89 extern uint32_t umem_logging;
90 extern uint32_t umem_mtbf;
91 extern size_t umem_transaction_log_size;
92 extern size_t umem_content_log_size;
93 extern size_t umem_failure_log_size;
94 extern size_t umem_slab_log_size;
95 extern size_t umem_content_maxsave;
96 extern size_t umem_lite_minsize;
97 extern size_t umem_lite_maxalign;
98 extern size_t umem_maxverify;
99 extern size_t umem_minfirewall;
100 
101 extern uint32_t umem_flags;
102 
103 /*
104  * umem.c: Internal aliases (to avoid PLTs)
105  */
106 extern void *_umem_alloc(size_t size, int umflags);
107 extern void *_umem_zalloc(size_t size, int umflags);
108 extern void _umem_free(void *buf, size_t size);
109 
110 extern void *_umem_cache_alloc(umem_cache_t *cache, int flags);
111 extern void _umem_cache_free(umem_cache_t *cache, void *buffer);
112 
113 /*
114  * umem.c: private interfaces
115  */
116 extern void umem_type_init(caddr_t, size_t, size_t);
117 extern int umem_get_max_ncpus(void);
118 extern void umem_process_updates(void);
119 extern void umem_cache_applyall(void (*)(umem_cache_t *));
120 extern void umem_cache_update(umem_cache_t *);
121 
122 extern void umem_alloc_sizes_add(size_t);
123 extern void umem_alloc_sizes_clear(void);
124 extern void umem_alloc_sizes_remove(size_t);
125 
126 /*
127  * umem_fork.c: private interfaces
128  */
129 extern void umem_forkhandler_init(void);
130 
131 /*
132  * umem_update_thread.c
133  */
134 extern int umem_create_update_thread(void);
135 
136 /*
137  * envvar.c:
138  */
139 void umem_setup_envvars(int);
140 void umem_process_envvars(void);
141 
142 #ifdef	__cplusplus
143 }
144 #endif
145 
146 #endif	/* _UMEM_BASE_H */
147