From patchwork Wed Oct 26 11:29:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 11199 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp205213wru; Wed, 26 Oct 2022 04:31:18 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4OHAqKliwaztWVz8FxAvv1H2QLU1Hnv/bRtW5Gdzc6NeTs1HeoX2X/lBahLWb05dBcqILR X-Received: by 2002:a17:907:a4c:b0:77b:ba98:d3e with SMTP id be12-20020a1709070a4c00b0077bba980d3emr37346913ejc.13.1666783878301; Wed, 26 Oct 2022 04:31:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666783878; cv=none; d=google.com; s=arc-20160816; b=lZk+/MhLH9pSnypBO0vPNqzubV7tlssCx2mNtn7+2IRLkAcFguU7Q4YxIB8N0OeNgO DkYk/A/nebTNj6yFyhDyKp0foFwN0/k9Q8iHakbux/bm4Tq49FWQfbrK6dnhTbeRb9Wr RPzYpQBZgHGTLGsNAwtMoBYPGt6RUzr8TNSjcrtYtzUNgQFHvIc+beyi9le4N+dOaRvt XZNw5R+odYalSmUaA3HTu7OYZX4U67YdXgtaCvyhrfgfMz3WU1gSdGuPYkCb7W1PApx+ kTHH0oRQP2JqyyXSVKiUArfmpmQ2mC3yk48azqo8ZR0DOGUiGqWnFxcVZPvWJVrNRHCE SjLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GHzCyKbWb+aU+sZGmdZ8m8JVMN9OaN+P/JFQjaIcOqo=; b=XvWCo86Fw95S1U+JgS8DonqXc/LJqchsjqR/fx4LCK4aJPJlqJfIEDsArzVYFe3tW0 U8LkUIisHBCySKmd53NbeHR8W5+dTggZmPIh6g8HEX5nKSKXmzmMLrBl5ent+TiNHUUy Wr6mZ4/kPMrR1cF/jiH8kO6ulXT3/jiFTV0BQcfv3W4o1tU30/xXrml4SeNAzOgaAajE x8Xen5tXtKeZbIoBp/qk1+L0cGCB8CiK3aUno54BZjQCfYwu31CsSsAso9STPYtR2IBe ixs7jRcnQWWQIGwtU3wWkt5EXFB1+o6JnUkQx1wYw6B592uWe8zdofQl81IP5LP5b1/J Jp1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="CLe/xD6M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s13-20020a056402520d00b00458ab54baa5si6249722edd.503.2022.10.26.04.30.51; Wed, 26 Oct 2022 04:31:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="CLe/xD6M"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233373AbiJZLab (ORCPT + 99 others); Wed, 26 Oct 2022 07:30:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57776 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233111AbiJZLaT (ORCPT ); Wed, 26 Oct 2022 07:30:19 -0400 Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 63F732F021 for ; Wed, 26 Oct 2022 04:30:18 -0700 (PDT) Received: by mail-pg1-x52a.google.com with SMTP id e129so14463705pgc.9 for ; Wed, 26 Oct 2022 04:30:18 -0700 (PDT) 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=GHzCyKbWb+aU+sZGmdZ8m8JVMN9OaN+P/JFQjaIcOqo=; b=CLe/xD6MM8eGCn9K4ey1Id/4Y+RMm1UdxlSXb3Af8TSUSccKm0tWe/dZMBkT5nF2IM A+QXB7pCZKWwzYs63P+o//k4SjonuoD+Fp7NpqTPITOrM+7tz5g8IEUOkFgA5jS1wFCh 9VyRUexk961XMuPn8A2B9UzeZWIYfAFCwoFTY= 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=GHzCyKbWb+aU+sZGmdZ8m8JVMN9OaN+P/JFQjaIcOqo=; b=DA3j9WtQh6Vcw8mugcviB59wcHQ4IKDLcsRHDCbBpvCUSGuljJH/tBisLJarWTYCQA mdzj20yo37B3Yz2A0pZH1LiTyco1Nncuik+9UtypLTapcaAp5wN2rvRz+W/Z/BY40M1H f6qxGpq+H4lPH4Lp5WBpzXGwOyvfCMCPCnvmmxRLQYEx9Vbid7QxtDkRM3cXCAA2BiHQ yUUPye746hzUzRwhcArImDZ7E6k5R/0HclgGVsg9uUVCVAyxacIFUMN+HmJ6+r/FhgoU S6gTfyGFWn+GU6u/IpGOB2aygWzKyOAzxboCYcyFVaFeRy46cs+fYXyLjQ9JnUewn69A hpgw== X-Gm-Message-State: ACrzQf2OTjSH6gRWqJJOB3T+qtaTo6VcAE0NLSUcLV/sARUrQWSjDyeH B5yZCz7Pr6GD9Yw0AwxiNAiymQ== X-Received: by 2002:a63:454d:0:b0:43c:e834:ec0 with SMTP id u13-20020a63454d000000b0043ce8340ec0mr38246206pgk.270.1666783817832; Wed, 26 Oct 2022 04:30:17 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:749c:f7f5:1a8e:d0be]) by smtp.gmail.com with ESMTPSA id x127-20020a626385000000b005627868e27esm2814919pfb.127.2022.10.26.04.30.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Oct 2022 04:30:17 -0700 (PDT) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Nitin Gupta , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv2 3/9] zsmalloc: move away from page order defines Date: Wed, 26 Oct 2022 20:29:27 +0900 Message-Id: <20221026112933.4122957-4-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.0.135.g90850a2211-goog In-Reply-To: <20221026112933.4122957-1-senozhatsky@chromium.org> References: <20221026112933.4122957-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747749571914767502?= X-GMAIL-MSGID: =?utf-8?q?1747749571914767502?= There is no reason for us to require pages per-zspage to be a power of two. Rename macros and use plain limit numbers there instead of 2 ^ N values. This will let us to have more tunable limits. Signed-off-by: Sergey Senozhatsky --- include/linux/zsmalloc.h | 16 +++++++--------- mm/zsmalloc.c | 4 +--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h index 6cd1d95b928a..b6b8654a2d45 100644 --- a/include/linux/zsmalloc.h +++ b/include/linux/zsmalloc.h @@ -33,17 +33,15 @@ enum zs_mapmode { */ }; -#define ZS_PAGE_ORDER_2 2 -#define ZS_PAGE_ORDER_4 4 - /* - * A single 'zspage' is composed of up to 2^N discontiguous 0-order (single) - * pages. ZS_MAX_PAGE_ORDER defines upper limit on N, ZS_MIN_PAGE_ORDER - * defines lower limit on N. ZS_DEFAULT_PAGE_ORDER is recommended value. + * A single 'zspage' is composed of up to N discontiguous 0-order + * (single) pages. ZS_MAX_PAGES_PER_ZSPAGE defines upper limit on N, + * ZS_MIN_PAGES_PER_ZSPAGE defines lower limit on N. + * ZS_DEFAULT_PAGES_PER_ZSPAGE is a recommended value. */ -#define ZS_MIN_PAGE_ORDER ZS_PAGE_ORDER_2 -#define ZS_MAX_PAGE_ORDER ZS_PAGE_ORDER_4 -#define ZS_DEFAULT_PAGE_ORDER ZS_PAGE_ORDER_2 +#define ZS_MIN_PAGES_PER_ZSPAGE 1 +#define ZS_MAX_PAGES_PER_ZSPAGE 16 +#define ZS_DEFAULT_PAGES_PER_ZSPAGE 4 struct zs_pool_stats { /* How many pages were migrated (freed) */ diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index bc377e5d3417..d4f68fba746b 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -74,8 +74,6 @@ */ #define ZS_ALIGN 8 -#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_PAGE_ORDER) - #define ZS_HANDLE_SIZE (sizeof(unsigned long)) /* @@ -2215,7 +2213,7 @@ struct zs_pool *zs_create_pool(const char *name) if (!pool) return NULL; - max_pages_per_zspage = 1U << ZS_DEFAULT_PAGE_ORDER; + max_pages_per_zspage = ZS_DEFAULT_PAGES_PER_ZSPAGE; /* min_alloc_size must be multiple of ZS_ALIGN */ pool->min_alloc_size = (max_pages_per_zspage << PAGE_SHIFT) >> OBJ_INDEX_BITS;