Skip to contentSkip to conversation

btrfs: cleanup btrfs_async_submit_limit to return the final limit value

PATCH Superseded Anand Jain 3 participants 8 messages Oct 31, 2017 – Nov 7, 2017 Btrfs file system

lore
Share & tools
lore

Anand Jain

author
#0 lore raw

PATCH 1/1 btrfs: cleanup btrfs_async_submit_limit to return the final limit value

btrfs_async_submit_limit() would return the q depth to be 256, however when we are using it we are making it 2/3 times of it. So instead let the function return the final computed value.

---
 fs/btrfs/disk-io.c | 6 ++++--
 fs/btrfs/volumes.c | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +4 -2
index dfdab849037b..e58bbc2a68a5 100644
@@ -861,7 +861,10 @@ unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
 	unsigned long limit = min_t(unsigned long,
 				    info->thread_pool_size,
 				    info->fs_devices->open_devices);
-	return 256 * limit;
+	/*
+	 * As of now limit is computed as 2/3 * 256.
+	 */
+	return 170 * limit;
 }
 
 static void run_one_async_start(struct btrfs_work *work)
@@ -887,7 +890,6 @@ static void run_one_async_done(struct btrfs_work *work)
 	fs_info = async->fs_info;
 
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 	/*
 	 * atomic_dec_return implies a barrier for waitqueue_active
fs/btrfs/volumes.c +0 -1
index d1d8aa226bff..8044790c5de6 100644
@@ -382,7 +382,6 @@ static noinline void run_scheduled_bios(struct btrfs_device *device)
 
 	bdi = device->bdev->bd_bdi;
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 loop:
 	spin_lock(&device->io_lock);
Signature · 1 line
2.13.1
#1 lore raw
Quoted 5 lines · Anand Jain

btrfs_async_submit_limit() would return the q depth to be 256, however when we are using it we are making it 2/3 times of it. So instead let the function return the final computed value.

Could you put a bit info about what exactly is this limit controlling in the changelog.

Quoted 10 lines
---
 fs/btrfs/disk-io.c | 6 ++++--
 fs/btrfs/volumes.c | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +0 -0
index dfdab849037b..e58bbc2a68a5 100644

fs/btrfs/disk-io.c unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info) · line 866

Quoted 7 lines
fs/btrfs/disk-io.c +3 -1
@@ -861,7 +861,10 @@ unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
 	unsigned long limit = min_t(unsigned long,
 				    info->thread_pool_size,
 				    info->fs_devices->open_devices);
-	return 256 * limit;
+	/*
+	 * As of now limit is computed as 2/3 * 256.
+	 */

Drop the "As of now" part, since it doesn't bring any value.

Quoted 25 lines
fs/btrfs/disk-io.c +1 -1
+	return 170 * limit;
 }
 
 static void run_one_async_start(struct btrfs_work *work)
@@ -887,7 +890,6 @@ static void run_one_async_done(struct btrfs_work *work)
 	fs_info = async->fs_info;
 
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 	/*
 	 * atomic_dec_return implies a barrier for waitqueue_active
fs/btrfs/volumes.c +0 -1
index d1d8aa226bff..8044790c5de6 100644
@@ -382,7 +382,6 @@ static noinline void run_scheduled_bios(struct btrfs_device *device)
 
 	bdi = device->bdev->bd_bdi;
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 loop:
 	spin_lock(&device->io_lock);
author
#2 lore raw
Quoted 11 lines · Nikolay Borisov
Quoted 5 lines · Anand Jain

btrfs_async_submit_limit() would return the q depth to be 256, however when we are using it we are making it 2/3 times of it. So instead let the function return the final computed value.

Could you put a bit info about what exactly is this limit controlling in the changelog.

Ok will update.

Quoted 5 lines
Quoted 5 lines
---
  fs/btrfs/disk-io.c | 6 ++++--
  fs/btrfs/volumes.c | 1 -
  2 files changed, 4 insertions(+), 3 deletions(-)
Quoted 14 lines

fs/btrfs/disk-io.c unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info) · line 866

Quoted 12 lines
fs/btrfs/disk-io.c +3 -1
index dfdab849037b..e58bbc2a68a5 100644
@@ -861,7 +861,10 @@ unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
  	unsigned long limit = min_t(unsigned long,
  				    info->thread_pool_size,
  				    info->fs_devices->open_devices);
-	return 256 * limit;
+	/*
+	 * As of now limit is computed as 2/3 * 256.
+	 */

Drop the "As of now" part, since it doesn't bring any value.

Ok.

Thanks
Anand

Quoted 30 lines
Quoted 18 lines
fs/btrfs/disk-io.c +1 -1
+	return 170 * limit;
  }
 
  static void run_one_async_start(struct btrfs_work *work)
