Skip to contentSkip to conversation

Cleanup some writeback codes

PATCH Superseded Tang Yizhou 3 participants 13 messages Oct 2, 2024 – Oct 10, 2024

Subsystems (4)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Cleanup some writeback codes

From: Tang Yizhou <[email protected]>

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL and update some comments.

Tang Yizhou (3):
mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL mm/page-writeback.c: Fix comment of wb_domain_writeout_add()
xfs: Fix comment of xfs_buffered_write_iomap_begin()

 fs/xfs/xfs_iomap.c  |  2 +-
 mm/page-writeback.c | 18 +++++++++---------
 2 files changed, 10 insertions(+), 10 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/3 mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL

From: Tang Yizhou <[email protected]>

The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit().

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL to make things clear.

This patche doesn't introduce any behavioral changes.

---
 mm/page-writeback.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/page-writeback.c +8 -8
index fcd4c1439cb9..a848e7f0719d 100644
@@ -54,9 +54,9 @@
 #define DIRTY_POLL_THRESH	(128 >> (PAGE_SHIFT - 10))
 
 /*
- * Estimate write bandwidth at 200ms intervals.
+ * Estimate write bandwidth or update dirty limit at 200ms intervals.
  */
-#define BANDWIDTH_INTERVAL	max(HZ/5, 1)
+#define UPDATE_INTERVAL		max(HZ/5, 1)
 
 #define RATELIMIT_CALC_SHIFT	10
 
@@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc,
 	/*
 	 * check locklessly first to optimize away locking for the most time
 	 */
-	if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL))
+	if (time_before(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL))
 		return;
 
 	spin_lock(&dom->lock);
-	if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) {
+	if (time_after_eq(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL)) {
 		update_dirty_limit(dtc);
 		dom->dirty_limit_tstamp = now;
 	}
@@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
 		wb->dirty_exceeded = gdtc->dirty_exceeded ||
 				     (mdtc && mdtc->dirty_exceeded);
 		if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-					   BANDWIDTH_INTERVAL))
+					   UPDATE_INTERVAL))
 			__wb_update_bandwidth(gdtc, mdtc, true);
 
 		/* throttle according to the chosen dtc */
@@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
 	 * writeback bandwidth is updated once in a while.
 	 */
 	if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-				   BANDWIDTH_INTERVAL))
+				   UPDATE_INTERVAL))
 		wb_update_bandwidth(wb);
 	return ret;
 }
@@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
 	atomic_dec(&wb->writeback_inodes);
 	/*
 	 * Make sure estimate of writeback throughput gets updated after
-	 * writeback completed. We delay the update by BANDWIDTH_INTERVAL
+	 * writeback completed. We delay the update by UPDATE_INTERVAL
 	 * (which is the interval other bandwidth updates use for batching) so
 	 * that if multiple inodes end writeback at a similar time, they get
 	 * batched into one bandwidth update.
 	 */
 	spin_lock_irqsave(&wb->work_lock, flags);
 	if (test_bit(WB_registered, &wb->state))
-		queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+		queue_delayed_work(bdi_wq, &wb->bw_dwork, UPDATE_INTERVAL);
 	spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
Signature · 1 line
2.25.1
maintainer
#2 lore raw

Re: [PATCH 1/3] mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL

Quoted 7 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit().

Quoted 5 lines

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL to make things clear.

This patche doesn't introduce any behavioral changes.

Umm, I agree BANDWIDTH_INTERVAL may be confusing but UPDATE_INTERVAL does not seem much better to be honest. I actually have hard time coming up with a more descriptive name so what if we settled on updating the comment only instead of renaming to something not much better?

Honza

Quoted 73 lines
---
 mm/page-writeback.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/page-writeback.c +8 -8
index fcd4c1439cb9..a848e7f0719d 100644
@@ -54,9 +54,9 @@
 #define DIRTY_POLL_THRESH	(128 >> (PAGE_SHIFT - 10))
 
 /*
- * Estimate write bandwidth at 200ms intervals.
+ * Estimate write bandwidth or update dirty limit at 200ms intervals.
  */
