summaryrefslogtreecommitdiff
path: root/mm/zsmalloc.c
diff options
context:
space:
mode:
authorSergey Senozhatsky <senozhatsky@chromium.org>2023-01-18 09:52:08 +0900
committerAndrew Morton <akpm@linux-foundation.org>2023-02-02 22:33:23 -0800
commite1d1f3546913ae0af9da31df8183a6f3da0cd590 (patch)
tree17b2e297362a6300267820fdc3f1f843663d5c6c /mm/zsmalloc.c
parent6260ae3583456808dceb4d78077e6388c49ca6d7 (diff)
zsmalloc: skip chain size calculation for pow_of_2 classes
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/20230118005210.2814763-3-senozhatsky@chromium.org Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> Acked-by: Minchan Kim <minchan@kernel.org> Cc: Mike Kravetz <mike.kravetz@oracle.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'mm/zsmalloc.c')
-rw-r--r--mm/zsmalloc.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 00ab4cca49e4..7b904f9bed70 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2370,6 +2370,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;