Skip to contentSkip to conversation

regmap: Expose total memory consumption in the rbtree debugfs entry

PATCH Superseded Dimitris Papastamos 1 participant 1 message Mar 11, 2013

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 regmap: Expose total memory consumption in the rbtree debugfs entry

Provide a feel of how much overhead the rbtree cache adds to the game.

---
 drivers/base/regmap/regcache-rbtree.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/base/regmap/regcache-rbtree.c +10 -2
index 461cff8..7b732ad 100644
@@ -138,6 +138,7 @@ static int rbtree_show(struct seq_file *s, void *ignored)
 	struct regcache_rbtree_node *n;
 	struct rb_node *node;
 	unsigned int base, top;
+	size_t mem_size = sizeof(*rbtree_ctx);
 	int nodes = 0;
 	int registers = 0;
 	int this_registers, average;
@@ -147,6 +148,8 @@ static int rbtree_show(struct seq_file *s, void *ignored)
 	for (node = rb_first(&rbtree_ctx->root); node != NULL;
 	     node = rb_next(node)) {
 		n = container_of(node, struct regcache_rbtree_node, node);
+		mem_size += sizeof(*n);
+		mem_size += (n->blklen * map->cache_word_size);
 
 		regcache_rbtree_get_base_top_reg(map, n, &base, &top);
 		this_registers = ((top - base) / map->reg_stride) + 1;
@@ -161,8 +164,13 @@ static int rbtree_show(struct seq_file *s, void *ignored)
 	else
 		average = 0;
 
-	seq_printf(s, "%d nodes, %d registers, average %d registers\n",
-		   nodes, registers, average);
+	if (mem_size > 1024)
+		mem_size /= 1024;
+	else
+		mem_size = 1;
+
+	seq_printf(s, "%d nodes, %d registers, average %d registers, memory overhead %zukB\n",
+		   nodes, registers, average, mem_size);
 
 	map->unlock(map);
 
Signature · 1 line
1.8.1.5