linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tony Battersby <tonyb@cybernetics.com>
To: linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: iommu@lists.linux-foundation.org, kernel-team@fb.com,
	Matthew Wilcox <willy@infradead.org>,
	Keith Busch <kbusch@kernel.org>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Robin Murphy <robin.murphy@arm.com>,
	Tony Lindgren <tony@atomide.com>
Subject: [PATCH v6 05/11] dmapool: improve accuracy of debug statistics
Date: Tue, 7 Jun 2022 14:42:56 -0400	[thread overview]
Message-ID: <c918d44b-1822-b076-0833-7645a2079809@cybernetics.com> (raw)
In-Reply-To: <340ff8ef-9ff5-7175-c234-4132bbdfc5f7@cybernetics.com>

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.

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

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

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

 mm/dmapool.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/mm/dmapool.c b/mm/dmapool.c
index 122781fe2c03..d3e5a6151fb4 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -47,6 +47,7 @@ struct dma_pool {		/* the pool */
 	unsigned int size;
 	unsigned int allocation;
 	unsigned int boundary;
+	unsigned int blks_per_alloc;
 	char name[32];
 	struct list_head pools;
 };
@@ -85,8 +86,7 @@ static ssize_t pools_show(struct device *dev, struct device_attribute *attr, cha
 		/* per-pool info, no real statistics yet */
 		size += sysfs_emit_at(buf, 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);
 	}
 	mutex_unlock(&pools_lock);
@@ -159,6 +159,9 @@ struct dma_pool *dma_pool_create(const char *name, struct device *dev,
 	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);
 
-- 
2.25.1



  parent reply	other threads:[~2022-06-07 18:42 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-07 18:38 [PATCH v6 00/11] mpt3sas and dmapool scalability Tony Battersby
2022-06-07 18:39 ` [PATCH v6 01/11] dmapool: remove checks for dev == NULL Tony Battersby
2022-06-07 18:40 ` [PATCH v6 02/11] dmapool: use sysfs_emit() instead of scnprintf() Tony Battersby
2022-06-07 18:41 ` [PATCH v6 03/11] dmapool: cleanup integer types Tony Battersby
2022-06-07 18:42 ` [PATCH v6 04/11] dmapool: fix boundary comparison Tony Battersby
2022-06-07 18:42 ` Tony Battersby [this message]
2022-06-07 18:43 ` [PATCH v6 06/11] dmapool: debug: prevent endless loop in case of corruption Tony Battersby
2022-06-07 18:44 ` [PATCH v6 07/11] dmapool: ignore init_on_free when DMAPOOL_DEBUG enabled Tony Battersby
2022-06-07 18:44 ` [PATCH v6 08/11] dmapool: speedup DMAPOOL_DEBUG with init_on_alloc Tony Battersby
2022-06-07 18:45 ` [PATCH v6 09/11] dmapool: cleanup dma_pool_destroy Tony Battersby
2022-06-07 18:46 ` [PATCH v6 10/11] dmapool: improve scalability of dma_pool_alloc Tony Battersby
2022-06-07 18:46 ` [PATCH v6 11/11] dmapool: improve scalability of dma_pool_free Tony Battersby

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c918d44b-1822-b076-0833-7645a2079809@cybernetics.com \
    --to=tonyb@cybernetics.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=kbusch@kernel.org \
    --cc=kernel-team@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=robin.murphy@arm.com \
    --cc=tony@atomide.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox