* [PATCH] iomap: add dirty page control to iomap_zero_iter
@ 2026-05-10 6:47 Chi Zhiling
2026-05-11 8:57 ` Christoph Hellwig
0 siblings, 1 reply; 3+ messages in thread
From: Chi Zhiling @ 2026-05-10 6:47 UTC (permalink / raw)
To: linux-xfs, linux-fsdevel, linux-kernel
Cc: brauner, djwong, hch, sj1557.seo, yuezhang.mo, Chi Zhiling,
Namjae Jeon
From: Chi Zhiling <chizhiling@kylinos.cn>
This patch prepares the iomap framework for exFAT's upcoming migration to
iomap. During testing of the exFAT iomap branch with xfstests generic/299
on a VM with 8GB RAM and a 40GB disk, system unresponsiveness was observed.
iomap_zero_iter() lacked dirty page throttling, which could cause memory
pressure when exFAT's valid_size mechanism triggers large-scale zeroing
operations during writes beyond valid_size.
Align iomap_zero_iter() with iomap_write_iter() by adding
balance_dirty_pages_ratelimited() to throttle dirty page generation during
large zeroing operations. Also add cond_resched() to provide voluntary
rescheduling points during long-running loops.
Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
Cc: Namjae Jeon <linkinjeon@kernel.org>
---
exFAT iomap migration:
https://lore.kernel.org/linux-fsdevel/20260507124238.7313-1-linkinjeon@kernel.org/
fs/iomap/buffered-io.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
index d7b648421a70..f6955786c8ad 100644
--- a/fs/iomap/buffered-io.c
+++ b/fs/iomap/buffered-io.c
@@ -1543,6 +1543,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
size_t offset;
bool ret;
+ balance_dirty_pages_ratelimited(iter->inode->i_mapping);
+
bytes = min_t(u64, SIZE_MAX, bytes);
status = iomap_write_begin(iter, write_ops, &folio, &offset,
&bytes);
@@ -1571,6 +1573,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
if (WARN_ON_ONCE(!ret))
return -EIO;
+ cond_resched();
+
status = iomap_iter_advance(iter, bytes);
if (status)
break;
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iomap: add dirty page control to iomap_zero_iter
2026-05-10 6:47 [PATCH] iomap: add dirty page control to iomap_zero_iter Chi Zhiling
@ 2026-05-11 8:57 ` Christoph Hellwig
2026-05-11 9:09 ` Chi Zhiling
0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2026-05-11 8:57 UTC (permalink / raw)
To: Chi Zhiling
Cc: linux-xfs, linux-fsdevel, linux-kernel, brauner, djwong, hch,
sj1557.seo, yuezhang.mo, Chi Zhiling, Namjae Jeon
On Sun, May 10, 2026 at 02:47:37PM +0800, Chi Zhiling wrote:
> From: Chi Zhiling <chizhiling@kylinos.cn>
>
> This patch prepares the iomap framework for exFAT's upcoming migration to
> iomap. During testing of the exFAT iomap branch with xfstests generic/299
> on a VM with 8GB RAM and a 40GB disk, system unresponsiveness was observed.
>
> iomap_zero_iter() lacked dirty page throttling, which could cause memory
> pressure when exFAT's valid_size mechanism triggers large-scale zeroing
> operations during writes beyond valid_size.
>
> Align iomap_zero_iter() with iomap_write_iter() by adding
> balance_dirty_pages_ratelimited() to throttle dirty page generation during
> large zeroing operations. Also add cond_resched() to provide voluntary
> rescheduling points during long-running loops.
The balance_dirty_pages_ratelimited looks good. Now with lazy preempt
we really should not need more cond_resched calls, though.
>
> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
> Cc: Namjae Jeon <linkinjeon@kernel.org>
> ---
>
> exFAT iomap migration:
> https://lore.kernel.org/linux-fsdevel/20260507124238.7313-1-linkinjeon@kernel.org/
>
> fs/iomap/buffered-io.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
> index d7b648421a70..f6955786c8ad 100644
> --- a/fs/iomap/buffered-io.c
> +++ b/fs/iomap/buffered-io.c
> @@ -1543,6 +1543,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
> size_t offset;
> bool ret;
>
> + balance_dirty_pages_ratelimited(iter->inode->i_mapping);
> +
> bytes = min_t(u64, SIZE_MAX, bytes);
> status = iomap_write_begin(iter, write_ops, &folio, &offset,
> &bytes);
> @@ -1571,6 +1573,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
> if (WARN_ON_ONCE(!ret))
> return -EIO;
>
> + cond_resched();
> +
> status = iomap_iter_advance(iter, bytes);
> if (status)
> break;
> --
> 2.43.0
---end quoted text---
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iomap: add dirty page control to iomap_zero_iter
2026-05-11 8:57 ` Christoph Hellwig
@ 2026-05-11 9:09 ` Chi Zhiling
0 siblings, 0 replies; 3+ messages in thread
From: Chi Zhiling @ 2026-05-11 9:09 UTC (permalink / raw)
To: Christoph Hellwig
Cc: linux-xfs, linux-fsdevel, linux-kernel, brauner, djwong,
sj1557.seo, yuezhang.mo, Chi Zhiling, Namjae Jeon
On 5/11/26 16:57, Christoph Hellwig wrote:
> On Sun, May 10, 2026 at 02:47:37PM +0800, Chi Zhiling wrote:
>> From: Chi Zhiling <chizhiling@kylinos.cn>
>>
>> This patch prepares the iomap framework for exFAT's upcoming migration to
>> iomap. During testing of the exFAT iomap branch with xfstests generic/299
>> on a VM with 8GB RAM and a 40GB disk, system unresponsiveness was observed.
>>
>> iomap_zero_iter() lacked dirty page throttling, which could cause memory
>> pressure when exFAT's valid_size mechanism triggers large-scale zeroing
>> operations during writes beyond valid_size.
>>
>> Align iomap_zero_iter() with iomap_write_iter() by adding
>> balance_dirty_pages_ratelimited() to throttle dirty page generation during
>> large zeroing operations. Also add cond_resched() to provide voluntary
>> rescheduling points during long-running loops.
>
> The balance_dirty_pages_ratelimited looks good. Now with lazy preempt
> we really should not need more cond_resched calls, though.
Okay, will drop it in next version.
Thanks,
>
>>
>> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
>> Cc: Namjae Jeon <linkinjeon@kernel.org>
>> ---
>>
>> exFAT iomap migration:
>> https://lore.kernel.org/linux-fsdevel/20260507124238.7313-1-linkinjeon@kernel.org/
>>
>> fs/iomap/buffered-io.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/iomap/buffered-io.c b/fs/iomap/buffered-io.c
>> index d7b648421a70..f6955786c8ad 100644
>> --- a/fs/iomap/buffered-io.c
>> +++ b/fs/iomap/buffered-io.c
>> @@ -1543,6 +1543,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
>> size_t offset;
>> bool ret;
>>
>> + balance_dirty_pages_ratelimited(iter->inode->i_mapping);
>> +
>> bytes = min_t(u64, SIZE_MAX, bytes);
>> status = iomap_write_begin(iter, write_ops, &folio, &offset,
>> &bytes);
>> @@ -1571,6 +1573,8 @@ static int iomap_zero_iter(struct iomap_iter *iter, bool *did_zero,
>> if (WARN_ON_ONCE(!ret))
>> return -EIO;
>>
>> + cond_resched();
>> +
>> status = iomap_iter_advance(iter, bytes);
>> if (status)
>> break;
>> --
>> 2.43.0
> ---end quoted text---
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-11 9:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-10 6:47 [PATCH] iomap: add dirty page control to iomap_zero_iter Chi Zhiling
2026-05-11 8:57 ` Christoph Hellwig
2026-05-11 9:09 ` Chi Zhiling
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox