From patchwork Mon Oct 31 05:41:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13025391 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 B6912FA3744 for ; Mon, 31 Oct 2022 05:41:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5519F8E0003; Mon, 31 Oct 2022 01:41:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4DEFD8E0001; Mon, 31 Oct 2022 01:41:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 35EB78E0003; Mon, 31 Oct 2022 01:41:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0D78E8E0001 for ; Mon, 31 Oct 2022 01:41:27 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A9A0C160499 for ; Mon, 31 Oct 2022 05:41:26 +0000 (UTC) X-FDA: 80080146972.21.3AC8B98 Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf15.hostedemail.com (Postfix) with ESMTP id 2A520A000F for ; Mon, 31 Oct 2022 05:41:25 +0000 (UTC) Received: by mail-pj1-f50.google.com with SMTP id d59-20020a17090a6f4100b00213202d77e1so14963060pjk.2 for ; Sun, 30 Oct 2022 22:41:25 -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=q47a/PNtxAlJKL8yCX3+cfAOXZEGpDh+HXwifBH5lKc=; b=OYKyQePuyQDoHhgCchBV4FMDx0nWgF7FRbwlJg+5H3agLccnKM3iywpXD9Ad6WlB9e 2hKoZcKk5G/boerau0bifRUyl66HD3wpSCWk/agkmOsrg0WbI+yuve3bQQODeG1tBhlr jW9CV4MIvC/C7cUB7KWXWdWNpbLLs4wlJYM+Y= 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=q47a/PNtxAlJKL8yCX3+cfAOXZEGpDh+HXwifBH5lKc=; b=2fuOwfaejjOUod5uY6iV526wnn8Q+MFe+/cdaOdVtL4+vUaewBPX74kF1RbsHQKE9C Pe8cC2NOCRlxpAhxMHGTl4LL/Dp8HZVpxwYThBj06vo0Y8vpp2sMEobXWr+K6IT+AC5X 7mXoyCK2wIY5UX2pEjxR60Bvkzp99Ul98RJ0Ep6DQecKZh3Yymh2w8ivuO+HEWi3l5fm K6gKTnJF0TVJ5tPV6v2e7HtRMyC0cMQ1qRObqrrnE+ZDsq566By4rSXfQ/WdoaDLfvYz U6+mEmbj5vOYhAR/TbcFrGna3QHxSRXpcPaTxs81Q/UvtRAG8+QR9DljA3zSUtaWLFsl jvyQ== X-Gm-Message-State: ACrzQf2KJdgPLLyC6971ZZzW6EAsKjM3kPcoqk5MHzKof/S+t7XTYJYP HYz9efW3YKQTgradHfMv0LzRRQ== X-Google-Smtp-Source: AMsMyM7lIE25lBRCfac1jIjiko+Si6xCOBbIGSlmJaY3ParCu8pVW0pf03O7dc9ImI+Po6W9R2fxGg== X-Received: by 2002:a17:903:4d7:b0:178:8564:f754 with SMTP id jm23-20020a17090304d700b001788564f754mr12779632plb.60.1667194885017; Sun, 30 Oct 2022 22:41:25 -0700 (PDT) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:7616:afe0:ba6c:96f4]) by smtp.gmail.com with ESMTPSA id w12-20020aa79a0c000000b0056befcd7958sm3573308pfj.84.2022.10.30.22.41.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 30 Oct 2022 22:41:24 -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: [PATCHv4 3/9] zsmalloc: move away from page order defines Date: Mon, 31 Oct 2022 14:41:02 +0900 Message-Id: <20221031054108.541190-4-senozhatsky@chromium.org> X-Mailer: git-send-email 2.38.1.273.g43a17bfeac-goog In-Reply-To: <20221031054108.541190-1-senozhatsky@chromium.org> References: <20221031054108.541190-1-senozhatsky@chromium.org> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667194886; 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=q47a/PNtxAlJKL8yCX3+cfAOXZEGpDh+HXwifBH5lKc=; b=tYPegehsOpDzP3igrVpGm41RPWin4n31iwJ2XN/mUg8tgE7avFu4y4jr3SRZZGR13U+xLn 3P8c+O0Cr8tTKNpvYQTfbE5qAbBUXYiUXr4+4Xr6ZndCKYpoVAFEO6/NDmMNfzaGVoQJdo QjTH8ovjf5xnelNfn5mQ3r/kQKOq8bY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=OYKyQePu; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.50 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667194886; a=rsa-sha256; cv=none; b=pkvdkSRJlc2n28YERjEcGrr1/VDqqLOz7ooiWj3NUtxZyW6DvthTn4v9zxl2Fmn+L3t68o +lBJb5iJAnfllknnRvN3dlrQp4ruLiKB4+SBngMD6Nx8D4cdXrRbddengHZrtFvDj9I/w2 g6fIonN62kzuN4Np+h3rlkCsXUe6/0g= X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 2A520A000F X-Rspam-User: Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=OYKyQePu; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf15.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.50 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org X-Stat-Signature: bqkowkijwuzpbk8mt6yt4gfuckn5nix6 X-HE-Tag: 1667194885-626636 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: 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 a9773566f85b..5f79223e7bfe 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; - num_pages = 1UL << ZS_DEFAULT_PAGE_ORDER; + num_pages = ZS_DEFAULT_PAGES_PER_ZSPAGE; /* min_alloc_size must be multiple of ZS_ALIGN */ pool->min_alloc_size = num_pages << PAGE_SHIFT >> OBJ_INDEX_BITS; pool->min_alloc_size = max(pool->min_alloc_size, ZS_MIN_ALLOC_SIZE);