summaryrefslogtreecommitdiff
path: root/rc/bin/kmem
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2011-03-30 17:14:36 +0300
committerTaru Karttunen <taruti@taruti.net>2011-03-30 17:14:36 +0300
commit2959e1ede0ebc6fdffd7b8660f43c2ce14c9696f (patch)
treef6343b1ce11a8c87251dd27cf3d3e26b50693fa7 /rc/bin/kmem
parente463eb40363ff4c68b1d903f4e0cdd0ac1c5977f (diff)
Import sources from 2011-03-30 iso image - rc
Diffstat (limited to 'rc/bin/kmem')
-rwxr-xr-xrc/bin/kmem31
1 files changed, 31 insertions, 0 deletions
diff --git a/rc/bin/kmem b/rc/bin/kmem
new file mode 100755
index 000000000..573e70b89
--- /dev/null
+++ b/rc/bin/kmem
@@ -0,0 +1,31 @@
+#!/bin/rc
+# kmem [kernel] - print summary of allocate blocks in running kernel
+rfork e
+if(! ~ $#* 0 1){
+ echo 'usage: kmem [kernel]' >[1=2]
+ exit usage
+}
+
+if(~ $#* 1)
+ binary=$1
+
+echo 'kinit(); blocksummary()' | acid -k -lkernel -lpool -lleak $pid $binary | awk '
+ $1 == "block" {
+ addr=$6
+ size=$3
+ alloc=$4
+ total[alloc] += size
+ count[alloc]++
+ }
+ $1 == "summary" {
+ alloc=$2
+ cnt=$3
+ size=$4
+ total[alloc] += size
+ count[alloc] += cnt
+ }
+ END{
+ for(i in count)
+ printf("%6d %11d %s\n", count[i], total[i], i);
+ }
+' | sort -nr