linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: Do not start/end writeback for pages stored in zswap
@ 2024-06-10 14:30 Usama Arif
  2024-06-10 17:31 ` Yosry Ahmed
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Usama Arif @ 2024-06-10 14:30 UTC (permalink / raw)
  To: akpm
  Cc: willy, hannes, yosryahmed, nphamcs, chengming.zhou, linux-mm,
	linux-kernel, kernel-team, Usama Arif

start/end writeback combination incorrectly increments NR_WRITTEN
counter, eventhough the pages aren't written to disk. Pages successfully
stored in zswap should just unlock folio and return from writepage.

Signed-off-by: Usama Arif <usamaarif642@gmail.com>
---
 mm/page_io.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index a360857cf75d..501784d79977 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -196,9 +196,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
 		return ret;
 	}
 	if (zswap_store(folio)) {
-		folio_start_writeback(folio);
 		folio_unlock(folio);
-		folio_end_writeback(folio);
 		return 0;
 	}
 	if (!mem_cgroup_zswap_writeback_enabled(folio_memcg(folio))) {
-- 
2.43.0



^ permalink raw reply	[flat|nested] 12+ messages in thread
* [PATCH] mm: Do not start/end writeback for pages stored in zswap
@ 2024-06-12 10:01 Usama Arif
  0 siblings, 0 replies; 12+ messages in thread
From: Usama Arif @ 2024-06-12 10:01 UTC (permalink / raw)
  To: akpm
  Cc: shakeel.butt, willy, hannes, yosryahmed, nphamcs, chengming.zhou,
	linux-mm, linux-kernel, kernel-team, Usama Arif

Most of the work done in folio_start_writeback is reversed in
folio_end_writeback. For e.g. NR_WRITEBACK and NR_ZONE_WRITE_PENDING
are incremented in start_writeback and decremented in end_writeback.
Calling end_writeback immediately after start_writeback (separated by
folio_unlock) cancels the affect of most of the work done in start
hence can be removed.

There is some extra work done in folio_end_writeback, however it is
incorrect/not applicable to zswap:
- folio_end_writeback incorrectly increments NR_WRITTEN counter,
  eventhough the pages aren't written to disk, hence this change
  corrects this behaviour.
- folio_end_writeback calls folio_rotate_reclaimable, but that only
  makes sense for async writeback pages, while for zswap pages are
  synchronously reclaimed.

Suggested-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Chengming Zhou <chengming.zhou@linux.dev>
Reviewed-by: Shakeel Butt <shakeel.butt@linux.dev>
Acked-by: Yosry Ahmed <yosryahmed@google.com>
Signed-off-by: Usama Arif <usamaarif642@gmail.com>
---
 mm/page_io.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/mm/page_io.c b/mm/page_io.c
index a360857cf75d..501784d79977 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -196,9 +196,7 @@ int swap_writepage(struct page *page, struct writeback_control *wbc)
 		return ret;
 	}
 	if (zswap_store(folio)) {
-		folio_start_writeback(folio);
 		folio_unlock(folio);
-		folio_end_writeback(folio);
 		return 0;
 	}
 	if (!mem_cgroup_zswap_writeback_enabled(folio_memcg(folio))) {
-- 
2.43.0



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-06-12 10:01 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 14:30 [PATCH] mm: Do not start/end writeback for pages stored in zswap Usama Arif
2024-06-10 17:31 ` Yosry Ahmed
2024-06-10 18:11   ` Usama Arif
2024-06-10 18:29     ` Yosry Ahmed
2024-06-10 19:08   ` Shakeel Butt
2024-06-10 20:05     ` Yosry Ahmed
2024-06-10 20:15 ` Johannes Weiner
2024-06-11  9:53 ` Chengming Zhou
2024-06-11 15:59   ` Usama Arif
2024-06-11 17:16 ` Shakeel Butt
2024-06-11 17:28   ` Yosry Ahmed
2024-06-12 10:01 Usama Arif

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox