summaryrefslogtreecommitdiffstats
path: root/usr.bin
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
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')
-rw-r--r--usr.bin/netstat/mbuf.c18
-rw-r--r--usr.bin/systat/mbufs.c13
2 files changed, 12 insertions, 19 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));
diff --git a/usr.bin/systat/mbufs.c b/usr.bin/systat/mbufs.c
index df53e0c..1983e0a 100644
--- a/usr.bin/systat/mbufs.c
+++ b/usr.bin/systat/mbufs.c
@@ -50,7 +50,7 @@ static const char rcsid[] =
#include "extern.h"
static struct mbpstat **mbpstat;
-static int num_objs, ncpu;
+static int num_objs;
#define GENLST (num_objs - 1)
/* XXX: mbtypes stats temporarily disabled. */
@@ -150,8 +150,11 @@ showmbufs()
* Print total number of free mbufs.
*/
totfree = mbpstat[GENLST]->mb_mbfree;
- for (i = 0; i < ncpu; i++)
+ for (i = 0; i < (num_objs - 1); i++) {
+ if (mbpstat[i]->mb_active == 0)
+ continue;
totfree += mbpstat[i]->mb_mbfree;
+ }
j = 0; /* XXX */
if (totfree > 0) {
mvwprintw(wnd, 1+j, 0, "%-10.10s", "free");
@@ -189,12 +192,6 @@ initmbufs()
}
nmbtypes = mbtypeslen / sizeof(*m_mbtypes);
#endif
- len = sizeof(int);
- if (sysctlbyname("kern.smp.cpus", &ncpu, &len, NULL, 0) < 0 &&
- sysctlbyname("hw.ncpu", &ncpu, &len, NULL, 0) < 0) {
- error("sysctl getting number of cpus");
- return 0;
- }
if (sysctlbyname("kern.ipc.mb_statpcpu", NULL, &len, NULL, 0) < 0) {
error("sysctl getting mbpstat total size failed");
return 0;
OpenPOWER on IntegriCloud