summaryrefslogtreecommitdiff
path: root/rts/sm/BlockAlloc.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2009-12-02 12:38:06 +0000
committerSimon Marlow <marlowsd@gmail.com>2009-12-02 12:38:06 +0000
commitf6013eedb4dea47afac8167dfa08561ae90454db (patch)
tree31c1b07b14e86f60b2af3187f9ce0ec2ed3e0ca1 /rts/sm/BlockAlloc.c
parent51741bdea146fbc65ad3509c8f97a5ebff1433de (diff)
downloadhaskell-f6013eedb4dea47afac8167dfa08561ae90454db.tar.gz
Refactoring only
Diffstat (limited to 'rts/sm/BlockAlloc.c')
-rw-r--r--rts/sm/BlockAlloc.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c
index d30d29b2f5..898624a267 100644
--- a/rts/sm/BlockAlloc.c
+++ b/rts/sm/BlockAlloc.c
@@ -629,6 +629,40 @@ initMBlock(void *mblock)
}
/* -----------------------------------------------------------------------------
+ Stats / metrics
+ -------------------------------------------------------------------------- */
+
+nat
+countBlocks(bdescr *bd)
+{
+ nat n;
+ for (n=0; bd != NULL; bd=bd->link) {
+ n += bd->blocks;
+ }
+ return n;
+}
+
+// (*1) Just like countBlocks, except that we adjust the count for a
+// megablock group so that it doesn't include the extra few blocks
+// that would be taken up by block descriptors in the second and
+// subsequent megablock. This is so we can tally the count with the
+// number of blocks allocated in the system, for memInventory().
+nat
+countAllocdBlocks(bdescr *bd)
+{
+ nat n;
+ for (n=0; bd != NULL; bd=bd->link) {
+ n += bd->blocks;
+ // hack for megablock groups: see (*1) above
+ if (bd->blocks > BLOCKS_PER_MBLOCK) {
+ n -= (MBLOCK_SIZE / BLOCK_SIZE - BLOCKS_PER_MBLOCK)
+ * (bd->blocks/(MBLOCK_SIZE/BLOCK_SIZE));
+ }
+ }
+ return n;
+}
+
+/* -----------------------------------------------------------------------------
Debugging
-------------------------------------------------------------------------- */