@@ -887,7 +890,6 @@ static void run_one_async_done(struct btrfs_work *work)
  	fs_info = async->fs_info;
 
  	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
  	/*
  	 * atomic_dec_return implies a barrier for waitqueue_active
fs/btrfs/volumes.c +0 -0
index d1d8aa226bff..8044790c5de6 100644

fs/btrfs/volumes.c static noinline void run_scheduled_bios(struct btrfs_device *device) · line 387

Quoted 7 lines
fs/btrfs/volumes.c +0 -1
@@ -382,7 +382,6 @@ static noinline void run_scheduled_bios(struct btrfs_device *device)
 
  	bdi = device->bdev->bd_bdi;
  	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
  loop:
  	spin_lock(&device->io_lock);

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw

PATCH v2 1/1 btrfs: cleanup btrfs_async_submit_limit to return the final limit value

In reply to Anand Jain

We feedback IO progress when it falls below 2/3 times of the limit obtained from btrfs_async_submit_limit(), and creates a wait for the write process and makes progress during the async submission.

In general device/transport q depth is 256 and, btrfs_async_submit_limit() returns 256 times per device which originally was introduced by [1]. But 256 at the device level is for all types of IOs (R/W sync/async) and so may be it was possible that entire of 256 could have occupied by async writes and, so later patch [2] took only 2/3 times of 256 which seemed to work well.

[1]
cb03c743c648
Btrfs: Change the congestion functions to meter the number of async submits as well

[2]
4854ddd0ed0a
Btrfs: Wait for kernel threads to make progress during async submission

This patch is a cleanup patch, no functional changes. And now as we are taking only 2/3 of limit (256), so btrfs_async_submit_limit() will return 170 itself.

---
IMO:
1. If the pdflush issue is fixed, we should go back to bdi congestion method, as block layer is more appropriate and accurate to tell when the device is congested. Device q depth 256 is very generic.
2. Consider RAID1 devices at different speed (SSD and iscsi LUN) not too sure if this approach would lead to the FS layer IO performance throttle at the speed of the lowest ? wonder how to reliably test it.

 fs/btrfs/disk-io.c | 6 ++++--
 fs/btrfs/volumes.c | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +4 -2
index dfdab849037b..12702e292007 100644
@@ -861,7 +861,10 @@ unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
 	unsigned long limit = min_t(unsigned long,
 				    info->thread_pool_size,
 				    info->fs_devices->open_devices);
-	return 256 * limit;
+	/*
+	 * limit:170 is computed as 2/3 * 256.
+	 */
+	return 170 * limit;
 }
 
 static void run_one_async_start(struct btrfs_work *work)
@@ -887,7 +890,6 @@ static void run_one_async_done(struct btrfs_work *work)
 	fs_info = async->fs_info;
 
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 	/*
 	 * atomic_dec_return implies a barrier for waitqueue_active
fs/btrfs/volumes.c +0 -1
index d1d8aa226bff..8044790c5de6 100644
@@ -382,7 +382,6 @@ static noinline void run_scheduled_bios(struct btrfs_device *device)
 
 	bdi = device->bdev->bd_bdi;
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 loop:
 	spin_lock(&device->io_lock);
Signature · 1 line
2.13.1
#4 lore raw
Quoted 41 lines · Anand Jain

We feedback IO progress when it falls below 2/3 times of the limit obtained from btrfs_async_submit_limit(), and creates a wait for the write process and makes progress during the async submission.

In general device/transport q depth is 256 and, btrfs_async_submit_limit() returns 256 times per device which originally was introduced by [1]. But 256 at the device level is for all types of IOs (R/W sync/async) and so may be it was possible that entire of 256 could have occupied by async writes and, so later patch [2] took only 2/3 times of 256 which seemed to work well.

[1]
cb03c743c648
Btrfs: Change the congestion functions to meter the number of async submits as well

[2]
4854ddd0ed0a
Btrfs: Wait for kernel threads to make progress during async submission

This patch is a cleanup patch, no functional changes. And now as we are taking only 2/3 of limit (256), so btrfs_async_submit_limit() will return 170 itself.

---
IMO:
1. If the pdflush issue is fixed, we should go back to bdi congestion method, as block layer is more appropriate and accurate to tell when the device is congested. Device q depth 256 is very generic.
2. Consider RAID1 devices at different speed (SSD and iscsi LUN) not too sure if this approach would lead to the FS layer IO performance throttle at the speed of the lowest ? wonder how to reliably test it.

 fs/btrfs/disk-io.c | 6 ++++--
 fs/btrfs/volumes.c | 1 -
 2 files changed, 4 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +0 -0
index dfdab849037b..12702e292007 100644

fs/btrfs/disk-io.c unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info) · line 867

Quoted 8 lines
fs/btrfs/disk-io.c +4 -1
@@ -861,7 +861,10 @@ unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
 	unsigned long limit = min_t(unsigned long,
 				    info->thread_pool_size,
 				    info->fs_devices->open_devices);
-	return 256 * limit;
+	/*
+	 * limit:170 is computed as 2/3 * 256.
+	 */
+	return 170 * limit;

