Correct two libmemstat(3) bugs:
- Move memory_type_list flushing logic from memstat_mtl_free() to _memstat_mtl_empty(), a libmemstat-internal function that can be called from other parts of the library. Invoke _memstat_mtl_empty() from memstat_mtl_free(), which also frees the containing list structure. Invoke _memstat_mtl_empty() instead of memstat_mtl_free() in various error cases in memstat_malloc.c and memstat_uma.c, which previously resulted in the list being freed prematurely. - Reverse the order of updating the mt_kegfree and mt_free fields of the memory_type in memstat_uma.c, otherwise keg free items won't be counted properly for non-secondary zones. MFC after: 3 days
This commit is contained in:
parent
e1d9e33240
commit
22247a2a38
|
@ -88,7 +88,7 @@ memstat_mtl_next(struct memory_type *mtp)
|
|||
}
|
||||
|
||||
void
|
||||
memstat_mtl_free(struct memory_type_list *list)
|
||||
_memstat_mtl_empty(struct memory_type_list *list)
|
||||
{
|
||||
struct memory_type *mtp;
|
||||
|
||||
|
@ -96,6 +96,13 @@ memstat_mtl_free(struct memory_type_list *list)
|
|||
LIST_REMOVE(mtp, mt_list);
|
||||
free(mtp);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
memstat_mtl_free(struct memory_type_list *list)
|
||||
{
|
||||
|
||||
_memstat_mtl_empty(list);
|
||||
free(list);
|
||||
}
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@ struct memory_type_list {
|
|||
int mtl_error;
|
||||
};
|
||||
|
||||
void _memstat_mtl_empty(struct memory_type_list *list);
|
||||
struct memory_type *_memstat_mt_allocate(struct memory_type_list *list,
|
||||
int allocator, const char *name);
|
||||
void _memstat_mt_reset_stats(struct memory_type *mtp);
|
||||
|
|
|
@ -175,7 +175,7 @@ retry:
|
|||
mtp = _memstat_mt_allocate(list, ALLOCATOR_MALLOC,
|
||||
mthp->mth_name);
|
||||
if (mtp == NULL) {
|
||||
memstat_mtl_free(list);
|
||||
_memstat_mtl_empty(list);
|
||||
free(buffer);
|
||||
list->mtl_error = MEMSTAT_ERROR_NOMEMORY;
|
||||
return (-1);
|
||||
|
|
|
@ -176,7 +176,7 @@ retry:
|
|||
mtp = _memstat_mt_allocate(list, ALLOCATOR_UMA,
|
||||
uthp->uth_name);
|
||||
if (mtp == NULL) {
|
||||
memstat_mtl_free(list);
|
||||
_memstat_mtl_empty(list);
|
||||
free(buffer);
|
||||
list->mtl_error = MEMSTAT_ERROR_NOMEMORY;
|
||||
return (-1);
|
||||
|
@ -218,8 +218,8 @@ retry:
|
|||
* items only in the primary zone.
|
||||
*/
|
||||
if (!(uthp->uth_zone_flags & UTH_ZONE_SECONDARY)) {
|
||||
mtp->mt_free += mtp->mt_kegfree;
|
||||
mtp->mt_kegfree = uthp->uth_keg_free;
|
||||
mtp->mt_free += mtp->mt_kegfree;
|
||||
}
|
||||
mtp->mt_free += mtp->mt_zonefree;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue