Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp531873lqp; Tue, 11 Jun 2024 11:20:58 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXNHXq+JCaE+5kb7DKS6rzqvCrQ5mft+6tmnEiZk5SMqTy8OyIYYjRzlQR6Bo5XM+q8aLzE3czCd1AlRkgK+/ByETp+gwsrBgo9cNpwog== X-Google-Smtp-Source: AGHT+IGrc8OOQ402i9r/Dm12un17yfp3GeJj9ZEsyOe5hg+Yom/BS01AdQrDsCiJaxHT7vMrsYu1 X-Received: by 2002:a17:902:f542:b0:1f6:1c1f:f32f with SMTP id d9443c01a7336-1f6d02dd999mr141222855ad.16.1718130058603; Tue, 11 Jun 2024 11:20:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718130058; cv=pass; d=google.com; s=arc-20160816; b=q9/VUbFZfOGkW+gzGVv/nYJTSPkQ7KXXsdeHCcD1AapmAy92Wa111xU4CQxdM2r4XP zTaZM+clajIiEcrScb7lBYknLolBTJ7smguJOcEV/1hDWnWhRQZwVHPVOsuqf/hnRI9g JBOGcJ72D2aIQnfTyTJApdTIoDw13eYOTx0ydoA9mzC/NZ9CdnK/ffdoSp6JwhDoKR+G KMjYD/2VnTlQhN/sq/l0O2caVMSPYAbczbpkTIiUWbPDoye3P1QotIGwNx9FL07mAqzR pX/+D4lE5v5XC0Z+6RvOx/pyYLkSSP7Ii8ThxW4uoNGHsUxJYe5KwaYOQcRJnvTYvsqb Ivvw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=mbopcsfn5WDDZMHTl7045YVZTo/YxkYjZ3QqPNkTqbU=; fh=Fpc8JqCBi9n/iiyPECrq1X/tDAJK6SqFLS23wcEVBxg=; b=ZZxnt755Dds8y9KUQYm9Uh8bNve2I0iSM0niah9WIO1pfy0xp+K0jCVcE2iA1aP3gQ vY1mswEmaB+unSS9/yfOd19z5Oz69vLIRKMw8bWn6cOhPKIZ7KRGw9WANpUURc+iRdAH 0u3BXk7fm60CYeZ7f5hTrMJcxJJ7PfUJnPPwQUrN17Z2my/svhiwrb9ij+CgCz/yY2Fh 5K952AKhaxEtU0OUkU4u8ngYHNdhzjqn8zG7RpRYdlgLSFJozJ5nhfWH3NZ1BWaPrWpB NeRilGYqmx6tfrXPf9VUgnCGzf4wf4JaQwxZkst35+5lQ0ZUUAUmqqd7AkDmsYnYiwSf GopQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BUft8noa; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-210403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210403-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f70648e866si48833955ad.597.2024.06.11.11.20.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 11:20:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-210403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=BUft8noa; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-210403-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-210403-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 921ACB24B01 for ; Tue, 11 Jun 2024 18:11:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29E126F301; Tue, 11 Jun 2024 18:10:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BUft8noa" Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C44AC38F82; Tue, 11 Jun 2024 18:10:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718129446; cv=none; b=Qo+W8Fjl2kA8sjQ5YLBXFKsrOXpFpHxa2mnNKVVx7TLz+l9npEa5sDIkcn/7kcxq2PtRXAa1NLWWnDnXriyi0Ou1o6G51+yZF0ND+1kIOWXEPcH3coWrw+8isSwoSNyM5XWIf7Ck3ON2ngy55SEUEV81WO3KRMUlzq0OHYcwQ/g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718129446; c=relaxed/simple; bh=/kBuMNz5xz6ybpf6jMEy9R7kpmTZY+KerEUZxX8ArSM=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=tejGWYMbODyRY9VyNWsOz9xUB0oTzMZiGZfmsceC2GygbmYkS16B2kopuB4If9YWlJ2ZtMTKU1HhxLX/LvHteGjI9D/IjI1xi+73fU9Oc2YzTCASssUf/f3PmrnCVNNWpZMUQTLelTF93tZ9opg3oJoqQWI7h1M/xLQbJxoGo60= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BUft8noa; arc=none smtp.client-ip=209.85.222.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-797f0c49a11so26139385a.0; 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=vger.kernel.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=BUft8noaB/JcKOHApMPx71DBblngbPk4064qJoXT/B/85uigZW5BPQa641YeSUPK56 cqXrMVGm0qR5o9ewn9XZsF1cnKQ7mVTiAo/GUdh5NaHW4wiNtMgICUyyeweKTfkSBznM /Pn3Lmrt5BT2hnYzC89cZ3JPgmBFVsdfHZoAxSE5Sxd3lVU3NMcX2e/0GSLmlkJoVoib /qIVTjLDo+79u8t1hUcz2MWtEWxo5J8vXDYQjP2WcgrT+LUhS4prVzOK6U4VWkJVCJI/ qWlWyHPQAKTFORKTbqwm4sEqRfueuvDvUZHNnyWrte2tw1fI4xuORW4vPwMCXTDHicC5 JUyQ== 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=HM7XIHTkLiNSbx3XYlyvKfOyzrpaS3ux0wT4PDRwJL/NMctmdEwq/oAORmsCKW/BcK KoezOhr5HInWnYyoYtoNA8AgA3ItypYw5k6TFt9WXHuGzlysbf+0L28ZpkLKCww+vNRp WNMGiPUYzlf/azfgeg/eag8PEFuisObrVu1DdM/ozMQU5FQsOgcdy4FFcvf8wfGfW/ox vXBjHdUuJZK8LuecIVVS8QS/gDwRL4MSnuMfnc4drDQwYWmOqkB3MWT+8Y6jYXikXoDB dexSdqAHap+Hs5vgrCMnh7vnmICN9T3Dn/sYCxKQ4xFLR5eXqEVSsnoWB1Ok4FDRjoQE HlNA== X-Forwarded-Encrypted: i=1; AJvYcCUw6dUaFkxrUPKMzyv5Oo1qvGYH12mxdHhVm8gs17mT6ObH8fXfOFj3jf3ZbDbikzDgJRvSJZPWurXDnurTYQD/tJNkhhK4TCU13UKFCrV4s21KKaklbc4FlaoHG7RT6/7ISl4gI5Ci X-Gm-Message-State: AOJu0YzW9u0Z5AFxuj5KshdBsxtkSis2MPUHIWSBeJ5NlNlDpANACXYz Kk5c1UyW60shMrORzI0ybsZgs+b6BsFYeIjMoYREwFoyAnAvHEdWdThCPjEo0/xU65EyTkh91t9 18UBX4iGzSwbhfg5u5SE87f02Wzo= 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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 >