iomap: add dirty page control to iomap_zero_iter
Subsystems (2)
PATCH 1/1 iomap: add dirty page control to iomap_zero_iter
From: Chi Zhiling <[email protected]>
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.
---
exFAT iomap migration:
https://lore.kernel.org/linux-fsdevel/[email protected]/
fs/iomap/buffered-io.c | 4 ++++ 1 file changed, 4 insertions(+)
fs/iomap/buffered-io.c +4 -0
@@ -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 ;
Signature · 1 line
2.43.0
Quoted 6 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
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.
Quoted 8 lines
iomap_zero_iter()lacked dirty page throttling, which could cause memory pressure when exFAT'svalid_sizemechanism triggers large-scale zeroing operations during writes beyondvalid_size.Align
iomap_zero_iter()withiomap_write_iter()by addingbalance_dirty_pages_ratelimited()to throttle dirty page generation during large zeroing operations. Also addcond_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.
Quoted 35 lines
Signed-off-by Chi Zhiling <[email protected]>Cc Namjae Jeon <[email protected]>---
exFAT iomap migration:
https://lore.kernel.org/linux-fsdevel/[email protected]/fs/iomap/buffered-io.c | 4 ++++ 1 file changed, 4 insertions(+)fs/iomap/buffered-io.c +4
-0@@ -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 ;Signature · 1 line
2.43.0
---end quoted text---
Quoted 11 lines · Christoph Hellwig
Quoted 10 lines · Chi Zhiling
From: Chi Zhiling <[email protected]>
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'svalid_sizemechanism triggers large-scale zeroing operations during writes beyondvalid_size.
Quoted 7 lines
Quoted 4 lines
Align
iomap_zero_iter()withiomap_write_iter()by addingbalance_dirty_pages_ratelimited()to throttle dirty page generation during large zeroing operations. Also addcond_resched()to provide voluntary rescheduling points during long-running loops.The
balance_dirty_pages_ratelimitedlooks good. Now with lazy preempt we really should not need morecond_reschedcalls, though.
Okay, will drop it in next version.
Thanks,
Quoted 37 lines
Quoted 36 lines
Signed-off-by Chi Zhiling <[email protected]>Cc Namjae Jeon <[email protected]>---
exFAT iomap migration:
https://lore.kernel.org/linux-fsdevel/[email protected]/fs/iomap/buffered-io.c | 4 ++++ 1 file changed, 4 insertions(+)fs/iomap/buffered-io.c +4
-0@@ -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 ;Signature · 1 line
2.43.0---end quoted text---