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.
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.
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]
23 * Copyright (c) 2012, Joyent, Inc. All rights reserved.
27 #include "thr_uberdata.h"
30 * This file implements the private interface with libumem for per-thread
31 * caching umem (ptcumem). For the full details on how tcumem works and how
32 * these functions work, see section 8.4 of the big theory statement in
33 * lib/libumem/common/umem.c.
35 static tmem_func_t tmem_cleanup
= NULL
;
40 return ((uintptr_t)&curthread
->ul_tmem
- (uintptr_t)curthread
);
44 _tmem_get_nentries(void)
50 _tmem_set_cleanup(tmem_func_t f
)
56 * This is called by _thrp_exit() to clean up any per-thread allocations that
57 * are still hanging around and haven't been cleaned up.
64 tumem_t
*tp
= &curthread
->ul_tmem
;
71 * Since we have something stored here, we need to ensure we declared a
72 * clean up handler. If we haven't that's broken and our single private
73 * consumer should be shot.
75 if (tmem_cleanup
== NULL
)
77 for (ii
= 0; ii
< NTMEMBASE
; ii
++) {
78 buf
= tp
->tm_roots
[ii
];
81 tmem_cleanup(buf
, ii
);