/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
* Copyright (c) 2015 by Delphix. All rights reserved.
*/
#ifndef _UMEM_IMPL_H
#define _UMEM_IMPL_H
#include <umem.h>
#include <sys/sysmacros.h>
#include <thread.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* umem memory allocator: implementation-private data structures
*/
/*
* Internal flags for umem_cache_create
*/
/*
* Cache flags
*/
#define UMEM_SLEEP_FLAGS (0)
/*
* Redzone size encodings for umem_alloc() / umem_free(). We encode the
* allocation size, rather than storing it directly, so that umem_free()
* can distinguish frees of the wrong size from redzone violations.
*/
/*
* The bufctl (buffer control) structure keeps some minimal information
* about each buffer: its address, its slab, and its current linkage,
* which is either on the slab's freelist (if the buffer is free), or
* on the cache's buf-to-bufctl hash table (if the buffer is allocated).
* In the case of non-hashed, or "raw", caches (the common case), only
* the freelist linkage is necessary: the buffer address is at a fixed
* offset from the bufctl address, and the slab is at the end of the page.
*
* NOTE: bc_next must be the first field; raw buffers have linkage only.
*/
typedef struct umem_bufctl {
/*
* The UMF_AUDIT version of the bufctl structure. The beginning of this
* structure must be identical to the normal bufctl structure so that
* pointers are interchangeable.
*/
/*
* umem_bufctl_audits must be allocated from a UMC_NOHASH cache, so we
* require that 2 of them, plus 2 buftags, plus a umem_slab_t, all fit on
* a single page.
*
* For ILP32, this is about 1000 frames.
* For LP64, this is about 490 frames.
*/
#define UMEM_BUFCTL_AUDIT_MAX_SIZE \
sizeof (umem_buftag_t), UMEM_BUFCTL_AUDIT_ALIGN))
#define UMEM_MAX_STACK_DEPTH \
UMEM_BUFCTL_AUDIT_SIZE_DEPTH(0)) / sizeof (uintptr_t))
typedef struct umem_bufctl_audit {
*(bcpp) = (umem_bufctl_audit_t *) \
#define UMEM_BUFCTL_AUDIT_SIZE \
/*
* A umem_buftag structure is appended to each buffer whenever any of the
* UMF_BUFTAG flags (UMF_DEADBEEF, UMF_REDZONE, UMF_VERIFY) are set.
*/
typedef struct umem_buftag {
typedef struct umem_slab {
} umem_slab_t;
((cp)->cache_hash_table + \
typedef struct umem_magazine {
void *mag_next;
/*
* The magazine types for fast per-cpu allocation
*/
typedef struct umem_magtype {
typedef struct umem_cpu_cache {
#ifndef _LP64
#endif
/*
* The magazine lists used in the depot.
*/
typedef struct umem_maglist {
struct umem_cache {
/*
* Statistics
*/
/*
* Cache properties
*/
/*
* Slab layer
*/
/*
* Depot layer
*/
/*
* Per-CPU layer
*/
};
typedef struct umem_cpu_log_header {
char *clh_current;
int clh_chunk;
int clh_hits;
sizeof (size_t) - 2 * sizeof (int)];
typedef struct umem_log_header {
char *lh_base;
int *lh_free;
int lh_nchunks;
int lh_head;
int lh_tail;
int lh_hits;
typedef struct umem_cpu {
} umem_cpu_t;
/*
* For 64 bits, buffers >= 16 bytes must be 16-byte aligned
*/
#ifdef _LP64
#else
#endif
#ifdef _LP64
#endif
#ifdef UMEM_STANDALONE
#endif
/*
* Private interface with libc for tcumem.
*/
extern uintptr_t _tmem_get_base(void);
extern int _tmem_get_nentries(void);
extern void _tmem_set_cleanup(void(*)(void *, int));
#ifdef __cplusplus
}
#endif
#endif /* _UMEM_IMPL_H */