From patchwork Fri Mar 3 07:31:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13158387 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 2DE46C7EE32 for ; Fri, 3 Mar 2023 07:31:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 641176B0074; Fri, 3 Mar 2023 02:31:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C8336B0075; Fri, 3 Mar 2023 02:31:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 48FF16B0078; Fri, 3 Mar 2023 02:31:42 -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 39AB96B0074 for ; Fri, 3 Mar 2023 02:31:42 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0C6111C6A2D for ; Fri, 3 Mar 2023 07:31:42 +0000 (UTC) X-FDA: 80526767244.29.AEC7315 Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by imf22.hostedemail.com (Postfix) with ESMTP id 43627C0011 for ; Fri, 3 Mar 2023 07:31:40 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=BraWG+bY; spf=pass (imf22.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.179 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=1677828700; 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=wJN4vQ0bDt9mp9ZIcGCUIy6xbfFhJeCXLnKUnVtISUQ=; b=Y3OXpsq991O4mFopymwerNNsYZ+UdAOZtNNOThV48vUh6oaiVtn9kk/iMVo2ty2DBCImwV TY6kFRK2c78UziXRq2MB7EzBL56+fJoLQwVTu0zsN8MRFrixkNKIostH77VPRMf8MVttsy mCBi1/4RpEU6mye4Zbg6nolZRjEJUvY= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=BraWG+bY; spf=pass (imf22.hostedemail.com: domain of senozhatsky@chromium.org designates 209.85.210.179 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=1677828700; a=rsa-sha256; cv=none; b=FE7h+xFXfYZVefc8++I8ke77kE6jRbUKHV61+GaH07zF3jrUZwvlkrxhAwWYLVRf8BWQNM s2bh485a65Fx+Lq7/bbKTh0i0wDp4xgk0AaO81yfKr8YIGeGW/0WcT157kwekJsz2Axms0 stzwTNvm4NFjZiImYLF1adm48ws8Mm4= Received: by mail-pf1-f179.google.com with SMTP id cp12so993894pfb.5 for ; Thu, 02 Mar 2023 23:31:39 -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=wJN4vQ0bDt9mp9ZIcGCUIy6xbfFhJeCXLnKUnVtISUQ=; b=BraWG+bYowp5bBIS+PtIYQF9Rpx33u9GNrykqtbmeWA6S6s4w1E5GxGPFXzBgM55Vb AHS1hwM0Iu+sWFlALS1u15V9RuJ4TL2Xg+HZKBEW6jfMKUIEJ45Z32ZfLrwkkc25i1Uw 6xNkDv6D+iW6Zzf19xw4IgYO1f5MjYoI/q3wE= 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=wJN4vQ0bDt9mp9ZIcGCUIy6xbfFhJeCXLnKUnVtISUQ=; b=KzAf0sFmnactyZskAMM1ZbW9sXwd20Wm5wxi2G1LmL415Na+QM+gf6e/MCIR85M3s3 PmSFF9AiM/sEdTpbcr81KCbVQ+BdvJ/OPQp4BBgmXR7oyfdosYFxg8Cmcf6U2pz2RlIk Q9+nRa8zxQqtks4svq0DpnRPbYsOh+4F0QYyE51yUQ7ilxbtkGzoBTBkJ077Z8dY4jR0 os1bQc9f1913SKlx60t9pOmZeRq2N99+uV2frPnydAFx1g7ktsBbe0CdrdLIdOD683to 8dvZGB+GFnSjSVjFwcYbk7iM45jy6p7GeQ1ZZW4w02MLOjRCwaiy2hdoJJCmb/l/+FAf XnPg== X-Gm-Message-State: AO0yUKXemYPe9FQdLZj6NprmCFO3SIgQvxOG/dw83ChuB+tyzCnTAcRD cy1gNQkC0w5ogne6mQjqGVlsCOfhVsMS56jy X-Google-Smtp-Source: AK7set+MG8sg99gbwmv4ChCLIROydfYD4dg6WLUwYOTSp1GoDMJXVYpVbhjFtk4IbuYTEwXHoy1SUg== X-Received: by 2002:aa7:9f84:0:b0:5e5:6452:223f with SMTP id z4-20020aa79f84000000b005e56452223fmr1171701pfr.8.1677828699061; Thu, 02 Mar 2023 23:31:39 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:badf:7e3e:d3f9:4956]) by smtp.gmail.com with ESMTPSA id c18-20020aa781d2000000b005a8b4dcd21asm933439pfn.15.2023.03.02.23.31.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 23:31:38 -0800 (PST) From: Sergey Senozhatsky To: Minchan Kim , Andrew Morton Cc: Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Sergey Senozhatsky Subject: [PATCHv3 1/4] zsmalloc: remove insert_zspage() ->inuse optimization Date: Fri, 3 Mar 2023 16:31:27 +0900 Message-Id: <20230303073130.1950714-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog In-Reply-To: <20230303073130.1950714-1-senozhatsky@chromium.org> References: <20230303073130.1950714-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 43627C0011 X-Stat-Signature: pnt4aut367ocehm78qrxfesxaff9pmhr X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1677828700-29160 X-HE-Meta: U2FsdGVkX18Wd7UR8lkX6QSGTezCl6DS8j5O9+3seQoONCTqX1z5xo52otKDPrVooOGfLfB7ie8CuMD60b1A5YabcwAsXeqDlREDZskFZbODhNkH1yXG+afhDYpFtcu07TVeoCt561wOCvfAg/92Iwr+z0wiEPCQ0YM16N3DwYAyoSAlKNZJWyeDPb3rlC5RdL0JT/tzXUgLs3gMNvZ3EazbGmEUqxvZp2e03qr2Rr/aOb1FBarqkWo0jolj+Yg9Ho7n8HTAsrg2gx58p1je5h/2ys7wlnzpgL7+rne4C7zDf8yPGkvSQY7l+9k6dO1+yTVaHbr4XuYHr8GxTac5de0TwZfg7u4cjDSYA65jWeukAqlXhE33VMRcsTfzK0DLtpaoZ+KIE61yo4SYgOXg3NY+KhRrYESMOckXam9VF2DmDMqyLrOgpxURqNtoCHv3nzNTZXArV6O/DT0lnYvrfVf621rWYCdEOpu19MI+doCHpSmJXZRlDMdIcAp17gdv7IeoaZ63ueLM/lnWUwREzkv2nn8CzZ76L3XgQ8f0ue3j+ad6xRb8xxVSIDxQ9HC86HeIYMuc51WlQeVj44QiyFYoGmFv4WAQ5SGEH53M3SUAl5kriYri4WAIP59EEIQ0uPPC7VgPlqgjD0HCe5ykXA12pHEdzNjydv4tEh8hmsoJsVrI9jWmYniOUpiHbaKVXj0jyQFz2rfv7BAhtxP7vvxkXq876XDY+zhIn+PyDPTocehPlSSA38VDon28p2n0xWpaR2R0ibMS2WNogFZLEqMt66oN85NBrIHD3vfn01Sd/m36R5zq9nXbgQ/XJeWYBNRobyDvL3zA3yY3Ltn6jfH0pfjrC5GM4nBjuq58JS6ffHtfLiaCGCj2In4Y3BixfCiPJrdUIqyiWEKYELPVJU/Hkfdz6a0DMtjXo4YA0DdCOSMUXpmFkgOP5mJBaEZGB/mJnr3ERYk8wdbaWXJ 4zXs6jgS QBc/SXdg80hfXt3eLiE/195eyJXiOaLqpljDODxVON6iclTHykAhV/d4Vltqe/gBWp9mAH+nAWizZI5ucfc4JuV9IzId4mDzYYohLLvsHZXkBmBI5fyzArs8vuTkveJFbXhbw+jZluhePW0i4ssODPZt5qE1JCw/m5m/bXTM5XcfPrHYzQ5wr9kK/fbeWUde5n37CeWo/YscjbPftgEqqqvpWkJY54Qs/PtnlshuWNErDyO/9yl5vHlRb4iIT1hal2n6XmoCLz4c946pikVU1HjRcnl3Hu5bRGAhyMdzmUNMkpsw30wux53BWveoeI2b2jzFBcZQJioTOxZGRrf7FsjJf+TmN4xM9nwugjbL+9vo+05zUJjcyDFhnPuEWGJ4Jw8TUnfsvzaTTANdtlcxmVezHoiQbL0JILmPzO+M74q9mdlaa0Pr2ZCAGFyK3Vw7MlDMn7rKldBZ1I5kcvS4UUdmykj91t55mC5pY/GSNz4JhQNk= 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 optimization has no effect. It only ensures that when a zspage was added to its corresponding fullness list, its "inuse" counter was higher or lower than the "inuse" counter of the zspage at the head of the list. The intention was to keep busy zspages at the head, so they could be filled up and moved to the ZS_FULL fullness group more quickly. However, this doesn't work as the "inuse" counter of a zspage can be modified by obj_free() but the zspage may still belong to the same fullness list. So, fix_fullness_group() won't change the zspage's position in relation to the head's "inuse" counter, leading to a largely random order of zspages within the fullness list. For instance, consider a printout of the "inuse" counters of the first 10 zspages in a class that holds 93 objects per zspage: ZS_ALMOST_EMPTY: 36 67 68 64 35 54 63 52 As we can see the zspage with the lowest "inuse" counter is actually the head of the fullness list. Remove this pointless "optimisation". Signed-off-by: Sergey Senozhatsky --- mm/zsmalloc.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3aed46ab7e6c..1cd180caff76 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -753,32 +753,19 @@ static enum fullness_group get_fullness_group(struct size_class *class, } /* - * Each size class maintains various freelists and zspages are assigned - * to one of these freelists based on the number of live objects they - * have. This functions inserts the given zspage into the freelist - * identified by . + * This function adds the given zspage to the fullness list identified + * by . */ static void insert_zspage(struct size_class *class, struct zspage *zspage, enum fullness_group fullness) { - struct zspage *head; - class_stat_inc(class, fullness, 1); - head = list_first_entry_or_null(&class->fullness_list[fullness], - struct zspage, list); - /* - * We want to see more ZS_FULL pages and less almost empty/full. - * Put pages with higher ->inuse first. - */ - if (head && get_zspage_inuse(zspage) < get_zspage_inuse(head)) - list_add(&zspage->list, &head->list); - else - list_add(&zspage->list, &class->fullness_list[fullness]); + list_add(&zspage->list, &class->fullness_list[fullness]); } /* - * This function removes the given zspage from the freelist identified + * This function removes the given zspage from the fullness list identified * by . */ static void remove_zspage(struct size_class *class,