From patchwork Wed Jan 18 00:52: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: 13105308 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 A8A92C00A5A for ; Wed, 18 Jan 2023 00:52:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2506D6B0072; Tue, 17 Jan 2023 19:52:26 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 200AB6B0074; Tue, 17 Jan 2023 19:52:26 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0CA016B0075; Tue, 17 Jan 2023 19:52:26 -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 F2AC26B0072 for ; Tue, 17 Jan 2023 19:52:25 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id D115A80795 for ; Wed, 18 Jan 2023 00:52:25 +0000 (UTC) X-FDA: 80366093850.13.9C09B52 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf11.hostedemail.com (Postfix) with ESMTP id 301C140005 for ; Wed, 18 Jan 2023 00:52:22 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Eev0f7aY; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.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=1674003143; 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=nkttQsu9CYNbqVs+SWUxgP6kf/grlmJh2/+ItE14A1E=; b=xwp8/je+Mmqb8QnaWhOxaOcJBEo9D83PrAVo+i8D2FNnmmPtE5j3vnRGITGZjQK5cYkwrs bdFos5hewqU8udkc/bcCtAah2phAQn8EBEwk/wN8WpjeCSBlFOYQ3j5cX/TuRyxXFhxSBL shjILuRMZ3Vu8Adu8gXuY+RZ8GKtC34= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Eev0f7aY; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.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=1674003143; a=rsa-sha256; cv=none; b=pBYvFRnoaX90uLK4xd3b7qw+god1xCl6RHWmCio7mooO+mAtCrjTJzVGDxcmVZYy+cIBON tk70ZqTwJ27zcmQOp6O3xgwSLcFw/4Apajw+WaRelkJ5K+3hArl2GIXvnR2vFKda2AOdKM v8z+t1vwJaOI4RGih7OmOFI24yLow6E= Received: by mail-pl1-f169.google.com with SMTP id p24so35278835plw.11 for ; Tue, 17 Jan 2023 16:52:22 -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=nkttQsu9CYNbqVs+SWUxgP6kf/grlmJh2/+ItE14A1E=; b=Eev0f7aYKnrE4GRG70azP9o2tu74O+ZYXgQ9BucWkBQ5FM/5i2gw0n6a0ytPEDUY34 NqCPhdY234pdbdl4KdLymrKkyHnTuyOC86MzD6DdZt33oz5vpXX+EX/zKeRe6sWnT8ce vxnYh7s6VkjLzd/SF89wzvvgAShJ9gBGQOGmw= 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=nkttQsu9CYNbqVs+SWUxgP6kf/grlmJh2/+ItE14A1E=; b=vRfv4heEph1bAtEduTk6ROL3QMFiRzBaS+ajRk/2nqDKOzCyhCXo/XeGV+5blKVOtV TY0oiwLvEHeGP93P3lgrYfAL3UEvGlA4BKxplFScknDxITHHhW68EK1HndrWOKVL7jjO nr74bMHCb8J/d9DqbOGaF/jucs+qCVDX76qWKmwDgZjmOGeqTTbQKPf692eHvxJEpAwC lAJZ0TBx0Q0L+Rm8vIdXy7/bWgi8lt9QyA+KCJ8pzBnodPRiS97L08I6zSZjuGBKE4ab dotV+wrCP1sRCVxOtrMT/nBofa+LDBNu/mQUgYZ6rzKTK7cQlpqoWEtKS5v9TXPBnF5Z EvFg== X-Gm-Message-State: AFqh2kpsdb8mlUyqRp+L+67e0XxME7hmX9fDT5TmwYMAZhmoy0eGgNpK CPBTwC9hwRpsb7RGVny1vh8SVg== X-Google-Smtp-Source: AMrXdXsY7AyOsWXIqG+pfml6Gremcjag/qdnrV8bvDCBrr5vs4Og1jMyl/Drqe0slS2JWAsgBo6Y/A== X-Received: by 2002:a05:6a20:6f06:b0:ad:5cde:8f05 with SMTP id gt6-20020a056a206f0600b000ad5cde8f05mr4157965pzb.37.1674003142135; Tue, 17 Jan 2023 16:52:22 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:10f3:73a5:7e44:adbf]) by smtp.gmail.com with ESMTPSA id u10-20020a17090341ca00b00192f4fbdeb5sm8351461ple.102.2023.01.17.16.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 16:52:21 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Mike Kravetz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv3 1/4] zsmalloc: rework zspage chain size selection Date: Wed, 18 Jan 2023 09:52:07 +0900 Message-Id: <20230118005210.2814763-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230118005210.2814763-1-senozhatsky@chromium.org> References: <20230118005210.2814763-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 301C140005 X-Stat-Signature: 6hno55n6d6epojoxkqz17pg4ttzi4kaz X-HE-Tag: 1674003142-544156 X-HE-Meta: U2FsdGVkX19grTEuFTpE65w+rpVjVvuh9ypc8HeJLpQrFrTFGexdVdBIqp6DpCsSVHljQ8kj+2JU3QCwnieKxdgo7+g1PqW7araQ7DwQf/rFi968BCTrtamYXBCVCaihjx7OUL36pcLdzsvLQuJCC+V181tUuQP3MqUOSmyY4djGGEqlc5xH5Eky91117tKbdZn6BQ+8NZIkHPovL9qOErs+0WbsVZ1CJ3rRTZL60CWZGNX8cSA4glx0sMH+93+ycCRE3hlW6uNKMi0SgQKjekRSXkZlxeBhwKZCNlXC/LyDtMwscOPVSRca6lO8YpgNsK3p1Ktnv5nFG56omBQKq05VeAsI/8I7j96fWDq528e18eXoKqVPHMcX8Bf4/W8P9TMO3Pl36kv/LH4HrFrvhRgbcAcJCOeGJp5mzH9hlvVsLo2nJ/Y2NSi+RV14SLYL2IJA31CT9iI3twj5HLmvaZA/jnRu+OHOaITn52gvMlCCZht5sVJMVBF3sTyZy+vsLp49bnDzp4FLWMX3uNzq5D8FUG1+bMhANR6xVQKXHDaVx6YV8Vvfs83S4oSRFliOf7DrYVwb1UmleUB9SdhLLaIwrOtAcjqcXVzFFXNRiVPDZG+FpFS45pk82AR757n6B1W0YKCvm1bsVSBEVZ1HOBDL7IW/voIsjNsuFeKfMWpRA0BV4z8n1Y/F7Mcuvn1/bC/bW8AmX5kd6cA52pfXou/aJLROKBFHbcJ4e857FJlEji8SKW4COLFpRj8qKvl/NCyuFQkqhkClDkcafBtcVSIaS07YbSRDaiSshAdsRct6tGJhlGEbdGR3YY7FmE25m7jGxMbTC9pTumSw+BaoLfQ3HEUVF16mXMAJLuzetKjMDbbc40JNrje8jK4MiDSyk0ZwIK7fzcjvt7pwsV3IpRYbxUrY+GRpnAfgF6lpi2SC+oOTMOBVoNouxDNFPFS2FsED8fTp3Mncf9Mczl1 mhsvAVbw FnWqspcgh4l31Z1nXUi/1blkw+DxyR+gvYuq4RbxB/Idg97PSJXOHqQJMlGtv2hLpmXw/rp37y4vafNVZ8wWF2clLaivpKUmCzdZZhKI6GjSsuR2YvNhcEUlHkgf1d9D2Jny/ X-Bogosity: Ham, tests=bogofilter, spamicity=0.003111, 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 Acked-by: Minchan Kim --- mm/zsmalloc.c | 56 +++++++++++++++++---------------------------------- 1 file changed, 19 insertions(+), 37 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 6aafacd664fc..effe10fe76e9 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); @@ -2318,6 +2282,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 @@ -2362,7 +2344,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 Wed Jan 18 00:52: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: 13105309 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 82674C38147 for ; Wed, 18 Jan 2023 00:52:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0F2156B0074; Tue, 17 Jan 2023 19:52:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0A1746B0075; Tue, 17 Jan 2023 19:52:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAB516B0078; Tue, 17 Jan 2023 19:52:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id DC6FA6B0074 for ; Tue, 17 Jan 2023 19:52:28 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id AE2EDA0C4C for ; Wed, 18 Jan 2023 00:52:28 +0000 (UTC) X-FDA: 80366093976.22.3370B65 Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf24.hostedemail.com (Postfix) with ESMTP id 13F59180006 for ; Wed, 18 Jan 2023 00:52:26 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=TLu9c0Cj; spf=pass (imf24.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.174 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=1674003147; a=rsa-sha256; cv=none; b=ZzEX1Aa1Ht6sMcsCA/FuvAkj/dWIAydoTPWQhJq21EPo8BP6h8iENV33iHhtLuQw9RHftE jhcmzKWl23Fo6nEuXoGaB0h3kSQnw+9HyITnOSBCy8kwfxMhH21Oq3fh6T5Z72NWVsLDS1 6MRfKo3ii4t/jqn25rz0rplTDjkARCQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=TLu9c0Cj; spf=pass (imf24.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.174 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=1674003147; 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=wlEuvLJ1OIwhsVr6jP4j+nVp1P/tzWBP4lAYnG/eYgY=; b=ScwMOs32U9e0D7X+/EGqeamHtsvmN/TtLzR/x2ASnxs6FlARuSqCWVQ3I5kvt2+zFx4jKX 3CRToQ7aegzMQRM93l0bUIPVhKzYLXHvCzUUkXYJTrEdBOjp9JU6E0pKvjMwIHrnqLtiCk 9OhBAwhsrX7bJ6xbOWuvqfMQTtYGTFI= Received: by mail-pl1-f174.google.com with SMTP id z13so7498114plg.6 for ; Tue, 17 Jan 2023 16:52:26 -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=wlEuvLJ1OIwhsVr6jP4j+nVp1P/tzWBP4lAYnG/eYgY=; b=TLu9c0Cj9B2z19rRraJKbiywIrmYs/BVdE12dMxlvW8Y149yooSO39yxohc5u8cq2d iUC1z81ahFo78NQK8aD1I9A9YnnL2f69pBet4g2EhZAiqQHWUM3UP/Cm/nQMw5XYJU1D himUcbF+wJEhI9kS2XeqnPuGlUxxUFPHNZCXQ= 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=wlEuvLJ1OIwhsVr6jP4j+nVp1P/tzWBP4lAYnG/eYgY=; b=iqbCJR8AzUi0VeJZzt9YFfD49gsEDST6HCSCXIbyUC1TUapzJpg/JuukkO7VJRJjwy BX2hBa6EYKetOxKWG24exR45FRlvsU77gGikHW2SoIhdeqDIDsLBYqFLIC9SxKQPme9t RNrrkcaiAAUQM8q8l+ePAzmOjs+8QIREDHmK9RCyePtP18Oa5aVMjZuwgZ1dAMYPjL27 dJIVgR5oL7eFww8GbhfsBna4zsLCKu8AdIo/cgqpe7hTxukKDudvv5q9SdoBL7P/pkCF 2mM2MZWEmTQBC5idfAEx6mhV3ehANO4uWkHKbZXQozGwa7GkF7693Turh7m+2rjluiCO +hRQ== X-Gm-Message-State: AFqh2kojHTcGSQ46IZ7Fa09xIZStkHm5g8i3P0NcyOHHYMd/uWGvi4GS fWP0w+/kZ4Bw++leAC7rXckfNg== X-Google-Smtp-Source: AMrXdXvg3Wmcxlr+zxIzbctf0szk1Alr8VFtzl74qmArJYWCAlwZt9atsHWVsv5Y4QATS8R33CZw/w== X-Received: by 2002:a17:902:8d94:b0:192:d9dd:167d with SMTP id v20-20020a1709028d9400b00192d9dd167dmr4633379plo.43.1674003146107; Tue, 17 Jan 2023 16:52:26 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:10f3:73a5:7e44:adbf]) by smtp.gmail.com with ESMTPSA id u10-20020a17090341ca00b00192f4fbdeb5sm8351461ple.102.2023.01.17.16.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 16:52:25 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Mike Kravetz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv3 2/4] zsmalloc: skip chain size calculation for pow_of_2 classes Date: Wed, 18 Jan 2023 09:52:08 +0900 Message-Id: <20230118005210.2814763-3-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230118005210.2814763-1-senozhatsky@chromium.org> References: <20230118005210.2814763-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 13F59180006 X-Rspamd-Server: rspam01 X-Stat-Signature: pk163ze4q64e5a6is938dfbpqsycbteg X-HE-Tag: 1674003146-714447 X-HE-Meta: U2FsdGVkX18kNoAI7kwZJgxFgQNFjsqsisDmv/mcA8kAucSY1IkAyUHY/fctQtMmw1a7lmSKYQEPq3i22fFebJnWBMoxns4pPTETmz6U79h+FBcg/uRhJChP/SuxpqlFCd5is8d8bZvT+SvYlGFjUlgR6G/2ap8JE3AyIjnOhYeqM8DIr0vG1jiAu39PjOUwHbo/xIIiPFgGGgYBq0tWQNp/fNUlqu1v96wv6qIy9PXWk535lsIkvknzL3hrwNiUFxj3/ePUUAVuX5z3M3kZrYCjPRyyXYpMPHgUNkzmxyt8FlumPmoG5+8RJzkEjc4+jiIWBZGZkXMrP10t4LpVI3NTFQRqWYLWm3jQhYn9O8aDV5buZJ+QeKtj7B6IiEsdl761696Sladqu6cFSpl/WrDiso2G6ZQHUdeVXHBqG0FIRewoS1uF7ifqD5wm152FmeO8NjGhqdDQ2LN5UrIYKNoDCbiHarrADP6QHAFL0oaBXSevIVxMKmPBuQvDJcihNEKjCdNbduYT8NKVXuyJ4XhSZat0TJRS92/xhFD+Nx8FZJdhYRYruukqnMF0ghUYcS5AnqAqzc7q37Z7iH6AzUkoQqOr+iEL1TBczyuQ8XHqBqoYenqgpEIdb5e1NdrdTAQDPSdkK2ExHUbFSC624Ceusoz8zOQ3v2GW0wi0FfyKvNFpOt35XyOtBXh832KCDe86OdQrEmW7diuCkjlaUyNaSab7sLvzEykQ4H5mCXmLgz8XVWJSpoidaySsu46Zqt5khFkTuKo5c6mM+FYYrnY+S/bj3DI1lp2PquYjTub8HfndI16oGuegLypbOvLdUPDxR3VRLHxJ19r+1sLVR+jzawrCWTHimdfnpeSuFszXYiQ6eRzPy1Fp7oVywW6rYBiP5JszFah+VWhrJZBFviX3wwpUzKZ8bJp/jiyNpzUMsYAz0X+h6bXWq6yN6upukRn7oSjM/ZjVYEcD9xP rABqnSU0 oyQJ/sOGMmxUm3AJbu2uk7ShywkeJhGYs/qmScwhRo1F+JHW2n96+oYC9QY7q/SgLTCM8KGikFSHeCPWKEvVSSazMtg4+nAzj/GRcqr/Wkvu/IlOttE2rX3j/kWxKovnErmxkVHSd9R3QHG+QjZfarQDNjbvJ84f4+airE+oVDYBEq0KvO+vgCf8+LQ== 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 Acked-by: Minchan Kim --- mm/zsmalloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index effe10fe76e9..ee8431784998 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -2287,6 +2287,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 Wed Jan 18 00:52: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: 13105310 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 07E01C00A5A for ; Wed, 18 Jan 2023 00:52:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F20B6B0075; Tue, 17 Jan 2023 19:52:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A1D86B0078; Tue, 17 Jan 2023 19:52:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89CFA6B007B; Tue, 17 Jan 2023 19:52:32 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7B4F76B0075 for ; Tue, 17 Jan 2023 19:52:32 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 5334740B92 for ; Wed, 18 Jan 2023 00:52:32 +0000 (UTC) X-FDA: 80366094144.03.756AE8F Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by imf21.hostedemail.com (Postfix) with ESMTP id A89A01C0006 for ; Wed, 18 Jan 2023 00:52:30 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=dKn2e93s; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.50 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=1674003150; a=rsa-sha256; cv=none; b=vw26ROwUN5F2K+rQ+Tcpr+rLic4V+0fNdTghrjwcyZwjnM5JD+Y5Q1gtTEVMGkfPT8nFr7 vsXU3wXv+jyiDUsA/IoYilHAJaPf/RW4LkPsH3EU4OthGt10MuP+gKvqHjmBapQUCgrOsZ MQz+FVLWEjhebMDziRLthZDSelZlJHs= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=dKn2e93s; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.50 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=1674003150; 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=CIIcftnTzg8Kfx+49Y7UDaJ1lnEPtZ3NItF9OqS/fDU=; b=hQdTq6IzHyYrQUbYjaOJQ5IssX/QUEOTHg7QSOWUiguPFU9b9YV3EQhmF+SZa6IW+FVrjT ygnu1t2DYgHo7q4ZdrBzfnR7VU7MxdW+x590g6CLfCU/Y0XHunzK8wyuZ/lC8kZ8CgVwRQ DWAzkPdDoyGzjdvcsmTIfClwaw8Nyns= Received: by mail-pj1-f50.google.com with SMTP id a14-20020a17090a70ce00b00229a2f73c56so670397pjm.3 for ; Tue, 17 Jan 2023 16:52: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=CIIcftnTzg8Kfx+49Y7UDaJ1lnEPtZ3NItF9OqS/fDU=; b=dKn2e93spigc03KLoXF7ZTvVdGY4XHGNHnI/QVdRnTJdStKDXdwLMk4o7DqqMfWHHO T/G/I+6eLpYdy/tTV7clT0V0xsm+nkJuExMO/sXyx4IPTW38Qde+EdFSLKH1HHZQzPnc VV5m4HySicj9ZEu9Ag3VnYKm5AY5GJ635n4JU= 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=CIIcftnTzg8Kfx+49Y7UDaJ1lnEPtZ3NItF9OqS/fDU=; b=hnv+j24YOrZSb5TaJi8TPEFpdJ0wL4iydyWwlzUVxjpyecdI4A5XDHpGofZ2GCw65q D8364pGWo58/Oo65h7webXoKNjR/hmw5F2jE102+aMIEEM8ULy6kDXpb/UZppu64iDCC BtwdY7VDR49N7ObSXXSqL+5/PXuiqnS+edqI/iAwzZ83HA5Cwm2hqj7sD+cgzG8WhuFC NrzCilc6uvag2OKOhlkyNEFF2N95Y6a3UHI0E1cucd4QZEXUwfmkur3r5SLjEa7/UFag M4Uyplm4C/7f/IhDp6v3gUkFSslSmzDMX5qtMRLH4TDGpM56Z01EHbJho2kPZ7vPlSb1 OXvw== X-Gm-Message-State: AFqh2krM61qv+BbHncabdVn04k03VQYIY6QVnwJ3nsu+C4Gdefm6gFpx FPKGK8rHn40CimLXhR3h5ZxqEA== X-Google-Smtp-Source: AMrXdXt+yEbHb017zotxisctz8oAkeMlBJeMXC+abT7hLpAAamlMLlet/dkMa+wmQJxZGPxJa539Uw== X-Received: by 2002:a17:902:aa05:b0:194:52ed:7a2b with SMTP id be5-20020a170902aa0500b0019452ed7a2bmr5362165plb.39.1674003149509; Tue, 17 Jan 2023 16:52:29 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:10f3:73a5:7e44:adbf]) by smtp.gmail.com with ESMTPSA id u10-20020a17090341ca00b00192f4fbdeb5sm8351461ple.102.2023.01.17.16.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 16:52:28 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Mike Kravetz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv3 3/4] zsmalloc: make zspage chain size configurable Date: Wed, 18 Jan 2023 09:52:09 +0900 Message-Id: <20230118005210.2814763-4-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230118005210.2814763-1-senozhatsky@chromium.org> References: <20230118005210.2814763-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: A89A01C0006 X-Rspamd-Server: rspam01 X-Stat-Signature: ha7946qp5r4op678rj8uw7beqp5bu6yg X-HE-Tag: 1674003150-478671 X-HE-Meta: U2FsdGVkX18r4qTmdkjzJe96ziXiP4w0JvdDDxyv7Pz2dEuvCn15LMpC9odYHwMrhuE5uRvs2MmtZvKLf71l3tI+2jnYT1H8m1NYqDptnF2AROq5wQKlaPRwnH3HmrRMldmzHA/CZwpgNFeAypb5vRUKewWJO3PvLzkR5x/JQqfjA4sfWJiYxhAn4fkfo1kQztuLFcrZd6Xl3I+H+0lYi/L/rOi5fbZybX/MDuc+Jzl8JM3wKy8EQ8rsUruwKwhltFGtfSs8bV91m9SIRaYJlL6QJwng5L3kKNfoYa3TA7JzvRiidkFc9ESpLatvScPO+4ES3Y7tcpcjlGG4MTjmvmMuvK1hyVSmHcjgsNCNrLZJpVgAHCyklZPILmnE9UP6AC04up+7EeXPjE7QRSClJ2XNKuQ5jcUEap1rNOKrF7wVCbvP2FZYev9GU2aWahE9MIu6bHiyW9KCgomI/YMhTbWHUEM4EAIF44KxdvaoPvMkUF97sKS/MAcsjVOwUzKMyh+BA09Mny9iLgtrox7XeDnOmu69os4D6GTg0YL6kAzq1OQT+N8mmSlo2qppXxXe/woURa+G73dYgTHMds+5rcPNQlBHOWPxgZ+GzdpZvKkT6xivi0CJOxWX7ghnLQOE47q+cmLcDj0mfY5PIdKh5AajCtL9iUxbDOKXFzZm1HEzxUGYy4OU9FkzQToQBuEvHrpahAqo95EwZiq2uDVjPY97e2q0BNizdHzL8yTs6tLtMI+gut9TvkyA893bEDp/iytPrckzBACpJ41BsKGdOsBoK3um/Vl7g2uioSsGdG8iNuiV1PMdDnBfJ/JzBHuGB4e1WFVMyqzbISVzfLWinMjbQPvYP67NkIJPJ7v3/UkVeE+CpvcEe7VpTjVKfdPc7z2Bwtc9PF7Js3910M4PEO5rcSO36p/Qsj3NIpn3/PiTbFlYK8/S9K8qGFJsjkXaw7stkUzhxuhV262BZYX 9a3jvqfg nnfU0hHzFeGq0u5kwiUpyLY3mJpuO4jsBuLRqVATBlrZcLQl5DNoAep31dPam6TgdkeunZxVeFx4UfgJjTKI0Of1mlUomtcweEWw2PUwA3F6XW6E6kuSF1kk80ipm2IxQVbWi 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 Acked-by: Minchan Kim --- Documentation/mm/zsmalloc.rst | 168 ++++++++++++++++++++++++++++++++++ mm/Kconfig | 19 ++++ mm/zsmalloc.c | 12 +-- 3 files changed, 191 insertions(+), 8 deletions(-) diff --git a/Documentation/mm/zsmalloc.rst b/Documentation/mm/zsmalloc.rst index 6e79893d6132..40323c9b39d8 100644 --- a/Documentation/mm/zsmalloc.rst +++ b/Documentation/mm/zsmalloc.rst @@ -80,3 +80,171 @@ Similarly, we assign zspage to: * ZS_ALMOST_FULL when n > N / f * ZS_EMPTY when n == 0 * ZS_FULL when n == N + + +Internals +========= + +zsmalloc has 255 size classes, each of which can hold a number of zspages. +Each zspage can contain up to ZSMALLOC_CHAIN_SIZE physical (0-order) pages. +The optimal zspage chain size for each size class is calculated during the +creation of the zsmalloc pool (see calculate_zspage_chain_size()). + +As an optimization, zsmalloc merges size classes that have similar +characteristics in terms of the number of pages per zspage and the number +of objects that each zspage can store. + +For instance, consider 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. This means that when we +need to store an object of size, say, 1568 bytes, we end up using size class +#100 instead of size class #96. Size class #100 is meant for objects of size +1632 bytes, so each object of size 1568 bytes wastes 1632-1568=64 bytes. + +Size class #100 consists of zspages with 2 physical pages each, which can +hold a total of 5 objects. If we need to store 13 objects of size 1568, we +end up allocating three zspages, or 6 physical pages. + +However, if we take a closer look at size class #96 (which is meant for +objects of size 1568 bytes) and trace `calculate_zspage_chain_size()`, we +find that the most optimal zspage configuration for this class is a chain +of 5 physical pages::: + + pages per zspage wasted bytes used% + 1 960 76 + 2 352 95 + 3 1312 89 + 4 704 95 + 5 96 99 + +This means that a class #96 configuration with 5 physical pages can store 13 +objects of size 1568 in a single zspage, using a total of 5 physical pages. +This is more efficient than the class #100 configuration, which would use 6 +physical pages to store the same number of objects. + +As the zspage chain size for class #96 increases, its key characteristics +such as pages per-zspage and objects per-zspage also change. This leads to +dewer class mergers, resulting in a more compact grouping of classes, which +reduces 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 + ... + +Size class #202 stores objects of size 3264 bytes and has a maximum of 4 pages +per zspage. Any object larger than 3264 bytes is considered huge and belongs +to size class #254, which stores each object in its own physical page (objects +in huge classes do not share pages). + +Increasing the size of the chain of zspages also results in a higher watermark +for the huge size class and fewer huge classes overall. This allows for more +efficient storage of large objects. + +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 +---------------- + +zram as a build artifacts storage (Linux kernel compilation). + +* `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 + +Using larger zspage chains may result in using fewer physical pages, as seen +in the example where the number of physical pages used decreased from 159955 +to 156666, at the same time maximum zsmalloc pool memory usage went down from +655175680 to 641703936 bytes. + +However, this advantage may be offset by the potential for increased system +memory pressure (as some zspages have larger chain sizes) in cases where there +is heavy internal fragmentation and zspool compaction is unable to relocate +objects and release zspages. In these cases, it is recommended to decrease +the limit on the size of the zspage chains (as specified by the +CONFIG_ZSMALLOC_CHAIN_SIZE option). diff --git a/mm/Kconfig b/mm/Kconfig index 4eb4afa53e6d..1cfc0ec4e35e 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 4 16 + depends on ZSMALLOC + help + This option sets the upper limit on the number of physical pages + that a zmalloc page (zspage) can consist of. The optimal zspage + chain size is calculated for each size class during the + initialization of the pool. + + Changing this option can alter the characteristics of size classes, + such as the number of pages per zspage and the number of objects + per zspage. This can also result in different configurations of + the pool, as zsmalloc merges size classes with similar + characteristics. + + For more information, see zsmalloc documentation. + menu "SLAB allocator options" choice diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index ee8431784998..1a7f68c46ccd 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)) /* @@ -120,10 +113,13 @@ #define HUGE_BITS 1 #define FULLNESS_BITS 2 #define CLASS_BITS 8 -#define ISOLATED_BITS 3 +#define ISOLATED_BITS 5 #define MAGIC_VAL_BITS 8 #define MAX(a, b) ((a) >= (b) ? (a) : (b)) + +#define ZS_MAX_PAGES_PER_ZSPAGE (_AC(CONFIG_ZSMALLOC_CHAIN_SIZE, UL)) + /* 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)) From patchwork Wed Jan 18 00:52: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: 13105311 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 2C82BC38142 for ; Wed, 18 Jan 2023 00:52:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AB4F06B0078; Tue, 17 Jan 2023 19:52:35 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A65106B007B; Tue, 17 Jan 2023 19:52:35 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92CAC6B007D; Tue, 17 Jan 2023 19:52:35 -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 839236B0078 for ; Tue, 17 Jan 2023 19:52:35 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6494480BD2 for ; Wed, 18 Jan 2023 00:52:35 +0000 (UTC) X-FDA: 80366094270.16.E780C0F Received: from mail-pj1-f43.google.com (mail-pj1-f43.google.com [209.85.216.43]) by imf21.hostedemail.com (Postfix) with ESMTP id C00171C0006 for ; Wed, 18 Jan 2023 00:52:33 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Fz8NyEIR; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.43 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=1674003153; 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=EsTMdrrDLcqpHJRbM6PDDky4/t4qR5IEdsq7S2Y6nHw=; b=HmjE2GwnwsP8rhdV7bF4ASnr6ToUtJdyrKhCL5rCFzpglf+J2UqvIT1Nh6+RKjA3mMwvty tXPOACa3b+a/0DlYFYTlAPyfulY36Hd8i05D8XYZGxW52iFEk5nbX/al0T/r5uTIERdQxk 7GbVnLQci+TaOsdyHMWY/oS4xubbdco= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=Fz8NyEIR; spf=pass (imf21.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.43 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=1674003153; a=rsa-sha256; cv=none; b=NSve54plrdQT/nMgWSjBragTDnUfkJp6yMkAI9wrwfxfGLDLdMcUJ4wFrq1wiWQL+0GyAw LSM/LLzC+xGvyJIjnza/htWRLMMmznXw/2bn5jAM1qLF1AGVg5IvFs9UUkJKLlIUqMwWHV iLokePRGoPhsKnrSZwM+UF6LGqcO39Q= Received: by mail-pj1-f43.google.com with SMTP id d8so3010703pjc.3 for ; Tue, 17 Jan 2023 16:52:33 -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=EsTMdrrDLcqpHJRbM6PDDky4/t4qR5IEdsq7S2Y6nHw=; b=Fz8NyEIRMQqp+I4ZCxQepR1p8/ydkvg2hf1HWGJ8u/aCQ9zbwbo77E3dYl7YNtJc4i BUn0gxOOa7Ai0hZJHABejQtg+WfubPi/k0+hJgmX2tztw22xre3y8cf3ZlgKFEFs+OLF +bW3L/RBjQHekHwrqA7plGbudq0By7lrRWw8o= 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=EsTMdrrDLcqpHJRbM6PDDky4/t4qR5IEdsq7S2Y6nHw=; b=D8gKpGbwqNY8BU2GgJi14YSgDkFP5i5SafRl7br0lFMnwT68uMc+0xZ+wnZ+CBAqID 1I6LAT/KDX4SKAVnvII98hbBY0CCxuqQXOQI7RMX0f8MMCcRFAl3Dlh9B7DHpwquCVtL g0k14KlWCVHfCOZ2qdjxlU1Gj7useL1VKZWjhh/jBOdHKtUrCOnns7fFl4bSsPw25QO7 /2Iv3XN9mgAoXxKUG2BaRJ1ITl3GqMGPJqF0wCCvDQYHNWhiCVoXMe3drOxLIynJ52c1 /DiigVpR29/UCLycO58oV4xqxxm/6FxR5gyDkmIIROvYdGTyJheVJbSh62fVE+ckD1I5 rgmQ== X-Gm-Message-State: AFqh2kpu/X2Xtkq53NVeFI/1WciKzKaU/URfd3ZLrJnR9II4uzLaz9s8 Z17QTSTQ/JVTCFXc1nBbC+HQog== X-Google-Smtp-Source: AMrXdXsdNKdUiGRGfP8RIbqx3A82w0/9Ni8LqjvhCZZQjbuQ2HELZUicdwQGq1iTQV8GzoNc5bTcWQ== X-Received: by 2002:a17:902:8208:b0:193:f76:aed4 with SMTP id x8-20020a170902820800b001930f76aed4mr5345353pln.1.1674003152775; Tue, 17 Jan 2023 16:52:32 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:10f3:73a5:7e44:adbf]) by smtp.gmail.com with ESMTPSA id u10-20020a17090341ca00b00192f4fbdeb5sm8351461ple.102.2023.01.17.16.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jan 2023 16:52:31 -0800 (PST) From: Sergey Senozhatsky To: Andrew Morton , Minchan Kim Cc: Mike Kravetz , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv3 4/4] zsmalloc: set default zspage chain size to 8 Date: Wed, 18 Jan 2023 09:52:10 +0900 Message-Id: <20230118005210.2814763-5-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230118005210.2814763-1-senozhatsky@chromium.org> References: <20230118005210.2814763-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: C00171C0006 X-Stat-Signature: gfhk4165fg7gieupwt3zyuhcdq1qi89e X-Rspam-User: X-HE-Tag: 1674003153-277120 X-HE-Meta: U2FsdGVkX1+mu6TQMMtLdWxQFSIAq3u8bu7PX/TNTwCyevtQkq1hRsG10owUDbawvz1L/xHumCtXYm28UbF4raJsgYmW/vgEVwPlroSIjAiIG2bHb3GwKAtuWOpj5jf+8gSc+RyDSjTzmDzfSXKSQ+lRTwL6O35tZJZAfG0q/Frfjom33r2DOWQK0KKywjtaT/kDoACIY3ulDQpQnk5JqSRU/v81iIYMWd1CkqqQ6ej9l1Sylu+didUIiZzf1tFgnL4+UlNE0Nqz58U5j3TYPLK2ks+2xBdA5o+i3GmwUW2ugQXYO6b+VGGPiTRm1pLeyzxQvVLCHBsgmOQA0wsSi5OjRDI8gE71gVgDSEgqSt6jo/K3Y/3z5oYCduEpoQPNBB2OuD6YqGF4E4raxQ7u0xSkpp/GKe+eV1FhDgpHktInylWY9ePeqVYOLYmJKjQQFSRN2OCtojw0Ae/kudGVFiRUTWZpgRygfyW1qiG+K+0ROnG5CgDv9OkMjsw6PfqXRvXvv2N0tBfaI9GqahbpPaNt7DkC9lB6yvzCfEby6c7hd9FymJ70Zs243u28kabyLl3zRy5Sd46ByRiqhELjaPvUChkCwa1foHobnPm8evXaEMTEI2Q1F6ve4wE7x24n814dDg/Km39+JqQIt2WraSU96usApai5qO6q6+P3dBMEqf12LIP6TTATB1M4bcFbYYqd8lRkGC0FDehLQaOufs9Eqkc6Bf0OHWT8XqIRdHzOLerFJqrmrH8M/IqvKNNWz5/upFw1ml0QixfnSHDrNT9RSq+9NrH/g8rpLPjiXlL1RoKI5z0FPmuCGXL4KTcN0KKKcLIyidoKkOJG6olPMOInOUY1J8OGWuZ6mc+nz4vFYtLwaPdpBKAo7G+OrwrFDje8HpiZyDCnYIMe5rR0RWJH7nCBRqAN1sDHb1VGZjbiNozo6c0g1tg/N14tHyXFPax2SI5p+RFbaVpDVi9 8Vy3Kdq1 lAjLw7Htgg6C6q9+KVlSHFXKxI74jrT3Micb1qM1tGOoWwqp/pxf7EIW/Rd8dVf7Foz63OaSWyauokPCagta3k9RhFJH9Ee+xlrskOj4y00pV/DSOPbyi6uUJ+S7nLkjPRDTu 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 Acked-by: Minchan Kim --- mm/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/Kconfig b/mm/Kconfig index 1cfc0ec4e35e..ebfe5796adf8 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 4 16 depends on ZSMALLOC help