linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 0/6] Implement writeback for zsmalloc (fix)
@ 2022-11-23 19:17 Nhat Pham
  2022-11-23 19:17 ` [PATCH v6 4/6] zsmalloc: Add a LRU to zs_pool to keep track of zspages in LRU order (fix) Nhat Pham
  2022-11-23 19:17 ` [PATCH v6 6/6] zsmalloc: Implement writeback mechanism for zsmalloc (fix) Nhat Pham
  0 siblings, 2 replies; 3+ messages in thread
From: Nhat Pham @ 2022-11-23 19:17 UTC (permalink / raw)
  To: akpm
  Cc: hannes, linux-mm, linux-kernel, minchan, ngupta, senozhatsky,
	sjenning, ddstreet, vitaly.wool

This contains two small fixes that should be applied on top of patch 4
and patch 6 of my zsmalloc writeback series, respectively.

Changelog:
v6-fix:
  * Add a comment explaining LRU update logic in zs_map_object.
    (patch 4)
    (sugegested by Sergey Senozhatsky and Johannes Weiner).
  * Use get_first_page() and add cond_resched() in retry-loop.
    (patch 6) (sugegested by Sergey Senozhatsky).
v6:
  * Move the move-to-front logic into zs_map_object (patch 4)
    (suggested by Minchan Kim).
  * Small clean up for free_zspage at free_handles() call site
    (patch 6) (suggested by Minchan Kim).
v5:
  * Add a new patch that eliminates unused code in zpool and simplify
    the logic for storing evict handler in zbud/z3fold (patch 2)
  * Remove redudant fields in zs_pool (previously required by zpool)
    (patch 3)
  * Wrap under_reclaim and deferred handle freeing logic in CONFIG_ZPOOL
    (patch 6) (suggested by Minchan Kim)
  * Move a small piece of refactoring from patch 6 to patch 4.
v4:
  * Wrap the new LRU logic in CONFIG_ZPOOL (patch 3).
    (suggested by Minchan Kim)
v3:
  * Set pool->ops = NULL when pool->zpool_ops is null (patch 4).
  * Stop holding pool's lock when calling lock_zspage() (patch 5).
    (suggested by Sergey Senozhatsky)
  * Stop holding pool's lock when checking pool->ops and retries.
    (patch 5) (suggested by Sergey Senozhatsky)
  * Fix formatting issues (.shrink, extra spaces in casting removed).
    (patch 5) (suggested by Sergey Senozhatsky)
v2:
  * Add missing CONFIG_ZPOOL ifdefs (patch 5)
    (detected by kernel test robot).

--
2.30.2

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

* [PATCH v6 4/6] zsmalloc: Add a LRU to zs_pool to keep track of zspages in LRU order (fix)
  2022-11-23 19:17 [PATCH v6 0/6] Implement writeback for zsmalloc (fix) Nhat Pham
@ 2022-11-23 19:17 ` Nhat Pham
  2022-11-23 19:17 ` [PATCH v6 6/6] zsmalloc: Implement writeback mechanism for zsmalloc (fix) Nhat Pham
  1 sibling, 0 replies; 3+ messages in thread
From: Nhat Pham @ 2022-11-23 19:17 UTC (permalink / raw)
  To: akpm
  Cc: hannes, linux-mm, linux-kernel, minchan, ngupta, senozhatsky,
	sjenning, ddstreet, vitaly.wool

Add a comment explaining the mapping check for LRU update.

Signed-off-by: Nhat Pham <nphamcs@gmail.com>
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Suggested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 mm/zsmalloc.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 7dd464b5a6a5..d9bd865047e2 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1268,7 +1268,23 @@ void *zs_map_object(struct zs_pool *pool, unsigned long handle,
 	zspage = get_zspage(page);

 #ifdef CONFIG_ZPOOL
-	/* Move the zspage to front of pool's LRU */
+	/*
+	 * Move the zspage to front of pool's LRU.
+	 *
+	 * Note that this is swap-specific, so by definition there are no ongoing
+	 * accesses to the memory while the page is swapped out that would make
+	 * it "hot". A new entry is hot, then ages to the tail until it gets either
+	 * written back or swaps back in.
+	 *
+	 * Furthermore, map is also called during writeback. We must not put an
+	 * isolated page on the LRU mid-reclaim.
+	 *
+	 * As a result, only update the LRU when the page is mapped for write
+	 * when it's first instantiated.
+	 *
+	 * This is a deviation from the other backends, which perform this update
+	 * in the allocation function (zbud_alloc, z3fold_alloc).
+	 */
 	if (mm == ZS_MM_WO) {
 		if (!list_empty(&zspage->lru))
 			list_del(&zspage->lru);
--
2.30.2

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

* [PATCH v6 6/6] zsmalloc: Implement writeback mechanism for zsmalloc (fix)
  2022-11-23 19:17 [PATCH v6 0/6] Implement writeback for zsmalloc (fix) Nhat Pham
  2022-11-23 19:17 ` [PATCH v6 4/6] zsmalloc: Add a LRU to zs_pool to keep track of zspages in LRU order (fix) Nhat Pham
@ 2022-11-23 19:17 ` Nhat Pham
  1 sibling, 0 replies; 3+ messages in thread
From: Nhat Pham @ 2022-11-23 19:17 UTC (permalink / raw)
  To: akpm
  Cc: hannes, linux-mm, linux-kernel, minchan, ngupta, senozhatsky,
	sjenning, ddstreet, vitaly.wool

Use get_first_page(), and add cond_resched() in retry loop.

Signed-off-by: Nhat Pham <nphamcs@gmail.com>
Suggested-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 mm/zsmalloc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index e2bd41f37b5b..ab4fa17a0fad 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2488,12 +2488,13 @@ static int zs_reclaim_page(struct zs_pool *pool, unsigned int retries)
 		remove_zspage(class, zspage, fullness);

 		spin_unlock(&pool->lock);
+		cond_resched();

 		/* Lock backing pages into place */
 		lock_zspage(zspage);

 		obj_idx = 0;
-		page = zspage->first_page;
+		page = get_first_page(zspage);
 		while (1) {
 			handle = find_alloced_obj(class, page, &obj_idx);
 			if (!handle) {
--
2.30.2

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

end of thread, other threads:[~2022-11-23 19:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-23 19:17 [PATCH v6 0/6] Implement writeback for zsmalloc (fix) Nhat Pham
2022-11-23 19:17 ` [PATCH v6 4/6] zsmalloc: Add a LRU to zs_pool to keep track of zspages in LRU order (fix) Nhat Pham
2022-11-23 19:17 ` [PATCH v6 6/6] zsmalloc: Implement writeback mechanism for zsmalloc (fix) Nhat Pham

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).