This patch series adds a count of allocated objects for each of the zspage subpages. The main idea is that we can use the extra bytes of the page_type field, because with PAGE_SIZE = 4096 we only use the first two bytes there. By storing the number of allocated objects, we can optimize, for example, the running time of function find_allocated_obj, as well as the entire compact algorithm as a whole. Also, counting allocated objects has no effect on the performance of the entire zsmalloc: bitwise operations are fast and we don't use any extra memory. I also believe that we can also use this counter (maybe in the future) in some other things, which will speed up the allocator even more. Alexey Romanov (2): zsmalloc: add allocated objects counter for subpage zsmalloc: check empty page in find_alloced_obj mm/zsmalloc.c | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) -- 2.38.1