From mboxrd@z Thu Jan 1 00:00:00 1970 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 52A61C27C75 for ; Tue, 11 Jun 2024 18:10:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E30C36B0089; Tue, 11 Jun 2024 14:10:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DE0296B00B9; Tue, 11 Jun 2024 14:10:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CA8336B00BA; Tue, 11 Jun 2024 14:10:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id ABE756B0089 for ; Tue, 11 Jun 2024 14:10:47 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 62B5C41605 for ; Tue, 11 Jun 2024 18:10:47 +0000 (UTC) X-FDA: 82219398534.03.CB42682 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf30.hostedemail.com (Postfix) with ESMTP id A64838000E for ; Tue, 11 Jun 2024 18:10:44 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HM3uRDSB; spf=pass (imf30.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718129444; a=rsa-sha256; cv=none; b=KRi48YtJXKq1ZuzE4yWRkbrxeiGMTOlliK/+7Rj6NY0zK6u/inCwvriIKiAaBg5I2iA4nQ 7EOBlEmH28zxG4i3zuXUZqibJ5tW3LvGv61Q6I7i0yJ+w+Tvwmvqkfxq5tkcAtL16qQyRJ 85/JaoLUFH5/KkjMUxUEDYesluLzaoY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=HM3uRDSB; spf=pass (imf30.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=nphamcs@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718129444; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=mbopcsfn5WDDZMHTl7045YVZTo/YxkYjZ3QqPNkTqbU=; b=qEjKYwbGj6bDe964bHtbSs+LUjV8Dh7tnro0tp8wEjmv612mzi0l7HZkaGby0RpN+4YwCQ tjUhGKrR/nioWzi6Tr0ts5rIwPyZCi6v4bechEsgJLHEX8BRR0tIUpP5mJK6cg/XrPvKGn 7z5zHFKLeeysITpeg9NQ4IOILi8Iz9U= Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6b07e641535so7145066d6.3 for ; Tue, 11 Jun 2024 11:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718129444; x=1718734244; darn=kvack.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mbopcsfn5WDDZMHTl7045YVZTo/YxkYjZ3QqPNkTqbU=; b=HM3uRDSB0Oah74MbA4qfohZdU6QTk0RlNr+Vn7MGRpegXsBLe5DVxEkLHc08reYrLL EINgb086D3BNzxl9oE2dsBWwuiEnr0E+sjCS7d4cOleEv3oo3r/NihOuFCp2ntTeP+9o xdCIRzipKiQ4XJx1cAVQIg8HQC9oxVX7rJEi8hqXa28uqfJQJmEJ/SGPJ9yfkOCAB22W M8FxGx2rMHFFPwyg/nqQvGlXRdVPgJDB4OClD9zOHsDaeI1NH10WTDiDUBljbyeyCKuh hq9pTJfzYAAw86Vw6AdcYwR0nV23/D4yyJXxWFLUhwvp/vIvt3XC9cXYlwUMCtd4wumG OX/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718129444; x=1718734244; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mbopcsfn5WDDZMHTl7045YVZTo/YxkYjZ3QqPNkTqbU=; b=rJHuWLMPPU/4Sz0SnKxJ7uqTduv+I2+FPi5zqQCXvydXgspdzxVvE6Yi+pzk5rDgtp XDlgyHazLsfKTJNMw3jh/UsOsWTRGWi4VWhtDosIdWqIMcS+2RktjpTaoyn+rgBSdgqn /upL6QXw3UYf8ofLX8b6/FhqG8x7qcil8GQqOmQauzAZ6yfLO5UDE7FlUnY1FTw8h8qM DAkeW/gLnef3M8ouP/Az+cTjp/3AV/ddVhqXIXuP1+v8NC2A9II62rYUoXzXRsupMu+a yWTHmg8RE/ISVYp9QmdeKSOo/4IRklBc8+z4C2l13e1vszQZCWc60SKxNHLzDOPFSVLX uMLg== X-Forwarded-Encrypted: i=1; AJvYcCXop44NKtVvZo6QJEDk7H74za9ZoSF8VXJ4HrkvCVtDaqGaya/lBOpfB3nTbVlnqzRacBOrF+0wm1WfLObWKH+Hsl0= X-Gm-Message-State: AOJu0Yw29TU93yn+3iN0QcdUHxLQB/q3w23vScM5qIdeMfY/4LoJN1eZ YGW/AOMZED1p7HfQO0U65RWprkDh52H5TzboYld46sDYX/q7dhCErPSJlXSiM/uGc7dDuMqRc8d K+UfnuDpofXW7/4EPbGMM3LOh8yA= X-Google-Smtp-Source: AGHT+IFtxEhyO1IKcnlH0FvteEBSozy4uGTfjTxz7WgpzIPVgvq9ZeYKqdI+KxU7LzWVWP9cq7CmKh14evR3+BDswrY= X-Received: by 2002:a05:6214:5c04:b0:6b0:9048:9801 with SMTP id 6a1803df08f44-6b09048cedfmr17979356d6.39.1718129443649; Tue, 11 Jun 2024 11:10:43 -0700 (PDT) MIME-Version: 1.0 References: <20240608155316.451600-1-flintglass@gmail.com> In-Reply-To: <20240608155316.451600-1-flintglass@gmail.com> From: Nhat Pham Date: Tue, 11 Jun 2024 11:10:32 -0700 Message-ID: Subject: Re: [PATCH v1 0/3] mm: zswap: global shrinker fix and proactive shrink To: Takero Funaki Cc: Johannes Weiner , Yosry Ahmed , Chengming Zhou , Jonathan Corbet , Andrew Morton , Domenico Cerasuolo , linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Stat-Signature: gytzkbacst4z4qdrsmf9zt318njo14pf X-Rspamd-Queue-Id: A64838000E X-Rspam-User: X-Rspamd-Server: rspam06 X-HE-Tag: 1718129444-196911 X-HE-Meta: U2FsdGVkX181CcPgvqdyrY0BL4FdWDwL7vWZJvVzLQ6SyExlKRCP9AF3RzmMY4ra7UVUwqWeRcXEK1UVf0voNZhW3V/LdIj2H4mSaK4MPcNaq/Y3Kpa3m4Ln6WrzicikMNX7kgJV8njC8HnfzdqtoXYtMQuTQPfIozKclW4qKwAW5x52YykcFIZy3KPszUAOBsBDfaOt+l+oXfJtQEsgrOHAoGwSUOtHjG1nF3GMZJFQgz7tBYeDTGxQbxZn1ktagGrwaqbdJ4JVO2SkCHQR4xaXbK2Q8Qx07tMWZkUcUczFuk37mZ/astnMgvNH239kxtPh0UOeJGMy8kONg2xpB/UsHmbziHpXZQwHqWaQpLMr/AJv32EbQD9q8kzOWIZH7rf0U82laiEx6XZi+ccggeYWbvsk63nkXRZc2xWipJMTFAbWuhNLan7v8DwGthovD9RwMMoUopTJpAVlOJDS7xQTdzrWqVbytVTSazGy+onfLFYPOFiW4xEbG6MLed0WD3fy20NzbfEiekF77FmxrDPrXk50W35dZicuyORsunjuTM+EHLYJNLGjmiJsFSKI1IuJw8Uibve0DdPr1SUHQwyOfHqPBpaSYCFLjVklQg/UEG53Rymdr8SnUsdh90da06oanVEMTvbuoApzqL5esk3N5iwSgl2zPtv6FSA0sttR7p6NPd3EL74UhnH/sinl0VOWb+nQktghA9BFmfORRYbfFITKjgM83R+9oilUhkA2wv4GLDbbDaTSeUjVV33KbmOeIY3pwOIbXjvAUm5Xp+6JsJFGgq9S1BJApjEULXSrYhSwKNnzEtaE6H9WwJnXklmbcZisnytAP9+FSxmYcWswi7C4Xsy/sO+IliDTS3Mrg/Y7U9SSUUPRrJRIrG1l1VKW5nJ6vBLsvBY25EqVXaWxJLnJjvtyRSl3Tv6sjg1CZaCfgmIuulh+7PwyWXO/he397z9XJQf2aJJo7SW jxNg3TUb kzFNg9aV5/nSMEUf4Or6N+l0d0MGHTlNSffNdSZPEpgbGrLr9sQoG2bWQcNYFdtMV8jE6G/0WbBFB7kKKuv5zO1g0GzaW/Q7wIXCnMSOstp1XgwgpLVkQfeFq44VcERE2y9Jbz0YYEq8CuMVGzzkn2wY86ZSuup1ILN8BeVmw4Qo5UO9u0IghB4iR0PT/DTdUg/yjgsEG9vyFp8RczDup2eiDTdzIZDiYJfaQRWyBwhJUUCazdMs3jnv9XUHibEYJYPiL0PqbtATO3YWZnJkfuuPYu2J9HxxzYGSC 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: List-Subscribe: List-Unsubscribe: On Sat, Jun 8, 2024 at 8:53=E2=80=AFAM Takero Funaki = wrote: > > This series addresses two issues and introduces a minor improvement in > zswap global shrinker: By the way, what is your current setup? This global shrinker loop should only be run when the global pool limit is hit. That *never* happens to us in production, even with the zswap shrinker disabled. The default pool limit is 20% of memory, which is quite a lot, especially if anonymous memory is well-compressed and/or has a lot of zero pages (which do not count towards the limit). > > 1. Fix the memcg iteration logic that breaks iteration on offline memcgs. > 2. Fix the error path that aborts on expected error codes. > 3. Add proactive shrinking at 91% full, for 90% accept threshold. > > These patches need to be applied in this order to avoid potential loops > caused by the first issue. Patch 3 can be applied independently, but the > two issues must be resolved to ensure the shrinker can evict pages. > > Previously, the zswap pool could be filled with old pages that the > shrinker failed to evict, leading to zswap rejecting new pages. With > this series applied, the shrinker will continue to evict pages until the > pool reaches the accept_thr_percent threshold proactively, as > documented, and maintain the pool to keep recent pages. > > As a side effect of changes in the hysteresis logic, zswap will no > longer reject pages under the max pool limit. > > With this series, reclaims smaller than the proative shrinking amount > finish instantly and trigger background shrinking. Admins can check if > new pages are buffered by zswap by monitoring the pool_limit_hit > counter. > > Changes since v0: > mm: zswap: fix global shrinker memcg iteration > - Drop and reacquire spinlock before skipping a memcg. > - Add some comment to clarify the locking mechanism. > mm: zswap: proactive shrinking before pool size limit is hit > - Remove unneeded check before scheduling work. > - Change shrink start threshold to accept_thr_percent + 1%. > > Now it starts shrinking at accept_thr_percent + 1%. Previously, the > threshold was at the midpoint of 100% to accept_threshold. > > If a workload needs 10% space to buffer the average reclaim amount, with > the previous patch, it required setting the accept_thr_percent to 80%. > For 50%, it became 0%, which is not acceptable and unclear for admins. > We can use the accept percent as the shrink threshold directly but that > sounds shrinker is called too frequently around the accept threshold. I > added 1% as a minimum gap to the shrink threshold. > > ---- > > Takero Funaki (3): > mm: zswap: fix global shrinker memcg iteration > mm: zswap: fix global shrinker error handling logic > mm: zswap: proactive shrinking before pool size limit is hit > > Documentation/admin-guide/mm/zswap.rst | 17 ++- > mm/zswap.c | 172 ++++++++++++++++++------- > 2 files changed, 136 insertions(+), 53 deletions(-) > > -- > 2.43.0 >