From patchwork Thu Jan 5 05:35:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13089461 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 E604EC3DA7D for ; Thu, 5 Jan 2023 05:35:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 59FE68E0003; Thu, 5 Jan 2023 00:35:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 528178E0001; Thu, 5 Jan 2023 00:35:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C9AD8E0003; Thu, 5 Jan 2023 00:35:33 -0500 (EST) 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 2B3918E0001 for ; Thu, 5 Jan 2023 00:35:33 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EFC7D140B0B for ; Thu, 5 Jan 2023 05:35:32 +0000 (UTC) X-FDA: 80319632904.23.4631708 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf23.hostedemail.com (Postfix) with ESMTP id 61694140007 for ; Thu, 5 Jan 2023 05:35:30 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=b6rJqUBU; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf23.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.169 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672896930; 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=OHS7GwecdRuxXk3+Zc4WVXvP35qWQPtvOh3gevBpM+A=; b=hdo+lHDTmfZRtjllqLyaK9H/6CydlxsyzfVt4bHc4hGsjg+Sun+RVoHmyNcde8PEWP7+wU f17PwXpApSDIwRbQfe9zKVxJo4sPeHSORKS9OKt1wZp+V3Tu416vM4Q4M4XIfgbkxakqSK URtuh7rkx6fFtiS/3hIi3GboD+LiZnY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=b6rJqUBU; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf23.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.169 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672896930; a=rsa-sha256; cv=none; b=na8YEaRazmVWLZlIyr59x51JbBsuC4yr/bh8bYX8tFSPIA6JP8xQx1rTOErHMig9CwnbGC MljGSMtL+PYFufGgKRHZPvUnVqlKTnQWebC0PG+XiJ3Bwyxv0bYyOau92/+mUUS46Jgxbo AU5TmRJ6HMMVVZuF+jcCUVT4/WJzw+s= Received: by mail-pg1-f169.google.com with SMTP id h192so19001678pgc.7 for ; Wed, 04 Jan 2023 21:35:30 -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=OHS7GwecdRuxXk3+Zc4WVXvP35qWQPtvOh3gevBpM+A=; b=b6rJqUBUXZ6Q+Bgt7gJ5/kTxgMlrEP1hR1HsAaFEIJOVqcYGEqzmgqaayIu44OklLY aKr7mCHk9NuWDdeZ/sLDjprbzjTysci4voRXkScpJ9J7O3UQJDwMi88MSEXKhAd31MRX IkgpaAnfci6cSUtZQFzoqH74BOPlvcbzaXSNQ= 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=OHS7GwecdRuxXk3+Zc4WVXvP35qWQPtvOh3gevBpM+A=; b=SNyx/mXQavpd8HtBHh6FsqN4u5tWdu/x7VqBt6FlZSOnSyxbhnEiQlZWM31iTIgLUE T9Ii3+W+o8NbhUkuwkksbi+/tWCDYpimvoeNI8A+Tra8gTPmTguyCRxzitdFsa/MoUfq /AonsMJsNJ4odTyFB/t0qJF7IU7nhpGbDwBk3WQKXQlW7NSB/p/bkiepy1fQnEVGeQjF gPaQqnnYnOh/qoLOvrYo27NxSP6RlbWxwS4bspdSPLHr6fMU7VKW8rgVGhSHGBaq58Ge duLdML6hvc2OQAP5+ILiJtYKWnmLw0IRLZlESsPkqzJBRviXzsiFRZqH6RRWjMomWZGN UlGg== X-Gm-Message-State: AFqh2krdwB3KrSqTnSI2wkxC+1ZDIRlGJz344PMOY1B6QfN2XK/cP5p8 skzYnI4t8CaKAsP/4AEndHrt7A== X-Google-Smtp-Source: AMrXdXvCZQaKMjk2imZtfP2WyTYli30IFBbctSlFI2dnkGh9PE8CQrY3FcAiS28OhT3LjTERiI6OGw== X-Received: by 2002:a05:6a00:84c:b0:581:1ee0:75a with SMTP id q12-20020a056a00084c00b005811ee0075amr43961009pfk.32.1672896929190; Wed, 04 Jan 2023 21:35:29 -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.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 21:35:28 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCH 1/4] zsmalloc: rework zspage chain size selection Date: Thu, 5 Jan 2023 14:35:07 +0900 Message-Id: <20230105053510.1819862-2-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-Queue-Id: 61694140007 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: htuf1hmyqcdfepum9emqckzghsqp94hs X-HE-Tag: 1672896930-853625 X-HE-Meta: U2FsdGVkX1++wzz5oQTfFxHceAEmkduPOuGa2nwK90REjBKFDN+ZPMXSfgfnjuhTR9N6N2G5e9yGxAUW1g4s1GT1213Vp4LCYLmZPHl3by+toehRygE1MS8G13PqHESnJ1gIWvPlOAIvymH7bQs/616EIv9IvqC17uFYUNPXPoXYDUPKZW1LE1RFJ997eB9x334wy1O6LOeQEzUgxfQALYknas4TiU6aYDjkWBN+CDWBt5q6kjix/RJD9vRRIKLFPAyLHQX32kwHvIK8QWAp2GDEIgNtFORvI0J85YZJH6S3AvflwbnnIUp4UFh2G5ti/nIxEQF2AbfWYW/WxYd8Ng8f2xHZ6YyrAPIhC2h0gKbLa7eLtBqANX/4ORB5ShUPtve6Wje33QrPbxVfsT3v1xZS+kBFwezMdDqjXb2sC1Xv+7JRhZv2jbJ6bZA1JMGXnqxOFV5hQxCq3E2Ge0Ud2A4UnZx402htYnzzyO/c1gt/brB9QoWI4cvKg77ffa1FeEQo3a/ZxghzLrrhkzweTDG3U4Ddwzq+NH/9jl3lvZ2tYMx60DIY2XTCJ9yOMI9fUFLGZeN09htfHtb+/HVkAwq3oUk9yp196bdIzpibyiAtpzY0waz6g7AdIARtd67BLhHiV9vDl+p7f1PaLxwAVa/qbvRs8MdZN6mp149tJTsl7pGnSh1NG/XTd6v5zRQK+wNPqz5n87QgarDR804ZQ7M9fgeZj+Qqkxg8NARrR+QSwHExsG86aeR0Xl0CIbBboAzvDRjUjNbOlgoAInu+82jtMzD4cQkeEq9OjGRAbHvu7+1o0yufY28fgXqZA+vT8EWrHcHR0cYGlWATW6qf0Vpe0BJyb5kxJ6UnZGOointgJhgt7zANTWz7SEy2COLQdBokseWtXwTgPfilMnuebvy3v/s2G9oW1P7pNMGcdWZx27BSwMmHmNBb7eHz1GeJYr02ZEdbD6FQnoL0RGe o3C03jWu wwSMKMYDYCGSQL7bhD17yQfJEoNxTpunPIiK5oNzIO0RgmU5aHghgkzqZ0Tsk9NoLueplWpgt/YwBNPZGkB7+1Qe50XK5IetXS67AvYCodgWMattne57WyLILlb/ej/uownwU 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: Computers are bad at division. We currently decide the best zspage chain size (max number of physical pages per-zspage) by looking at a `used percentage` value. This is not enough as we lose precision during usage percentage calculations For example, let's look at size class 208: pages per zspage wasted bytes used% 1 144 96 2 80 99 3 16 99 4 160 99 Current algorithm will select 2 page per zspage configuration, as it's the first one to reach 99%. However, 3 pages per zspage waste less memory. Change algorithm and select zspage configuration that has lowest wasted value. Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 56 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 9445bee6b014..959126e708a3 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -802,42 +802,6 @@ static enum fullness_group fix_fullness_group(struct size_class *class, return newfg; } -/* - * We have to decide on how many pages to link together - * to form a zspage for each size class. This is important - * to reduce wastage due to unusable space left at end of - * each zspage which is given as: - * wastage = Zp % class_size - * usage = Zp - wastage - * where Zp = zspage size = k * PAGE_SIZE where k = 1, 2, ... - * - * For example, for size class of 3/8 * PAGE_SIZE, we should - * link together 3 PAGE_SIZE sized pages to form a zspage - * since then we can perfectly fit in 8 such objects. - */ -static int get_pages_per_zspage(int class_size) -{ - int i, max_usedpc = 0; - /* zspage order which gives maximum used size per KB */ - int max_usedpc_order = 1; - - for (i = 1; i <= ZS_MAX_PAGES_PER_ZSPAGE; i++) { - int zspage_size; - int waste, usedpc; - - zspage_size = i * PAGE_SIZE; - waste = zspage_size % class_size; - usedpc = (zspage_size - waste) * 100 / zspage_size; - - if (usedpc > max_usedpc) { - max_usedpc = usedpc; - max_usedpc_order = i; - } - } - - return max_usedpc_order; -} - static struct zspage *get_zspage(struct page *page) { struct zspage *zspage = (struct zspage *)page_private(page); @@ -2321,6 +2285,24 @@ static int zs_register_shrinker(struct zs_pool *pool) pool->name); } +static int calculate_zspage_chain_size(int class_size) +{ + int i, min_waste = INT_MAX; + int chain_size = 1; + + for (i = 1; i <= ZS_MAX_PAGES_PER_ZSPAGE; i++) { + int waste; + + waste = (i * PAGE_SIZE) % class_size; + if (waste < min_waste) { + min_waste = waste; + chain_size = i; + } + } + + return chain_size; +} + /** * zs_create_pool - Creates an allocation pool to work from. * @name: pool name to be created @@ -2365,7 +2347,7 @@ struct zs_pool *zs_create_pool(const char *name) size = ZS_MIN_ALLOC_SIZE + i * ZS_SIZE_CLASS_DELTA; if (size > ZS_MAX_ALLOC_SIZE) size = ZS_MAX_ALLOC_SIZE; - pages_per_zspage = get_pages_per_zspage(size); + pages_per_zspage = calculate_zspage_chain_size(size); objs_per_zspage = pages_per_zspage * PAGE_SIZE / size; /* 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; From patchwork Thu Jan 5 05:35:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13089463 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 9E09CC3DA7A for ; Thu, 5 Jan 2023 05:35:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 354D18E0006; Thu, 5 Jan 2023 00:35:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2DE4F8E0001; Thu, 5 Jan 2023 00:35:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 158718E0006; Thu, 5 Jan 2023 00:35:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 02FA48E0001 for ; Thu, 5 Jan 2023 00:35:43 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D391FAB27A for ; Thu, 5 Jan 2023 05:35:42 +0000 (UTC) X-FDA: 80319633324.28.BB604AD Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) by imf25.hostedemail.com (Postfix) with ESMTP id 373B6A0003 for ; Thu, 5 Jan 2023 05:35:40 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="UlX/lnwl"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf25.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.171 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1672896941; 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=jNDbEU6GJSl4dMMRDfb+E6NT+uZQaENbR2FZEs35hTc=; b=XobExyHqaZ5wSz1336IdcKw+EW+TGEo17vOtmDiTQEYU+8IllgxypYZ6X8hAECzXz8zgAK 87ItrCVY9zXy9qV5g3Wv0/TwpJcnzZJyxEmYe4hUJh/g2bsp4zmQn2yTf/zFLZ32GCqR/5 tVSOb6tQM5+AppdpJJq076ImYovGB/c= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b="UlX/lnwl"; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf25.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.171 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1672896941; a=rsa-sha256; cv=none; b=hETmyyqqu9LLHX8N+3WXfxRLJWR4W8jsoskYkq+tvmHnVv0JKzrqTTBABpr87nKnCYjg5D 0UDbl2dzQXJsA4ELWPFNOrxoemUZzhs0LnNqVNdv5BrxjIvsDRHaUz/tw8+NCDtOjT8BNk EGAOgT/1KPWuBuNjDD1IMauqtM6M/sg= Received: by mail-pg1-f171.google.com with SMTP id 141so5507289pgc.0 for ; Wed, 04 Jan 2023 21:35:40 -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=jNDbEU6GJSl4dMMRDfb+E6NT+uZQaENbR2FZEs35hTc=; b=UlX/lnwlf6fIQFIsZcBBD4u/IPlewAyXweh0bMynwmBpANcJ7jnMIod48XA9in383A 1UK4jVAaY2SfCjbsggvlu9ABgeEPohET6f7Sd1wbMcEVoU+rDpvh1LLGoGnsjZnmxfXt OztWNCYcuYgxz/E1e+NlICj1UXsrLnCP3mY68= 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=jNDbEU6GJSl4dMMRDfb+E6NT+uZQaENbR2FZEs35hTc=; b=QgNmimyaflF4+bwLmw/LXeGW5WUQzHVeTzD+aKAnPTjmKnj00/F/W96fqRvk3YKRRh Ffyp4URWWQmXZfHH1Q05bxZv/+W9+Qo8ecJlWFPpQhUz/WZjvuMkINhx52vWQE0MhEyd 7yip7n2Xr+MzrYVQwmQzrBplO5eL4ExwlvDwkB6Ft2Cef4IhhuMB1ozg56iCQgN1j1oE yy8mz5p8Mi3MasCjCQNQ7Y9H0XqeaqsHRa5NbSSTN1gMlySceYEC822RLX8RjZKUCjfa qUuPOReDuDBjsjBoFbLAaagwv4GLUBhjt+Iglz16KJD1bksrgl2IrjogTO8Jf4fB7KYd njQA== X-Gm-Message-State: AFqh2kp+M83RwtGoI4LH8CpzOXfNhZMe0LLmpbTn2e5rywKUMS2W8Iad 8/5Hl5/2rSfbSd8+WnDIc7cYsw4ypTFdJlmJ X-Google-Smtp-Source: AMrXdXs8xtoHQAu80/AXDIApYwbIuB3LIkfP6hr+4B2fJbDkMV6pCTZqhjjdA4EnSCvzd9059skuwg== X-Received: by 2002:a05:6a00:2281:b0:581:a8dc:8f95 with SMTP id f1-20020a056a00228100b00581a8dc8f95mr34967574pfe.12.1672896940075; Wed, 04 Jan 2023 21:35:40 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 21:35:39 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCH 3/4] zsmalloc: make zspage chain size configurable Date: Thu, 5 Jan 2023 14:35:09 +0900 Message-Id: <20230105053510.1819862-4-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-Queue-Id: 373B6A0003 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: fzfg1s8hybq6r91wkggeg1idu7max51i X-HE-Tag: 1672896940-746916 X-HE-Meta: U2FsdGVkX19kmJZJf2RZdgUXy/SsnXo0HQhHRt+e/u+OuE2K7ZSGbmvv/HYfx44qLxyG8UDa55FGjWYLx4mN2ssLXXjtY6Nt9UBMW55xr36S3b9HSlqih8ZYLRrsgUB20GkADGsBjPLxjguvv5UIV5CY470zfvX0NMQDt3slmVMexxY8BXA0rawK33a/Ay1sQ6/AlT7I2Wbx3R5q/EUPOeMJghc2CDjfhyRSh2S6VnT1UhquZN/OIov25fVVH/O8+LeigiPPu0Mv/JNvRtqWNssKzh+3jTxNZ+9sk+VbCMGGrLJREiPDzwv3z02y5aICixw4axq6gHFnn+T4JXxd2DhSV2/TlbDq6izGZNlEn2gUqhJCa1I8fSj3afMTV+odfRP+p2yR0zZrsryACyYjigoR2eKZOSyt/3EJKxG3AWVyTttGKYhFAGiX7hmlruUW6eKbh304euy1aRcnvqLx16QByiXE5sVcxM3ZmsakgdQslBEWpKh8wSX3jBkOp3/r/JYboIgGkfA8JTZbu3XmLE3ptLsjtWbXyoDsV1riyQMOZFHHnKeFt/SNAVybLqDaHDNya6flj4nIm7NzPp1ADCfsopxZEKPXjkEot8+01WSggC4csFGLzhhT1oHGVtCI8LFIWD6pcoWGHz9K7wFHm1riqt+Z5ZLbVtj6dMLxC/onFLo0TTIs05QdrrKbD8XSBfHf/x0iC6ZkA2dRvJNhcX9anqOLhmToCJ3tYM9CHySoyrcKM4HiY5EZwdK4tKjHXxZgyGe8Ld93dbCo5Ck3wNIHs9tS3OvuObJpXVweZ5G3cKJrsPP9FVHFGFiqOPNkD2rikza9kNV0ZF+nmGinPHY6TBJKT0t8K+H119EcDWRq40q6QdLHk8jjlh8iNRIMAiOKUgJyBb9pzfx9ukQ3yIOkoAEzIHVDqaslbkJ/A+XahRWTm2ceB+FajLK4XlouUXVADUolIuqRyClRd/U llNCmOYn IVbNBu3i2yZMQK3l/o3T6eYPd9D2wGO+m4dhXhvKBIZh0bdw3PvstifcZLuCDFgFJxSA2maMsoTEcCJBq0y9Y1f5AV+MV+Ldek6/RIgMaegRj+h+4n+ReaBudo7ey5lwpCkhb5LSvamF49Ik= 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: Remove hard coded limit on the maximum number of physical pages per-zspage. This will allow tuning of zsmalloc pool as zspage chain size changes `pages per-zspage` and `objects per-zspage` characteristics of size classes which also affects size classes clustering (the way size classes are merged). Signed-off-by: Sergey Senozhatsky --- .../admin-guide/blockdev/zsmalloc.rst | 157 ++++++++++++++++++ mm/Kconfig | 19 +++ mm/zsmalloc.c | 15 +- 3 files changed, 180 insertions(+), 11 deletions(-) create mode 100644 Documentation/admin-guide/blockdev/zsmalloc.rst diff --git a/Documentation/admin-guide/blockdev/zsmalloc.rst b/Documentation/admin-guide/blockdev/zsmalloc.rst new file mode 100644 index 000000000000..2e238afb1b4b --- /dev/null +++ b/Documentation/admin-guide/blockdev/zsmalloc.rst @@ -0,0 +1,157 @@ +======================================== +zsmalloc allocator +======================================== + +Internals +--------- + +zsmalloc has 255 size classes. Size classes hold a number of zspages, each +zspage can consist of up to ZSMALLOC_CHAIN_SIZE physical (0 order) pages. +The exact (most optimal) zspage chain size is calculated for each size class +during zsmalloc pool creation (see calculate_zspage_chain_size()). + +As a reasonable optimization, zsmalloc merges size classes that have +similar characteristics: number of pages per zspage and number of +objects zspage can store. + +For example, let's look at the following size classes::: + +class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable +.. + 94 1536 0 0 0 0 0 3 0 + 100 1632 0 0 0 0 0 2 0 +.. + +Size classes #95-99 are merged with size class #100. That is, each time +we store an object of size, say, 1568 bytes instead of using class #96 +we end up storing it in size class #100. Class #100 is for objects of +1632 bytes in size, hence every 1568 bytes object wastes 1632-1568 bytes. +Class #100 zspages consist of 2 physical pages and can hold 5 objects. +When we need to store, say, 13 objects of size 1568 we end up allocating +three zspages; in other words, 6 physical pages. + +However, if we'll look closer at size class #96 (which should hold objects +of size 1568 bytes) and trace calculate_zspage_chain_size()::: + + pages per zspage wasted bytes used% + 1 960 76 + 2 352 95 + 3 1312 89 + 4 704 95 + 5 96 99 + +We'd notice that the most optimal zspage configuration for this class is +when it consists of 5 physical pages. A 5 page class #96 configuration +would store 13 objects of size 1568 in a single zspage, allocating 5 physical +pages, as opposed to 6 physical pages that class #100 would allocate otherwise. + +A larger zspage chain size for class #96 also changes its key characteristics: +pages per-zspage and objects per-zspage. As a result we merge less classes. In +other words classes are grouped in a more compact way, which decreases memory +wastage. + +Let's take a closer look at the bottom of /sys/kernel/debug/zsmalloc/zramX/classes::: + +class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable +.. + 202 3264 0 0 0 0 0 4 0 + 254 4096 0 0 0 0 0 1 0 +.. + +For exactly same reason - maximum 4 pages per zspage - the last non-huge +size class is #202, which stores objects of size 3264 bytes. Any object +larger than 3264 bytes, hence, is considered to be huge and lands in size +class #254, which uses a whole physical page to store every object (objects +in huge classes don't share physical pages). + +Another consequence of larger zspages chain sizes is that we move the huge +size class watermark up and as a result have less huge classes and store +large objects in a more compact way. + +For zspage chain size of 8, huge class watermark becomes 3632 bytes::: + +class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable +.. + 202 3264 0 0 0 0 0 4 0 + 211 3408 0 0 0 0 0 5 0 + 217 3504 0 0 0 0 0 6 0 + 222 3584 0 0 0 0 0 7 0 + 225 3632 0 0 0 0 0 8 0 + 254 4096 0 0 0 0 0 1 0 +.. + +For zspage chain size of 16, huge class watermark becomes 3840 bytes::: + +class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable +.. + 202 3264 0 0 0 0 0 4 0 + 206 3328 0 0 0 0 0 13 0 + 207 3344 0 0 0 0 0 9 0 + 208 3360 0 0 0 0 0 14 0 + 211 3408 0 0 0 0 0 5 0 + 212 3424 0 0 0 0 0 16 0 + 214 3456 0 0 0 0 0 11 0 + 217 3504 0 0 0 0 0 6 0 + 219 3536 0 0 0 0 0 13 0 + 222 3584 0 0 0 0 0 7 0 + 223 3600 0 0 0 0 0 15 0 + 225 3632 0 0 0 0 0 8 0 + 228 3680 0 0 0 0 0 9 0 + 230 3712 0 0 0 0 0 10 0 + 232 3744 0 0 0 0 0 11 0 + 234 3776 0 0 0 0 0 12 0 + 235 3792 0 0 0 0 0 13 0 + 236 3808 0 0 0 0 0 14 0 + 238 3840 0 0 0 0 0 15 0 + 254 4096 0 0 0 0 0 1 0 +.. + +Overall the combined zspage chain size effect on zsmalloc pool configuration::: + +pages per zspage number of size classes (clusters) huge size class watermark + 4 69 3264 + 5 86 3408 + 6 93 3504 + 7 112 3584 + 8 123 3632 + 9 140 3680 + 10 143 3712 + 11 159 3744 + 12 164 3776 + 13 180 3792 + 14 183 3808 + 15 188 3840 + 16 191 3840 + +A synthetic test::: + +CONFIG_ZSMALLOC_CHAIN_SIZE=4 + +zsmalloc classes stats + class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable + .. + Total 13 51 413836 412973 159955 3 + +zram mm_stat +1691783168 628083717 655175680 0 655175680 60 0 34048 34049 + +CONFIG_ZSMALLOC_CHAIN_SIZE=8 + +zsmalloc classes stats + class size almost_full almost_empty obj_allocated obj_used pages_used pages_per_zspage freeable + .. + Total 18 87 414852 412978 156666 0 + +zram mm_stat +1691803648 627793930 641703936 0 641703936 60 0 33591 33591 + +Note that for the same amount of data zsmalloc uses less physical pages: down +to 156666 from 159955, and maximum zsmalloc pool memory usage also went down +from 655175680 to 641703936 bytes. + +The obvious downside of larger zspage chains is that some zspages require +more physical pages, which can, in theory, increase system memory pressure +in cases when zspool suffers from heavy internal fragmentation and zspool +compaction cannot relocate objects and release some zspages. In such cases +users are advised to lower zspage chain size limit (CONFIG_ZSMALLOC_CHAIN_SIZE +option). diff --git a/mm/Kconfig b/mm/Kconfig index ff7b209dec05..995a7c4083c2 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -191,6 +191,25 @@ config ZSMALLOC_STAT information to userspace via debugfs. If unsure, say N. +config ZSMALLOC_CHAIN_SIZE + int "Maximum number of physical pages per-zspage" + default 4 + range 1 16 + depends on ZSMALLOC + help + Each zmalloc page (zspage) can consist of 1 or more physical + (0 order) non contiguous pages. This option sets the upper + (hard) limit on that number. + + The exact zspage chain size is calculated for each size class + individually during pool initialisation. Changing this results + in different size classes characteristics (pages per-zspage, + objects per-zspage) which in turn results in different pool + configurations: zsmalloc merges size classes that share key + characteristics. + + Please read zsmalloc documentation for more details. + menu "SLAB allocator options" choice diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 9a0f1963b803..34ba97d1175f 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -73,13 +73,6 @@ */ #define ZS_ALIGN 8 -/* - * A single 'zspage' is composed of up to 2^N discontiguous 0-order (single) - * pages. ZS_MAX_ZSPAGE_ORDER defines upper limit on N. - */ -#define ZS_MAX_ZSPAGE_ORDER 2 -#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(1, UL) << ZS_MAX_ZSPAGE_ORDER) - #define ZS_HANDLE_SIZE (sizeof(unsigned long)) /* @@ -126,7 +119,7 @@ #define MAX(a, b) ((a) >= (b) ? (a) : (b)) /* ZS_MIN_ALLOC_SIZE must be multiple of ZS_ALIGN */ #define ZS_MIN_ALLOC_SIZE \ - MAX(32, (ZS_MAX_PAGES_PER_ZSPAGE << PAGE_SHIFT >> OBJ_INDEX_BITS)) + MAX(32, (CONFIG_ZSMALLOC_CHAIN_SIZE << PAGE_SHIFT >> OBJ_INDEX_BITS)) /* each chunk includes extra space to keep handle */ #define ZS_MAX_ALLOC_SIZE PAGE_SIZE @@ -1078,7 +1071,7 @@ static struct zspage *alloc_zspage(struct zs_pool *pool, gfp_t gfp) { int i; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE]; + struct page *pages[CONFIG_ZSMALLOC_CHAIN_SIZE]; struct zspage *zspage = cache_alloc_zspage(pool, gfp); if (!zspage) @@ -1910,7 +1903,7 @@ static void replace_sub_page(struct size_class *class, struct zspage *zspage, struct page *newpage, struct page *oldpage) { struct page *page; - struct page *pages[ZS_MAX_PAGES_PER_ZSPAGE] = {NULL, }; + struct page *pages[CONFIG_ZSMALLOC_CHAIN_SIZE] = {NULL, }; int idx = 0; page = get_first_page(zspage); @@ -2293,7 +2286,7 @@ static int calculate_zspage_chain_size(int class_size) if (is_power_of_2(class_size)) return chain_size; - for (i = 1; i <= ZS_MAX_PAGES_PER_ZSPAGE; i++) { + for (i = 1; i <= CONFIG_ZSMALLOC_CHAIN_SIZE; i++) { int waste; waste = (i * PAGE_SIZE) % class_size; From patchwork Thu Jan 5 05:35:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13089464 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 A3122C3DA7D for ; Thu, 5 Jan 2023 05:35:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CEA68E0007; Thu, 5 Jan 2023 00:35:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 157EC8E0001; Thu, 5 Jan 2023 00:35:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F132A8E0007; Thu, 5 Jan 2023 00:35:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DEEFF8E0001 for ; Thu, 5 Jan 2023 00:35:45 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B55621C6343 for ; Thu, 5 Jan 2023 05:35:45 +0000 (UTC) X-FDA: 80319633450.11.C100C41 Received: from mail-pg1-f170.google.com (mail-pg1-f170.google.com [209.85.215.170]) by imf11.hostedemail.com (Postfix) with ESMTP id 2CDC040002 for ; Thu, 5 Jan 2023 05:35:43 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=fU3ZxfwS; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.170 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=1672896944; a=rsa-sha256; cv=none; b=4iSKmmxXv5qxipiwoWXI0vUYkA9dXGIQFA+SjpAfoKIW96FfE2aVHskrZ5pe2qvwIiFWWm 3sofDEMRwi9n9C8MDbGdMnnv7XrnLPKFkIWAgmP51uRg6lgsDGYTBDEP7uiDGTmGxlzfKr kpfTyqbtz8P8LDkHAdDRQ8NC/wHyOQA= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=fU3ZxfwS; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.215.170 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=1672896944; 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=u3RcO+ukEEU2tRMGKkuSA42+1jjoCDn3FvnF70ujYWI=; b=Ar4ZwDkb/94YywxnLhnB6mEHcWmr2SgAnFzwl6MF6iIZVJkvE8MeKRS2kEA6ZapFgtUlFt LCszoNioe1CtXaV2UciP8GtNSkegDjbrAZxo3/gEOM8+EUw6cXZjtpqVftI0d6HMWBE6oy M5KmVICHzoftbhcfutc2gTP4vWOYx20= Received: by mail-pg1-f170.google.com with SMTP id e10so9924981pgc.9 for ; Wed, 04 Jan 2023 21:35:43 -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=u3RcO+ukEEU2tRMGKkuSA42+1jjoCDn3FvnF70ujYWI=; b=fU3ZxfwS35G2sd1ofLS0XH6rgua1/Y1Q81HU7Kz9UP7+pJN4hKAikLBBHWCqGEhwNJ 6sKba61QIGyVO9mZeRIBc6WKZ39X1PvO+i5DuWQQI9UZWlRkhNIcN9zzZhUCawyqxwCS Yasvmb2ntqX0rHqa/Jzqhid2eBOHoCUxCpZgY= 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=u3RcO+ukEEU2tRMGKkuSA42+1jjoCDn3FvnF70ujYWI=; b=jN9Tm9Mcv2e8PFx8JoopymDcx0ZmBCV0ScvXMIDMS8sSKtxq00yrk8v8N92M35EwSB diRrfFyW/7FoFdsK6LZ07cKhHihMI1ImbdcKGyBujUgh2rzqJ4G8S7R3MlsK3IRP2lQl s7aiHgMbCxFvWfV2bm8KA6s8CFN9SQCS4fD3uVbSqlgDq0Mn18DQp/9/N6S7wAEdFIB9 yaKFzqMGFU8re+cSLrsOUvbKpoFFiMCdIKbOXfNKIMcjMCguPzd2T4kPhGOXosD589zu qJPdmx5DNZ67rNDl38vc0tuFJ0NpKgO3FzeaIsHl5nxuzcqokGZV48DwXaSdN3Uht2+O wD1Q== X-Gm-Message-State: AFqh2kq93wC8K/HW7HZTqYMWzHluLss7iHsgK4iJn8UZ67nN4IQoTBY4 EoMpoPNsbjiICOq87VWrV1HgdA== X-Google-Smtp-Source: AMrXdXsLJCXHNR4z3LOOHq/EWKiZHaAIInb3wQ5+cuJXqsQVsZ3H0KlsmcXXMWSqiEVtXBS5uFTQMA== X-Received: by 2002:a05:6a00:450a:b0:56e:664f:a5f5 with SMTP id cw10-20020a056a00450a00b0056e664fa5f5mr61013213pfb.8.1672896943236; Wed, 04 Jan 2023 21:35:43 -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.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Jan 2023 21:35:42 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCH 4/4] zsmalloc: set default zspage chain size to 8 Date: Thu, 5 Jan 2023 14:35:10 +0900 Message-Id: <20230105053510.1819862-5-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-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 2CDC040002 X-Stat-Signature: sr5wfwnhcnz3s5r7fienjoz6kdgq83hi X-HE-Tag: 1672896943-131259 X-HE-Meta: U2FsdGVkX18YQPZYjHYCUMxJjdg91NanuNN8/GdJpInyyEuv/rpONKTxgsvId3346P67NhAxLNaLDvbE6pM1T6YUsiRfH9VobTGJbuR3Oh/wbKuTJwVhnVPjeiokWawK5BlJsowyQ4AO5B7mxNq2jw8MNTxzKLhXurucnpy8xa6WsGPg1d1Uh8oLU2wJWPxqARPxQbQU6VTw1T3cKe8WSVGbww2XsY5FAX/CgxhFH3CDqjOITrIsGC2HyYSPDFiqEtQFX5rZm3EFpNaM/+UmYY2e62ssULLsrpnz5YIMDNY/MwTRble4PaLaAq+8HZoVQUj4FrH5ZCUTwye6XVSHNefJZ5aPTyO2aYzJ762tmFjc7lip3mQ7pzMFue1eSL219JKdKEqJ167J4aM+Sz31rVpuedhpXUCtPZvHtt/alazybJ0qPfihX81zLk/NV+KUtFWULOlz1xJDo1SMcO3KrWNHKFXMZsW27rvs1uXX2GTKySPoLbMw9sDpWJXE6wcNm//hJwnxNmzSveSpDIEw9WmrJrIxw1f5KUhJmXHpgvXXOo7C9CztS25omHWY4vTj/XHFkgmORiSTxArWjipXaQNFBKikytxfFfsaw5BNGRv+jP+EUtaG9B0TqUC1CfuQ7WkKGaOsinxeMX29yDFrLxW+0VGANOKsk1qe/QeeRfHsgI9NVvnCkNSpVkgGtLqG6L8lV05wtc16nbK5E+FGTYTSggxFerqDh0p44XJiG+k03z5QXAeW3Qw2TaZY98A/KolObNJL7B7MNHaRCsN4VUdxxPJ5DD10Ez8LY5Ko5hvYL73WYj2Gud++epNDjXvLhBiRyB7WuH6ENudglp9bVThQ32ZGRsl5B4wVq7K+/fWpAi5zdyqID8aZZGcJSLBPmbo4+rjiK6L4WqXn6y1OAo3jELwNitK7uHGuh8UlHsUYg+hVFfE7MIsKG7BV8EE6vwwamqif18gynCzSxbC zd0+csEq uY51ebOSyS2Nzo0R2qoKNLcGSqAuIViGvvXN0Y6gGJr6Ns5cNDQvDFBM5RBeTcPa2dYmPozw6T3Y3MtYHoBY7Jk5zJx4vKnGXvnRhTGMRTUeAmCetWSmTWaPkL7HTn3cWfh8X 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: This changes key characteristics (pages per-zspage and objects per-zspage) of a number of size classes which in results in different pool configuration. With zspage chain size of 8 we have more size clases clusters (123) and higher huge size class watermark (3632 bytes). Please read zsmalloc documentation for more details. Signed-off-by: Sergey Senozhatsky --- mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/Kconfig b/mm/Kconfig index 995a7c4083c2..9ab5c1996a04 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -193,7 +193,7 @@ config ZSMALLOC_STAT config ZSMALLOC_CHAIN_SIZE int "Maximum number of physical pages per-zspage" - default 4 + default 8 range 1 16 depends on ZSMALLOC help