changelog shortlog tags branches changeset files revisions annotate raw help

Mercurial > hg > plan9front / rc/bin/kmem

changeset 7243: 34f64dcbbc25
parent: efddda59690a
author: cinap_lenrek@felloff.net
date: Fri, 17 May 2019 18:14:10 +0200
permissions: -rwxr-xr-x
description: 7l: don't hardcode 4k pagesize, use INITRND
1 #!/bin/rc
2 # kmem [kernel] - print summary of allocate blocks in running kernel
3 rfork e
4 if(! ~ $#* 0 1){
5  echo 'usage: kmem [kernel]' >[1=2]
6  exit usage
7 }
8 
9 if(~ $#* 1)
10  binary=$1
11 
12 echo 'kinit(); blocksummary()' | acid -k -lkernel -lpool -lleak $pid $binary | awk '
13  $1 == "block" {
14  addr=$6
15  size=$3
16  alloc=$4
17  total[alloc] += size
18  count[alloc]++
19  }
20  $1 == "summary" {
21  alloc=$2
22  cnt=$3
23  size=$4
24  total[alloc] += size
25  count[alloc] += cnt
26  }
27  END{
28  for(i in count)
29  printf("%6d %11d %s\n", count[i], total[i], i);
30  }
31 ' | sort -nr