On 02/09/15(Wed) 08:45, trondd wrote:
> I just noticed on my -current systems, memory reporting from netstat -m
> seems to show that memory is overcommited.
>
> $ netstat -m
> 535 mbufs in use:
> 289 mbufs allocated to data
> 8 mbufs allocated to packet headers
> 238 mbufs allocated to socket names and addresses
> 171/288/6144 mbuf 2048 byte clusters in use (current/peak/max)
> 0/8/6144 mbuf 4096 byte clusters in use (current/peak/max)
> 0/8/6144 mbuf 8192 byte clusters in use (current/peak/max)
> 0/14/6146 mbuf 9216 byte clusters in use (current/peak/max)
> 0/10/6150 mbuf 12288 byte clusters in use (current/peak/max)
> 0/8/6144 mbuf 16384 byte clusters in use (current/peak/max)
> 0/8/6144 mbuf 65536 byte clusters in use (current/peak/max)
> 272 Kbytes allocated to network (174% in use) <-------
> 0 requests for memory denied
> 0 requests for memory delayed
> 0 calls to protocol drain routines
>
> I see this on all -current systems, but not on 5.7-stable. I didn't see
> this on my system that was last updated to -current July 26.
> It does change the allocated Kbytes eventually but I saw it as high as 280%
> and rarely below 100%.
This is a side effect of the *8 pool change. Diff below fixes it, ok?
Index: mbuf.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/mbuf.c,v
retrieving revision 1.35
diff -u -p -r1.35 mbuf.c
--- mbuf.c 20 Jan 2015 18:26:57 -0000 1.35
+++ mbuf.c 3 Sep 2015 10:33:05 -0000
@@ -84,7 +84,6 @@ mbpr(void)
struct kinfo_pool pool;
struct mbtypes *mp;
size_t size;
- int page_size = getpagesize();
if (nmbtypes != 256) {
fprintf(stderr,
@@ -167,19 +166,22 @@ mbpr(void)
mbstat.m_mtypes[i],
plural(mbstat.m_mtypes[i]), i);
}
- totmem = (mbpool.pr_npages * (unsigned long)page_size);
+ totmem = (mbpool.pr_npages * mbpool.pr_pgsize);
totused = mbpool.pr_nout * mbpool.pr_size;
for (i = 0; i < mclp; i++) {
- printf("%u/%lu/%lu mbuf %d byte clusters in use
(current/peak/max)\n",
+ printf("%u/%lu/%lu mbuf %d byte clusters in use"
+ " (current/peak/max)\n",
mclpools[i].pr_nout,
- (u_long)mclpools[i].pr_hiwat * mclpools[i].pr_itemsperpage,
- (u_long)mclpools[i].pr_maxpages *
mclpools[i].pr_itemsperpage,
+ (unsigned long)
+ (mclpools[i].pr_hiwat * mclpools[i].pr_itemsperpage),
+ (unsigned long)
+ (mclpools[i].pr_maxpages * mclpools[i].pr_itemsperpage),
mclpools[i].pr_size);
- totmem += (mclpools[i].pr_npages * (unsigned long)page_size);
+ totmem += (mclpools[i].pr_npages * mclpools[i].pr_pgsize);
totused += mclpools[i].pr_nout * mclpools[i].pr_size;
}
- totpct = (totmem == 0)? 0 : (totused/(totmem / 100));
+ totpct = (totmem == 0) ? 0 : (totused/(totmem / 100));
printf("%lu Kbytes allocated to network (%d%% in use)\n",
totmem / 1024, totpct);
printf("%lu requests for memory denied\n", mbstat.m_drops);