summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorbmilekic <bmilekic@FreeBSD.org>2001-07-26 18:47:46 +0000
committerbmilekic <bmilekic@FreeBSD.org>2001-07-26 18:47:46 +0000
commit0caeab3ccdc5926c530383c04c96653559f47400 (patch)
treec92cd4663cb459d84696efa19cbdcbe5005277c8 /usr.bin/netstat
parentd3c6cce7de3c0e2296ad3aaaec504d56bd72ca1b (diff)
downloadFreeBSD-src-0caeab3ccdc5926c530383c04c96653559f47400.zip
FreeBSD-src-0caeab3ccdc5926c530383c04c96653559f47400.tar.gz
- Do not handle the per-CPU containers in mbuf code as though the cpuids
were indices in a dense array. The cpuids are a sparse set and treat them as such, setting up containers only for CPUs activated during mb_init(). - Fix netstat(1) and systat(1) to treat the per-CPU stats area as a sparse map, in accordance with the above. This allows us to properly boot with certain CPUs disactivated. However, if we later decide to re-activate said CPUs, we will barf until we decide to implement CPU spinon/spinoff callback hooks to allow for said CPUs' per-CPU containers to get configured on their activation. Reported by: mjacob Partially (sys/ diffs) Submitted by: mjacob
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/mbuf.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/usr.bin/netstat/mbuf.c b/usr.bin/netstat/mbuf.c
index 9cf319b..2bfdb0b 100644
--- a/usr.bin/netstat/mbuf.c
+++ b/usr.bin/netstat/mbuf.c
@@ -102,7 +102,7 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
u_long mblimaddr, u_long cllimaddr, u_long cpusaddr, u_long pgsaddr,
u_long mbpaddr)
{
- int i, nmbufs, nmbclusters, ncpu, page_size, num_objs;
+ int i, nmbufs, nmbclusters, page_size, num_objs;
u_int mbuf_limit, clust_limit;
u_long totspace, totnum, totfree;
size_t mlen;
@@ -180,8 +180,6 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
goto err;
if (kread(cllimaddr, (char *)&clust_limit, sizeof(u_int)))
goto err;
- if (kread(cpusaddr, (char *)&ncpu, sizeof(int)))
- goto err;
if (kread(pgsaddr, (char *)&page_size, sizeof(int)))
goto err;
} else {
@@ -228,12 +226,6 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
goto err;
}
mlen = sizeof(int);
- if (sysctlbyname("kern.smp.cpus", &ncpu, &mlen, NULL, 0) < 0 &&
- sysctlbyname("hw.ncpu", &ncpu, &mlen, NULL, 0) < 0) {
- warn("sysctl: retrieving number of cpus");
- goto err;
- }
- mlen = sizeof(int);
if (sysctlbyname("hw.pagesize", &page_size, &mlen, NULL, 0)
< 0) {
warn("sysctl: retrieving hw.pagesize");
@@ -259,7 +251,9 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
totnum = mbpstat[GENLST]->mb_mbpgs * MBPERPG;
totfree = mbpstat[GENLST]->mb_mbfree;
totspace = mbpstat[GENLST]->mb_mbpgs * page_size;
- for (i = 0; i < ncpu; i++) {
+ for (i = 0; i < (num_objs - 1); i++) {
+ if (mbpstat[i]->mb_active == 0)
+ continue;
printf("\tCPU #%d list:\t%lu/%lu (in use/in pool)\n", i,
(mbpstat[i]->mb_mbpgs * MBPERPG - mbpstat[i]->mb_mbfree),
(mbpstat[i]->mb_mbpgs * MBPERPG));
@@ -281,7 +275,9 @@ mbpr(u_long mbaddr, u_long mbtaddr, u_long nmbcaddr, u_long nmbufaddr,
totnum = mbpstat[GENLST]->mb_clpgs * CLPERPG;
totfree = mbpstat[GENLST]->mb_clfree;
totspace = mbpstat[GENLST]->mb_clpgs * page_size;
- for (i = 0; i < ncpu; i++) {
+ for (i = 0; i < (num_objs - 1); i++) {
+ if (mbpstat[i]->mb_active == 0)
+ continue;
printf("\tCPU #%d list:\t%lu/%lu (in use/in pool)\n", i,
(mbpstat[i]->mb_clpgs * CLPERPG - mbpstat[i]->mb_clfree),
(mbpstat[i]->mb_clpgs * CLPERPG));
OpenPOWER on IntegriCloud