-#define BANDWIDTH_INTERVAL	max(HZ/5, 1)
+#define UPDATE_INTERVAL		max(HZ/5, 1)
 
 #define RATELIMIT_CALC_SHIFT	10
 
@@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc,
 	/*
 	 * check locklessly first to optimize away locking for the most time
 	 */
-	if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL))
+	if (time_before(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL))
 		return;
 
 	spin_lock(&dom->lock);
-	if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) {
+	if (time_after_eq(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL)) {
 		update_dirty_limit(dtc);
 		dom->dirty_limit_tstamp = now;
 	}
@@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
 		wb->dirty_exceeded = gdtc->dirty_exceeded ||
 				     (mdtc && mdtc->dirty_exceeded);
 		if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-					   BANDWIDTH_INTERVAL))
+					   UPDATE_INTERVAL))
 			__wb_update_bandwidth(gdtc, mdtc, true);
 
 		/* throttle according to the chosen dtc */
@@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
 	 * writeback bandwidth is updated once in a while.
 	 */
 	if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-				   BANDWIDTH_INTERVAL))
+				   UPDATE_INTERVAL))
 		wb_update_bandwidth(wb);
 	return ret;
 }
@@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
 	atomic_dec(&wb->writeback_inodes);
 	/*
 	 * Make sure estimate of writeback throughput gets updated after
-	 * writeback completed. We delay the update by BANDWIDTH_INTERVAL
+	 * writeback completed. We delay the update by UPDATE_INTERVAL
 	 * (which is the interval other bandwidth updates use for batching) so
 	 * that if multiple inodes end writeback at a similar time, they get
 	 * batched into one bandwidth update.
 	 */
 	spin_lock_irqsave(&wb->work_lock, flags);
 	if (test_bit(WB_registered, &wb->state))
-		queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+		queue_delayed_work(bdi_wq, &wb->bw_dwork, UPDATE_INTERVAL);
 	spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#3 lore raw

Re: [PATCH 1/3] mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL

Quoted 13 lines · Jan Kara
Quoted 11 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit().

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL to make things clear.

This patche doesn't introduce any behavioral changes.

Quoted 8 lines
Quoted 1 line

Umm, I agree BANDWIDTH_INTERVAL may be confusing but UPDATE_INTERVAL does not seem much better to be honest. I actually have hard time coming up with a more descriptive name so what if we settled on updating the comment only instead of renaming to something not much better?

Honza

Thank you for your review. I agree that UPDATE_INTERVAL is not a good name. How about
renaming it to BW_DIRTYLIMIT_INTERVAL?

Yi

Quoted 76 lines
Quoted 70 lines
---
 mm/page-writeback.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/page-writeback.c +8 -9
index fcd4c1439cb9..a848e7f0719d 100644
@@ -54,9 +54,9 @@
 #define DIRTY_POLL_THRESH    (128 >> (PAGE_SHIFT - 10))
 
 /*
- * Estimate write bandwidth at 200ms intervals.
+ * Estimate write bandwidth or update dirty limit at 200ms intervals.
  */
-#define BANDWIDTH_INTERVAL   max(HZ/5, 1)
+#define UPDATE_INTERVAL              max(HZ/5, 1)
 
 #define RATELIMIT_CALC_SHIFT 10
 
@@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc,
      /*
       * check locklessly first to optimize away locking for the most time
       */
-     if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL))
+     if (time_before(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL))
              return;
 
      spin_lock(&dom->lock);
-     if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) {
+     if (time_after_eq(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL)) {
              update_dirty_limit(dtc);
              dom->dirty_limit_tstamp = now;
      }
@@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
              wb->dirty_exceeded = gdtc->dirty_exceeded ||
                                   (mdtc && mdtc->dirty_exceeded);
              if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                        BANDWIDTH_INTERVAL))
+                                        UPDATE_INTERVAL))
                      __wb_update_bandwidth(gdtc, mdtc, true);
 
              /* throttle according to the chosen dtc */
@@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
       * writeback bandwidth is updated once in a while.
       */
      if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                BANDWIDTH_INTERVAL))
+                                UPDATE_INTERVAL))
              wb_update_bandwidth(wb);
      return ret;
 }
