diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-01-05 00:52:14 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2018-01-05 00:52:14 +0100 |
commit | b437065950b5d0234358fcfe8495f6bdb0bf3003 (patch) | |
tree | dbed53ff75256bc401b50cd3b18ad14b321d10c4 /sys/src/9 | |
parent | d3e54ff2d9039c67f6fe7d99349e1c83b696b7ae (diff) |
stats: show amount of reclaimable pages (add -r flag)
reclaimable pages are user pages that are used for
caches like the image cache, mount cache and swap cache.
Diffstat (limited to 'sys/src/9')
-rw-r--r-- | sys/src/9/port/devswap.c | 6 | ||||
-rw-r--r-- | sys/src/9/port/portfns.h | 1 | ||||
-rw-r--r-- | sys/src/9/port/segment.c | 13 |
3 files changed, 19 insertions, 1 deletions
diff --git a/sys/src/9/port/devswap.c b/sys/src/9/port/devswap.c index ffcb2016b..7cd4446c1 100644 --- a/sys/src/9/port/devswap.c +++ b/sys/src/9/port/devswap.c @@ -517,25 +517,29 @@ static long swapread(Chan *c, void *va, long n, vlong off) { char tmp[256]; /* must be >= 18*NUMSIZE (Qswap) */ + ulong reclaim; switch((ulong)c->qid.path){ case Qdir: return devdirread(c, va, n, swapdir, nelem(swapdir), devgen); case Qswap: + reclaim = imagecached() + fscache.pgref + swapimage.pgref; snprint(tmp, sizeof tmp, "%llud memory\n" "%llud pagesize\n" "%lud kernel\n" "%lud/%lud user\n" "%lud/%lud swap\n" + "%lud/%lud reclaim\n" "%llud/%llud/%llud kernel malloc\n" "%llud/%llud/%llud kernel draw\n" "%llud/%llud/%llud kernel secret\n", (uvlong)conf.npage*BY2PG, (uvlong)BY2PG, conf.npage-conf.upages, - palloc.user-palloc.freecount-fscache.pgref-swapimage.pgref, palloc.user, + palloc.user-palloc.freecount-reclaim, palloc.user, conf.nswap-swapalloc.free, conf.nswap, + reclaim, palloc.user, (uvlong)mainmem->curalloc, (uvlong)mainmem->cursize, (uvlong)mainmem->maxsize, diff --git a/sys/src/9/port/portfns.h b/sys/src/9/port/portfns.h index c238c818e..5f60c1b9e 100644 --- a/sys/src/9/port/portfns.h +++ b/sys/src/9/port/portfns.h @@ -133,6 +133,7 @@ uintptr ibrk(uintptr, int); void ilock(Lock*); void interrupted(void); void iunlock(Lock*); +ulong imagecached(void); ulong imagereclaim(ulong); long incref(Ref*); void initseg(void); diff --git a/sys/src/9/port/segment.c b/sys/src/9/port/segment.c index bc16c3333..ca67c4b56 100644 --- a/sys/src/9/port/segment.c +++ b/sys/src/9/port/segment.c @@ -297,6 +297,19 @@ found: } ulong +imagecached(void) +{ + Image *i, *ie; + ulong np; + + np = 0; + ie = &imagealloc.list[conf.nimage]; + for(i = imagealloc.list; i < ie; i++) + np += i->pgref; + return np; +} + +ulong imagereclaim(ulong pages) { static Image *i, *ie; |