Date: Thu, 25 Jan 2024 15:03:04 GMT From: Mark Johnston <markj@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: f4524aff6d66 - stable/13 - top: Avoid printing a blank line when the ZFS ARC is empty Message-ID: <202401251503.40PF34ck057362@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=f4524aff6d66edbfb7b3f184118b0a4299c4b1af commit f4524aff6d66edbfb7b3f184118b0a4299c4b1af Author: Mark Johnston <markj@FreeBSD.org> AuthorDate: 2024-01-11 14:58:31 +0000 Commit: Mark Johnston <markj@FreeBSD.org> CommitDate: 2024-01-25 14:58:44 +0000 top: Avoid printing a blank line when the ZFS ARC is empty PR: 275994 MFC after: 2 weeks (cherry picked from commit 1f62718d8ba26d813d8c2e826ac5f4caee4c6730) --- usr.bin/top/machine.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c index b4cd29dab878..a76d77a80ce4 100644 --- a/usr.bin/top/machine.c +++ b/usr.bin/top/machine.c @@ -293,17 +293,27 @@ machine_init(struct statics *statics) size = sizeof(carc_en); if (arc_enabled && sysctlbyname("vfs.zfs.compressed_arc_enabled", &carc_en, &size, - NULL, 0) == 0 && carc_en == 1) - carc_enabled = 1; + NULL, 0) == 0 && carc_en == 1) { + uint64_t uncomp_sz; + + /* + * Don't report compression stats if no data is in the ARC. + * Otherwise, we end up printing a blank line. + */ + size = sizeof(uncomp_sz); + if (sysctlbyname("kstat.zfs.misc.arcstats.uncompressed_size", + &uncomp_sz, &size, NULL, 0) == 0 && uncomp_sz != 0) + carc_enabled = 1; + } kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open"); if (kd == NULL) return (-1); size = sizeof(nswapdev); - if (sysctlbyname("vm.nswapdev", &nswapdev, &size, NULL, - 0) == 0 && nswapdev != 0) - has_swap = 1; + if (sysctlbyname("vm.nswapdev", &nswapdev, &size, NULL, 0) == 0 && + nswapdev != 0) + has_swap = 1; GETSYSCTL("kern.ccpu", ccpu);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202401251503.40PF34ck057362>