From: Robin Murphy <robin.murphy@arm.com>
To: Tony Battersby <tonyb@cybernetics.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Tony Lindgren <tony@atomide.com>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
iommu@lists.linux-foundation.org, Keith Busch <kbusch@kernel.org>,
kernel-team@fb.com
Subject: Re: [PATCH 04/10] dmapool: improve accuracy of debug statistics
Date: Tue, 31 May 2022 22:55:57 +0100 [thread overview]
Message-ID: <417bd608-0eeb-b3a0-31e3-8e241ab75e59@arm.com> (raw)
In-Reply-To: <a57d3dde-ac45-be9c-5c16-263415060334@cybernetics.com>
On 2022-05-31 20:52, Tony Battersby wrote:
> On 5/31/22 15:48, Robin Murphy wrote:
>> On 2022-05-31 19:17, Tony Battersby wrote:
>>
>>> pool->name, blocks,
>>> - (size_t) pages *
>>> - (pool->allocation / pool->size),
>>> + (size_t) pages * pool->blks_per_alloc,
>>> pool->size, pages);
>>> size -= temp;
>>> next += temp;
>>> @@ -168,6 +168,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;
>> Do we really need to store this? Sure, 4 divisions (which could possibly
>> be fewer given the constraints on boundary) isn't the absolute cheapest
>> calculation, but I still can't imagine anyone would be polling sysfs
>> stats hard enough to even notice.
>>
> The stored value is also used in patch #5, in more performance-critical
> code, although only when debug is enabled.
Ah, fair enough. On second look I think 64-bit systems could effectively
store this for free anyway, if patch #2 moved "size" down past "dev" in
struct dma_pool, such that blks_per_alloc then ends up padding out the
hole again.
FWIW the mathematician in me also now can't help seeing the algebraic
reduction to at least "(allocation + (allocation % boundary)) / size",
but is now too tired to reason about the power-of-two constraints and
whether the intermediate integer truncations matter...
Cheers,
Robin.
next prev parent reply other threads:[~2022-05-31 21:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-31 18:11 [PATCH 00/10] mpt3sas and dmapool scalability Tony Battersby
2022-05-31 18:12 ` [PATCH 01/10] dmapool: remove checks for dev == NULL Tony Battersby
2022-05-31 18:23 ` Robin Murphy
2022-05-31 18:13 ` [PATCH 02/10] dmapool: cleanup integer types Tony Battersby
2022-05-31 18:14 ` [PATCH 03/10] dmapool: fix boundary comparison Tony Battersby
2022-05-31 18:17 ` [PATCH 04/10] dmapool: improve accuracy of debug statistics Tony Battersby
2022-05-31 19:48 ` Robin Murphy
2022-05-31 19:52 ` Tony Battersby
2022-05-31 21:55 ` Robin Murphy [this message]
2022-05-31 18:18 ` [PATCH 05/10] dmapool: debug: prevent endless loop in case of corruption Tony Battersby
2022-05-31 18:20 ` [PATCH 06/10] dmapool: ignore init_on_free when DMAPOOL_DEBUG enabled Tony Battersby
2022-05-31 18:21 ` [PATCH 07/10] dmapool: speedup DMAPOOL_DEBUG with init_on_alloc Tony Battersby
2022-05-31 18:22 ` [PATCH 08/10] dmapool: cleanup dma_pool_destroy Tony Battersby
2022-05-31 19:33 ` Robin Murphy
2022-05-31 21:40 ` Keith Busch
2022-05-31 18:23 ` [PATCH 09/10] dmapool: improve scalability of dma_pool_alloc Tony Battersby
2022-05-31 18:23 ` [PATCH 10/10] dmapool: improve scalability of dma_pool_free Tony Battersby
2022-05-31 21:54 ` Keith Busch
2022-05-31 22:10 ` Tony Battersby
2022-06-01 9:44 ` Robin Murphy
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=417bd608-0eeb-b3a0-31e3-8e241ab75e59@arm.com \
--to=robin.murphy@arm.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=tony@atomide.com \
--cc=tonyb@cybernetics.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;
as well as URLs for NNTP newsgroup(s).