@@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
      atomic_dec(&wb->writeback_inodes);
      /*
       * Make sure estimate of writeback throughput gets updated after
-      * writeback completed. We delay the update by BANDWIDTH_INTERVAL
+      * writeback completed. We delay the update by UPDATE_INTERVAL
       * (which is the interval other bandwidth updates use for batching) so
       * that if multiple inodes end writeback at a similar time, they get
       * batched into one bandwidth update.
       */
      spin_lock_irqsave(&wb->work_lock, flags);
      if (test_bit(WB_registered, &wb->state))
-             queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+             queue_delayed_work(bdi_wq, &wb->bw_dwork, UPDATE_INTERVAL);
      spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
--
Quoted 3 lines

2.25.1

--
Jan Kara <[email protected]>
SUSE Labs, CR

maintainer
#4 lore raw

Re: [PATCH 1/3] mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL

Quoted 21 lines · Tang Yizhou
Quoted 20 lines · Jan Kara
Quoted 7 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit().

Quoted 5 lines

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL to make things clear.

This patche doesn't introduce any behavioral changes.

Umm, I agree BANDWIDTH_INTERVAL may be confusing but UPDATE_INTERVAL does not seem much better to be honest. I actually have hard time coming up with a more descriptive name so what if we settled on updating the comment only instead of renaming to something not much better?

Quoted 5 lines
Quoted 1 line

Honza

Thank you for your review. I agree that UPDATE_INTERVAL is not a good name. How about
renaming it to BW_DIRTYLIMIT_INTERVAL?

Maybe WB_STAT_INTERVAL? Because it is interval in which we maintain statistics about writeback behavior.

Honza

Quoted 76 lines
Quoted 76 lines
Quoted 70 lines
---
 mm/page-writeback.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/page-writeback.c +8 -9
index fcd4c1439cb9..a848e7f0719d 100644
@@ -54,9 +54,9 @@
 #define DIRTY_POLL_THRESH    (128 >> (PAGE_SHIFT - 10))
 
 /*
- * Estimate write bandwidth at 200ms intervals.
+ * Estimate write bandwidth or update dirty limit at 200ms intervals.
  */
-#define BANDWIDTH_INTERVAL   max(HZ/5, 1)
+#define UPDATE_INTERVAL              max(HZ/5, 1)
 
 #define RATELIMIT_CALC_SHIFT 10
 
@@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc,
      /*
       * check locklessly first to optimize away locking for the most time
       */
-     if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL))
+     if (time_before(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL))
              return;
 
      spin_lock(&dom->lock);
-     if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) {
+     if (time_after_eq(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL)) {
              update_dirty_limit(dtc);
              dom->dirty_limit_tstamp = now;
      }
@@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
              wb->dirty_exceeded = gdtc->dirty_exceeded ||
                                   (mdtc && mdtc->dirty_exceeded);
              if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                        BANDWIDTH_INTERVAL))
+                                        UPDATE_INTERVAL))
                      __wb_update_bandwidth(gdtc, mdtc, true);
 
              /* throttle according to the chosen dtc */
@@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
       * writeback bandwidth is updated once in a while.
       */
      if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                BANDWIDTH_INTERVAL))
+                                UPDATE_INTERVAL))
              wb_update_bandwidth(wb);
      return ret;
 }
@@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
      atomic_dec(&wb->writeback_inodes);
      /*
       * Make sure estimate of writeback throughput gets updated after
-      * writeback completed. We delay the update by BANDWIDTH_INTERVAL
+      * writeback completed. We delay the update by UPDATE_INTERVAL
       * (which is the interval other bandwidth updates use for batching) so
       * that if multiple inodes end writeback at a similar time, they get
       * batched into one bandwidth update.
       */
      spin_lock_irqsave(&wb->work_lock, flags);
      if (test_bit(WB_registered, &wb->state))
-             queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+             queue_delayed_work(bdi_wq, &wb->bw_dwork, UPDATE_INTERVAL);
      spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
--
Quoted 3 lines

2.25.1

--
Jan Kara <[email protected]>
SUSE Labs, CR

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#5 lore raw

