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 03/10] dmapool: fix boundary comparison
Date: Tue, 31 May 2022 14:14:23 -0400 [thread overview]
Message-ID: <f418f3c5-32b7-31c1-c91a-1bdb64b44db3@cybernetics.com> (raw)
In-Reply-To: <9b08ab7c-b80b-527d-9adf-7716b0868fbc@cybernetics.com>
Fix the boundary comparison when constructing the list of free blocks
for the case that 'size' is a power of two. Since 'boundary' is also a
power of two, that would make 'boundary' a multiple of 'size', in which
case a single block would never cross the boundary. This bug would
cause some of the allocated memory to be wasted (but not leaked).
Example:
size = 512
boundary = 2048
allocation = 4096
Address range
0 - 511
512 - 1023
1024 - 1535
1536 - 2047 *
2048 - 2559
2560 - 3071
3072 - 3583
3584 - 4095 *
Prior to this fix, the address ranges marked with "*" would not have
been used even though they didn't cross the given boundary.
Fixes: e34f44b3517f ("pool: Improve memory usage for devices which can't cross boundaries")
Signed-off-by: Tony Battersby <tonyb@cybernetics.com>
---
mm/dmapool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/dmapool.c b/mm/dmapool.c
index d7b372248111..782143144a32 100644
--- a/mm/dmapool.c
+++ b/mm/dmapool.c
@@ -210,7 +210,7 @@ static void pool_initialise_page(struct dma_pool *pool, struct dma_page *page)
do {
unsigned int next = offset + pool->size;
- if (unlikely((next + pool->size) >= next_boundary)) {
+ if (unlikely((next + pool->size) > next_boundary)) {
next = next_boundary;
next_boundary += pool->boundary;
}
--
2.25.1
next prev parent reply other threads:[~2022-05-31 18:14 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 ` Tony Battersby [this message]
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
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=f418f3c5-32b7-31c1-c91a-1bdb64b44db3@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;
as well as URLs for NNTP newsgroup(s).