From patchwork Mon Jan 9 03:38:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13092910 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 2C5D6C54EBD for ; Mon, 9 Jan 2023 03:39:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F6978E0003; Sun, 8 Jan 2023 22:39:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A7068E0001; Sun, 8 Jan 2023 22:39:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 76FB68E0003; Sun, 8 Jan 2023 22:39:13 -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 669948E0001 for ; Sun, 8 Jan 2023 22:39:13 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 369A41A023B for ; Mon, 9 Jan 2023 03:39:13 +0000 (UTC) X-FDA: 80333854986.03.43976E3 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by imf26.hostedemail.com (Postfix) with ESMTP id 85FBC140004 for ; Mon, 9 Jan 2023 03:39:11 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=XjU2WoqB; spf=pass (imf26.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.171 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=1673235551; a=rsa-sha256; cv=none; b=BbPEgynrWNiNSiUXvs6tDInuo5ahJiKEieYHTsIfw6V9343jTJKF1F6Zh2WA4vdJMBnCRR EV9LLbCnLwT8XYuJhFskxajjrPgmBBigzdxBiaEHSZr/7/F1ORElJy/x9xsWV/Dm6YdofE F2eqAAjhzin+RjH2FZhJZQy5n04tmjs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=XjU2WoqB; spf=pass (imf26.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.171 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=1673235551; 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=uJf7dha5k2JA9z4OES9HOIhzl7+lcnfFyGyI5I7+NCk=; b=t3Tx1b5JR0TvLPGaVitqJo53EIcg6WS8q9U6vQerM20nKmmprNxEsEo2U3dJjKYz9iufBN DdeodO7QH8Hgrlnnln/cqnuGYgRFap8UDEXqFT9aIQjfc8kr8lMLo5Hkn5W3bHEpNPIufy f1P+Xfm9Aj9WhR0TJsR1N5aFHzxuOb4= Received: by mail-pl1-f171.google.com with SMTP id c6so8177711pls.4 for ; Sun, 08 Jan 2023 19:39:11 -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=uJf7dha5k2JA9z4OES9HOIhzl7+lcnfFyGyI5I7+NCk=; b=XjU2WoqBTvgShhdfuAbe+bCsbpszVIl+NO3iYTEPFSxxWxCQmQ0Sc02kQvqBLet9LA 78GlE/1M9AvlvigUsXRKDG2MKRXDr0Kadg8EX9IXlzjW9ZFkPPsFjLtq7PE9YrHnH0+C weFW+9evp3q545nBXO0snJPIvzB+qEb8Gz3qM= 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=uJf7dha5k2JA9z4OES9HOIhzl7+lcnfFyGyI5I7+NCk=; b=GlBSb5FamoMs/groPnuhEwIOpHQ/lXAcp7t+N4H147erhjkIQDJaQ+yPuQotSlaR00 B3bpihmn8LaHvdaWnZgxZx4t2SnPEpIG02be5bbwqSbWqaPssf0P9Bor1x90JiKUWtBT yLymlGvgYpYQj0V5loq8wszlei56yZWeG6j5VNkBjPbDU//EKdBOJ67++tQu79CmQnzK S2/ra8le6BloMdRgWBDjO68hGOvPTYVIWGbmTv9W+QPnWrF0AzTg5QQFIQv+6kesIWcC 5yFC/ACHvlSu99l0EsswYCsvG39UxgUbgkfy2hZDrluqpvusVn1vxVssKiYbTvr/D5v0 sLCA== X-Gm-Message-State: AFqh2kpOidrx/0eExfzclgoOjiXM7qq07+aq32zMxfzn6zQZZAJKyMom QRYUsrGvCQPaeOgQ5P3DBsxKSIFGY2Mavd1N X-Google-Smtp-Source: AMrXdXudxT6l1K3qFdscG3iOXMYQPHFdnQlKnpz72FQuGvE58k91OPIVpRStqcuSy21PbOJv/Y8mFA== X-Received: by 2002:a17:902:b78c:b0:193:1fc5:f611 with SMTP id e12-20020a170902b78c00b001931fc5f611mr6023821pls.38.1673235550467; Sun, 08 Jan 2023 19:39:10 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:5ec1:f8d2:ce47:7ddc]) by smtp.gmail.com with ESMTPSA id u5-20020a170902e80500b00189529ed580sm4896685plg.60.2023.01.08.19.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 19:39:09 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv2 1/4] zsmalloc: rework zspage chain size selection Date: Mon, 9 Jan 2023 12:38:35 +0900 Message-Id: <20230109033838.2779902-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230109033838.2779902-1-senozhatsky@chromium.org> References: <20230109033838.2779902-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Queue-Id: 85FBC140004 X-Rspamd-Server: rspam01 X-Stat-Signature: htubnwtf7n1bgame9t7b63p39qynsfyg X-HE-Tag: 1673235551-343035 X-HE-Meta: U2FsdGVkX1/gEqLX72Qd+WhyT8C4XLP0nGuVWqxoNFO/iPC5aS4szS1TOG+pcuwD8NkjTc+zj2JuxatdMsN6mMz20WaXVxDPtwAKwac0D0nX4VTJBlmxvROqGsLo7zbsyth/K6Uv7AlRN+ykhAdu4FHZd2xF64mg7lq+nbXOov6E53lK2RHF4E4NMduexuGsMBeiZEBqGBLlDDDMupGPYcLkcNRIs8NsqZJc9QAwiWrCwYtR5Z3pqtdBG/5KIUu1p9enWbV7CLuwuOK88PaS4wPtA2v5p5CrBMzupp2sUf3fyf+8T6l1pnVvPjVM0Ys6dxPaN7Ovk9TycG0dtI2BIvtt7VyRq8BUn7JfxukWdant4xZx/8b/Xdn2I227IxNmX/Nmtbrbq6/KmVI+iN+7f3OWOveRjBi4YoS//f4Ycltj9WW++ovNV+RJt+t5W+XsZR0+rjrXA2hIyDeA4wSETon2zdBvzvXKMs5nmVNddhhi5BjXG2f0UPU2IRckxB+6Oa0IW2tqfFcP+3mcCN+4SKEEYnYCIzEy/Yd4R7lVwWyxaKSuypI3KTd6pF4BdkOtoMeKrmwRog/gZ31n6Tz1Tp6fKTAS4+RON56TrgIto/DvtaI3fAu3ebCCq4JSpmt1FC2QzmpvWgmx6yhRgJ3muLi3c4+IQC9m0sZ4KVS+XQ9cQeTNS86zKJ850KneRKJZjiVewWJN87Yz+VqFmNWn1reVPCoLkcMmjtdRxVQa20PIqf+YDDDj9KdEpww5UiHGZnmxNIU1dAEH//LWC5vHV601d20NmSTWbdpowJpnwA9llI6VdLxXAVM0v20ZsziHcuZBxKaU6TCe/5Oxg+hHmxr0NxhR7cgND7Lx6HTLzMM6o3wxyC9tRx95i4xx6M3Mq8oRwkuJBIY8ZDi6bAr5t9l1k9fYWcoF71VycuUBHwvq14hs5BdZt6inVm8k0Jze3moMFtiMcMjOh1++1cq 6h8SyvPy /aqEAPOHhQbYLg+qo3Qs1jJJW+6E7JQhQ5F6HL4XHC10J7qBPH5u5B9hvH1NR9XCBt9ledAZls5b9xslN+RLloNdJvBAHTbQgj4G1f77tRjc39zZuxQsxkV5iILob8xbrPoFu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, 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 Mon Jan 9 03:38:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13092911 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 6D53DC54EBD for ; Mon, 9 Jan 2023 03:39:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E74F18E0005; Sun, 8 Jan 2023 22:39:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E250B8E0001; Sun, 8 Jan 2023 22:39:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CECF98E0005; Sun, 8 Jan 2023 22:39:16 -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 C07888E0001 for ; Sun, 8 Jan 2023 22:39:16 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 968C2C019F for ; Mon, 9 Jan 2023 03:39:16 +0000 (UTC) X-FDA: 80333855112.22.2E275E4 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf25.hostedemail.com (Postfix) with ESMTP id F1829A000C for ; Mon, 9 Jan 2023 03:39:14 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=WQwcvUaQ; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf25.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.170 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=1673235555; 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=AEbqzpe3o1M34E1TK5SG9WYfEV64gTPdXoQ0O7E/LWQ=; b=yKrCTS+8O2EKWsk3zhyfE6l7gznoAV5Cpv241xL42/XkJ7Zynp1SkgNHX4g2X5zOefsDJ+ HxPevg/VCEDhSLLes1s+6z6NLRqZhuRVvvTXtZ5xQpoIZQv1g8PX3FLvKrWS+Eb7opwtM/ RfdeBf4wfmgb/eYj70GzZ8JLkbpF7uA= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=WQwcvUaQ; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf25.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.214.170 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673235555; a=rsa-sha256; cv=none; b=hS+d8zac5Vc1DMSkZ+ZozbQfRnje2beBK26qfi9isJDk99GI/OcueKu/4TYB46Hf9I+O0Z SfRn6vHPafMKa5J7j6gdvoLPrg/h8B994I8htI79r+z/z9PX2Ik9ztZhUiTpOR5kO0v7IW jGgqZ50jcokt+MWfHVOZjP2m4tK3aZ4= Received: by mail-pl1-f170.google.com with SMTP id 17so8212572pll.0 for ; Sun, 08 Jan 2023 19:39:14 -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=AEbqzpe3o1M34E1TK5SG9WYfEV64gTPdXoQ0O7E/LWQ=; b=WQwcvUaQg4HJvYV5wdvB976BQcDb2ieJxDOiGtrty58I7ls1CoGJAe+vD3cCTZp0mS MPzdxEZgAGUlrS6cKJYGVF2aAESwfwE6LZMlPD5NWQcc0HUDKXcHX6v7+prbsOpr1QtL IYdJ1jZd59PF3ZX5SIaIzmqcHL1J296Zz2HzM= 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=AEbqzpe3o1M34E1TK5SG9WYfEV64gTPdXoQ0O7E/LWQ=; b=m5y3+3q7++xYX+AgJkoJ13q1Eohu0Do70iqkqJRi8di+ayKuEF0b+NJgOwm/NMeWe/ ea3lcAA4yJ3FwpML1l8mVGsR+TJLE5OMYu3XYv0ErSw+jOZDtBYQOdcbU1y3zTgZczyG MCWCMioUvxcFCH01tXISQpNO7zfS3oS0AxLc4ck6/3cUC0k849wrnUGJRTJtSqN/mDP5 SFXQzs3h/GDwrwS0RBep2a/nETeXgOdAE+FoaSElWnlfsPx+c0YQ6SpE8K1Qz8alwg+M ZDzstAZiTja3lnYI21UWzLURKWMsWGDsMT2BJBTFLEhVDtB3YU2hP97L9Nn8CxKfA5Un KA/w== X-Gm-Message-State: AFqh2krxMkS9R+C/tQkqmeXHt6cf44h5MG1T854jl90DcTFmPSAHM3Hm qESYPPCfryITu902gxviLgyyaw== X-Google-Smtp-Source: AMrXdXuHYjjQwDymUilhCJ/UhceAK/SDhGEV9/RSE9nacPsscyxB7o9e8XDsnKmXaH8nblH8oShCVQ== X-Received: by 2002:a17:903:ca:b0:192:9fda:7665 with SMTP id x10-20020a17090300ca00b001929fda7665mr33824571plc.53.1673235553783; Sun, 08 Jan 2023 19:39:13 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:5ec1:f8d2:ce47:7ddc]) by smtp.gmail.com with ESMTPSA id u5-20020a170902e80500b00189529ed580sm4896685plg.60.2023.01.08.19.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 19:39:13 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv2 2/4] zsmalloc: skip chain size calculation for pow_of_2 classes Date: Mon, 9 Jan 2023 12:38:36 +0900 Message-Id: <20230109033838.2779902-3-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230109033838.2779902-1-senozhatsky@chromium.org> References: <20230109033838.2779902-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: F1829A000C X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: f6h4i65axxuitnd7faornnfaojn9spyr X-HE-Tag: 1673235554-980250 X-HE-Meta: U2FsdGVkX1/XBrjA2D/Y10tTfHCE96vS9coZq4VB+WSTLeh7h5+fGagjaEWWNijbPqeoVuHLOr6ZlLRv9RLltoGlxyZlHpYunamBo7jW8IcPNG6cb7YgR70j7j9ynNLzjQ4MFe2hqr59cSRptGZmS4oAG+e6dZ04+aiFoD3c1DJ+v/ceHbV0KZN/l6URaKwjNphxJF/Q3tAK6n7o+td6REdn4aFVDkQp7t3YAzd4zxdUdRzQdPovIVTmJgrrjHY3xgLcBbqwLxycCjBFKOBwUKyTW/cOyyBTGVJftROMCazg2nYW73f9FuBFfiVyplul6Wx8dZSwHZ399ezRPMbHAoGZadwg6+P42aIN72AA2ayHLygLMKQ2O8Hl9nCueBdR3tOGNLi5EMaDPeKdaVIoHacBlwoJaTO/bLo+a7JLRRclJPa6Pikk3qauRV+m1o6IgtSyl9omvlsyfyE4p/VKR5QbbarE98J1bsmLBqqg3oivMPzTFDlnVm9Q2FarVB4rLsNNPVRVJB5Ib6CGzss4GAp++wVjHXiMgeXP+HAavXz2p7Y8IXUc9hrD+7rm7jBOtdgDUc7hdHxDP06QPIJcKV5rbiAWmLbOwqdyeMY0HMio0ZqZSI/r3XKzBHlgUodTO+Euer3BZ4UAZka1FIGSnNbtaxeVV/4853BtRbn/to++bjjcmiMy7WALH+5axLVcbmZ73tmdCLILZkTyG0Wpzx/i3R/v45tT7a5uKQU2ZyDcQhjWzKpaLyGwP6p0C3XtSPN9pYFDiSaHNDW8MGqNF8WB709FlNz2ljAas2IJVmfzVwGVdwaDx78AlrrEsbs1rWOsERSZWvq5C/ixlbhXUB6TqFZn/ahFxPsZrIo0SprePQ2WhbysegRQRypJBCsPAxAh1g1YFhnHwF7cCysGw16MtewPAOH2OZ9Kia2CmWbUrIqgsCQ5Dwsj9ozWkG9c92fdgYHn/3QDwFMtcwI TSA/qHO7 lMzREygZYbQBuVxkBKvzwj0eYfMoLsafopAjVzov5Ohl7D9r4Vsz2JPXNLsS+OFf5XC8zsW0CsH8C0tlLhNeUs/z39BYFwUDMsOlFZsaeQgjvTvma4HXKh0P7GUKUCAo80dsWcMGAdXPiLrmzG0OzAFTjnyBLNZnqErxiHgMw9ty4M8PLzogVmftqTw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000031, 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 Mon Jan 9 03:38:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13092912 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 BCC2FC54EBD for ; Mon, 9 Jan 2023 03:39:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5C2908E0006; Sun, 8 Jan 2023 22:39:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 573458E0001; Sun, 8 Jan 2023 22:39:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4138F8E0006; Sun, 8 Jan 2023 22:39:21 -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 2E6788E0001 for ; Sun, 8 Jan 2023 22:39:21 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id C28A71A014D for ; Mon, 9 Jan 2023 03:39:20 +0000 (UTC) X-FDA: 80333855280.10.88AD52F Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) by imf19.hostedemail.com (Postfix) with ESMTP id 1A3651A0003 for ; Mon, 9 Jan 2023 03:39:17 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SCSfs735; spf=pass (imf19.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.48 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=1673235558; a=rsa-sha256; cv=none; b=D1Xt51ySe1HXQWHc7tXjazXorpwlHB0ezw+USb0QGybjiKGaGHcMl1i5/VkKw+41yIhE53 Xux+9cCa9z5B/lAq8nJslUt4yQSPSaMVk8/wXaS/Rz1I3G17vAvfddKUxm2+XL+YrYVE2j uUAEPLn/X/eywKHWjWTsKK7s6fAmtks= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SCSfs735; spf=pass (imf19.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.48 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=1673235558; 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=qQbjoovHIbft3RuQS8+IrwvvTG2S26k6XMimw8ssuDA=; b=3kEBDSQSpy1KtI6xRiWRO8WjvlDLyBmWikVMJEjeHeT4N2/DqzP7Ni4vxDg/9kjTlLYsjQ csyo/wGyRDPU1+rKWMk31THXniDWFmg9AWYcwvzkHZ4Rg7v/rVli/jfsDiQPDQJOyOIWBL 3PaiJgrUnDzOBabc8AyQrpLT7HjUXjY= Received: by mail-pj1-f48.google.com with SMTP id m7-20020a17090a730700b00225ebb9cd01so11437683pjk.3 for ; Sun, 08 Jan 2023 19:39:17 -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=qQbjoovHIbft3RuQS8+IrwvvTG2S26k6XMimw8ssuDA=; b=SCSfs735viHd2ONTHdFuB/QRBfu12D1iYUKzZBxHfrk9umA28I3o96DV9p4KIxDGdb Vg3nOZCj57Scd2L08A4WTyzmg1XyEJtBkeaj21D6FkT4iIlPHc+TFBBztPZrgv8WYhcl Htplhe/4VymOfMi14VoVszZGZfHxS5aiKLEHU= 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=qQbjoovHIbft3RuQS8+IrwvvTG2S26k6XMimw8ssuDA=; b=cQHM4tRGk4Hx7a7zRh+8m3n8rRfPLjBgxn+WaeUpDcx22Oh3yUhTfsTXeM2dHurPZw Iwbc/6+aq2GDPZSzhWie/HVZlHFPW+oXFvAWI5FM7AdzLGy6t/hRr/2utNxt5o8tBsgC smWBuz0v7+LUeMQepoAriPN4wARIHO+0HahlWMyjv7o6+TeqXEZak0/WF0qybNfIVqPs H5idWNmT9G8YvKuMw6EbjfOzQRfIfjYqHqRLMHMF6wHg0iIXSiZVRRHZrJLgAvEn5+7P PN0+HIFl+c/VWI21zLzwndXh7E2yWy+yYbglUdOG00nfxTTgR7JswnnXqymsFAPwSNQI hfew== X-Gm-Message-State: AFqh2koig2BjrusJ4oJhJFlr80iQcNNCaU3F07ZEgY1fy47uw0wPjUO1 M0xQSC5BJegfpcLRb9Qr2Ni+Zg== X-Google-Smtp-Source: AMrXdXtj8xLVO107KV9BITn1xookzhwU9dCBIXBCpCmlSedliUr6hztw2Bnod2xV5fqJGXwuK1omdQ== X-Received: by 2002:a05:6a20:2d1e:b0:af:6f24:b154 with SMTP id g30-20020a056a202d1e00b000af6f24b154mr81534280pzl.60.1673235556895; Sun, 08 Jan 2023 19:39:16 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:5ec1:f8d2:ce47:7ddc]) by smtp.gmail.com with ESMTPSA id u5-20020a170902e80500b00189529ed580sm4896685plg.60.2023.01.08.19.39.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 19:39:16 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv2 3/4] zsmalloc: make zspage chain size configurable Date: Mon, 9 Jan 2023 12:38:37 +0900 Message-Id: <20230109033838.2779902-4-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230109033838.2779902-1-senozhatsky@chromium.org> References: <20230109033838.2779902-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 1A3651A0003 X-Stat-Signature: q3bgcqna5rpjqhykmunbwpact8fjzjyj X-HE-Tag: 1673235557-401696 X-HE-Meta: U2FsdGVkX191sXZSfXKCMOtjZjBPKyL1Lbbb73v32Vj2zfmhT4iQIM/uAWzjoVrESOI9O7yArZKO5t+NaG5sJ88fj6sjBhayHKEkruRp8kUgkDRICeVbQgClFhepcOA9PHEp5itEDDt2hEcJ535EwIJUSoUrdEsS4xmAfOGkeHtPD9xJfw/dP46m1ADw8U0fFMrYs0Q47lNmuMusSq4ns06vBaq8neZMCjojOrvcBlhYovcHiVPhVI74irxAJr2ylglbgJ19O6SF14g9geDrrcNt0BkNO3e3A2lvPeu7/Wab4om/4/6EqQ7L7iXm1Nhc132D0HMwBlK8ixCmn1kNT41+xmC//6QQ7t2uqiCyGEXLCdbU9nWHJetmsyIn7PLQ3NKf3GLuhALJ9Z3bdWFVHfD+I3zDk3fKSGPV5ZU732O3Vslcc39liQkU5ZNWI1IR66FoFbw7JMKp22+9BaeCJE6wkwHiUSMNoW4VcHvli2r9eeqXe+fEGPXVU2oeAYOqeChy2w56v/likJz9phS87XBmLEYfXEAOEu5nH3auEJ+1NTONSfiwxtqCGqQCTfjSkzl+Puq3GJbnaWqSBHpuFKKOa6MVI2YhLrcOnrE7lExL2iixVff971/47EMAt4ya2LwU2g4cOHTCNbj1/t8V6UtQsHGMaM/vrpKiCG7l41tRHEaAPUXeuvvnVkl8+cL72QRQnc4A+DW5zB6a+2dXQx0piAJiSAboA8t9ynp7OAjjsreUXo6KIzDx3wuEGBwbzDoWUxOXTbTt88roLDfhLF1GoRoQbdxX6Pob5Pux7VCI84wG3qj38RQaWFppelanWH0l9CjmuPx6CUS7nNxYE4OkLeF6s0lZLUY2FEHPO1mEIJJzdP7oInzoCNhvliu0cV26r7MsNRrE0sJVGpLNk9H2qxtR4jOKaVcTOSjRLE/aM50wHI33l09B7xL+coTkKUTDdrdivMd+0LzNuWi Oahhcjqc oJQDCc/ujTW5sf+z7R1ifNBa87ZOYKxft6Jo1PK3CGHzLHjCkiv2u3UYo3N/5CaqZN7AtIibDlGN5PdNwHQiIjA4yiBSKOpf9ffpVtGCNBPgpzxwxgF3JeJOKrvT4We31mtHy 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 | 15 +-- 3 files changed, 191 insertions(+), 11 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..5b2863de4be5 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 + 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..77a8746a453d 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); @@ -2290,7 +2283,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 Mon Jan 9 03:38:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13092913 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 B9C38C5479D for ; Mon, 9 Jan 2023 03:39:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5756D8E0007; Sun, 8 Jan 2023 22:39:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4FDFC8E0001; Sun, 8 Jan 2023 22:39:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 377AC8E0007; Sun, 8 Jan 2023 22:39:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 1FAA08E0001 for ; Sun, 8 Jan 2023 22:39:22 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id DFEF61A014D for ; Mon, 9 Jan 2023 03:39:21 +0000 (UTC) X-FDA: 80333855322.04.34A93B2 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by imf11.hostedemail.com (Postfix) with ESMTP id 58D964000A for ; Mon, 9 Jan 2023 03:39:20 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=c2tPZUtn; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.44 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=1673235560; 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=dlWwNcLaCNMrFJn+GAHPbY9EaslTtgv1WCZYoXPvAgg=; b=hOJRmpCggEEqAWcXvmKB9spAFk+qNA8F4W+dWyq1OeqtdmNN5x2NZM/KdOBimGibVhb7dU R6lqgro+P9TMpzfgNAQr+PI/BhdB/4OA4FpN26k3NJT8NV6soHnRS+sMR66jusOhDwRsfJ Eh8SvxvkPBsuWMopI06hXY0UXhpODyY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=c2tPZUtn; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf11.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.216.44 as permitted sender) smtp.mailfrom=senozhatsky@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673235560; a=rsa-sha256; cv=none; b=BPVv6Qj8+kWCHAH5uLAeOLW1J8crM4PsqhMleNJ9vAflAMNkdZWYLCq+rGfR3PfPJ+wlX9 E7GUzNUuMsjZ05bVZTRUjQLqg9+u6ATKPq7JWlTGPiyZmm6dtoilnaSU7HdfTy8GcMjkAE PzjkZkKZFiydj7o0IXDQ03YwcI2EE18= Received: by mail-pj1-f44.google.com with SMTP id m7-20020a17090a730700b00225ebb9cd01so11437768pjk.3 for ; Sun, 08 Jan 2023 19:39:20 -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=dlWwNcLaCNMrFJn+GAHPbY9EaslTtgv1WCZYoXPvAgg=; b=c2tPZUtnfZYWUQEK/A+qra/pRjcTxBywGXUW2sLZfBlvY/CSVfMlKyEq0F6U6KfncB 0CBatdDY9OYDgJn4SGVqfFjg16m/HYXm5u1TpVVTtCVDKD+2spct3OLBo9tX8exo6E3a qmYUYHmT+f49hii4ylUIELFNoVNOomwoXRtSI= 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=dlWwNcLaCNMrFJn+GAHPbY9EaslTtgv1WCZYoXPvAgg=; b=smfdcnaHbLnSIo3pZbIN7B/vJLTNgEBm3zJKlzyD+1hLetffm3AEWJw4nJq/oK6+xM zb5fzvvqcAl64+tYgiCzjY8Rk1NiFHN3WGXIJsszLEur2CkZtjIMF/sXDoMkQyW50rat qfDCQJJLfFuR6+5v/7ZChFQZ5plWbnzKfv0IMBSbBQ62oPIfL0vlADQqvY8yHt1tLsGY r5gXnEv3aproBhR7xLn5uwSsZ8am+Mns7aOPqwaSnTEV10x77uS4TVkaCIIoIshwuyym GjqUmc8GLHgoqnDaZnJzKRCR2iWBb7ZCgoO71cN0UQQqlBAaqajLzJvnDQ5scx/nkf90 +Zag== X-Gm-Message-State: AFqh2krPs3CYTxyb3LJj70EBgvEwI28C6Hfaz34XIRJtuM2ipmuQ7TNZ AnGTxgY1xY9Hza0LfsQp+nZSdQ== X-Google-Smtp-Source: AMrXdXur0oxpjEODUUF9GTMwdIwC4g2lAGrc6cfHN0+4pkbqW99KdO9dMuvuer5o6Azo6AL3Yo2pYw== X-Received: by 2002:a05:6a21:6da8:b0:af:d295:e2f0 with SMTP id wl40-20020a056a216da800b000afd295e2f0mr120307008pzb.27.1673235559303; Sun, 08 Jan 2023 19:39:19 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:5ec1:f8d2:ce47:7ddc]) by smtp.gmail.com with ESMTPSA id u5-20020a170902e80500b00189529ed580sm4896685plg.60.2023.01.08.19.39.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Jan 2023 19:39:18 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv2 4/4] zsmalloc: set default zspage chain size to 8 Date: Mon, 9 Jan 2023 12:38:38 +0900 Message-Id: <20230109033838.2779902-5-senozhatsky@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog In-Reply-To: <20230109033838.2779902-1-senozhatsky@chromium.org> References: <20230109033838.2779902-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 58D964000A X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: wm8ejin5egjsc4x738extzku46cfz7ga X-HE-Tag: 1673235560-691559 X-HE-Meta: U2FsdGVkX19yS9IJgelezdeqESdPub+m6cVTCQovFLpMhP7W5eLf12Jbw3BsUsK09gPct/yESPZFudVhSHs1HSR9kUmQTJDVHRjk3dOcPnIji89BAiNsrdF5W33tKqMP/3+sib4le9r0jLs8QuCuTM3GDliqQ4lndsGJrlx6/IxsuUQrPOfGGI3QXrVQePvCijAUapcSOeIktHAKITI/079D0rJzG234Sketsxx5VtOC4Ev49XScb33H4ztEkybT8pe/OVEkQYfMYXhhQLib46HMATqMH3xfVIr/1gyujdmnqlwjG/qrN0iQRFfpPzDR9FC0Y2cXBf9XsiroOVPnuXyRgkCYCuQqC56UwVKvDiySRyNUQ6PX3Brloy1cHSRTzzazqKhraAUoBsATPmVq/NyXLLMvVIImQ6HLxpdPfux3viy2x/95E+3+bW5fbrtwAoMcGG73bz0l631YMj8cYaGrbNrxQGDSNSgUC0MP99q+Ou8+90oXtAEQF+fcqbPcoXa4/anz19l+e4QKIKjHltkU81gdDerV7tKLDOkHVlIuVRty9FEbZAkD/qLePsqkwtPPTgmPhdzpw48A69apdn4akYN3HhfMTPa0e169BkpwXW9zk/U+bRPFWYD0DPM5H9eO4j1Hou0lBAieYaKcQrmbz7Pyho3zW8HflaSr/JWsz1ewtXeBJ90XPR5VS77LncROZwtwBPxd8SYdMJCNeIM8ZrJew8E6ihEgGrTPyscom6i8nG72/dJNyMt9UXn7IvYpRAbhH6XADUonu7qxailvUajfjX1CLb9nqOIxpJiJIlFlyFGsYj7xagduOeZunQfSeaXScLkutgjtfzo2z9fWpmW/KwKRYr50aIV9lXVQOR/j5R+nOKkQZc32wokEX6rQi5ndXW4y2vHaf+FZERxIvMHH0QhQqybBxSWh6TLWGUIPJwbq1hwQvN8ewpWb6mXf9Me5xHRHRV0V0LL qUsI9c6L LhrcyzLj5ZsHQeDYAv5JK+NyiZOyW7hYibpYgWR5QSe3+v6J4yzCCFBiBcnVSGa4AaWBJCcdgE/BcXtolA22mP5mlXtd78nmtFtqnaHME3DPkeczfdcyQ4g4nQM7xUwH5beGmKffUc6OrUcU= 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 5b2863de4be5..d854a421821b 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