Skip to content

Commit

Permalink
zsmalloc: skip chain size calculation for pow_of_2 classes
Browse files Browse the repository at this point in the history
If a class size is power of 2 then it wastes no memory and the best
configuration is 1 physical page per-zspage.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Sergey Senozhatsky <[email protected]>
Acked-by: Minchan Kim <[email protected]>
Cc: Mike Kravetz <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
sergey-senozhatsky authored and dereference23 committed Jun 18, 2023
1 parent da5d758 commit a42e329
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions mm/zsmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2281,6 +2281,9 @@ static int calculate_zspage_chain_size(int class_size)
int i, min_waste = INT_MAX;
int chain_size = 1;

if (is_power_of_2(class_size))
return chain_size;

for (i = 1; i <= ZS_MAX_PAGES_PER_ZSPAGE; i++) {
int waste;

Expand Down

0 comments on commit a42e329

Please sign in to comment.