17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5789d94c2Sjwadams * Common Development and Distribution License (the "License"). 6789d94c2Sjwadams * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22789d94c2Sjwadams * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 25*4f364e7cSRobert Mustacchi /* 26*4f364e7cSRobert Mustacchi * Copyright (c) 2012, Joyent, Inc. All rights reserved. 27*4f364e7cSRobert Mustacchi */ 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #ifndef _UMEM_BASE_H 307c478bd9Sstevel@tonic-gate #define _UMEM_BASE_H 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #include <umem_impl.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #include "misc.h" 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate extern size_t pagesize; 417c478bd9Sstevel@tonic-gate #undef PAGESIZE 427c478bd9Sstevel@tonic-gate #define PAGESIZE pagesize 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * umem.c: non-tunables 467c478bd9Sstevel@tonic-gate */ 477c478bd9Sstevel@tonic-gate extern vmem_t *umem_memalign_arena; 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate extern int umem_ready; 507c478bd9Sstevel@tonic-gate extern thread_t umem_init_thr; /* the thread doing the init */ 517c478bd9Sstevel@tonic-gate 527c478bd9Sstevel@tonic-gate extern int umem_init(void); /* do umem's initialization */ 537c478bd9Sstevel@tonic-gate #pragma rarely_called(umem_init) 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate extern umem_log_header_t *umem_transaction_log; 567c478bd9Sstevel@tonic-gate extern umem_log_header_t *umem_content_log; 577c478bd9Sstevel@tonic-gate extern umem_log_header_t *umem_failure_log; 587c478bd9Sstevel@tonic-gate extern umem_log_header_t *umem_slab_log; 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate extern mutex_t umem_init_lock; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate extern mutex_t umem_cache_lock; 637c478bd9Sstevel@tonic-gate extern umem_cache_t umem_null_cache; 647c478bd9Sstevel@tonic-gate 657c478bd9Sstevel@tonic-gate extern mutex_t umem_flags_lock; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate extern mutex_t umem_update_lock; 687c478bd9Sstevel@tonic-gate extern cond_t umem_update_cv; 697c478bd9Sstevel@tonic-gate extern volatile thread_t umem_st_update_thr; 707c478bd9Sstevel@tonic-gate extern thread_t umem_update_thr; 717c478bd9Sstevel@tonic-gate extern struct timeval umem_update_next; 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate extern volatile hrtime_t umem_reap_next; 747c478bd9Sstevel@tonic-gate extern volatile uint32_t umem_reaping; 757c478bd9Sstevel@tonic-gate #define UMEM_REAP_DONE 0x00000000 /* inactive */ 767c478bd9Sstevel@tonic-gate #define UMEM_REAP_ADDING 0x00000001 /* umem_reap() is active */ 777c478bd9Sstevel@tonic-gate #define UMEM_REAP_ACTIVE 0x00000002 /* update thread is reaping */ 787c478bd9Sstevel@tonic-gate 79*4f364e7cSRobert Mustacchi extern uintptr_t umem_tmem_off; 80*4f364e7cSRobert Mustacchi 817c478bd9Sstevel@tonic-gate /* 827c478bd9Sstevel@tonic-gate * umem.c: tunables 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate extern uint32_t umem_max_ncpus; 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate extern uint32_t umem_stack_depth; 877c478bd9Sstevel@tonic-gate extern uint32_t umem_reap_interval; 887c478bd9Sstevel@tonic-gate extern uint32_t umem_update_interval; 897c478bd9Sstevel@tonic-gate extern uint32_t umem_depot_contention; 907c478bd9Sstevel@tonic-gate extern uint32_t umem_abort; 917c478bd9Sstevel@tonic-gate extern uint32_t umem_output; 927c478bd9Sstevel@tonic-gate extern uint32_t umem_logging; 937c478bd9Sstevel@tonic-gate extern uint32_t umem_mtbf; 947c478bd9Sstevel@tonic-gate extern size_t umem_transaction_log_size; 957c478bd9Sstevel@tonic-gate extern size_t umem_content_log_size; 967c478bd9Sstevel@tonic-gate extern size_t umem_failure_log_size; 977c478bd9Sstevel@tonic-gate extern size_t umem_slab_log_size; 987c478bd9Sstevel@tonic-gate extern size_t umem_content_maxsave; 997c478bd9Sstevel@tonic-gate extern size_t umem_lite_minsize; 1007c478bd9Sstevel@tonic-gate extern size_t umem_lite_maxalign; 1017c478bd9Sstevel@tonic-gate extern size_t umem_maxverify; 1027c478bd9Sstevel@tonic-gate extern size_t umem_minfirewall; 103*4f364e7cSRobert Mustacchi extern size_t umem_ptc_size; 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate extern uint32_t umem_flags; 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* 1087c478bd9Sstevel@tonic-gate * umem.c: Internal aliases (to avoid PLTs) 1097c478bd9Sstevel@tonic-gate */ 1107c478bd9Sstevel@tonic-gate extern void *_umem_alloc(size_t size, int umflags); 1117c478bd9Sstevel@tonic-gate extern void *_umem_zalloc(size_t size, int umflags); 1127c478bd9Sstevel@tonic-gate extern void _umem_free(void *buf, size_t size); 1137c478bd9Sstevel@tonic-gate 1147c478bd9Sstevel@tonic-gate extern void *_umem_cache_alloc(umem_cache_t *cache, int flags); 1157c478bd9Sstevel@tonic-gate extern void _umem_cache_free(umem_cache_t *cache, void *buffer); 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate /* 1187c478bd9Sstevel@tonic-gate * umem.c: private interfaces 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate extern void umem_type_init(caddr_t, size_t, size_t); 1217c478bd9Sstevel@tonic-gate extern int umem_get_max_ncpus(void); 1227c478bd9Sstevel@tonic-gate extern void umem_process_updates(void); 1237c478bd9Sstevel@tonic-gate extern void umem_cache_applyall(void (*)(umem_cache_t *)); 1247c478bd9Sstevel@tonic-gate extern void umem_cache_update(umem_cache_t *); 1257c478bd9Sstevel@tonic-gate 126789d94c2Sjwadams extern void umem_alloc_sizes_add(size_t); 127789d94c2Sjwadams extern void umem_alloc_sizes_clear(void); 128789d94c2Sjwadams extern void umem_alloc_sizes_remove(size_t); 129789d94c2Sjwadams 1307c478bd9Sstevel@tonic-gate /* 1317c478bd9Sstevel@tonic-gate * umem_fork.c: private interfaces 1327c478bd9Sstevel@tonic-gate */ 1337c478bd9Sstevel@tonic-gate extern void umem_forkhandler_init(void); 1347c478bd9Sstevel@tonic-gate 1357c478bd9Sstevel@tonic-gate /* 1367c478bd9Sstevel@tonic-gate * umem_update_thread.c 1377c478bd9Sstevel@tonic-gate */ 1387c478bd9Sstevel@tonic-gate extern int umem_create_update_thread(void); 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* 1417c478bd9Sstevel@tonic-gate * envvar.c: 1427c478bd9Sstevel@tonic-gate */ 1437c478bd9Sstevel@tonic-gate void umem_setup_envvars(int); 1447c478bd9Sstevel@tonic-gate void umem_process_envvars(void); 1457c478bd9Sstevel@tonic-gate 146*4f364e7cSRobert Mustacchi /* 147*4f364e7cSRobert Mustacchi * umem_genasm.c: private interfaces 148*4f364e7cSRobert Mustacchi */ 149*4f364e7cSRobert Mustacchi extern const int umem_genasm_supported; 150*4f364e7cSRobert Mustacchi extern int umem_genasm(int *, umem_cache_t **, int); 151*4f364e7cSRobert Mustacchi 152*4f364e7cSRobert Mustacchi /* 153*4f364e7cSRobert Mustacchi * malloc.c: traditional malloc/free interface for genasm 154*4f364e7cSRobert Mustacchi */ 155*4f364e7cSRobert Mustacchi extern void *umem_malloc(size_t); 156*4f364e7cSRobert Mustacchi extern void umem_malloc_free(void *); 157*4f364e7cSRobert Mustacchi extern void *_malloc(size_t); 158*4f364e7cSRobert Mustacchi extern void _free(void *); 159*4f364e7cSRobert Mustacchi 1607c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate #endif 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #endif /* _UMEM_BASE_H */ 165