lkml.org 
[lkml]   [2023]   [Jan]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/4] zsmalloc: skip chain size calculation for pow_of_2 classes
Date
If a class size is power of 2 then it wastes no memory
and the best configuration is 1 physical page per-zspage.

Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
mm/zsmalloc.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c
index 959126e708a3..9a0f1963b803 100644
--- a/mm/zsmalloc.c
+++ b/mm/zsmalloc.c
@@ -2290,6 +2290,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;

--
2.39.0.314.g84b9a713c41-goog
\
 
 \ /
  Last update: 2023-03-26 23:28    [W:1.879 / U:0.004 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site