Skip to contentSkip to conversation

mm : bail out from psi memstall after submit_bio in swap_readpage

PATCH In review Huangzhaoyang 3 participants 6 messages Sep 7, 2021 – Sep 8, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm : bail out from psi memstall after submit_bio in swap_readpage

From: Zhaoyang Huang <[email protected]>

It doesn't make sense to count IO time into psi memstall. Bail out after bio submitted.

---
 mm/page_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/page_io.c +2 -1
index c493ce9..1d131fc 100644
@@ -423,6 +423,7 @@ int swap_readpage(struct page *page, bool synchronous)
 	count_vm_event(PSWPIN);
 	bio_get(bio);
 	qc = submit_bio(bio);
+	psi_memstall_leave(&pflags);
 	while (synchronous) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (!READ_ONCE(bio->bi_private))
@@ -433,7 +434,7 @@ int swap_readpage(struct page *page, bool synchronous)
 	}
 	__set_current_state(TASK_RUNNING);
 	bio_put(bio);
-
+	return ret;
 out:
 	psi_memstall_leave(&pflags);
 	return ret;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 4 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

It doesn't make sense to count IO time into psi memstall. Bail out after bio submitted.

Isn't that the point if psi, to observe real stalls, which include IO? Anyway, CCing Johannes.

Quoted 27 lines
---
 mm/page_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/page_io.c +2 -1
index c493ce9..1d131fc 100644
@@ -423,6 +423,7 @@ int swap_readpage(struct page *page, bool synchronous)
 	count_vm_event(PSWPIN);
 	bio_get(bio);
 	qc = submit_bio(bio);
+	psi_memstall_leave(&pflags);
 	while (synchronous) {
 		set_current_state(TASK_UNINTERRUPTIBLE);
 		if (!READ_ONCE(bio->bi_private))
@@ -433,7 +434,7 @@ int swap_readpage(struct page *page, bool synchronous)
 	}
 	__set_current_state(TASK_RUNNING);
 	bio_put(bio);
-
+	return ret;
 out:
 	psi_memstall_leave(&pflags);
 	return ret;
#2 lore raw
Quoted 9 lines · Vlastimil Babka
Quoted 4 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

It doesn't make sense to count IO time into psi memstall. Bail out after bio submitted.

Isn't that the point if psi, to observe real stalls, which include IO? Anyway, CCing Johannes.

IO stalls could be observed within blk_io_schedule. The time cost of the data from block device to RAM is counted here. The original purpose is to deal with the ZRAM alike devices which deal with the bio locally instead of submitting it to request queue.

Quoted 29 lines
Quoted 28 lines
---
 mm/page_io.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
mm/page_io.c +2 -1
index c493ce9..1d131fc 100644
@@ -423,6 +423,7 @@ int swap_readpage(struct page *page, bool synchronous)
      count_vm_event(PSWPIN);
      bio_get(bio);
      qc = submit_bio(bio);
+     psi_memstall_leave(&pflags);
      while (synchronous) {
              set_current_state(TASK_UNINTERRUPTIBLE);
              if (!READ_ONCE(bio->bi_private))
@@ -433,7 +434,7 @@ int swap_readpage(struct page *page, bool synchronous)
      }
      __set_current_state(TASK_RUNNING);
      bio_put(bio);
-
+     return ret;
 out:
      psi_memstall_leave(&pflags);
      return ret;
#3 lore raw
Quoted 9 lines · Zhaoyang Huang
Quoted 8 lines · Vlastimil Babka
Quoted 4 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

It doesn't make sense to count IO time into psi memstall. Bail out after bio submitted.

Isn't that the point if psi, to observe real stalls, which include IO?

Yes, correct.

Quoted 2 lines

IO stalls could be observed within blk_io_schedule. The time cost of the data from block device to RAM is counted here.

Yes, that is on purpose. The time a thread waits for swap read IO is time in which the thread is not productive due to a lack of memory.

For async-submitted IO, this happens in lock_page() called from do_swap_page(). If the submitting thread directly waits after the submit_bio(), then that should be accounted too.

This patch doesn't make sense to me.

#4 lore raw
Quoted 17 lines · Johannes Weiner
Quoted 9 lines · Zhaoyang Huang
Quoted 8 lines · Vlastimil Babka
Quoted 4 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

It doesn't make sense to count IO time into psi memstall. Bail out after bio submitted.

Isn't that the point if psi, to observe real stalls, which include IO?

Yes, correct.

Quoted 2 lines

IO stalls could be observed within blk_io_schedule. The time cost of the data from block device to RAM is counted here.

Quoted 6 lines

Yes, that is on purpose. The time a thread waits for swap read IO is time in which the thread is not productive due to a lack of memory.

For async-submitted IO, this happens in lock_page() called from do_swap_page(). If the submitting thread directly waits after the submit_bio(), then that should be accounted too.

IMO, memstall counting should be terminated by bio submitted. blk driver fetching request and the operation on the real device shouldn't be counted in. It especially doesn't make sense in a virtualization system like XEN etc, where the blk driver is implemented via backend-frontend way that introduce memory irrelevant latency

Quoted 2 lines

This patch doesn't make sense to me.

#5 lore raw
Quoted 21 lines · Zhaoyang Huang
Quoted 20 lines · Johannes Weiner
Quoted 9 lines · Zhaoyang Huang
Quoted 8 lines · Vlastimil Babka
Quoted 4 lines · Huangzhaoyang

From: Zhaoyang Huang <[email protected]>

It doesn't make sense to count IO time into psi memstall. Bail out after bio submitted.

Isn't that the point if psi, to observe real stalls, which include IO?

Yes, correct.

Quoted 2 lines

IO stalls could be observed within blk_io_schedule. The time cost of the data from block device to RAM is counted here.

Yes, that is on purpose. The time a thread waits for swap read IO is time in which the thread is not productive due to a lack of memory.

Quoted 8 lines
Quoted 3 lines

For async-submitted IO, this happens in lock_page() called from do_swap_page(). If the submitting thread directly waits after the submit_bio(), then that should be accounted too.

IMO, memstall counting should be terminated by bio submitted. blk driver fetching request and the operation on the real device shouldn't be counted in. It especially doesn't make sense in a virtualization system like XEN etc, where the blk driver is implemented via backend-frontend way that introduce memory irrelevant latency

Yes but the entire IO operation and all the associated latency only happens due to a shortage of memory in the first place. The thread is incurring these delays due to a lack of memory.

What is a memstall if not the latencies and wait times incurred in the process of reloading pages that were evicted prematurely?