linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Minchan Kim <minchan@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Sergey Senozhatsky <senozhatsky@chromium.org>
Subject: [PATCH 2/4] zsmalloc: skip chain size calculation for pow_of_2 classes
Date: Thu,  5 Jan 2023 14:35:08 +0900	[thread overview]
Message-ID: <20230105053510.1819862-3-senozhatsky@chromium.org> (raw)
In-Reply-To: <20230105053510.1819862-1-senozhatsky@chromium.org>

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



  parent reply	other threads:[~2023-01-05  5:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-05  5:35 [PATCH 0/4] zsmalloc: make zspage chain size configurable Sergey Senozhatsky
2023-01-05  5:35 ` [PATCH 1/4] zsmalloc: rework zspage chain size selection Sergey Senozhatsky
2023-01-05  5:35 ` Sergey Senozhatsky [this message]
2023-01-05  5:35 ` [PATCH 3/4] zsmalloc: make zspage chain size configurable Sergey Senozhatsky
2023-01-05 19:49   ` kernel test robot
2023-01-06  2:40     ` Sergey Senozhatsky
2023-01-05  5:35 ` [PATCH 4/4] zsmalloc: set default zspage chain size to 8 Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230105053510.1819862-3-senozhatsky@chromium.org \
    --to=senozhatsky@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=minchan@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox