Skip to contentSkip to conversation

Revert "f2fs: avoid cpu lockup"

RFC PATCH In review Yunlei He 3 participants 6 messages May 31, 2018 – Jun 16, 2018 F2FS file system

lore
Share & tools
lore

Yunlei He

author
#0 lore raw

RFC PATCH 1/1 Revert "f2fs: avoid cpu lockup"

This reverts commit 4db08d016ccedb5b97869724a096990acad59685 to fix hungtask problem which can be reproduced as follow:

Thread 0~3:

while true
do
touch /xxx/test/file_xxx
done

Thread 5 write a new checkpoint every three seconds.

In the meantime, fio start 16 threads for randwrite.

With my debug info, cycles num will exceed 1000 in function f2fs_sync_dirty_inodes, and most of cycle will be dropped into congestion_wait() and sleep more than 20ms.

---
 fs/f2fs/checkpoint.c | 10 ----------
 1 file changed, 10 deletions(-)
fs/f2fs/checkpoint.c +0 -10
index 8eb184c..76e1856 100644
@@ -944,7 +944,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	struct inode *inode;
 	struct f2fs_inode_info *fi;
 	bool is_dir = (type == DIR_INODE);
-	unsigned long ino = 0;
 
 	trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir,
 				get_pages(sbi, is_dir ?
@@ -967,8 +966,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	inode = igrab(&fi->vfs_inode);
 	spin_unlock(&sbi->inode_lock[type]);
 	if (inode) {
-		unsigned long cur_ino = inode->i_ino;
-
 		if (is_dir)
 			F2FS_I(inode)->cp_task = current;
 
@@ -978,13 +975,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 			F2FS_I(inode)->cp_task = NULL;
 
 		iput(inode);
-		/* We need to give cpu to another writers. */
-		if (ino == cur_ino) {
-			congestion_wait(BLK_RW_ASYNC, HZ/50);
-			cond_resched();
-		} else {
-			ino = cur_ino;
-		}
 	} else {
 		/*
 		 * We should submit bio, since it exists several
Signature · 6 lines
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
maintainer
#1 lore raw

Hi Yunlei,

Quoted 10 lines · Yunlei He

This reverts commit 4db08d016ccedb5b97869724a096990acad59685 to fix hungtask problem which can be reproduced as follow:

Thread 0~3:

while true
do
touch /xxx/test/file_xxx
done

Quoted 7 lines

Thread 5 write a new checkpoint every three seconds.

In the meantime, fio start 16 threads for randwrite.

With my debug info, cycles num will exceed 1000 in function f2fs_sync_dirty_inodes, and most of cycle will be dropped into congestion_wait() and sleep more than 20ms.

Original patch tries to fix watchdog which sync_dirty_inodes() grabs one cpu for a long time. Have you tried reproduce that as well?

Thanks,

Quoted 43 lines
---
 fs/f2fs/checkpoint.c | 10 ----------
 1 file changed, 10 deletions(-)
fs/f2fs/checkpoint.c +0 -10
index 8eb184c..76e1856 100644
@@ -944,7 +944,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	struct inode *inode;
 	struct f2fs_inode_info *fi;
 	bool is_dir = (type == DIR_INODE);
-	unsigned long ino = 0;
 
 	trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir,
 				get_pages(sbi, is_dir ?
@@ -967,8 +966,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	inode = igrab(&fi->vfs_inode);
 	spin_unlock(&sbi->inode_lock[type]);
 	if (inode) {
-		unsigned long cur_ino = inode->i_ino;
-
 		if (is_dir)
 			F2FS_I(inode)->cp_task = current;
 
@@ -978,13 +975,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 			F2FS_I(inode)->cp_task = NULL;
 
 		iput(inode);
-		/* We need to give cpu to another writers. */
-		if (ino == cur_ino) {
-			congestion_wait(BLK_RW_ASYNC, HZ/50);
-			cond_resched();
-		} else {
-			ino = cur_ino;
-		}
 	} else {
 		/*
 		 * We should submit bio, since it exists several
Signature · 1 line
1.9.1

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot

author
#2 lore raw
Quoted 11 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, June 01, 2018 1:56 AM
To: heyunlei
Cc: Yuchao (T); [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH RFC] Revert "f2fs: avoid cpu lockup"

Hi Yunlei,

Hi Jaegeuk,

Quoted 13 lines · Yunlei He
Quoted 12 lines

This reverts commit 4db08d016ccedb5b97869724a096990acad59685 to fix hungtask problem which can be reproduced as follow:

Thread 0~3:

while true
do
touch /xxx/test/file_xxx
done

Thread 5 write a new checkpoint every three seconds.

Quoted 9 lines
Quoted 5 lines

In the meantime, fio start 16 threads for randwrite.

With my debug info, cycles num will exceed 1000 in function f2fs_sync_dirty_inodes, and most of cycle will be dropped into congestion_wait() and sleep more than 20ms.

Original patch tries to fix watchdog which sync_dirty_inodes() grabs one cpu for a long time. Have you tried reproduce that as well?

I have test this patch with increasing touch file threads to 32,and other remain same as previous, But I have not reproduce your problem.

Besides, I try to test the code just remove this line:

		congestion_wait(BLK_RW_ASYNC, HZ/50);

It's also ok to my test, and cycle num reduced to < 3

Thanks.

Quoted 32 lines

Thanks,

Quoted 30 lines
---
 fs/f2fs/checkpoint.c | 10 ----------
 1 file changed, 10 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 8eb184c..76e1856 100644
@@ -944,7 +944,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	struct inode *inode;
 	struct f2fs_inode_info *fi;
 	bool is_dir = (type == DIR_INODE);
-	unsigned long ino = 0;
 
 	trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir,
 				get_pages(sbi, is_dir ?
@@ -967,8 +966,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	inode = igrab(&fi->vfs_inode);
 	spin_unlock(&sbi->inode_lock[type]);
 	if (inode) {
-		unsigned long cur_ino = inode->i_ino;
-
 		if (is_dir)
 			F2FS_I(inode)->cp_task = current;
 
@@ -978,13 +975,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 			F2FS_I(inode)->cp_task = NULL;
 
Quoted 13 lines
Quoted 12 lines
fs/f2fs/checkpoint.c +0 -8
 		iput(inode);
-		/* We need to give cpu to another writers. */
-		if (ino == cur_ino) {
-			congestion_wait(BLK_RW_ASYNC, HZ/50);
-			cond_resched();
-		} else {
-			ino = cur_ino;
-		}
 	} else {
 		/*
 		 * We should submit bio, since it exists several
--
Quoted 1 line

1.9.1

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#3 lore raw
Quoted 35 lines · heyunlei
Quoted 11 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, June 01, 2018 1:56 AM
To: heyunlei
Cc: Yuchao (T); [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH RFC] Revert "f2fs: avoid cpu lockup"

Hi Yunlei,

Hi Jaegeuk,

Quoted 13 lines · Yunlei He
Quoted 12 lines

This reverts commit 4db08d016ccedb5b97869724a096990acad59685 to fix hungtask problem which can be reproduced as follow:

Thread 0~3:

while true
do
touch /xxx/test/file_xxx
done

Thread 5 write a new checkpoint every three seconds.

Quoted 9 lines
Quoted 5 lines

In the meantime, fio start 16 threads for randwrite.

With my debug info, cycles num will exceed 1000 in function f2fs_sync_dirty_inodes, and most of cycle will be dropped into congestion_wait() and sleep more than 20ms.

Original patch tries to fix watchdog which sync_dirty_inodes() grabs one cpu for a long time. Have you tried reproduce that as well?

Quoted 7 lines

I have test this patch with increasing touch file threads to 32,and other remain same as previous, But I have not reproduce your problem.

Besides, I try to test the code just remove this line:

		congestion_wait(BLK_RW_ASYNC, HZ/50);

It's also ok to my test, and cycle num reduced to < 3

You may be able to add threshold here?

Quoted 35 lines

Thanks.

Quoted 32 lines

Thanks,

Quoted 30 lines
---
 fs/f2fs/checkpoint.c | 10 ----------
 1 file changed, 10 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 8eb184c..76e1856 100644
@@ -944,7 +944,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	struct inode *inode;
 	struct f2fs_inode_info *fi;
 	bool is_dir = (type == DIR_INODE);
-	unsigned long ino = 0;
 
 	trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir,
 				get_pages(sbi, is_dir ?
@@ -967,8 +966,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	inode = igrab(&fi->vfs_inode);
 	spin_unlock(&sbi->inode_lock[type]);
 	if (inode) {
-		unsigned long cur_ino = inode->i_ino;
-
 		if (is_dir)
 			F2FS_I(inode)->cp_task = current;
 
@@ -978,13 +975,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 			F2FS_I(inode)->cp_task = NULL;
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
fs/f2fs/checkpoint.c +0 -4
 		iput(inode);
-		/* We need to give cpu to another writers. */
-		if (ino == cur_ino) {
-			congestion_wait(BLK_RW_ASYNC, HZ/50);
-			cond_resched();
Quoted 8 lines
Quoted 8 lines
fs/f2fs/checkpoint.c +0 -4
-		} else {
-			ino = cur_ino;
-		}
 	} else {
 		/*
 		 * We should submit bio, since it exists several
--

1.9.1

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

#4 lore raw
Quoted 39 lines · Jaegeuk Kim
Quoted 38 lines · heyunlei
Quoted 11 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, June 01, 2018 1:56 AM
To: heyunlei
Cc: Yuchao (T); [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH RFC] Revert "f2fs: avoid cpu lockup"

Hi Yunlei,

Hi Jaegeuk,

Quoted 13 lines · Yunlei He
Quoted 12 lines

This reverts commit 4db08d016ccedb5b97869724a096990acad59685 to fix hungtask problem which can be reproduced as follow:

Thread 0~3:

while true
do
touch /xxx/test/file_xxx
done

Thread 5 write a new checkpoint every three seconds.

Quoted 9 lines
Quoted 5 lines

In the meantime, fio start 16 threads for randwrite.

With my debug info, cycles num will exceed 1000 in function f2fs_sync_dirty_inodes, and most of cycle will be dropped into congestion_wait() and sleep more than 20ms.

Original patch tries to fix watchdog which sync_dirty_inodes() grabs one cpu for a long time. Have you tried reproduce that as well?

I have test this patch with increasing touch file threads to 32,and other remain same as previous, But I have not reproduce your problem.

Quoted 6 lines
Quoted 4 lines

Besides, I try to test the code just remove this line:

		congestion_wait(BLK_RW_ASYNC, HZ/50);

It's also ok to my test, and cycle num reduced to < 3

You may be able to add threshold here?

Hmm, if cycle exceeds threshold, still we can encounter this issue. How about just removing congestion_wait, and keep cond_resched, it can switch current cpu out?

Thanks,

Quoted 36 lines
Quoted 36 lines

Thanks.

Quoted 32 lines

Thanks,

Quoted 30 lines
---
 fs/f2fs/checkpoint.c | 10 ----------
 1 file changed, 10 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 8eb184c..76e1856 100644
@@ -944,7 +944,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	struct inode *inode;
 	struct f2fs_inode_info *fi;
 	bool is_dir = (type == DIR_INODE);
-	unsigned long ino = 0;
 
 	trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir,
 				get_pages(sbi, is_dir ?
@@ -967,8 +966,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	inode = igrab(&fi->vfs_inode);
 	spin_unlock(&sbi->inode_lock[type]);
 	if (inode) {
-		unsigned long cur_ino = inode->i_ino;
-
 		if (is_dir)
 			F2FS_I(inode)->cp_task = current;
 
@@ -978,13 +975,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 			F2FS_I(inode)->cp_task = NULL;
 
Quoted 16 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
fs/f2fs/checkpoint.c +0 -4
 		iput(inode);
-		/* We need to give cpu to another writers. */
-		if (ino == cur_ino) {
-			congestion_wait(BLK_RW_ASYNC, HZ/50);
-			cond_resched();
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
fs/f2fs/checkpoint.c +0 -4
-		} else {
-			ino = cur_ino;
-		}
 	} else {
 		/*
 		 * We should submit bio, since it exists several
--

1.9.1

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

maintainer
#5 lore raw
Quoted 43 lines · Chao Yu
Quoted 42 lines · Jaegeuk Kim
Quoted 41 lines · heyunlei
Quoted 11 lines

-----Original Message-----
From: Jaegeuk Kim [mailto:[email protected]]
Sent: Friday, June 01, 2018 1:56 AM
To: heyunlei
Cc: Yuchao (T); [email protected]; Wangbintian; Zhangdianfang (Euler)
Subject: Re: [f2fs-dev][PATCH RFC] Revert "f2fs: avoid cpu lockup"

Hi Yunlei,

Hi Jaegeuk,

Quoted 13 lines · Yunlei He
Quoted 12 lines

This reverts commit 4db08d016ccedb5b97869724a096990acad59685 to fix hungtask problem which can be reproduced as follow:

Thread 0~3:

while true
do
touch /xxx/test/file_xxx
done

Thread 5 write a new checkpoint every three seconds.

Quoted 9 lines
Quoted 5 lines

In the meantime, fio start 16 threads for randwrite.

With my debug info, cycles num will exceed 1000 in function f2fs_sync_dirty_inodes, and most of cycle will be dropped into congestion_wait() and sleep more than 20ms.

Original patch tries to fix watchdog which sync_dirty_inodes() grabs one cpu for a long time. Have you tried reproduce that as well?

I have test this patch with increasing touch file threads to 32,and other remain same as previous, But I have not reproduce your problem.

Besides, I try to test the code just remove this line:

		congestion_wait(BLK_RW_ASYNC, HZ/50);
Quoted 6 lines
Quoted 3 lines
Quoted 1 line

It's also ok to my test, and cycle num reduced to < 3

You may be able to add threshold here?

Hmm, if cycle exceeds threshold, still we can encounter this issue. How about just removing congestion_wait, and keep cond_resched, it can switch current cpu out?

Okay, let's try that and see what'll happen.

Thanks,

Quoted 55 lines

Thanks,

Quoted 52 lines
Quoted 36 lines

Thanks.

Quoted 32 lines

Thanks,

Quoted 30 lines
---
 fs/f2fs/checkpoint.c | 10 ----------
 1 file changed, 10 deletions(-)
fs/f2fs/checkpoint.c +0 -3
index 8eb184c..76e1856 100644
@@ -944,7 +944,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	struct inode *inode;
 	struct f2fs_inode_info *fi;
 	bool is_dir = (type == DIR_INODE);
-	unsigned long ino = 0;
 
 	trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir,
 				get_pages(sbi, is_dir ?
@@ -967,8 +966,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 	inode = igrab(&fi->vfs_inode);
 	spin_unlock(&sbi->inode_lock[type]);
 	if (inode) {
-		unsigned long cur_ino = inode->i_ino;
-
 		if (is_dir)
 			F2FS_I(inode)->cp_task = current;
 
@@ -978,13 +975,6 @@ int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 			F2FS_I(inode)->cp_task = NULL;
 
Quoted 13 lines
Quoted 5 lines
Quoted 5 lines
fs/f2fs/checkpoint.c +0 -4
 		iput(inode);
-		/* We need to give cpu to another writers. */
-		if (ino == cur_ino) {
-			congestion_wait(BLK_RW_ASYNC, HZ/50);
-			cond_resched();
Quoted 8 lines
Quoted 8 lines
fs/f2fs/checkpoint.c +0 -4
-		} else {
-			ino = cur_ino;
-		}
 	} else {
 		/*
 		 * We should submit bio, since it exists several
--

1.9.1

.

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel