mm/zswap: misc cleanup of code and documentations
Subsystems (6)
cover mm/zswap: misc cleanup of code and documentations
Cleanup an unnecessary local variable write in incompressible pages handling, typos (s/zwap/zswap/) and outdated comments/documentations about the zswap's red-black tree, which is replaced by xarray.
SeongJae Park (4):
mm/zswap: remove unnecessary dlen writes for incompressible pages mm/zswap: fix typos: s/zwap/zswap/
mm/zswap: s/red-black tree/xarray/ Docs/admin-guide/mm/zswap: s/red-black tree/xarray/
Documentation/admin-guide/mm/zswap.rst | 10 +++++----- mm/memcontrol.c | 2 +- mm/zswap.c | 7 +++---- 3 files changed, 9 insertions(+), 10 deletions(-)
base-commit: 2e943d9cc1fdd399a2f95d1c1d6b865d04bfa239
Signature · 1 line
2.39.5
PATCH 1/4 mm/zswap: remove unnecessary dlen writes for incompressible pages
Incompressible pages handling logic in zswap_compress() is setting 'dlen' as PAGE_SIZE twice. Once before deciding whether to save the content as is, and once again after it is decided to save it as is. But the value of 'dlen' is used only if it is decided to save the content as is, so the first write is unnecessary. It is not causing real user issues, but making code confusing to read. Remove the unnecessary write operation.
--- mm/zswap.c | 1 - 1 file changed, 1 deletion(-)
mm/zswap.c +0 -1
@@ -894,7 +894,6 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,* to the active LRU list in the case. */ if (comp_ret || !dlen || dlen >=PAGE_SIZE ) { - dlen =PAGE_SIZE ;if (!mem_cgroup_zswap_writeback_enabled (folio_memcg (page_folio (page)))) { comp_ret = comp_ret ? comp_ret : -EINVAL ;
Signature · 1 line
2.39.5
PATCH 2/4 mm/zswap: fix typos: s/zwap/zswap/
In reply to SeongJae ParkAs the subject says.
--- mm/memcontrol.c | 2 +- mm/zswap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
mm/memcontrol.c +1 -1
@@ -5421,7 +5421,7 @@ bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)* @size: size of compressed object * * This forces the charge after obj_cgroup_may_zswap() allowed -* compression and storage in zwap for this cgroup to go ahead. +* compression and storage in zswap for this cgroup to go ahead. */ void obj_cgroup_charge_zswap (struct obj_cgroup *objcg,size_t size) {
mm/zswap.c +2 -2
@@ -879,7 +879,7 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,* acomp instance, then get those requests done simultaneously. but in this * case, zswap actually does store and load page by page, there is no * existing method to send the second page before the first page is done -* in one thread doing zwap. +* in one thread doing zswap. * but in different threads running on different cpu, we have different * acomp instance, so multiple threads can do (de)compression in parallel. */
@@ -1128,7 +1128,7 @@ static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_o* * 1. We extract the swp_entry_t to the stack, allowing * zswap_writeback_entry() to pin the swap entry and -* then validate the zwap entry against that swap entry's +* then validate the zswap entry against that swap entry's * tree using pointer value comparison. Only when that * is successful can the entry be dereferenced. *
Signature · 1 line
2.39.5
PATCH 3/4 mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkChanges made by commit 796c2c23e14e ("zswap: replace RB tree with xarray") is not reflected on a comment. Update the comment.
--- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/zswap.c +1 -1
@@ -175,7 +175,7 @@ static struct shrinker *zswap_shrinker;* This structure contains the metadata for tracking a single compressed * page within zswap. * -* swpentry - associated swap entry, the offset indexes into the red-black tree +* swpentry - associated swap entry, the offset indexes into the xarray * length - the length in bytes of the compressed page data. Needed during * decompression. * referenced - true if the entry recently entered the zswap pool. Unset by the
Signature · 1 line
2.39.5
PATCH 4/4 Docs/admin-guide/mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkThe change from commit 796c2c23e14e ("zswap: replace RB tree with xarray") is not reflected on the document. Update the document.
--- Documentation/admin-guide/mm/zswap.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
Documentation/admin-guide/mm/zswap.rst +5 -5
@@ -59,11 +59,11 @@ returned by the allocation routine and that handle must be mapped before being accessed. The compressed memory pool grows on demand and shrinks as compressed pages are freed. The pool is not preallocated. -When a swap page is passed from swapout to zswap, zswap maintains a mapping -of the swap entry, a combination of the swap type and swap offset, to the -zsmalloc handle that references that compressed swap page. This mapping is -achieved with a red-black tree per swap type. The swap offset is the search -key for the tree nodes. +When a swap page is passed from swapout to zswap, zswap maintains a mapping of +the swap entry, a combination of the swap type and swap offset, to the zsmalloc +handle that references that compressed swap page. This mapping is achieved +with an xarray per swap type. The swap offset is the search key for the xarray +nodes. During a page fault on a PTE that is a swap entry, the swapin code calls the zswap load function to decompress the page into the page allocated by the page
Signature · 1 line
2.39.5
Re: [PATCH 1/4] mm/zswap: remove unnecessary dlen writes for incompressible pages
In reply to SeongJae ParkQuoted 9 lines · SeongJae Park
Incompressible pages handling logic in
zswap_compress()is setting 'dlen' asPAGE_SIZEtwice. Once before deciding whether to save the content as is, and once again after it is decided to save it as is. But the value of 'dlen' is used only if it is decided to save the content as is, so the first write is unnecessary. It is not causing real user issues, but making code confusing to read. Remove the unnecessary write operation.Signed-off-by SeongJae Park <[email protected]>
Quoted 18 lines
--- mm/zswap.c | 1 - 1 file changed, 1 deletion(-)mm/zswap.c +0
-1@@ -894,7 +894,6 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,* to the active LRU list in the case. */ if (comp_ret || !dlen || dlen >=PAGE_SIZE ) { - dlen =PAGE_SIZE ;if (!mem_cgroup_zswap_writeback_enabled (folio_memcg (page_folio (page)))) { comp_ret = comp_ret ? comp_ret : -EINVAL ;Signature · 1 line
2.39.5
Re: [PATCH 2/4] mm/zswap: fix typos: s/zwap/zswap/
In reply to SeongJae ParkQuoted 3 lines · SeongJae Park
As the subject says.
Signed-off-by SeongJae Park <[email protected]>
Quoted 42 lines
--- mm/memcontrol.c | 2 +- mm/zswap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)mm/memcontrol.c +1
-1@@ -5421,7 +5421,7 @@ bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)* @size: size of compressed object * * This forces the charge after obj_cgroup_may_zswap() allowed -* compression and storage in zwap for this cgroup to go ahead. +* compression and storage in zswap for this cgroup to go ahead. */ void obj_cgroup_charge_zswap (struct obj_cgroup *objcg,size_t size) {mm/zswap.c +2
-2@@ -879,7 +879,7 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,* acomp instance, then get those requests done simultaneously. but in this * case, zswap actually does store and load page by page, there is no * existing method to send the second page before the first page is done -* in one thread doing zwap. +* in one thread doing zswap. * but in different threads running on different cpu, we have different * acomp instance, so multiple threads can do (de)compression in parallel. */ @@ -1128,7 +1128,7 @@ static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_o* * 1. We extract the swp_entry_t to the stack, allowing * zswap_writeback_entry() to pin the swap entry and -* then validate the zwap entry against that swap entry's +* then validate the zswap entry against that swap entry's * tree using pointer value comparison. Only when that * is successful can the entry be dereferenced. * Signature · 1 line
2.39.5
Re: [PATCH 3/4] mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
Changes made by commit
796c2c23e14e("zswap: replace RB tree with xarray") is not reflected on a comment. Update the comment.Signed-off-by SeongJae Park <[email protected]>
Quoted 19 lines
--- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/zswap.c +1
-1@@ -175,7 +175,7 @@ static struct shrinker *zswap_shrinker;* This structure contains the metadata for tracking a single compressed * page within zswap. * -* swpentry - associated swap entry, the offset indexes into the red-black tree +* swpentry - associated swap entry, the offset indexes into the xarray * length - the length in bytes of the compressed page data. Needed during * decompression. * referenced - true if the entry recently entered the zswap pool. Unset by the Signature · 1 line
2.39.5
Re: [PATCH 4/4] Docs/admin-guide/mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
The change from commit
796c2c23e14e("zswap: replace RB tree with xarray") is not reflected on the document. Update the document.Signed-off-by SeongJae Park <[email protected]>
Quoted 27 lines
--- Documentation/admin-guide/mm/zswap.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)Documentation/admin-guide/mm/zswap.rst +5
-5@@ -59,11 +59,11 @@ returned by the allocation routine and that handle must be mapped before being accessed. The compressed memory pool grows on demand and shrinks as compressed pages are freed. The pool is not preallocated. -When a swap page is passed from swapout to zswap, zswap maintains a mapping -of the swap entry, a combination of the swap type and swap offset, to the -zsmalloc handle that references that compressed swap page. This mapping is -achieved with a red-black tree per swap type. The swap offset is the search -key for the tree nodes. +When a swap page is passed from swapout to zswap, zswap maintains a mapping of +the swap entry, a combination of the swap type and swap offset, to the zsmalloc +handle that references that compressed swap page. This mapping is achieved +with an xarray per swap type. The swap offset is the search key for the xarray +nodes. During a page fault on a PTE that is a swap entry, the swapin code calls the zswap load function to decompress the page into the page allocated by the pageSignature · 1 line
2.39.5
Re: [PATCH 1/4] mm/zswap: remove unnecessary dlen writes for incompressible pages
In reply to SeongJae ParkQuoted 10 lines · SeongJae Park
Incompressible pages handling logic in
zswap_compress()is setting 'dlen' asPAGE_SIZEtwice. Once before deciding whether to save the content as is, and once again after it is decided to save it as is. But the value of 'dlen' is used only if it is decided to save the content as is, so the first write is unnecessary. It is not causing real user issues, but making code confusing to read. Remove the unnecessary write operation.Signed-off-by SeongJae Park <[email protected]>
Re: [PATCH 2/4] mm/zswap: fix typos: s/zwap/zswap/
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
As the subject says.
Signed-off-by SeongJae Park <[email protected]>
Re: [PATCH 3/4] mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkQuoted 5 lines · SeongJae Park
Changes made by commit
796c2c23e14e("zswap: replace RB tree with xarray") is not reflected on a comment. Update the comment.Signed-off-by SeongJae Park <[email protected]>
Re: [PATCH 4/4] Docs/admin-guide/mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkQuoted 18 lines · SeongJae Park
The change from commit
796c2c23e14e("zswap: replace RB tree with xarray") is not reflected on the document. Update the document.Signed-off-by SeongJae Park <[email protected]>--- Documentation/admin-guide/mm/zswap.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)Documentation/admin-guide/mm/zswap.rst +0
-1@@ -59,11 +59,11 @@ returned by the allocation routine and that handle must be mapped before being accessed. The compressed memory pool grows on demand and shrinks as compressed pages are freed. The pool is not preallocated. -When a swap page is passed from swapout to zswap, zswap maintains a mapping
Documentation/admin-guide/mm/zswap.rst returned by the allocation routine and that handle must be mapped before being · line 67
Quoted 10 lines
Documentation/admin-guide/mm/zswap.rst +5
-4-of the swap entry, a combination of the swap type and swap offset, to the -zsmalloc handle that references that compressed swap page. This mapping is -achieved with a red-black tree per swap type. The swap offset is the search -key for the tree nodes. +When a swap page is passed from swapout to zswap, zswap maintains a mapping of +the swap entry, a combination of the swap type and swap offset, to the zsmalloc +handle that references that compressed swap page. This mapping is achieved +with an xarray per swap type. The swap offset is the search key for the xarray +nodes.
Re: [PATCH 1/4] mm/zswap: remove unnecessary dlen writes for incompressible pages
In reply to SeongJae ParkQuoted 9 lines · SeongJae Park
Incompressible pages handling logic in
zswap_compress()is setting 'dlen' asPAGE_SIZEtwice. Once before deciding whether to save the content as is, and once again after it is decided to save it as is. But the value of 'dlen' is used only if it is decided to save the content as is, so the first write is unnecessary. It is not causing real user issues, but making code confusing to read. Remove the unnecessary write operation.Signed-off-by SeongJae Park <[email protected]>
Quoted 16 lines
--- mm/zswap.c | 1 - 1 file changed, 1 deletion(-)mm/zswap.c +0
-1@@ -894,7 +894,6 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,* to the active LRU list in the case. */ if (comp_ret || !dlen || dlen >=PAGE_SIZE ) { - dlen =PAGE_SIZE ;if (!mem_cgroup_zswap_writeback_enabled (folio_memcg (page_folio (page)))) { comp_ret = comp_ret ? comp_ret : -EINVAL ;
Re: [PATCH 2/4] mm/zswap: fix typos: s/zwap/zswap/
In reply to SeongJae ParkQuoted 3 lines · SeongJae Park
As the subject says.
Signed-off-by SeongJae Park <[email protected]>
Quoted 40 lines
--- mm/memcontrol.c | 2 +- mm/zswap.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)mm/memcontrol.c +1
-1@@ -5421,7 +5421,7 @@ bool obj_cgroup_may_zswap(struct obj_cgroup *objcg)* @size: size of compressed object * * This forces the charge after obj_cgroup_may_zswap() allowed -* compression and storage in zwap for this cgroup to go ahead. +* compression and storage in zswap for this cgroup to go ahead. */ void obj_cgroup_charge_zswap (struct obj_cgroup *objcg,size_t size) {mm/zswap.c +2
-2@@ -879,7 +879,7 @@ static bool zswap_compress(struct page *page, struct zswap_entry *entry,* acomp instance, then get those requests done simultaneously. but in this * case, zswap actually does store and load page by page, there is no * existing method to send the second page before the first page is done -* in one thread doing zwap. +* in one thread doing zswap. * but in different threads running on different cpu, we have different * acomp instance, so multiple threads can do (de)compression in parallel. */ @@ -1128,7 +1128,7 @@ static enum lru_status shrink_memcg_cb(struct list_head *item, struct list_lru_o* * 1. We extract the swp_entry_t to the stack, allowing * zswap_writeback_entry() to pin the swap entry and -* then validate the zwap entry against that swap entry's +* then validate the zswap entry against that swap entry's * tree using pointer value comparison. Only when that * is successful can the entry be dereferenced. *
Re: [PATCH 3/4] mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
Changes made by commit
796c2c23e14e("zswap: replace RB tree with xarray") is not reflected on a comment. Update the comment.Signed-off-by SeongJae Park <[email protected]>
Quoted 17 lines
--- mm/zswap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/zswap.c +1
-1@@ -175,7 +175,7 @@ static struct shrinker *zswap_shrinker;* This structure contains the metadata for tracking a single compressed * page within zswap. * -* swpentry - associated swap entry, the offset indexes into the red-black tree +* swpentry - associated swap entry, the offset indexes into the xarray * length - the length in bytes of the compressed page data. Needed during * decompression. * referenced - true if the entry recently entered the zswap pool. Unset by the
Re: [PATCH 4/4] Docs/admin-guide/mm/zswap: s/red-black tree/xarray/
In reply to SeongJae ParkQuoted 4 lines · SeongJae Park
The change from commit
796c2c23e14e("zswap: replace RB tree with xarray") is not reflected on the document. Update the document.Signed-off-by SeongJae Park <[email protected]>
Quoted 25 lines
--- Documentation/admin-guide/mm/zswap.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)Documentation/admin-guide/mm/zswap.rst +5
-5@@ -59,11 +59,11 @@ returned by the allocation routine and that handle must be mapped before being accessed. The compressed memory pool grows on demand and shrinks as compressed pages are freed. The pool is not preallocated. -When a swap page is passed from swapout to zswap, zswap maintains a mapping -of the swap entry, a combination of the swap type and swap offset, to the -zsmalloc handle that references that compressed swap page. This mapping is -achieved with a red-black tree per swap type. The swap offset is the search -key for the tree nodes. +When a swap page is passed from swapout to zswap, zswap maintains a mapping of +the swap entry, a combination of the swap type and swap offset, to the zsmalloc +handle that references that compressed swap page. This mapping is achieved +with an xarray per swap type. The swap offset is the search key for the xarray +nodes. During a page fault on a PTE that is a swap entry, the swapin code calls the zswap load function to decompress the page into the page allocated by the page