Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Oct 2022 02:00:52 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 38fe63afdc9d - stable/13 - vmstat: remove processor counting from getcpuinfo()
Message-ID:  <202210070200.29720qkJ050770@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=38fe63afdc9d4473629881c805d82c5034934c0d

commit 38fe63afdc9d4473629881c805d82c5034934c0d
Author:     Elliott Mitchell <ehem+freebsd@m5p.com>
AuthorDate: 2022-09-29 16:27:24 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2022-10-07 02:00:23 +0000

    vmstat: remove processor counting from getcpuinfo()
    
    (cherry picked from commit 42dc8696df5e3004ea65fd315aba500d269dbcbf)
---
 usr.bin/vmstat/vmstat.c | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 403dc6e2a054..5e04dc26ac6c 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -604,18 +604,17 @@ fill_vmtotal(struct vmtotal *vmtp)
 }
 
 /* Determine how many cpu columns, and what index they are in kern.cp_times */
-static int
+static void
 getcpuinfo(u_long *maskp, int *maxidp)
 {
 	long *times;
 	u_long mask;
 	size_t size;
-	int empty, i, j, maxcpu, maxid, ncpus;
+	int empty, i, j, maxcpu, maxid;
 
 	if (kd != NULL)
 		xo_errx(1, "not implemented");
 	mask = 0;
-	ncpus = 0;
 	size = sizeof(maxcpu);
 	mysysctl("kern.smp.maxcpus", &maxcpu, &size);
 	if (size != sizeof(maxcpu))
@@ -632,16 +631,13 @@ getcpuinfo(u_long *maskp, int *maxidp)
 			if (times[i * CPUSTATES + j] != 0)
 				empty = 0;
 		}
-		if (!empty) {
+		if (!empty)
 			mask |= (1ul << i);
-			ncpus++;
-		}
 	}
 	if (maskp)
 		*maskp = mask;
 	if (maxidp)
 		*maxidp = maxid;
-	return (ncpus);
 }
 
 
@@ -670,12 +666,11 @@ dovmstat(unsigned int interval, int reps)
 	u_long cpumask;
 	size_t size;
 	time_t uptime, halfuptime;
-	int ncpus, maxid, rate_adj, retval;
+	int maxid, rate_adj, retval;
 
 	uptime = getuptime() / 1000000000LL;
 	halfuptime = uptime / 2;
 	rate_adj = 1;
-	ncpus = 1;
 	maxid = 0;
 	cpumask = 0;
 
@@ -714,7 +709,7 @@ dovmstat(unsigned int interval, int reps)
 	}
 
 	if (Pflag) {
-		ncpus = getcpuinfo(&cpumask, &maxid);
+		getcpuinfo(&cpumask, &maxid);
 		size_cp_times = sizeof(long) * (maxid + 1) * CPUSTATES;
 		cur_cp_times = calloc(1, size_cp_times);
 		last_cp_times = calloc(1, size_cp_times);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202210070200.29720qkJ050770>