[v1,2/2] zsmalloc: check empty page in find_alloced_obj

Message ID 20230619143506.45253-3-avromanov@sberdevices.ru
State New
Headers
Series Add obj allocated counter for subpages |

Commit Message

Alexey Romanov June 19, 2023, 2:35 p.m. UTC
  It makes no sense to search for an allocated object
if there are none on the page. Using this check, we
get rid of the extra kmap_atomic, as well as the search
for a tagged object. On my synthetic test data, this
change speed up zsmalloc compaction time by up to 10%.

Signed-off-by: Alexey Romanov <avromanov@sberdevices.ru>
---
 mm/zsmalloc.c | 3 +++
 1 file changed, 3 insertions(+)
  

Patch

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index dd6e2c3429e0..d0ce579dcde5 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -1764,6 +1764,9 @@  static unsigned long find_tagged_obj(struct size_class *class,
 static unsigned long find_alloced_obj(struct size_class *class,
 					struct page *page, int *obj_idx)
 {
+	if (!get_obj_allocated(page))
+		return 0;
+
 	return find_tagged_obj(class, page, obj_idx, OBJ_ALLOCATED_TAG);
 }