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;