From patchwork Thu Jan 5 05:35:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13089462 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 830D2C3DA7D for ; Thu, 5 Jan 2023 05:35:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A0C768E0005; Thu, 5 Jan 2023 00:35:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 994B48E0001; Thu, 5 Jan 2023 00:35:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80F688E0005; Thu, 5 Jan 2023 00:35:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6C3FC8E0001 for ; Thu, 5 Jan 2023 00:35:40 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 404561C63C6 for ; Thu, 5 Jan 2023 05:35:40 +0000 (UTC) X-FDA: 80319633240.11.6679DCD Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf19.hostedemail.com (Postfix) with ESMTP id 9F3AD1A0007 for ; Thu, 5 Jan 2023 05:35:38 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=ZOigF9gP; spf=pass (imf19.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.169 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672896938; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EvvS87mfgDK3AanjNOiSdWY479pGlUeMdWmydMONAbM=; b=mPYVHrhy0bdo7Tu0QxQbb20l1MOxAjpzFR3OCyW+Xl0lqBFKpowMFa5vYNVyT5VrERErBR NRzdrHhQuJsSdlifR3P9D8Bbysrv9kzjz4BrBvUaqWhNsTyEMegss4Mc46cJz9KRcELJJG WOor24Q725f+qx0+RCyZhjmVAUyg1bk= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=ZOigF9gP; spf=pass (imf19.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.169 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672896938; a=rsa-sha256; cv=none; b=WE1E+NIi5uhYVI8R3l6uKfmu6uavrCk4eol3J5+fWOq8Vpj3vDIpFFlLXtOJx5rf1p8p3O gGrQAeiN/gSa2kWC6dWv+2iqeC5QX53udI+3nUoHBEIFC9Q+XlOWGrZKf9FzgYzwkHakyJ YRcjvKkLhcitWO/P80+IaqHrOnfPYQs= Received: by mail-pf1-f169.google.com with SMTP id x26so18331456pfq.10 for ; Wed, 04 Jan 2023 21:35:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EvvS87mfgDK3AanjNOiSdWY479pGlUeMdWmydMONAbM=; b=ZOigF9gP3ox2wQ1zSpV804cSF8sMjwowDtxNQg8uNjyVvXHeLqggLSqwx1tRbjrl9B bnJrcbil85V6vAirx2XZPoC0C8R/EU2ZbD+54woGiRCo9GR8JP4hAMJkbFPpQyAk6EhY U7FslFAbJPenKL019W92H94OSDxTBVtGcc3wM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EvvS87mfgDK3AanjNOiSdWY479pGlUeMdWmydMONAbM=; b=ldO1tRL5rTRiRcxOzVMiztym0zKUbYLhMHZUdIUEzB+/VFYtGZg3kzwRdXMCZPzIpE d+93eNEeaurnw+RZ1A2Kyar6xcEfdIUX16gnj0kfD4JE5sKRUt7kbMgARr1whP70Lysx wWGXV8lTPWMrWcTW4yROVgDzoTkotoyIwuaI3lRIZVuTb76EQ0elf+tdJQhrjnTLm2BG mUnOsxdvrERM2yyv/rJ8s+TwCiBW+xUOeUfYS7fOIp/CqCbu/yQT4zoesypR0Wg9aAQ/ gN7ToqxAwtQ7g6SHM9BuiW/eHYcdY5jpKFZaNFzvK9AfQSZy+MyKSEABu9AxAW1nWr10 S3Bw== X-Gm-Message-State: AFqh2korWEsfObxTGBVikdhtmyEhdWEz/lBexsZMlTcBzlAoHZWVJgf3 S1gBqpdbe7MLuAAtEh2Sifu35A== X-Google-Smtp-Source: AMrXdXs7ikuwn0bVOye9xIcYyunW3Of68phhtfVO0eCIT+czMyzUJEhFuS9IQZf97Bw1n6CWls1t3g== X-Received: by 2002:a62:d45e:0:b0:56e:dca8:ba71 with SMTP id u30-20020a62d45e000000b0056edca8ba71mr43482025pfl.32.1672896937609; Wed, 04 Jan 2023 21:35:37 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:da84:4bce:bb29:7dea]) by smtp.gmail.com with ESMTPSA id v27-20020aa799db000000b00577c5915138sm2036855pfi.128.2023.01.04.21.35.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 21:35:37 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCH 2/4] zsmalloc: skip chain size calculation for pow_of_2 classes Date: Thu, 5 Jan 2023 14:35:08 +0900 Message-Id: <20230105053510.1819862-3-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230105053510.1819862-1-senozhatsky@chromium.org> References: <20230105053510.1819862-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9F3AD1A0007 X-Stat-Signature: s7ub6gwkn3e9eo53hmjdf8swzp5ixjfd X-Rspam-User: X-HE-Tag: 1672896938-512528 X-HE-Meta: U2FsdGVkX1+y57GqzaOw9wGx8wWWjzQjTL9wMVXHjH9qQB5aIeaBxykKkFh9OI7LIuKa5hD4zRNg6pFPkL1jbWVgtzPzYYbifORvFZhFq2yPnvwkRP86vvQ7vPy/tXtx5Lzrgs4OHw0kNXQF1EMNQNNDyNubHY0UlfDwAKY+LNWu11Kk7CVvmWEiIT+NTVvgYul7kxXdQKogtms5Pu0h1b/n6dFb0Y1e/W9XZLvATqvG4gPCKv3KwH+I/csJG42sZdi7A81ZPqt7rF5qQd+RWYkjcXcNIiPDg79+dypjF1gE6SisrRQ/L8Sr57RgeQrc6TG8y9dvP6RS8nz9TR+ntEzeERK1BSTLqzAJfRWYhZWc5dOcjU6zFCXSWy9nTvzn47M45SNZHf1m83zlOZPAKtERdZ34eH7/iZSXQA1GizGwkcsJ4IstTQOHIgKRANUL7vmgt+R+glrz0FJBNOLD+aMUpzoe01LyXlVbuuyXOu4ZFbrN91VU6nsaHrGkH8ZQ6Io3bSKJiio2/qUV47TZA77OXXibU1cfxFi/OHZPw7eGvhmnQXjsegDNyhzXuBErhSrHsaNBfUOh5tgwO7L18pfVrtxNSHd5dLqIxeim2CikxE/jpyV13l220Xl81iG7736aXCABykxdltUQOQr2AKuD3LUqtVc/0BxYmp/hMAz/mjPrn58WL/bJqicSfwfhEJiNIflrvLpavAaS8a6uISt6BgH8oPjMLSCA7moOC91y8ERIA6hTyo8SsKrk9MeHMM/RendPBEWFxk1P5/NBVQCLeSlSELHQj5x0tHZ3WSylvehhBrhEtjQeXhINW36bkLpGZROUof6WoHa2fhlN9fdJKhsZAwDnwVFVXMMh171RBynEJ0u3zQIW5CuVi5kbV3fGQ0/40A9oBONj2MV9bqEolPwqPpTTgPFghMaHhdZtwut4sjmCuxU6Z+/glWZTv6Vs6QorgAPf8NOAU8B ev975EHC MCWWFsd5Q/+fOi9SR89mmEkV8qzodNZXNnqX+cePiHbmQRoidaaubAZStVYXqw5Vx83Unn6k+eX9GFV415Vkms0Vk5HGmJlVXLZ9fL5AabTtAfzRGiBLJqMHDT6wM5y7KgL9TJnqsoRwtS1zRev5KMPwgKvx1nrgjGz22DKfTQuEG+QC5F+ESI78P+Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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;