Re: [PATCH 1/3] mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL

Quoted 23 lines · Jan Kara
Quoted 21 lines · Tang Yizhou
Quoted 20 lines · Jan Kara
Quoted 7 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit().

Quoted 5 lines

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL to make things clear.

This patche doesn't introduce any behavioral changes.

Umm, I agree BANDWIDTH_INTERVAL may be confusing but UPDATE_INTERVAL does not seem much better to be honest. I actually have hard time coming up with a more descriptive name so what if we settled on updating the comment only instead of renaming to something not much better?

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Honza

Thank you for your review. I agree that UPDATE_INTERVAL is not a good name. How about
renaming it to BW_DIRTYLIMIT_INTERVAL?

Maybe WB_STAT_INTERVAL? Because it is interval in which we maintain statistics about writeback behavior.

I don't think this is a good name, as it suggests a relation to enum wb_stat_item, but bandwidth and dirty limit are not in wb_stat_item.

Yi

Quoted 81 lines

Honza

Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
---
 mm/page-writeback.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/page-writeback.c +8 -8
index fcd4c1439cb9..a848e7f0719d 100644
@@ -54,9 +54,9 @@
 #define DIRTY_POLL_THRESH    (128 >> (PAGE_SHIFT - 10))
 
 /*
- * Estimate write bandwidth at 200ms intervals.
+ * Estimate write bandwidth or update dirty limit at 200ms intervals.
  */
-#define BANDWIDTH_INTERVAL   max(HZ/5, 1)
+#define UPDATE_INTERVAL              max(HZ/5, 1)
 
 #define RATELIMIT_CALC_SHIFT 10
 
@@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc,
      /*
       * check locklessly first to optimize away locking for the most time
       */
-     if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL))
+     if (time_before(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL))
              return;
 
      spin_lock(&dom->lock);
-     if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) {
+     if (time_after_eq(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL)) {
              update_dirty_limit(dtc);
              dom->dirty_limit_tstamp = now;
      }
@@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
              wb->dirty_exceeded = gdtc->dirty_exceeded ||
                                   (mdtc && mdtc->dirty_exceeded);
              if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                        BANDWIDTH_INTERVAL))
+                                        UPDATE_INTERVAL))
                      __wb_update_bandwidth(gdtc, mdtc, true);
 
              /* throttle according to the chosen dtc */
@@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
       * writeback bandwidth is updated once in a while.
       */
      if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                BANDWIDTH_INTERVAL))
+                                UPDATE_INTERVAL))
              wb_update_bandwidth(wb);
      return ret;
 }
@@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
      atomic_dec(&wb->writeback_inodes);
      /*
       * Make sure estimate of writeback throughput gets updated after
-      * writeback completed. We delay the update by BANDWIDTH_INTERVAL
+      * writeback completed. We delay the update by UPDATE_INTERVAL
       * (which is the interval other bandwidth updates use for batching) so
       * that if multiple inodes end writeback at a similar time, they get
       * batched into one bandwidth update.
       */
      spin_lock_irqsave(&wb->work_lock, flags);
      if (test_bit(WB_registered, &wb->state))
-             queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+             queue_delayed_work(bdi_wq, &wb->bw_dwork, UPDATE_INTERVAL);
      spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

--
2.25.1

--
Jan Kara <[email protected]>
SUSE Labs, CR

--
Jan Kara <[email protected]>
SUSE Labs, CR

maintainer
#6 lore raw

Re: [PATCH 1/3] mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL

Quoted 30 lines · Tang Yizhou
Quoted 29 lines · Jan Kara
Quoted 26 lines · Tang Yizhou
Quoted 13 lines · Jan Kara
Quoted 11 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit().

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL to make things clear.

This patche doesn't introduce any behavioral changes.

Quoted 8 lines
Quoted 1 line

Umm, I agree BANDWIDTH_INTERVAL may be confusing but UPDATE_INTERVAL does not seem much better to be honest. I actually have hard time coming up with a more descriptive name so what if we settled on updating the comment only instead of renaming to something not much better?

Honza

Thank you for your review. I agree that UPDATE_INTERVAL is not a good name. How about
renaming it to BW_DIRTYLIMIT_INTERVAL?

Quoted 6 lines
Quoted 3 lines

Maybe WB_STAT_INTERVAL? Because it is interval in which we maintain statistics about writeback behavior.

I don't think this is a good name, as it suggests a relation to enum wb_stat_item, but bandwidth and dirty limit are not in wb_stat_item.

OK, so how about keeping BANDWIDTH_INTERVAL as is and adding DIRTY_LIMIT_INTERVAL with the same value? There's nothing which would strictly tie them to the same value.

Honza

Quoted 79 lines
Quoted 79 lines
Quoted 69 lines
Quoted 69 lines
Quoted 69 lines
---
 mm/page-writeback.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/page-writeback.c +8 -8
index fcd4c1439cb9..a848e7f0719d 100644
@@ -54,9 +54,9 @@
 #define DIRTY_POLL_THRESH    (128 >> (PAGE_SHIFT - 10))
 
 /*
- * Estimate write bandwidth at 200ms intervals.
+ * Estimate write bandwidth or update dirty limit at 200ms intervals.
  */
-#define BANDWIDTH_INTERVAL   max(HZ/5, 1)
+#define UPDATE_INTERVAL              max(HZ/5, 1)
 
 #define RATELIMIT_CALC_SHIFT 10
 
@@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc,
      /*
       * check locklessly first to optimize away locking for the most time
       */
-     if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL))
+     if (time_before(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL))
              return;
 
      spin_lock(&dom->lock);
-     if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) {
+     if (time_after_eq(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL)) {
              update_dirty_limit(dtc);
              dom->dirty_limit_tstamp = now;
      }
@@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
              wb->dirty_exceeded = gdtc->dirty_exceeded ||
                                   (mdtc && mdtc->dirty_exceeded);
              if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                        BANDWIDTH_INTERVAL))
+                                        UPDATE_INTERVAL))
                      __wb_update_bandwidth(gdtc, mdtc, true);
 
              /* throttle according to the chosen dtc */
@@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
       * writeback bandwidth is updated once in a while.
       */
      if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                BANDWIDTH_INTERVAL))
+                                UPDATE_INTERVAL))
              wb_update_bandwidth(wb);
      return ret;
 }
@@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
      atomic_dec(&wb->writeback_inodes);
      /*
       * Make sure estimate of writeback throughput gets updated after
-      * writeback completed. We delay the update by BANDWIDTH_INTERVAL
+      * writeback completed. We delay the update by UPDATE_INTERVAL
       * (which is the interval other bandwidth updates use for batching) so
       * that if multiple inodes end writeback at a similar time, they get
       * batched into one bandwidth update.
       */
      spin_lock_irqsave(&wb->work_lock, flags);
      if (test_bit(WB_registered, &wb->state))
-             queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+             queue_delayed_work(bdi_wq, &wb->bw_dwork, UPDATE_INTERVAL);
      spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

--
2.25.1

--
Jan Kara <[email protected]>
SUSE Labs, CR

--
Jan Kara <[email protected]>
SUSE Labs, CR

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#7 lore raw

Re: [PATCH 1/3] mm/page-writeback.c: Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL

Quoted 36 lines · Jan Kara
Quoted 34 lines · Tang Yizhou
Quoted 32 lines · Jan Kara
Quoted 21 lines · Tang Yizhou
Quoted 20 lines · Jan Kara
Quoted 7 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

The name of the BANDWIDTH_INTERVAL macro is misleading, as it is not only used in the bandwidth update functions wb_update_bandwidth() and __wb_update_bandwidth(), but also in the dirty limit update function domain_update_dirty_limit().

Quoted 5 lines

Rename BANDWIDTH_INTERVAL to UPDATE_INTERVAL to make things clear.

This patche doesn't introduce any behavioral changes.

Umm, I agree BANDWIDTH_INTERVAL may be confusing but UPDATE_INTERVAL does not seem much better to be honest. I actually have hard time coming up with a more descriptive name so what if we settled on updating the comment only instead of renaming to something not much better?

Quoted 5 lines
Quoted 1 line

Honza

