From patchwork Sat Mar 4 03:48:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Senozhatsky X-Patchwork-Id: 13159779 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 30A7BC678D5 for ; Sat, 4 Mar 2023 03:48:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ADE786B0074; Fri, 3 Mar 2023 22:48:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A672F6B0075; Fri, 3 Mar 2023 22:48:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B9CC6B0078; Fri, 3 Mar 2023 22:48:47 -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 73B6F6B0074 for ; Fri, 3 Mar 2023 22:48:47 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3F819140321 for ; Sat, 4 Mar 2023 03:48:47 +0000 (UTC) X-FDA: 80529834294.11.94DB917 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) by imf07.hostedemail.com (Postfix) with ESMTP id 7219E4000C for ; Sat, 4 Mar 2023 03:48:44 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=OSN6KWn7; spf=pass (imf07.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=1677901724; 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=SEq3MDoFcR7yz1bLKCGz9x04eW60/3Ets++p8vd9Ctw=; b=3pV2snq9/+EcSuKngxvcq8bKFQo6cUodMnyXsfO8OFApkjFoBk2kPPvUkK0xRMuucA2a+F I85WvvH7Ro6c0qjjKRtsP/s5/D6wG09dJWcqO00k5IUrZ6HGG9WEhAP82vjw5aQKxUNshP n2UmRqcOp0kzFU7wqcvEtGJGfRQX+b4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=OSN6KWn7; spf=pass (imf07.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=1677901724; a=rsa-sha256; cv=none; b=Hnjne3L7/9Uz+/EQm8H1pzXkqEEs0srkYecSPDzbIfqWB57BZwgLAULut+rJ67I3OpnBKX fViGFvyOVPQznU25hm8xoue0COBkgjMnmYiT1u5Sf1BIEjC+304SlEMP9/P/TBSGNIXMJ9 g+FWySOz7Dy82R5F4rq37CJehVl2FSw= Received: by mail-pl1-f169.google.com with SMTP id p20so4742368plw.13 for ; Fri, 03 Mar 2023 19:48:44 -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=SEq3MDoFcR7yz1bLKCGz9x04eW60/3Ets++p8vd9Ctw=; b=OSN6KWn7hEXJmiSwcCwf+j4CxdT8wPCagEal0qiSFk+/V8atkJMsWd9LYZUtjmsPXr 9CRmtA+NB7lVYdNh98oMEGUcsk0IzMtp3hVLlNUeYtTmnR1IdOQSDJgHlTb/6bPe258k cYr52SWQApBs9ogj8FNmQ3LcCt0GmMZsOzeLY= 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=SEq3MDoFcR7yz1bLKCGz9x04eW60/3Ets++p8vd9Ctw=; b=awtnDHsUeedglbREMpQHta3St0WVggTfpGE/PGG4TvYdnaKDk8DTxDBD1txKJJicub o88zmDnq/Mm6GB20TQD47UQjetZkh8PLSbLl5kpw5RmiCBFKn7MJbuGlfYkhfKk1dvor BuPinWCm7hClWtwXqFNDlgsFpKT2AtwOwY6cCU33zCKcrommJb2zrTIvt+Mptgj+CmA2 Z4ZC0MNoT2QsGeuj50RIfkU67aqySJtvehXGNFC0Y/9VEsTm/bDwOx0uxJ1qPlb7r1qP Vw8rjA+I81Io9eSPK3ndMjc1QGH4u69bbQ9qcaEQTaWra1jUG8yBH6NAxTOJv8FyFDSh IcDg== X-Gm-Message-State: AO0yUKVVganu43viYZox5dbLRjG46cz0IlZO41pv1Hw65vEAKuPMzt5v EfDcbSzEZY9I6xnXc1npYoT5VA== X-Google-Smtp-Source: AK7set/tt+odDA27bkzjmHOQ+zF7n6+n5T9hL7wxUbL0XcZs6V/tJCFYEzPfag5hO0XniqIk8YzmhQ== X-Received: by 2002:a17:902:ce92:b0:19e:27a1:dd94 with SMTP id f18-20020a170902ce9200b0019e27a1dd94mr5079134plg.35.1677901723382; Fri, 03 Mar 2023 19:48:43 -0800 (PST) Received: from tigerii.tok.corp.google.com ([2401:fa00:8f:203:6ac2:6eee:5465:7ee6]) by smtp.gmail.com with ESMTPSA id d6-20020a170902c18600b00199025284b3sm2249204pld.151.2023.03.03.19.48.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Mar 2023 19:48:43 -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: [PATCHv4 1/4] zsmalloc: remove insert_zspage() ->inuse optimization Date: Sat, 4 Mar 2023 12:48:32 +0900 Message-Id: <20230304034835.2082479-2-senozhatsky@chromium.org> X-Mailer: git-send-email 2.40.0.rc0.216.gc4246ad0f0-goog In-Reply-To: <20230304034835.2082479-1-senozhatsky@chromium.org> References: <20230304034835.2082479-1-senozhatsky@chromium.org> MIME-Version: 1.0 X-Stat-Signature: h8r7o8gz4nkqa9sgc388rz1bn3unyhh9 X-Rspam-User: X-Rspamd-Queue-Id: 7219E4000C X-Rspamd-Server: rspam06 X-HE-Tag: 1677901724-982186 X-HE-Meta: U2FsdGVkX1/bZHugJb62ZpIsFR650NCcNtVsoqCxeIiK7I8agz6FGtujcr1nlYEiFeg2a+Lw+1fDc3rZEJLTSLMUHWxg9/Xm8AYvn8vMXuB+MyaQiXe1/PfM0zXpRLSXjxw78hFkA5eTOfVn62Zdx4UbchyUdDujZ7ByW704c1qEx35RCT7sPWwEcAdUW8UnA/JEklgYvDNHQ/SFKOG/t9t2ov6rXxc8dGc+qEE7iS0VVKvBdTHOZEM01b5/ciAX4WwZdSqi8vNrf8a64HRQJkRTUgscpNtFABMyWZ+Ls0NKrvA/k1WrpIHkGGiFhKaCYPOl9H7peM99ksqxxI/iK8vwDpvEgcxO7O3kZ3uJxSHR9XYGftzwvK8WEV5m0vjis/EUJS+5eVERMhIxnkThCxaQ0oHYBL7VmXInGBdWgm8Y5abixgMCaZDnxrAiKbGJCPhFWKfoJnQ3Gn9fRYLjSifZg/DvAgytEceKRMDjAeA9tqvQx5Qv7vr9h2jHphT0nIHaQZvdZc3cKZDvH3DiYFv3P3zEzKkXor2DP/RgmvnUN0AtoRUXptkRj+VDhRrpTYPzRVClY7GUwjCOb+NJPLZupg3rj8CZgDq6KDEsj6uJ0jXRIAbP+vUrdZelZtmuwxLfuStR2g1K6ZkFebX6V2NnS08Zlxj55gMzRtJ4PVnv4FMrMwXKpyweHtKSAbtJdtAyQHzaSe0FFUq8AjHcEwblya374cyzs5umlH4Kzn4nnPW/leR1Adn5rpgAyOhcwqlBZ31bwZc+SjrD6z8ay4jTSrHnmyOvHYsi+0DfS9igoLc3VgpXa2ujgWyHBVy630pS7wFJBE4ubXrWDgFU8SCXfhr6iDvDMmDroyysxicGJravJCDB7799K4Y5Mmpm9AQNyurVModU7UsJRzNzyJs2FMzgdDSTHe6fkMGo3C4/Yz8T4if8d1h92G2S2SnuGFD+CeJpi8UFQz9G2FK 0CankMqM fiXtDGDmAjkbb1DICijqEC0JYPVA7GeyQN3JlqOSKckm2HqeUY8tK/nkGCb5W+jOoQNLU7OcYQyoBd+xv0KMGc5Cnw7sPiI3my2MVRCNEoAHSvYePKt7EXipyFrCPc2o90kt3U5pvOOdC5iKiKslSMTcv0BpNbx2HzwK/R/Mp33NXyh1ZY3nIuoYDoG3c7G+VBlog+U6TqmkOKJrXlFLRaqwlP9pVvXfVFd17eVj/byRUvercQNkelmBCSl6gv5ktZLUXfYPATQaaIfAdnQjitoTxBBB56euH9xaNt27j3RYeBTHEEx4ghyayYW5P+rRFh02dOKRFwD6407vKvfXGQgAPiJ9d2aAbzlCE8vj0wPA9QPrZUQCeQA3SQQwy15QUKgBl2ceMXrgiNGxRMJpUxf2dHjfFdrUvlEH1nD3EWFQ0qS3xRkwylme7jMHyTbQGVBIYhnpmHqPy9NxhOLjcVUYc7SQoXcwvj0bu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000076, 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 | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c index 3aed46ab7e6c..abe0c4d7942d 100644 --- a/mm/zsmalloc.c +++ b/mm/zsmalloc.c @@ -762,19 +762,8 @@ 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]); } /*