* + arm-implement-the-new-page-table-range-api-fix.patch added to mm-unstable branch
@ 2023-08-09 18:55 Andrew Morton
2023-08-09 19:12 ` Matthew Wilcox
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Morton @ 2023-08-09 18:55 UTC (permalink / raw)
To: mm-commits, willy, rppt, linux, m.szyprowski, akpm
The patch titled
Subject: arm: dma-mapping: fix potential endless loop in __dma_page_dev_to_cpu()
has been added to the -mm mm-unstable branch. Its filename is
arm-implement-the-new-page-table-range-api-fix.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/arm-implement-the-new-page-table-range-api-fix.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via the mm-everything
branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there every 2-3 working days
------------------------------------------------------
From: Marek Szyprowski <m.szyprowski@samsung.com>
Subject: arm: dma-mapping: fix potential endless loop in __dma_page_dev_to_cpu()
Date: Wed, 9 Aug 2023 19:27:37 +0200
The D-cache cleaning loop should not call folio_next() beyond the
requested region and rely on its parameters. Simply stop looping if left
counter reaches zero.
This fixes the following endless loop observed by RCU stall on the ARM
32bit Exynos5422-based Odroid-XU3lite board:
--->8---
rcu: INFO: rcu_sched self-detected stall on CPU
rcu: 0-....: (27320 ticks this GP) idle=e414/1/0x40000002 softirq=36/36 fqs=13044
rcu: (t=27385 jiffies g=-1067 q=34 ncpus=8)
CPU: 0 PID: 93 Comm: kworker/0:1H Not tainted 6.5.0-rc5-next-20230807 #6981
Hardware name: Samsung Exynos (Flattened Device Tree)
Workqueue: mmc_complete mmc_blk_mq_complete_work
PC is at _set_bit+0x28/0x44
LR is at __dma_page_dev_to_cpu+0xdc/0x170
..
_set_bit from __dma_page_dev_to_cpu+0xdc/0x170
__dma_page_dev_to_cpu from dma_direct_unmap_sg+0x100/0x130
dma_direct_unmap_sg from dw_mci_post_req+0x68/0x6c
dw_mci_post_req from mmc_blk_mq_post_req+0x34/0x100
mmc_blk_mq_post_req from mmc_blk_mq_complete_work+0x50/0x60
mmc_blk_mq_complete_work from process_one_work+0x20c/0x4d8
process_one_work from worker_thread+0x58/0x54c
worker_thread from kthread+0xe0/0xfc
kthread from ret_from_fork+0x14/0x2c
--->8---
While touching this code, move the set_bit() operation, which deals with
atomics, a bit up in the call chain. The new order helps a bit compiler
to produce code computing folio_size() only once.
Link: https://lkml.kernel.org/r/20230809172737.3574190-1-m.szyprowski@samsung.com
Fixes: cc24e9c0895c ("arm: implement the new page table range API")
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mike Rapoport (IBM) <rppt@kernel.org>
Cc: Russell King <linux@armlinux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
arch/arm/mm/dma-mapping.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/arch/arm/mm/dma-mapping.c~arm-implement-the-new-page-table-range-api-fix
+++ a/arch/arm/mm/dma-mapping.c
@@ -719,8 +719,10 @@ static void __dma_page_dev_to_cpu(struct
}
while (left >= (ssize_t)folio_size(folio)) {
- set_bit(PG_dcache_clean, &folio->flags);
left -= folio_size(folio);
+ set_bit(PG_dcache_clean, &folio->flags);
+ if (!left)
+ break;
folio = folio_next(folio);
}
}
_
Patches currently in -mm which might be from m.szyprowski@samsung.com are
arm-implement-the-new-page-table-range-api-fix.patch
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: + arm-implement-the-new-page-table-range-api-fix.patch added to mm-unstable branch
2023-08-09 18:55 + arm-implement-the-new-page-table-range-api-fix.patch added to mm-unstable branch Andrew Morton
@ 2023-08-09 19:12 ` Matthew Wilcox
0 siblings, 0 replies; 2+ messages in thread
From: Matthew Wilcox @ 2023-08-09 19:12 UTC (permalink / raw)
To: Andrew Morton; +Cc: mm-commits, rppt, linux, m.szyprowski
On Wed, Aug 09, 2023 at 11:55:19AM -0700, Andrew Morton wrote:
>
> The patch titled
> Subject: arm: dma-mapping: fix potential endless loop in __dma_page_dev_to_cpu()
> has been added to the -mm mm-unstable branch. Its filename is
> arm-implement-the-new-page-table-range-api-fix.patch
Thanks. Can you add ia64-implement-the-new-page-table-range-api-fix.patch
as well, please? (Debian no longer ships the compilers, so not even
compile tested)
diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c
index 48d475f10003..c4d477e8bcd4 100644
--- a/arch/ia64/hp/common/sba_iommu.c
+++ b/arch/ia64/hp/common/sba_iommu.c
@@ -811,12 +811,16 @@ static void mark_clean(void *addr, size_t size)
if (offset) {
left -= folio_size(folio) - offset;
+ if (left <= 0)
+ return;
folio = folio_next(folio);
}
while (left >= folio_size(folio)) {
- set_bit(PG_arch_1, &folio->flags);
left -= folio_size(folio);
+ set_bit(PG_arch_1, &folio->flags);
+ if (!left)
+ break;
folio = folio_next(folio);
}
}
diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
index b95debabdc2a..05b0f2f0c073 100644
--- a/arch/ia64/mm/init.c
+++ b/arch/ia64/mm/init.c
@@ -76,12 +76,16 @@ void arch_dma_mark_clean(phys_addr_t paddr, size_t size)
if (offset) {
left -= folio_size(folio) - offset;
+ if (left <= 0)
+ return;
folio = folio_next(folio);
}
while (left >= (ssize_t)folio_size(folio)) {
- set_bit(PG_arch_1, &pfn_to_page(pfn)->flags);
left -= folio_size(folio);
+ set_bit(PG_arch_1, &pfn_to_page(pfn)->flags);
+ if (!left)
+ break;
folio = folio_next(folio);
}
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-08-09 19:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-09 18:55 + arm-implement-the-new-page-table-range-api-fix.patch added to mm-unstable branch Andrew Morton
2023-08-09 19:12 ` 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.