All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 8/9] dmapool: improve accuracy of debug statistics
@ 2018-11-12 15:45 ` Tony Battersby
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Battersby @ 2018-11-12 15:45 UTC (permalink / raw)
  To: Matthew Wilcox, Christoph Hellwig, Marek Szyprowski,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	linux-mm-Bw31MaZKKs3YtjvyW6yDsg
  Cc: linux-scsi-u79uwXL29TY76Z2rM5mHXA

The "total number of blocks in pool" debug statistic currently does not
take the boundary value into account, so it diverges from the "total
number of blocks in use" statistic when a boundary is in effect.  Add a
calculation for the number of blocks per allocation that takes the
boundary into account, and use it to replace the inaccurate calculation.

Signed-off-by: Tony Battersby <tonyb-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
---

This depends on patch #1 "dmapool: fix boundary comparison" for the
calculated blks_per_alloc value to be correct.

The added blks_per_alloc value will also be used in the next patch.

--- linux/mm/dmapool.c.orig	2018-08-06 17:48:54.000000000 -0400
+++ linux/mm/dmapool.c	2018-08-06 17:52:53.000000000 -0400
@@ -61,6 +61,7 @@ struct dma_pool {		/* the pool */
 	struct device *dev;
 	unsigned int allocation;
 	unsigned int boundary;
+	unsigned int blks_per_alloc;
 	char name[32];
 	struct list_head pools;
 };
@@ -105,8 +106,7 @@ show_pools(struct device *dev, struct de
 		/* per-pool info, no real statistics yet */
 		temp = scnprintf(next, size, "%-16s %4zu %4zu %4u %2u\n",
 				 pool->name, blocks,
-				 (size_t) pages *
-				 (pool->allocation / pool->size),
+				 (size_t) pages * pool->blks_per_alloc,
 				 pool->size, pages);
 		size -= temp;
 		next += temp;
@@ -182,6 +182,9 @@ struct dma_pool *dma_pool_create(const c
 	retval->size = size;
 	retval->boundary = boundary;
 	retval->allocation = allocation;
+	retval->blks_per_alloc =
+		(allocation / boundary) * (boundary / size) +
+		(allocation % boundary) / size;
 
 	INIT_LIST_HEAD(&retval->pools);
 

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

* [PATCH v4 8/9] dmapool: improve accuracy of debug statistics
@ 2018-11-12 15:45 ` Tony Battersby
  0 siblings, 0 replies; 4+ messages in thread
From: Tony Battersby @ 2018-11-12 15:45 UTC (permalink / raw)
  To: Matthew Wilcox, Christoph Hellwig, Marek Szyprowski, iommu, linux-mm
  Cc: linux-scsi

The "total number of blocks in pool" debug statistic currently does not
take the boundary value into account, so it diverges from the "total
number of blocks in use" statistic when a boundary is in effect.  Add a
calculation for the number of blocks per allocation that takes the
boundary into account, and use it to replace the inaccurate calculation.

Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
---

This depends on patch #1 "dmapool: fix boundary comparison" for the
calculated blks_per_alloc value to be correct.

The added blks_per_alloc value will also be used in the next patch.

--- linux/mm/dmapool.c.orig	2018-08-06 17:48:54.000000000 -0400
+++ linux/mm/dmapool.c	2018-08-06 17:52:53.000000000 -0400
@@ -61,6 +61,7 @@ struct dma_pool {		/* the pool */
 	struct device *dev;
 	unsigned int allocation;
 	unsigned int boundary;
+	unsigned int blks_per_alloc;
 	char name[32];
 	struct list_head pools;
 };
