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 8046AC27C4F for ; Thu, 13 Jun 2024 15:13:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA14D6B0096; Thu, 13 Jun 2024 11:13:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E51CE6B0098; Thu, 13 Jun 2024 11:13:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D198B6B0099; Thu, 13 Jun 2024 11:13:26 -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 B2DD06B0096 for ; Thu, 13 Jun 2024 11:13:26 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1532EC01CC for ; Thu, 13 Jun 2024 15:13:25 +0000 (UTC) X-FDA: 82226209212.02.35B0B92 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) by imf06.hostedemail.com (Postfix) with ESMTP id 2122D180019 for ; Thu, 13 Jun 2024 15:13:23 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YsRD0ke0; spf=pass (imf06.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.41 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=1718291603; 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=tD51o0Y1ksGPreKO2RCSDyc0HAD564QL05nYWkEYiaE=; b=h4565/tvD+xmycNj4CgC/1nCUMNCh2NXSWpFWFeVzAcY314jqGQ5G9l6iyM9prC75AlSGT 4t/z7YiOPNDwBzFZnz5uyb59skguMG6bdKSPaoSMx1VzhIsEY1/CXvmUhk64rL8xsEHp9t KkjAkm7Uz9c2jhP7Ki+1jt0MZqWZxpw= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=YsRD0ke0; spf=pass (imf06.hostedemail.com: domain of nphamcs@gmail.com designates 209.85.219.41 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=1718291603; a=rsa-sha256; cv=none; b=CTCk2UcrfQ/CT+dQ5eKYHYWavDumDrr574lGaR0Nuf734/ivoIEouzvFEXYTyEligLRi+q 7VMOmL8Z0aB2257YTTSVxn3l1i9sPZUmaa7qcPVLCrYf9YuZaxO7PLMs1v+mVBeO/Sjkmk +1QbBFK2qb+DZNApT9VBBtq6EBl+Z7s= Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-6ae259b1c87so19350276d6.1 for ; Thu, 13 Jun 2024 08:13:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718291603; x=1718896403; 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=tD51o0Y1ksGPreKO2RCSDyc0HAD564QL05nYWkEYiaE=; b=YsRD0ke034v8MvvcrJ2enZrxkF1gKW3KtecB+fSTGTYjEAdKkj0QwfThYDASS9efQN 2TRC5mbkmcGgwdq6Eun8/s4yiRkPrlI23ASbv5cvh8QyJcvGvTSYQpQ9lMLroWu+ZpWt tIyvCzKOmk/HC855UrryESjQm2Qrv1heE+5OYTZhgtCy84rdUBLy1Khd/6wwKMSMxROw +4opw9XBB7AyUbTjiUIJTYBnbLifDwD2LZ78ZI9+v6eYyRZKHiPpbL+w55BRXomadF8r 1lBXv+dx9kW6GfRMm3sWYSTLWD9uKAoR7I9m6pui/BXC0P75+4sw8ErmDzk7c8nG4iWv bTxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718291603; x=1718896403; 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=tD51o0Y1ksGPreKO2RCSDyc0HAD564QL05nYWkEYiaE=; b=mHPrRZIOeTUciU79VGqsm7MwIRQYiAnaarI7D/FModGOK6N7E0yxiRgNmVQ2iF1rqP KCGh7xFooysvkw54ikcv9l27y8Klfl3QPb+DcBOZ57Ke5Su/oGT29GUnxpDZpbSvUpIb lG2clJCmeW5G37C5XJLB9Rw5x2o68HnHLZUG5o34HqMaZ3JNV08LVTDBYg2aeWC7TPmx fHCM3sMVC2Wz1xevPkiptJ1vDm13vNMErXx6wwtcc3/Ir+ATI3cYokHdhnt6ePKCKeH2 3MI+IOyzcpg7rsmRrGT2m+z7hMXKc1qGh6ethcXsKhOsYBP7OnwMx0qppS+QYUhKyBSO 2hDQ== X-Forwarded-Encrypted: i=1; AJvYcCVooXC4P+FuMJXoD4pLmXtOXNNL50+ogmcx95TKrD4diFnswu9nMyvp+lDza1oJki50Zq3I9XjTcNSjHsI0e9Z9Vus= X-Gm-Message-State: AOJu0Yz413BBqjCkAOsInI4AHxFQuD6Di1lrrWeZ6NZYpKeSt+v2Y2uR wRS+7w3AP86a8LRBXCHcJo8NiLE1igaBs1u3ak17CrJU0rJvNkg4jT8HpX+0yL0jpJCz19xMygY Z/MYj+rwREuo7hkCrreKLztSzwHM= X-Google-Smtp-Source: AGHT+IGW6rnw+BQabFawV0pm/2GpvLPrBzbXMkIgKzqD4lNHr4ky/rvWXSuj65jR7lHLZQPMM59NAef8eQa9ZzeUTRI= X-Received: by 2002:a05:6214:130d:b0:6ad:753d:45cb with SMTP id 6a1803df08f44-6b2a343d2b7mr49824026d6.20.1718291603122; Thu, 13 Jun 2024 08:13:23 -0700 (PDT) MIME-Version: 1.0 References: <20240608155316.451600-1-flintglass@gmail.com> <20240608155316.451600-4-flintglass@gmail.com> In-Reply-To: <20240608155316.451600-4-flintglass@gmail.com> From: Nhat Pham Date: Thu, 13 Jun 2024 08:13:11 -0700 Message-ID: Subject: Re: [PATCH v1 3/3] mm: zswap: proactive shrinking before pool size limit is hit 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-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 2122D180019 X-Stat-Signature: skcxyjqrfya8yeies7cy1dhqj7rxxco5 X-HE-Tag: 1718291603-730620 X-HE-Meta: U2FsdGVkX1/dAf0SulSpQmHEFXcchyWcInKwqanuYVf5iA4ILvK7QIamw+XMtTgt2oqd45IYHpkOTH51MQTCS5jrSTcmR+J/N6+LmdxiGku7YPQdVk/9iGBBlTr6JJYIruBZcouCn67cxS81h2oqnwOlbdJh51eYwmQhscrZSpiIvy3lsOb2C7cT2dlOCFdGCo60N6vx6jiLZf0ruhMqbHSUysqP+vUgoM9Z4Ht76dzsoKHRXi4e2TNo/ZngQ4PrV03ObBc75X8kpL/stdWgOCb8nrkb81VM2Pu7bdu+BvsvZyvRgpUkbh14LYz/xFWHvVXriSbDBQ5O/yRoQd0rmXbVDFLvQ4E2XkLu8pZiVHpmbT4M1g3M3RZgOXBqDJUlEzBHdrftGpzCk/vopKViYxhDyuowotIo/+VyW1R/FNj8qUcmOPTbcBbgzvVMKXMIPzx7b6MHNo98zYFjJY/rb662LghAm5nNhKZVYQHxRJCoC1kMvYaUO+f0hIaYJRMnNOyzLj8MS14jR9qKFKrAErGa/xe7cS6oHsdtKtD3qOSG2eLnQ2Z5e3htMajvnc90MopUns2s8kYKmtOVyaKoXJMTdkWy6S/oK+npPx0Nb8b9wmBH5t2qhnwlYj/9hr97/loeLrOII48Czoyw+O2Wi5TVTJdknS4gH6rpIJvL4NkWT1+k23yTu3VE2zcR2dd/K7/k80j0BGLaWVw3vYy+vDc2vNyjvuE2UKRrsr5+5KyZ48fghjAFPoAzB+euyP6oFJDZ7z7d1O9qM/cje90Jx1KN9O/W2pLDU3iss0O607dkqnZMhUfpx+t8xyS2Xc4PRaJJ3Y6CrZJK8UfCEjlNOskP1cLKkmlVMwHk9YCLJOPSXzhAYB6peyZNHJX/VNdR7uSYPTniOQH9QwMyizDIeF2S+X9TBsoTDY8DOrnniOEZVuBi1OcA92ccWFMUGuiKfpwXra8bZ1mpIcpL+uz 9HpdJHXi tjj18r7P9iH0HCRNAmn3GPl8jnEvrQ9cWuymD/d2QhMXf2MmQ1Hypt0Cwhe5H5QlH4FKZKTU67x6CArMLrgD6/JQEBNQ6LMokd3JTR2m4PD0hC2XDtO/xpgPiiWz9SWFdJZfKMCgNrb0nJwSRJn6fhuX4GverJkFItsp7tSR7DN4haPJwY+Jqs5SQVm6WLZHSlpkERuKBtERDmOsvMlR4uFZNQ+QX2Czi917UOTbOi/rOPFpsAeZHl7orZzQDhuQW9n6h3ngdLrbVtUJJNwimlJq3MRUAQh9s1XNpBGOoqylMgWV1DWnA/Hg7LC98BXflhKFP 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 patch implements proactive shrinking of zswap pool before the max > pool size limit is reached. This also changes zswap to accept new pages > while the shrinker is running. > > To prevent zswap from rejecting new pages and incurring latency when > zswap is full, this patch queues the global shrinker by a pool usage > threshold between 100% and accept_thr_percent, instead of the max pool > size. The pool size will be controlled between 90% to 91% for the > default accept_thr_percent=3D90. Since the current global shrinker > continues to shrink until accept_thr_percent, we do not need to maintain > the hysteresis variable tracking the pool limit overage in > zswap_store(). > > Before this patch, zswap rejected pages while the shrinker is running > without incrementing zswap_pool_limit_hit counter. It could be a reason > why zswap writethrough new pages before writeback old pages. With this > patch, zswap accepts new pages while shrinking, and zswap increments > the counter when and only when zswap rejects pages by the max pool size. > > Now, reclaims smaller than the proactive 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. > > The name of sysfs tunable accept_thr_percent is unchanged as it is still > the stop condition of the shrinker. > The respective documentation is updated to describe the new behavior. > > Signed-off-by: Takero Funaki Taking a step back, could you benchmark and include relevant userspace-visible metrics to show: a) This is a problem happening in realistic-ish workloads. b) The solution shows improvements over the status quo. before we justify any extra complexity? This goes for pretty much the whole series (i.e why are we fixing this), but for this patch specifically, since we are optimizing things.