public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry
@ 2013-03-12 17:26 Dimitris Papastamos
  2013-03-12 18:12 ` Mark Brown
  2013-03-13 11:13 ` Mark Brown
  0 siblings, 2 replies; 5+ messages in thread
From: Dimitris Papastamos @ 2013-03-12 17:26 UTC (permalink / raw)
  To: Mark Brown; +Cc: patches, linux-kernel

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

Signed-off-by: Dimitris Papastamos <dp@opensource.wolfsonmicro.com>
---
 Print the size in bytes instead of kB.

 drivers/base/regmap/regcache-rbtree.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/base/regmap/regcache-rbtree.c b/drivers/base/regmap/regcache-rbtree.c
index 461cff8..11011ec 100644
--- a/drivers/base/regmap/regcache-rbtree.c
+++ b/drivers/base/regmap/regcache-rbtree.c
@@ -138,15 +138,20 @@ 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;
 	int nodes = 0;
 	int registers = 0;
 	int this_registers, average;
 
 	map->lock(map);
 
+	mem_size = sizeof(*rbtree_ctx);
+
 	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 +166,8 @@ 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);
+	seq_printf(s, "%d nodes, %d registers, average %d registers, memory overhead %zuB\n",
+		   nodes, registers, average, mem_size);
 
 	map->unlock(map);
 
-- 
1.8.1.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry
  2013-03-12 17:26 [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry Dimitris Papastamos
@ 2013-03-12 18:12 ` Mark Brown
  2013-03-12 20:08   ` Dimitris Papastamos
  2013-03-13 11:13 ` Mark Brown
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2013-03-12 18:12 UTC (permalink / raw)
  To: Dimitris Papastamos; +Cc: patches, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 448 bytes --]

On Tue, Mar 12, 2013 at 05:26:49PM +0000, Dimitris Papastamos wrote:

> +	mem_size = sizeof(*rbtree_ctx);
> +
>  	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);

This appears to ignore the size of the node structure and only have the
root context and the data.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry
  2013-03-12 18:12 ` Mark Brown
@ 2013-03-12 20:08   ` Dimitris Papastamos
  0 siblings, 0 replies; 5+ messages in thread
From: Dimitris Papastamos @ 2013-03-12 20:08 UTC (permalink / raw)
  To: Mark Brown; +Cc: patches, linux-kernel

On Tue, Mar 12, 2013 at 06:12:47PM +0000, Mark Brown wrote:
> On Tue, Mar 12, 2013 at 05:26:49PM +0000, Dimitris Papastamos wrote:
> 
> > +	mem_size = sizeof(*rbtree_ctx);
> > +
> >  	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);
> 
> This appears to ignore the size of the node structure and only have the
> root context and the data.

I've got mem_size += sizeof(*n) which is the size of the rbnode.  That
contains the underlying rbtree node links.

Thanks,
Dimitris

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry
  2013-03-12 17:26 [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry Dimitris Papastamos
  2013-03-12 18:12 ` Mark Brown
@ 2013-03-13 11:13 ` Mark Brown
  2013-03-13 11:54   ` Dimitris Papastamos
  1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2013-03-13 11:13 UTC (permalink / raw)
  To: Dimitris Papastamos; +Cc: patches, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 304 bytes --]

On Tue, Mar 12, 2013 at 05:26:49PM +0000, Dimitris Papastamos wrote:
> Provide a feel of how much overhead the rbtree cache adds to
> the game.

Applied, with a tweak to the log to say "used X bytes" for clarity (it's
arguable if the cached data itself is overhead, depends on what you're
comparing to).

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry
  2013-03-13 11:13 ` Mark Brown
@ 2013-03-13 11:54   ` Dimitris Papastamos
  0 siblings, 0 replies; 5+ messages in thread
From: Dimitris Papastamos @ 2013-03-13 11:54 UTC (permalink / raw)
  To: Mark Brown; +Cc: patches, linux-kernel

On Wed, Mar 13, 2013 at 11:13:26AM +0000, Mark Brown wrote:
> On Tue, Mar 12, 2013 at 05:26:49PM +0000, Dimitris Papastamos wrote:
> > Provide a feel of how much overhead the rbtree cache adds to
> > the game.
> 
> Applied, with a tweak to the log to say "used X bytes" for clarity (it's
> arguable if the cached data itself is overhead, depends on what you're
> comparing to).

Aha yes, it makes sense.

Thanks,
Dimitris

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-03-13 11:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-12 17:26 [PATCH v2] regmap: Expose total memory consumption in the rbtree debugfs entry Dimitris Papastamos
2013-03-12 18:12 ` Mark Brown
2013-03-12 20:08   ` Dimitris Papastamos
2013-03-13 11:13 ` Mark Brown
2013-03-13 11:54   ` Dimitris Papastamos

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox