ext4: add cond_resched() to ext4_mb_init_backend()
PATCH 1/1 ext4: add cond_resched() to ext4_mb_init_backend()
on non-preempt kernels for filesystems with large number of groups we may take a long time (>50 ticks) initializing all the groups.
--- fs/ext4/mballoc.c | 1 + 1 file changed, 1 insertion(+)
fs/ext4/mballoc.c +1 -0
@@ -2490,6 +2490,7 @@ static int ext4_mb_init_backend(struct super_block *sb) sbi->s_buddy_cache->i_ino =EXT4_BAD_INO ;EXT4_I (sbi->s_buddy_cache)->i_disksize =0 ;for (i =0 ; i < ngroups; i++) { +cond_resched (); desc =ext4_get_group_desc (sb, i,NULL );if (desc ==NULL ) {ext4_msg (sb,KERN_ERR ,"can't read descriptor %u" , i);
Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Jan Kara
reviewerQuoted 4 lines · Khazhismel Kumykov
on non-preempt kernels for filesystems with large number of groups we may take a long time (>50 ticks) initializing all the groups.
Signed-off-by Khazhismel Kumykov <[email protected]>
Thanks for the patch. I'm not opposed to this but I'm just wondering: Has this caused any real issues to you? Or how have you come across this particular loop? Because I'd think we have more similar loops in ext4 codebase...
Honza
Quoted 19 lines
--- fs/ext4/mballoc.c | 1 + 1 file changed, 1 insertion(+)fs/ext4/mballoc.c +1
-0@@ -2490,6 +2490,7 @@ static int ext4_mb_init_backend(struct super_block *sb) sbi->s_buddy_cache->i_ino =EXT4_BAD_INO ;EXT4_I (sbi->s_buddy_cache)->i_disksize =0 ;for (i =0 ; i < ngroups; i++) { +cond_resched (); desc =ext4_get_group_desc (sb, i,NULL );if (desc ==NULL ) {ext4_msg (sb,KERN_ERR ,"can't read descriptor %u" , i);Signature · 1 line
2.21.0.392.gf8f6787159e-goog
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 5 lines · Jan Kara
Quoted 3 lines · Khazhismel Kumykov
on non-preempt kernels for filesystems with large number of groups we may take a long time (>50 ticks) initializing all the groups.
Quoted 9 lines
Quoted 1 line
Signed-off-by Khazhismel Kumykov <[email protected]>Thanks for the patch. I'm not opposed to this but I'm just wondering: Has this caused any real issues to you? Or how have you come across this particular loop? Because I'd think we have more similar loops in ext4 codebase...
Honza
We have some instrumentation to warn for these longer periods without scheduling, which admittedly does trigger relatively frequently from various places. This particular loop just so happens to be during system startup where it caught my eye.
PATCH v2 1/1 ext4: cond_resched in work-heavy group loops
These functions may take a long time looping over many groups, which may cause issues for non-preempt kernels. ext4_mb_init_backend()ext4_setup_system_zone()ext4_mb_release()
---
v2:
- a few other places that in testing showed to be slow
fs/ext4/block_validity.c | 1 + fs/ext4/mballoc.c | 2 ++ 2 files changed, 3 insertions(+)
fs/ext4/block_validity.c +1 -0
@@ -155,6 +155,7 @@ int ext4_setup_system_zone(struct super_block *sb)return 0 ;for (i=0 ; i < ngroups; i++) { +cond_resched ();if (ext4_bg_has_super (sb, i) && ((i <5 ) || ((i % flex_size) ==0 ))) add_system_zone(sbi, ext4_group_first_block_no(sb, i),
fs/ext4/mballoc.c +2 -0
@@ -2490,6 +2490,7 @@ static int ext4_mb_init_backend(struct super_block *sb) sbi->s_buddy_cache->i_ino =EXT4_BAD_INO ;EXT4_I (sbi->s_buddy_cache)->i_disksize =0 ;for (i =0 ; i < ngroups; i++) { +cond_resched (); desc =ext4_get_group_desc (sb, i,NULL );if (desc ==NULL ) {ext4_msg (sb,KERN_ERR ,"can't read descriptor %u" , i);
@@ -2705,6 +2706,7 @@ int ext4_mb_release(struct super_block *sb)if (sbi->s_group_info) {for (i =0 ; i < ngroups; i++) { +cond_resched (); grinfo =ext4_get_group_info (sb, i);#ifdef DOUBLE_CHECK kfree (grinfo->bb_bitmap);
Signature · 1 line
2.21.0.593.g511ec345e18-goog
Re: [PATCH v2] ext4: cond_resched in work-heavy group loops
Quoted 8 lines · Khazhismel Kumykov
These functions may take a long time looping over many groups, which may cause issues for non-preempt kernels.
ext4_mb_init_backend()ext4_setup_system_zone()ext4_mb_release()Signed-off-by Khazhismel Kumykov <[email protected]>
Quoted 41 lines
---
v2:
- a few other places that in testing showed to be slow
fs/ext4/block_validity.c| 1 +fs/ext4/mballoc.c| 2 ++2 files changed, 3 insertions(+)fs/ext4/block_validity.c +1
-0@@ -155,6 +155,7 @@ int ext4_setup_system_zone(struct super_block *sb)return 0 ;for (i=0 ; i < ngroups; i++) { +cond_resched ();if (ext4_bg_has_super (sb, i) && ((i <5 ) || ((i % flex_size) ==0 ))) add_system_zone(sbi, ext4_group_first_block_no(sb, i),fs/ext4/mballoc.c +2
-1@@ -2490,6 +2490,7 @@ static int ext4_mb_init_backend(struct super_block *sb) sbi->s_buddy_cache->i_ino =EXT4_BAD_INO ;EXT4_I (sbi->s_buddy_cache)->i_disksize =0 ;for (i =0 ; i < ngroups; i++) { +cond_resched (); desc =ext4_get_group_desc (sb, i,NULL );if (desc ==NULL ) {ext4_msg (sb,KERN_ERR ,"can't read descriptor %u" , i);@@ -2705,6 +2706,7 @@ int ext4_mb_release(struct super_block *sb)if (sbi->s_group_info) {for (i =0 ; i < ngroups; i++) { +cond_resched (); grinfo =ext4_get_group_info (sb, i);#ifdef DOUBLE_CHECK kfree (grinfo->bb_bitmap); --
Quoted 2 lines
2.21.0.593.g511ec345e18-goog
Cheers, Andreas
Re: [PATCH v2] ext4: cond_resched in work-heavy group loops
In reply to Khazhismel KumykovQuoted 7 lines · Khazhismel Kumykov
These functions may take a long time looping over many groups, which may cause issues for non-preempt kernels.
ext4_mb_init_backend()ext4_setup_system_zone()ext4_mb_release()Signed-off-by Khazhismel Kumykov <[email protected]>
Thanks, applied.
- Ted