11eaf0ac3Slogwang /*-
222ce4affSfengbojiang * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
322ce4affSfengbojiang *
41eaf0ac3Slogwang * Copyright (c) 2005 Robert N. M. Watson
51eaf0ac3Slogwang * All rights reserved.
61eaf0ac3Slogwang *
71eaf0ac3Slogwang * Redistribution and use in source and binary forms, with or without
81eaf0ac3Slogwang * modification, are permitted provided that the following conditions
91eaf0ac3Slogwang * are met:
101eaf0ac3Slogwang * 1. Redistributions of source code must retain the above copyright
111eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer.
121eaf0ac3Slogwang * 2. Redistributions in binary form must reproduce the above copyright
131eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer in the
141eaf0ac3Slogwang * documentation and/or other materials provided with the distribution.
151eaf0ac3Slogwang *
161eaf0ac3Slogwang * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
171eaf0ac3Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
181eaf0ac3Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
191eaf0ac3Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
201eaf0ac3Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
211eaf0ac3Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
221eaf0ac3Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
231eaf0ac3Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
241eaf0ac3Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
251eaf0ac3Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
261eaf0ac3Slogwang * SUCH DAMAGE.
271eaf0ac3Slogwang *
281eaf0ac3Slogwang * $FreeBSD$
291eaf0ac3Slogwang */
301eaf0ac3Slogwang
311eaf0ac3Slogwang #include <sys/types.h>
321eaf0ac3Slogwang #include <sys/queue.h>
331eaf0ac3Slogwang
34*d4a07e70Sfengbojiang #ifdef FSTACK
35*d4a07e70Sfengbojiang #include <stdint.h>
36*d4a07e70Sfengbojiang #endif
37*d4a07e70Sfengbojiang
381eaf0ac3Slogwang #include "memstat.h"
391eaf0ac3Slogwang
401eaf0ac3Slogwang /*
411eaf0ac3Slogwang * Query all available memory allocator sources. Currently this consists of
421eaf0ac3Slogwang * malloc(9) and UMA(9).
431eaf0ac3Slogwang */
441eaf0ac3Slogwang int
memstat_sysctl_all(struct memory_type_list * mtlp,int flags)451eaf0ac3Slogwang memstat_sysctl_all(struct memory_type_list *mtlp, int flags)
461eaf0ac3Slogwang {
471eaf0ac3Slogwang
481eaf0ac3Slogwang if (memstat_sysctl_malloc(mtlp, flags) < 0)
491eaf0ac3Slogwang return (-1);
501eaf0ac3Slogwang if (memstat_sysctl_uma(mtlp, flags) < 0)
511eaf0ac3Slogwang return (-1);
521eaf0ac3Slogwang return (0);
531eaf0ac3Slogwang }
541eaf0ac3Slogwang
55*d4a07e70Sfengbojiang #ifndef FSTACK
561eaf0ac3Slogwang int
memstat_kvm_all(struct memory_type_list * mtlp,void * kvm_handle)571eaf0ac3Slogwang memstat_kvm_all(struct memory_type_list *mtlp, void *kvm_handle)
581eaf0ac3Slogwang {
591eaf0ac3Slogwang
601eaf0ac3Slogwang if (memstat_kvm_malloc(mtlp, kvm_handle) < 0)
611eaf0ac3Slogwang return (-1);
621eaf0ac3Slogwang if (memstat_kvm_uma(mtlp, kvm_handle) < 0)
631eaf0ac3Slogwang return (-1);
641eaf0ac3Slogwang return (0);
651eaf0ac3Slogwang }
66*d4a07e70Sfengbojiang #endif
67*d4a07e70Sfengbojiang
68