Thank you for your review. I agree that UPDATE_INTERVAL is not a good name. How about
renaming it to BW_DIRTYLIMIT_INTERVAL?

Maybe WB_STAT_INTERVAL? Because it is interval in which we maintain statistics about writeback behavior.

Quoted 7 lines
Quoted 2 lines

I don't think this is a good name, as it suggests a relation to enum wb_stat_item, but bandwidth and dirty limit are not in wb_stat_item.

OK, so how about keeping BANDWIDTH_INTERVAL as is and adding DIRTY_LIMIT_INTERVAL with the same value? There's nothing which would strictly tie them to the same value.

Good idea, but this patch has already been merged. If there is any writeback-related code that needs to be modified next time, I will update this part as well.

Yi

Quoted 84 lines

Honza

Quoted 76 lines
Quoted 76 lines
Quoted 76 lines
Quoted 76 lines
Quoted 70 lines
---
 mm/page-writeback.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
mm/page-writeback.c +8 -9
index fcd4c1439cb9..a848e7f0719d 100644
@@ -54,9 +54,9 @@
 #define DIRTY_POLL_THRESH    (128 >> (PAGE_SHIFT - 10))
 
 /*
- * Estimate write bandwidth at 200ms intervals.
+ * Estimate write bandwidth or update dirty limit at 200ms intervals.
  */
-#define BANDWIDTH_INTERVAL   max(HZ/5, 1)
+#define UPDATE_INTERVAL              max(HZ/5, 1)
 
 #define RATELIMIT_CALC_SHIFT 10
 
@@ -1331,11 +1331,11 @@ static void domain_update_dirty_limit(struct dirty_throttle_control *dtc,
      /*
       * check locklessly first to optimize away locking for the most time
       */
-     if (time_before(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL))
+     if (time_before(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL))
              return;
 
      spin_lock(&dom->lock);
-     if (time_after_eq(now, dom->dirty_limit_tstamp + BANDWIDTH_INTERVAL)) {
+     if (time_after_eq(now, dom->dirty_limit_tstamp + UPDATE_INTERVAL)) {
              update_dirty_limit(dtc);
              dom->dirty_limit_tstamp = now;
      }
@@ -1928,7 +1928,7 @@ static int balance_dirty_pages(struct bdi_writeback *wb,
              wb->dirty_exceeded = gdtc->dirty_exceeded ||
                                   (mdtc && mdtc->dirty_exceeded);
              if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                        BANDWIDTH_INTERVAL))
+                                        UPDATE_INTERVAL))
                      __wb_update_bandwidth(gdtc, mdtc, true);
 
              /* throttle according to the chosen dtc */
@@ -2705,7 +2705,7 @@ int do_writepages(struct address_space *mapping, struct writeback_control *wbc)
       * writeback bandwidth is updated once in a while.
       */
      if (time_is_before_jiffies(READ_ONCE(wb->bw_time_stamp) +
-                                BANDWIDTH_INTERVAL))
+                                UPDATE_INTERVAL))
              wb_update_bandwidth(wb);
      return ret;
 }
@@ -3057,14 +3057,14 @@ static void wb_inode_writeback_end(struct bdi_writeback *wb)
      atomic_dec(&wb->writeback_inodes);
      /*
       * Make sure estimate of writeback throughput gets updated after
-      * writeback completed. We delay the update by BANDWIDTH_INTERVAL
+      * writeback completed. We delay the update by UPDATE_INTERVAL
       * (which is the interval other bandwidth updates use for batching) so
       * that if multiple inodes end writeback at a similar time, they get
       * batched into one bandwidth update.
       */
      spin_lock_irqsave(&wb->work_lock, flags);
      if (test_bit(WB_registered, &wb->state))
-             queue_delayed_work(bdi_wq, &wb->bw_dwork, BANDWIDTH_INTERVAL);
+             queue_delayed_work(bdi_wq, &wb->bw_dwork, UPDATE_INTERVAL);
      spin_unlock_irqrestore(&wb->work_lock, flags);
 }
 
--
Quoted 3 lines

2.25.1

--
Jan Kara <[email protected]>
SUSE Labs, CR

