11eaf0ac3Slogwang /*-
222ce4affSfengbojiang * SPDX-License-Identifier: BSD-4-Clause
322ce4affSfengbojiang *
41eaf0ac3Slogwang * Copyright (c) 1983, 1988, 1993
51eaf0ac3Slogwang * The Regents of the University of California.
61eaf0ac3Slogwang * Copyright (c) 2005 Robert N. M. Watson
71eaf0ac3Slogwang * All rights reserved.
81eaf0ac3Slogwang *
91eaf0ac3Slogwang * Redistribution and use in source and binary forms, with or without
101eaf0ac3Slogwang * modification, are permitted provided that the following conditions
111eaf0ac3Slogwang * are met:
121eaf0ac3Slogwang * 1. Redistributions of source code must retain the above copyright
131eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer.
141eaf0ac3Slogwang * 2. Redistributions in binary form must reproduce the above copyright
151eaf0ac3Slogwang * notice, this list of conditions and the following disclaimer in the
161eaf0ac3Slogwang * documentation and/or other materials provided with the distribution.
171eaf0ac3Slogwang * 3. All advertising materials mentioning features or use of this software
181eaf0ac3Slogwang * must display the following acknowledgement:
191eaf0ac3Slogwang * This product includes software developed by the University of
201eaf0ac3Slogwang * California, Berkeley and its contributors.
211eaf0ac3Slogwang * 4. Neither the name of the University nor the names of its contributors
221eaf0ac3Slogwang * may be used to endorse or promote products derived from this software
231eaf0ac3Slogwang * without specific prior written permission.
241eaf0ac3Slogwang *
251eaf0ac3Slogwang * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
261eaf0ac3Slogwang * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
271eaf0ac3Slogwang * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
281eaf0ac3Slogwang * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
291eaf0ac3Slogwang * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
301eaf0ac3Slogwang * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
311eaf0ac3Slogwang * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
321eaf0ac3Slogwang * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
331eaf0ac3Slogwang * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
341eaf0ac3Slogwang * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
351eaf0ac3Slogwang * SUCH DAMAGE.
361eaf0ac3Slogwang */
371eaf0ac3Slogwang
381eaf0ac3Slogwang #if 0
391eaf0ac3Slogwang #ifndef lint
401eaf0ac3Slogwang static char sccsid[] = "@(#)mbuf.c 8.1 (Berkeley) 6/6/93";
411eaf0ac3Slogwang #endif /* not lint */
421eaf0ac3Slogwang #endif
431eaf0ac3Slogwang
44*d4a07e70Sfengbojiang #ifdef FSTACK
45*d4a07e70Sfengbojiang #include <stdint.h>
46*d4a07e70Sfengbojiang #endif
47*d4a07e70Sfengbojiang
481eaf0ac3Slogwang #include <sys/cdefs.h>
491eaf0ac3Slogwang __FBSDID("$FreeBSD$");
501eaf0ac3Slogwang
511eaf0ac3Slogwang #include <sys/param.h>
521eaf0ac3Slogwang #include <sys/mbuf.h>
531eaf0ac3Slogwang #include <sys/protosw.h>
541eaf0ac3Slogwang #include <sys/sf_buf.h>
551eaf0ac3Slogwang #include <sys/socket.h>
561eaf0ac3Slogwang #include <sys/socketvar.h>
571eaf0ac3Slogwang #include <sys/sysctl.h>
581eaf0ac3Slogwang
591eaf0ac3Slogwang #include <err.h>
60*d4a07e70Sfengbojiang #ifndef FSTACK
611eaf0ac3Slogwang #include <kvm.h>
62*d4a07e70Sfengbojiang #endif
631eaf0ac3Slogwang #include <memstat.h>
641eaf0ac3Slogwang #include <stdint.h>
651eaf0ac3Slogwang #include <stdio.h>
661eaf0ac3Slogwang #include <stdlib.h>
671eaf0ac3Slogwang #include <stdbool.h>
681eaf0ac3Slogwang #include <string.h>
691eaf0ac3Slogwang #include <libxo/xo.h>
701eaf0ac3Slogwang #include "netstat.h"
711eaf0ac3Slogwang
721eaf0ac3Slogwang /*
731eaf0ac3Slogwang * Print mbuf statistics.
741eaf0ac3Slogwang */
751eaf0ac3Slogwang void
mbpr(void * kvmd,u_long mbaddr)761eaf0ac3Slogwang mbpr(void *kvmd, u_long mbaddr)
771eaf0ac3Slogwang {
781eaf0ac3Slogwang struct memory_type_list *mtlp;
791eaf0ac3Slogwang struct memory_type *mtp;
801eaf0ac3Slogwang uintmax_t mbuf_count, mbuf_bytes, mbuf_free, mbuf_failures, mbuf_size;
811eaf0ac3Slogwang uintmax_t mbuf_sleeps;
821eaf0ac3Slogwang uintmax_t cluster_count, cluster_limit, cluster_free;
831eaf0ac3Slogwang uintmax_t cluster_failures, cluster_size, cluster_sleeps;
841eaf0ac3Slogwang uintmax_t packet_count, packet_bytes, packet_free, packet_failures;
851eaf0ac3Slogwang uintmax_t packet_sleeps;
861eaf0ac3Slogwang uintmax_t tag_bytes;
871eaf0ac3Slogwang uintmax_t jumbop_count, jumbop_limit, jumbop_free;
881eaf0ac3Slogwang uintmax_t jumbop_failures, jumbop_sleeps, jumbop_size;
891eaf0ac3Slogwang uintmax_t jumbo9_count, jumbo9_limit, jumbo9_free;
901eaf0ac3Slogwang uintmax_t jumbo9_failures, jumbo9_sleeps, jumbo9_size;
911eaf0ac3Slogwang uintmax_t jumbo16_count, jumbo16_limit, jumbo16_free;
921eaf0ac3Slogwang uintmax_t jumbo16_failures, jumbo16_sleeps, jumbo16_size;
931eaf0ac3Slogwang uintmax_t bytes_inuse, bytes_incache, bytes_total;
941eaf0ac3Slogwang int nsfbufs, nsfbufspeak, nsfbufsused;
951eaf0ac3Slogwang struct sfstat sfstat;
961eaf0ac3Slogwang size_t mlen;
97*d4a07e70Sfengbojiang #ifndef FSTACK
981eaf0ac3Slogwang int error;
99*d4a07e70Sfengbojiang #endif
1001eaf0ac3Slogwang
1011eaf0ac3Slogwang mtlp = memstat_mtl_alloc();
1021eaf0ac3Slogwang if (mtlp == NULL) {
1031eaf0ac3Slogwang xo_warn("memstat_mtl_alloc");
1041eaf0ac3Slogwang return;
1051eaf0ac3Slogwang }
1061eaf0ac3Slogwang
1071eaf0ac3Slogwang /*
1081eaf0ac3Slogwang * Use memstat_*_all() because some mbuf-related memory is in uma(9),
1091eaf0ac3Slogwang * and some malloc(9).
1101eaf0ac3Slogwang */
1111eaf0ac3Slogwang if (live) {
1121eaf0ac3Slogwang if (memstat_sysctl_all(mtlp, 0) < 0) {
1131eaf0ac3Slogwang xo_warnx("memstat_sysctl_all: %s",
1141eaf0ac3Slogwang memstat_strerror(memstat_mtl_geterror(mtlp)));
1151eaf0ac3Slogwang goto out;
1161eaf0ac3Slogwang }
1171eaf0ac3Slogwang } else {
118*d4a07e70Sfengbojiang #ifndef FSTACK
1191eaf0ac3Slogwang if (memstat_kvm_all(mtlp, kvmd) < 0) {
1201eaf0ac3Slogwang error = memstat_mtl_geterror(mtlp);
1211eaf0ac3Slogwang if (error == MEMSTAT_ERROR_KVM)
1221eaf0ac3Slogwang xo_warnx("memstat_kvm_all: %s",
1231eaf0ac3Slogwang kvm_geterr(kvmd));
1241eaf0ac3Slogwang else
1251eaf0ac3Slogwang xo_warnx("memstat_kvm_all: %s",
1261eaf0ac3Slogwang memstat_strerror(error));
1271eaf0ac3Slogwang goto out;
1281eaf0ac3Slogwang }
129*d4a07e70Sfengbojiang #endif
1301eaf0ac3Slogwang }
1311eaf0ac3Slogwang
1321eaf0ac3Slogwang mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_MEM_NAME);
1331eaf0ac3Slogwang if (mtp == NULL) {
1341eaf0ac3Slogwang xo_warnx("memstat_mtl_find: zone %s not found", MBUF_MEM_NAME);
1351eaf0ac3Slogwang goto out;
1361eaf0ac3Slogwang }
1371eaf0ac3Slogwang mbuf_count = memstat_get_count(mtp);
1381eaf0ac3Slogwang mbuf_bytes = memstat_get_bytes(mtp);
1391eaf0ac3Slogwang mbuf_free = memstat_get_free(mtp);
1401eaf0ac3Slogwang mbuf_failures = memstat_get_failures(mtp);
1411eaf0ac3Slogwang mbuf_sleeps = memstat_get_sleeps(mtp);
1421eaf0ac3Slogwang mbuf_size = memstat_get_size(mtp);
1431eaf0ac3Slogwang
1441eaf0ac3Slogwang mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_PACKET_MEM_NAME);
1451eaf0ac3Slogwang if (mtp == NULL) {
1461eaf0ac3Slogwang xo_warnx("memstat_mtl_find: zone %s not found",
1471eaf0ac3Slogwang MBUF_PACKET_MEM_NAME);
1481eaf0ac3Slogwang goto out;
1491eaf0ac3Slogwang }
1501eaf0ac3Slogwang packet_count = memstat_get_count(mtp);
1511eaf0ac3Slogwang packet_bytes = memstat_get_bytes(mtp);
1521eaf0ac3Slogwang packet_free = memstat_get_free(mtp);
1531eaf0ac3Slogwang packet_sleeps = memstat_get_sleeps(mtp);
1541eaf0ac3Slogwang packet_failures = memstat_get_failures(mtp);
1551eaf0ac3Slogwang
1561eaf0ac3Slogwang mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_CLUSTER_MEM_NAME);
1571eaf0ac3Slogwang if (mtp == NULL) {
1581eaf0ac3Slogwang xo_warnx("memstat_mtl_find: zone %s not found",
1591eaf0ac3Slogwang MBUF_CLUSTER_MEM_NAME);
1601eaf0ac3Slogwang goto out;
1611eaf0ac3Slogwang }
1621eaf0ac3Slogwang cluster_count = memstat_get_count(mtp);
1631eaf0ac3Slogwang cluster_limit = memstat_get_countlimit(mtp);
1641eaf0ac3Slogwang cluster_free = memstat_get_free(mtp);
1651eaf0ac3Slogwang cluster_failures = memstat_get_failures(mtp);
1661eaf0ac3Slogwang cluster_sleeps = memstat_get_sleeps(mtp);
1671eaf0ac3Slogwang cluster_size = memstat_get_size(mtp);
1681eaf0ac3Slogwang
1691eaf0ac3Slogwang mtp = memstat_mtl_find(mtlp, ALLOCATOR_MALLOC, MBUF_TAG_MEM_NAME);
1701eaf0ac3Slogwang if (mtp == NULL) {
1711eaf0ac3Slogwang xo_warnx("memstat_mtl_find: malloc type %s not found",
1721eaf0ac3Slogwang MBUF_TAG_MEM_NAME);
1731eaf0ac3Slogwang goto out;
1741eaf0ac3Slogwang }
1751eaf0ac3Slogwang tag_bytes = memstat_get_bytes(mtp);
1761eaf0ac3Slogwang
1771eaf0ac3Slogwang mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBOP_MEM_NAME);
1781eaf0ac3Slogwang if (mtp == NULL) {
1791eaf0ac3Slogwang xo_warnx("memstat_mtl_find: zone %s not found",
1801eaf0ac3Slogwang MBUF_JUMBOP_MEM_NAME);
1811eaf0ac3Slogwang goto out;
1821eaf0ac3Slogwang }
1831eaf0ac3Slogwang jumbop_count = memstat_get_count(mtp);
1841eaf0ac3Slogwang jumbop_limit = memstat_get_countlimit(mtp);
1851eaf0ac3Slogwang jumbop_free = memstat_get_free(mtp);
1861eaf0ac3Slogwang jumbop_failures = memstat_get_failures(mtp);
1871eaf0ac3Slogwang jumbop_sleeps = memstat_get_sleeps(mtp);
1881eaf0ac3Slogwang jumbop_size = memstat_get_size(mtp);
1891eaf0ac3Slogwang
1901eaf0ac3Slogwang mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO9_MEM_NAME);
1911eaf0ac3Slogwang if (mtp == NULL) {
1921eaf0ac3Slogwang xo_warnx("memstat_mtl_find: zone %s not found",
1931eaf0ac3Slogwang MBUF_JUMBO9_MEM_NAME);
1941eaf0ac3Slogwang goto out;
1951eaf0ac3Slogwang }
1961eaf0ac3Slogwang jumbo9_count = memstat_get_count(mtp);
1971eaf0ac3Slogwang jumbo9_limit = memstat_get_countlimit(mtp);
1981eaf0ac3Slogwang jumbo9_free = memstat_get_free(mtp);
1991eaf0ac3Slogwang jumbo9_failures = memstat_get_failures(mtp);
2001eaf0ac3Slogwang jumbo9_sleeps = memstat_get_sleeps(mtp);
2011eaf0ac3Slogwang jumbo9_size = memstat_get_size(mtp);
2021eaf0ac3Slogwang
2031eaf0ac3Slogwang mtp = memstat_mtl_find(mtlp, ALLOCATOR_UMA, MBUF_JUMBO16_MEM_NAME);
2041eaf0ac3Slogwang if (mtp == NULL) {
2051eaf0ac3Slogwang xo_warnx("memstat_mtl_find: zone %s not found",
2061eaf0ac3Slogwang MBUF_JUMBO16_MEM_NAME);
2071eaf0ac3Slogwang goto out;
2081eaf0ac3Slogwang }
2091eaf0ac3Slogwang jumbo16_count = memstat_get_count(mtp);
2101eaf0ac3Slogwang jumbo16_limit = memstat_get_countlimit(mtp);
2111eaf0ac3Slogwang jumbo16_free = memstat_get_free(mtp);
2121eaf0ac3Slogwang jumbo16_failures = memstat_get_failures(mtp);
2131eaf0ac3Slogwang jumbo16_sleeps = memstat_get_sleeps(mtp);
2141eaf0ac3Slogwang jumbo16_size = memstat_get_size(mtp);
2151eaf0ac3Slogwang
2161eaf0ac3Slogwang xo_open_container("mbuf-statistics");
2171eaf0ac3Slogwang
2181eaf0ac3Slogwang xo_emit("{:mbuf-current/%ju}/{:mbuf-cache/%ju}/{:mbuf-total/%ju} "
2191eaf0ac3Slogwang "{N:mbufs in use (current\\/cache\\/total)}\n",
2201eaf0ac3Slogwang mbuf_count + packet_count, mbuf_free + packet_free,
2211eaf0ac3Slogwang mbuf_count + packet_count + mbuf_free + packet_free);
2221eaf0ac3Slogwang
2231eaf0ac3Slogwang xo_emit("{:cluster-current/%ju}/{:cluster-cache/%ju}/"
2241eaf0ac3Slogwang "{:cluster-total/%ju}/{:cluster-max/%ju} "
2251eaf0ac3Slogwang "{N:mbuf clusters in use (current\\/cache\\/total\\/max)}\n",
2261eaf0ac3Slogwang cluster_count - packet_free, cluster_free + packet_free,
2271eaf0ac3Slogwang cluster_count + cluster_free, cluster_limit);
2281eaf0ac3Slogwang
2291eaf0ac3Slogwang xo_emit("{:packet-count/%ju}/{:packet-free/%ju} "
2301eaf0ac3Slogwang "{N:mbuf+clusters out of packet secondary zone in use "
2311eaf0ac3Slogwang "(current\\/cache)}\n",
2321eaf0ac3Slogwang packet_count, packet_free);
2331eaf0ac3Slogwang
2341eaf0ac3Slogwang xo_emit("{:jumbo-count/%ju}/{:jumbo-cache/%ju}/{:jumbo-total/%ju}/"
2351eaf0ac3Slogwang "{:jumbo-max/%ju} {:jumbo-page-size/%ju}{U:k} {N:(page size)} "
2361eaf0ac3Slogwang "{N:jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
2371eaf0ac3Slogwang jumbop_count, jumbop_free, jumbop_count + jumbop_free,
2381eaf0ac3Slogwang jumbop_limit, jumbop_size / 1024);
2391eaf0ac3Slogwang
2401eaf0ac3Slogwang xo_emit("{:jumbo9-count/%ju}/{:jumbo9-cache/%ju}/"
2411eaf0ac3Slogwang "{:jumbo9-total/%ju}/{:jumbo9-max/%ju} "
2421eaf0ac3Slogwang "{N:9k jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
2431eaf0ac3Slogwang jumbo9_count, jumbo9_free, jumbo9_count + jumbo9_free,
2441eaf0ac3Slogwang jumbo9_limit);
2451eaf0ac3Slogwang
2461eaf0ac3Slogwang xo_emit("{:jumbo16-count/%ju}/{:jumbo16-cache/%ju}/"
2471eaf0ac3Slogwang "{:jumbo16-total/%ju}/{:jumbo16-limit/%ju} "
2481eaf0ac3Slogwang "{N:16k jumbo clusters in use (current\\/cache\\/total\\/max)}\n",
2491eaf0ac3Slogwang jumbo16_count, jumbo16_free, jumbo16_count + jumbo16_free,
2501eaf0ac3Slogwang jumbo16_limit);
2511eaf0ac3Slogwang
2521eaf0ac3Slogwang #if 0
2531eaf0ac3Slogwang xo_emit("{:tag-count/%ju} {N:mbuf tags in use}\n", tag_count);
2541eaf0ac3Slogwang #endif
2551eaf0ac3Slogwang
2561eaf0ac3Slogwang /*-
2571eaf0ac3Slogwang * Calculate in-use bytes as:
2581eaf0ac3Slogwang * - straight mbuf memory
2591eaf0ac3Slogwang * - mbuf memory in packets
2601eaf0ac3Slogwang * - the clusters attached to packets
2611eaf0ac3Slogwang * - and the rest of the non-packet-attached clusters.
2621eaf0ac3Slogwang * - m_tag memory
2631eaf0ac3Slogwang * This avoids counting the clusters attached to packets in the cache.
2641eaf0ac3Slogwang * This currently excludes sf_buf space.
2651eaf0ac3Slogwang */
2661eaf0ac3Slogwang bytes_inuse =
2671eaf0ac3Slogwang mbuf_bytes + /* straight mbuf memory */
2681eaf0ac3Slogwang packet_bytes + /* mbufs in packets */
2691eaf0ac3Slogwang (packet_count * cluster_size) + /* clusters in packets */
2701eaf0ac3Slogwang /* other clusters */
2711eaf0ac3Slogwang ((cluster_count - packet_count - packet_free) * cluster_size) +
2721eaf0ac3Slogwang tag_bytes +
2731eaf0ac3Slogwang (jumbop_count * jumbop_size) + /* jumbo clusters */
2741eaf0ac3Slogwang (jumbo9_count * jumbo9_size) +
2751eaf0ac3Slogwang (jumbo16_count * jumbo16_size);
2761eaf0ac3Slogwang
2771eaf0ac3Slogwang /*
2781eaf0ac3Slogwang * Calculate in-cache bytes as:
2791eaf0ac3Slogwang * - cached straught mbufs
2801eaf0ac3Slogwang * - cached packet mbufs
2811eaf0ac3Slogwang * - cached packet clusters
2821eaf0ac3Slogwang * - cached straight clusters
2831eaf0ac3Slogwang * This currently excludes sf_buf space.
2841eaf0ac3Slogwang */
2851eaf0ac3Slogwang bytes_incache =
2861eaf0ac3Slogwang (mbuf_free * mbuf_size) + /* straight free mbufs */
2871eaf0ac3Slogwang (packet_free * mbuf_size) + /* mbufs in free packets */
2881eaf0ac3Slogwang (packet_free * cluster_size) + /* clusters in free packets */
2891eaf0ac3Slogwang (cluster_free * cluster_size) + /* free clusters */
2901eaf0ac3Slogwang (jumbop_free * jumbop_size) + /* jumbo clusters */
2911eaf0ac3Slogwang (jumbo9_free * jumbo9_size) +
2921eaf0ac3Slogwang (jumbo16_free * jumbo16_size);
2931eaf0ac3Slogwang
2941eaf0ac3Slogwang /*
2951eaf0ac3Slogwang * Total is bytes in use + bytes in cache. This doesn't take into
2961eaf0ac3Slogwang * account various other misc data structures, overhead, etc, but
2971eaf0ac3Slogwang * gives the user something useful despite that.
2981eaf0ac3Slogwang */
2991eaf0ac3Slogwang bytes_total = bytes_inuse + bytes_incache;
3001eaf0ac3Slogwang
3011eaf0ac3Slogwang xo_emit("{:bytes-in-use/%ju}{U:K}/{:bytes-in-cache/%ju}{U:K}/"
3021eaf0ac3Slogwang "{:bytes-total/%ju}{U:K} "
3031eaf0ac3Slogwang "{N:bytes allocated to network (current\\/cache\\/total)}\n",
3041eaf0ac3Slogwang bytes_inuse / 1024, bytes_incache / 1024, bytes_total / 1024);
3051eaf0ac3Slogwang
3061eaf0ac3Slogwang xo_emit("{:mbuf-failures/%ju}/{:cluster-failures/%ju}/"
3071eaf0ac3Slogwang "{:packet-failures/%ju} {N:requests for mbufs denied "
3081eaf0ac3Slogwang "(mbufs\\/clusters\\/mbuf+clusters)}\n",
3091eaf0ac3Slogwang mbuf_failures, cluster_failures, packet_failures);
3101eaf0ac3Slogwang xo_emit("{:mbuf-sleeps/%ju}/{:cluster-sleeps/%ju}/{:packet-sleeps/%ju} "
3111eaf0ac3Slogwang "{N:requests for mbufs delayed "
3121eaf0ac3Slogwang "(mbufs\\/clusters\\/mbuf+clusters)}\n",
3131eaf0ac3Slogwang mbuf_sleeps, cluster_sleeps, packet_sleeps);
3141eaf0ac3Slogwang
3151eaf0ac3Slogwang xo_emit("{:jumbop-sleeps/%ju}/{:jumbo9-sleeps/%ju}/"
3161eaf0ac3Slogwang "{:jumbo16-sleeps/%ju} {N:/requests for jumbo clusters delayed "
3171eaf0ac3Slogwang "(%juk\\/9k\\/16k)}\n",
3181eaf0ac3Slogwang jumbop_sleeps, jumbo9_sleeps, jumbo16_sleeps, jumbop_size / 1024);
3191eaf0ac3Slogwang xo_emit("{:jumbop-failures/%ju}/{:jumbo9-failures/%ju}/"
3201eaf0ac3Slogwang "{:jumbo16-failures/%ju} {N:/requests for jumbo clusters denied "
3211eaf0ac3Slogwang "(%juk\\/9k\\/16k)}\n",
3221eaf0ac3Slogwang jumbop_failures, jumbo9_failures, jumbo16_failures,
3231eaf0ac3Slogwang jumbop_size / 1024);
3241eaf0ac3Slogwang
3251eaf0ac3Slogwang mlen = sizeof(nsfbufs);
3261eaf0ac3Slogwang if (live &&
3271eaf0ac3Slogwang sysctlbyname("kern.ipc.nsfbufs", &nsfbufs, &mlen, NULL, 0) == 0 &&
3281eaf0ac3Slogwang sysctlbyname("kern.ipc.nsfbufsused", &nsfbufsused, &mlen,
3291eaf0ac3Slogwang NULL, 0) == 0 &&
3301eaf0ac3Slogwang sysctlbyname("kern.ipc.nsfbufspeak", &nsfbufspeak, &mlen,
3311eaf0ac3Slogwang NULL, 0) == 0)
3321eaf0ac3Slogwang xo_emit("{:nsfbufs-current/%d}/{:nsfbufs-peak/%d}/"
3331eaf0ac3Slogwang "{:nsfbufs/%d} "
3341eaf0ac3Slogwang "{N:sfbufs in use (current\\/peak\\/max)}\n",
3351eaf0ac3Slogwang nsfbufsused, nsfbufspeak, nsfbufs);
3361eaf0ac3Slogwang
3371eaf0ac3Slogwang if (fetch_stats("kern.ipc.sfstat", mbaddr, &sfstat, sizeof(sfstat),
3381eaf0ac3Slogwang kread_counters) != 0)
3391eaf0ac3Slogwang goto out;
3401eaf0ac3Slogwang
3411eaf0ac3Slogwang xo_emit("{:sendfile-syscalls/%ju} {N:sendfile syscalls}\n",
3421eaf0ac3Slogwang (uintmax_t)sfstat.sf_syscalls);
3431eaf0ac3Slogwang xo_emit("{:sendfile-no-io/%ju} "
3441eaf0ac3Slogwang "{N:sendfile syscalls completed without I\\/O request}\n",
3451eaf0ac3Slogwang (uintmax_t)sfstat.sf_noiocnt);
3461eaf0ac3Slogwang xo_emit("{:sendfile-io-count/%ju} "
3471eaf0ac3Slogwang "{N:requests for I\\/O initiated by sendfile}\n",
3481eaf0ac3Slogwang (uintmax_t)sfstat.sf_iocnt);
3491eaf0ac3Slogwang xo_emit("{:sendfile-pages-sent/%ju} "
3501eaf0ac3Slogwang "{N:pages read by sendfile as part of a request}\n",
3511eaf0ac3Slogwang (uintmax_t)sfstat.sf_pages_read);
3521eaf0ac3Slogwang xo_emit("{:sendfile-pages-valid/%ju} "
3531eaf0ac3Slogwang "{N:pages were valid at time of a sendfile request}\n",
3541eaf0ac3Slogwang (uintmax_t)sfstat.sf_pages_valid);
35522ce4affSfengbojiang xo_emit("{:sendfile-pages-bogus/%ju} "
35622ce4affSfengbojiang "{N:pages were valid and substituted to bogus page}\n",
35722ce4affSfengbojiang (uintmax_t)sfstat.sf_pages_bogus);
3581eaf0ac3Slogwang xo_emit("{:sendfile-requested-readahead/%ju} "
3591eaf0ac3Slogwang "{N:pages were requested for read ahead by applications}\n",
3601eaf0ac3Slogwang (uintmax_t)sfstat.sf_rhpages_requested);
3611eaf0ac3Slogwang xo_emit("{:sendfile-readahead/%ju} "
3621eaf0ac3Slogwang "{N:pages were read ahead by sendfile}\n",
3631eaf0ac3Slogwang (uintmax_t)sfstat.sf_rhpages_read);
3641eaf0ac3Slogwang xo_emit("{:sendfile-busy-encounters/%ju} "
3651eaf0ac3Slogwang "{N:times sendfile encountered an already busy page}\n",
3661eaf0ac3Slogwang (uintmax_t)sfstat.sf_busy);
3671eaf0ac3Slogwang xo_emit("{:sfbufs-alloc-failed/%ju} {N:requests for sfbufs denied}\n",
3681eaf0ac3Slogwang (uintmax_t)sfstat.sf_allocfail);
3691eaf0ac3Slogwang xo_emit("{:sfbufs-alloc-wait/%ju} {N:requests for sfbufs delayed}\n",
3701eaf0ac3Slogwang (uintmax_t)sfstat.sf_allocwait);
3711eaf0ac3Slogwang out:
3721eaf0ac3Slogwang xo_close_container("mbuf-statistics");
3731eaf0ac3Slogwang memstat_mtl_free(mtlp);
3741eaf0ac3Slogwang }
375