@@ -105,8 +106,7 @@ show_pools(struct device *dev, struct de
 		/* per-pool info, no real statistics yet */
 		temp = scnprintf(next, size, "%-16s %4zu %4zu %4u %2u\n",
 				 pool->name, blocks,
-				 (size_t) pages *
-				 (pool->allocation / pool->size),
+				 (size_t) pages * pool->blks_per_alloc,
 				 pool->size, pages);
 		size -= temp;
 		next += temp;
@@ -182,6 +182,9 @@ struct dma_pool *dma_pool_create(const c
 	retval->size = size;
 	retval->boundary = boundary;
 	retval->allocation = allocation;
+	retval->blks_per_alloc =
+		(allocation / boundary) * (boundary / size) +
+		(allocation % boundary) / size;
 
 	INIT_LIST_HEAD(&retval->pools);
 

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

* Re: [PATCH v4 8/9] dmapool: improve accuracy of debug statistics
  2018-11-12 15:45 ` Tony Battersby
@ 2018-11-13  6:30     ` Matthew Wilcox
  -1 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2018-11-13  6:30 UTC (permalink / raw)
  To: Tony Battersby
  Cc: linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA,
	Christoph Hellwig, linux-scsi-u79uwXL29TY76Z2rM5mHXA

On Mon, Nov 12, 2018 at 10:45:58AM -0500, Tony Battersby wrote:
> +++ linux/mm/dmapool.c	2018-08-06 17:52:53.000000000 -0400
> @@ -61,6 +61,7 @@ struct dma_pool {		/* the pool */
>  	struct device *dev;
>  	unsigned int allocation;
>  	unsigned int boundary;
> +	unsigned int blks_per_alloc;
>  	char name[32];
>  	struct list_head pools;
>  };

This one I'm not totally happy with.  You're storing this value when
it could be easily calculated each time through the show_pools() code.
I appreciate this is a topic where reasonable people might have different
opinions about which solution is preferable.

> @@ -182,6 +182,9 @@ struct dma_pool *dma_pool_create(const c
>  	retval->size = size;
>  	retval->boundary = boundary;
>  	retval->allocation = allocation;
> +	retval->blks_per_alloc =
> +		(allocation / boundary) * (boundary / size) +
> +		(allocation % boundary) / size;
>  
>  	INIT_LIST_HEAD(&retval->pools);
>  
> 

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

* Re: [PATCH v4 8/9] dmapool: improve accuracy of debug statistics
@ 2018-11-13  6:30     ` Matthew Wilcox
  0 siblings, 0 replies; 4+ messages in thread
From: Matthew Wilcox @ 2018-11-13  6:30 UTC (permalink / raw)
  To: Tony Battersby
  Cc: Christoph Hellwig, Marek Szyprowski, iommu, linux-mm, linux-scsi

On Mon, Nov 12, 2018 at 10:45:58AM -0500, Tony Battersby wrote:
> +++ linux/mm/dmapool.c	2018-08-06 17:52:53.000000000 -0400
> @@ -61,6 +61,7 @@ struct dma_pool {		/* the pool */
>  	struct device *dev;
>  	unsigned int allocation;
>  	unsigned int boundary;
> +	unsigned int blks_per_alloc;
>  	char name[32];
>  	struct list_head pools;
>  };

This one I'm not totally happy with.  You're storing this value when
it could be easily calculated each time through the show_pools() code.
I appreciate this is a topic where reasonable people might have different
opinions about which solution is preferable.

> @@ -182,6 +182,9 @@ struct dma_pool *dma_pool_create(const c
>  	retval->size = size;
>  	retval->boundary = boundary;
>  	retval->allocation = allocation;
> +	retval->blks_per_alloc =
> +		(allocation / boundary) * (boundary / size) +
> +		(allocation % boundary) / size;
>  
>  	INIT_LIST_HEAD(&retval->pools);
>  
> 

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

end of thread, other threads:[~2018-11-13  6:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-12 15:45 [PATCH v4 8/9] dmapool: improve accuracy of debug statistics Tony Battersby
2018-11-12 15:45 ` Tony Battersby
     [not found] ` <bb0ee76c-78ac-b75b-b32d-8c94d881f7d6-vFAe+i1/wJI5UWNf+nJyDw@public.gmane.org>
2018-11-13  6:30   ` Matthew Wilcox
2018-11-13  6:30     ` Matthew Wilcox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.