Quoted 3 lines
Quoted 3 lines

--
Jan Kara <[email protected]>
SUSE Labs, CR

--
Jan Kara <[email protected]>
SUSE Labs, CR

#8 lore raw

PATCH 2/3 mm/page-writeback.c: Fix comment of wb_domain_writeout_add()

In reply to Tang Yizhou

From: Tang Yizhou <[email protected]>

__bdi_writeout_inc() has undergone multiple renamings, but the comment within the function body have not been updated accordingly. Update it to reflect the latest wb_domain_writeout_add().

---
 mm/page-writeback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page-writeback.c +1 -1
index a848e7f0719d..4f6efaa060bd 100644
@@ -586,7 +586,7 @@ static void wb_domain_writeout_add(struct wb_domain *dom,
 	/* First event after period switching was turned off? */
 	if (unlikely(!dom->period_time)) {
 		/*
-		 * We can race with other __bdi_writeout_inc calls here but
+		 * We can race with other wb_domain_writeout_add calls here but
 		 * it does not cause any harm since the resulting time when
 		 * timer will fire and what is in writeout_period_time will be
 		 * roughly the same.
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 2/3
#9 lore raw

Re: [PATCH 2/3] mm/page-writeback.c: Fix comment of wb_domain_writeout_add()

Quoted 7 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

__bdi_writeout_inc() has undergone multiple renamings, but the comment within the function body have not been updated accordingly. Update it to reflect the latest wb_domain_writeout_add().

Looks good. Feel free to add:

Honza

Quoted 21 lines
---
 mm/page-writeback.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/page-writeback.c +1 -1
index a848e7f0719d..4f6efaa060bd 100644
@@ -586,7 +586,7 @@ static void wb_domain_writeout_add(struct wb_domain *dom,
 	/* First event after period switching was turned off? */
 	if (unlikely(!dom->period_time)) {
 		/*
-		 * We can race with other __bdi_writeout_inc calls here but
+		 * We can race with other wb_domain_writeout_add calls here but
 		 * it does not cause any harm since the resulting time when
 		 * timer will fire and what is in writeout_period_time will be
 		 * roughly the same.
Signature · 1 line
2.25.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#10 lore raw

PATCH 3/3 xfs: Fix comment of xfs_buffered_write_iomap_begin()

In reply to Tang Yizhou

From: Tang Yizhou <[email protected]>

Since macro MAX_WRITEBACK_PAGES has been removed from the writeback path, change MAX_WRITEBACK_PAGES to the actual value of 1024.

---
 fs/xfs/xfs_iomap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_iomap.c +1 -1
index 1e11f48814c0..bb4018395b6e 100644
@@ -1097,7 +1097,7 @@ xfs_buffered_write_iomap_begin(
 		end_fsb = imap.br_startoff + imap.br_blockcount;
 	} else {
 		/*
-		 * We cap the maximum length we map here to MAX_WRITEBACK_PAGES
+		 * We cap the maximum length we map here to 1024
 		 * pages to keep the chunks of work done where somewhat
 		 * symmetric with the work writeback does.  This is a completely
 		 * arbitrary number pulled out of thin air.
Signature · 1 line
2.25.1
#11 lore raw

Re: [PATCH 3/3] xfs: Fix comment of xfs_buffered_write_iomap_begin()

Quoted 4 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

Since macro MAX_WRITEBACK_PAGES has been removed from the writeback path, change MAX_WRITEBACK_PAGES to the actual value of 1024.

Well, that's an indicator that this code need a bit of a resync with the writeback code so that the comment stays true.

#12 lore raw

Re: [PATCH 3/3] xfs: Fix comment of xfs_buffered_write_iomap_begin()

Quoted 9 lines · Christoph Hellwig
Quoted 4 lines · Tang Yizhou

From: Tang Yizhou <[email protected]>

Since macro MAX_WRITEBACK_PAGES has been removed from the writeback path, change MAX_WRITEBACK_PAGES to the actual value of 1024.

Well, that's an indicator that this code need a bit of a resync with the writeback code so that the comment stays true.

Thanks for your advice. I will rewrite the code following the logic of writeback_chunk_size().

Yi