Please keep it opencoded, the constant will be calculated by compiler but for code clarity it's better to be written as 2 / 3 and it's self-documenting, so you can drop the comment.

#5 lore raw
In reply to Anand Jain
Quoted 23 lines · Anand Jain

We feedback IO progress when it falls below 2/3 times of the limit obtained from btrfs_async_submit_limit(), and creates a wait for the write process and makes progress during the async submission.

In general device/transport q depth is 256 and, btrfs_async_submit_limit() returns 256 times per device which originally was introduced by [1]. But 256 at the device level is for all types of IOs (R/W sync/async) and so may be it was possible that entire of 256 could have occupied by async writes and, so later patch [2] took only 2/3 times of 256 which seemed to work well.

[1]
cb03c743c648
Btrfs: Change the congestion functions to meter the number of async submits as well

[2]
4854ddd0ed0a
Btrfs: Wait for kernel threads to make progress during async submission

This patch is a cleanup patch, no functional changes. And now as we are taking only 2/3 of limit (256), so btrfs_async_submit_limit() will return 170 itself.

Quoted 8 lines

---
IMO:
1. If the pdflush issue is fixed, we should go back to bdi congestion method, as block layer is more appropriate and accurate to tell when the device is congested. Device q depth 256 is very generic.
2. Consider RAID1 devices at different speed (SSD and iscsi LUN) not too sure if this approach would lead to the FS layer IO performance throttle at the speed of the lowest ? wonder how to reliably test it.

The referenced commits are from 2008, there have been many changes in the queue flushing etc, so we might need to revisit the current behaviour completely. Using the congestion API is desired, but we also need to keep the IO behaviour (or make it better of course). In such case I'd suggest small steps so we can possibly catch the regressions.

author
#7 lore raw

PATCH v3 1/1 btrfs: cleanup btrfs_async_submit_limit to return the final limit value

In reply to Anand Jain

We feedback IO progress when it falls below the 2/3 times of the limit obtained from btrfs_async_submit_limit() so to creates a wait for the write process and make uncontested progress during the async submission.

In general device/transport q depth is 256 and, btrfs_async_submit_limit() returns 256 times per device which originally was introduced by [1]. But 256 at the device level is for all types of IOs (R/W sync/async) and so may be it was possible that entire of 256 could have occupied by async writes and, so later patch [2] took only 2/3 times of 256 which seemed to work well.

[1]
cb03c743c648
Btrfs: Change the congestion functions to meter the number of async submits as well

[2]
4854ddd0ed0a
Btrfs: Wait for kernel threads to make progress during async submission

This patch is a cleanup patch, no functional changes. And now as we are taking only 2/3 of limit (256), so btrfs_async_submit_limit() will return 256 * 2/3.

---
v2: add more change log.
v3: don't compute 256 * 2/3. I didn't know compiler will do it anyway,
thats nice. So keeping that open coded. And comment removed.

 fs/btrfs/disk-io.c | 4 ++--
 fs/btrfs/volumes.c | 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)
fs/btrfs/disk-io.c +2 -2
index dfdab849037b..6e27259e965b 100644
@@ -861,7 +861,8 @@ unsigned long btrfs_async_submit_limit(struct btrfs_fs_info *info)
 	unsigned long limit = min_t(unsigned long,
 				    info->thread_pool_size,
 				    info->fs_devices->open_devices);
-	return 256 * limit;
+
+	return (256 * 2/3) * limit;
 }
 
 static void run_one_async_start(struct btrfs_work *work)
@@ -887,7 +888,6 @@ static void run_one_async_done(struct btrfs_work *work)
 	fs_info = async->fs_info;
 
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 	/*
 	 * atomic_dec_return implies a barrier for waitqueue_active
fs/btrfs/volumes.c +0 -1
index b39737568c22..61cefa37b56a 100644
@@ -376,7 +376,6 @@ static noinline void run_scheduled_bios(struct btrfs_device *device)
 
 	bdi = device->bdev->bd_bdi;
 	limit = btrfs_async_submit_limit(fs_info);
-	limit = limit * 2 / 3;
 
 loop:
 	spin_lock(&device->io_lock);
Signature · 1 line
2.13.1
author
#6 lore raw
In reply to David Sterba
Quoted 9 lines
Quoted 8 lines

1. If the pdflush issue is fixed, we should go back to bdi congestion method, as block layer is more appropriate and accurate to tell when the device is congested. Device q depth 256 is very generic.
2. Consider RAID1 devices at different speed (SSD and iscsi LUN) not too sure if this approach would lead to the FS layer IO performance throttle at the speed of the lowest ? wonder how to reliably test it.

Quoted 5 lines

The referenced commits are from 2008, there have been many changes in the queue flushing etc, so we might need to revisit the current behaviour completely. Using the congestion API is desired, but we also need to keep the IO behaviour (or make it better of course). In such case I'd suggest small steps so we can possibly catch the regressions.

Ok. Will try. Its still confusing to me.

Thanks, Anand