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: 63776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp274632wrd; Thu, 2 Mar 2023 23:32:58 -0800 (PST) X-Google-Smtp-Source: AK7set+8+ziqT80vXP7j0SiRr64WzSgf6irDTfl5g5Yzwv5vJgNMvdDv7mrlzv43CqkFrimq/yAk X-Received: by 2002:aa7:d7ca:0:b0:4af:6c5e:225c with SMTP id e10-20020aa7d7ca000000b004af6c5e225cmr837821eds.33.1677828778033; Thu, 02 Mar 2023 23:32:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677828778; cv=none; d=google.com; s=arc-20160816; b=gGsNuUHD0aCvESgbBy3QrYmK0d6WhUUxZGmQAYrM7XdSlvHH4AJM7tmdPuLMFKu/bQ 3c+K82Uns5Rk1NcxZRHe22O6G/wDC7BXn+JouoTBP4/MQCJ0v2fcCd9JcoCSALuhEYKq ZgLvbgrAuDQmv4qL1FllOTEzdhlbhOoI4F8f6xRq2zWOG56mtYm+4o4DEgf5km7N6Rjp gksDNl0xgekt2ifag4aWiHPQzrGTQ49rgta5odQdMK0+cHMO4zTTILNUFm2KFEKN1wgY 7X6tW8VZwIkbMVXrzmahf7hZ0tggY1vGLhDpkA0xRYOt3Uju6DX0g3FcvVmPPgDzpNPl Xs0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=wJN4vQ0bDt9mp9ZIcGCUIy6xbfFhJeCXLnKUnVtISUQ=; b=ERAYnW383MnDH2ba//PFaqDAv9/eSYA7z//Koz5mzdLzMZT+AfwvGvow39VTKbGYG+ sPrpOY4FB8z9vhzOxIp6YEuQV2spO5YjV9VZdYCyVrt1IKnNpkr0L90UaCyEr9z9Ult/ jih4dDkmC348XlakTxyCZ7Oeyq5XcMV/tEpNoi35vDuZsqzgOANtuMZ69pT6zVNZlNnE sJ4pcO9066C3eHJDaxBzjUBcr8OnUMbb4F00HJZY8jJ+dV4uwvo3nPz4gBH5uGlHijhF iBTwklebVGxLsAV00ht2wqLYiuASJtEhNS3KBQIckPnXJ7WycEnOiSQRt4lBoQ9dU9AW esGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BraWG+bY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g19-20020aa7d1d3000000b004aab2a7125dsi2238146edp.165.2023.03.02.23.32.36; Thu, 02 Mar 2023 23:32:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=BraWG+bY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229818AbjCCHbn (ORCPT + 99 others); Fri, 3 Mar 2023 02:31:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229796AbjCCHbl (ORCPT ); Fri, 3 Mar 2023 02:31:41 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A75F83C7B6 for ; Thu, 2 Mar 2023 23:31:39 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id 132so914137pgh.13 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=Gvz2jID4H1qOmPaxDq4TEejP4cxBAFQgA+QpkSyYhhYq9Hga0XDqLICAI42u/danW4 g0b+mLiXkkQsa4dI5NwikxDJ743mOQnSJ3HQbJis5zE6gpNfG7Hla38miupItp3FtQHe HOGPL5yjBaFgyFf3VDEvKcpX9xqt0Wf2GtZrHTLhoFQslHmBl0qoJzNnAT/0znMCMrBl 6f2z8xc+54GOAj9yZ69EURCp6IzS6Wy0y7DvliYzl1O/lvSm9kGUwA+JiEI1wSKvaHE6 WgcDpOUM3Zks4Iy+iDsDTkiTLLABNBs1xi8Yq0lcEQXOXrtbH4jtSzYZFG3F6QPajipt M+jw== X-Gm-Message-State: AO0yUKXxoT150bsCA86HMf9B5UHtW410jIDbpBeIEpktRSxrCGTumzWH hcIAqfyZmMOXvkjTIWIwgewrvA== 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-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759330989086401838?= X-GMAIL-MSGID: =?utf-8?q?1759330989086401838?= 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,