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 C042EC30653 for ; Sun, 7 Jul 2024 10:54:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DE4E6B007B; Sun, 7 Jul 2024 06:54:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 28EE26B0082; Sun, 7 Jul 2024 06:54:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1570E6B0083; Sun, 7 Jul 2024 06:54:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EA7726B007B for ; Sun, 7 Jul 2024 06:54:17 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 10F3B1A0CB6 for ; Sun, 7 Jul 2024 10:54:17 +0000 (UTC) X-FDA: 82312647354.12.E915F32 Received: from mail-yb1-f171.google.com (mail-yb1-f171.google.com [209.85.219.171]) by imf19.hostedemail.com (Postfix) with ESMTP id 4E5B81A0011 for ; Sun, 7 Jul 2024 10:54:15 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mBl4URnn; spf=pass (imf19.hostedemail.com: domain of flintglass@gmail.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=flintglass@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=1720349626; 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=t4zNRufwwT/TrxbOR4gV2QOmKOXRZvDSyFYKnOgFyDg=; b=vbzDhcER5499chAZTBDcy8x/hH1v2wOrYJAGZod0ZwVb+S3C4/eulle3NRn4eIQzN+LkPx RZMHPvlIILS3wxH2XBQpsK8bErd1b5PKYIlqXY9nKHmIJAzdfO1BZ/0wablTkCww4gTpCX KbmSOaLzPg2ghBIOYixnKV6zV5usWb0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1720349626; a=rsa-sha256; cv=none; b=zyOTUETTos1TMGxkr0aIiugiHo62ELYHKq8YAHA592R49nUaKDBaUHlVGs45sTIrcj+iOS pZioW684MEX8pPrOv4VEH83I34+/IVhzrh8BRkqwsW9d1tbWziJ9oE/zjJlAoOa2CzBags RqkpoWxWd0dZ9YCKnpPgWNIZ6TnBFPs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=mBl4URnn; spf=pass (imf19.hostedemail.com: domain of flintglass@gmail.com designates 209.85.219.171 as permitted sender) smtp.mailfrom=flintglass@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yb1-f171.google.com with SMTP id 3f1490d57ef6-dff1ccdc17bso3224192276.0 for ; Sun, 07 Jul 2024 03:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1720349654; x=1720954454; 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=t4zNRufwwT/TrxbOR4gV2QOmKOXRZvDSyFYKnOgFyDg=; b=mBl4URnnjF7CjFGuxJNfWpuFyflHbkZ7xsskXDls5OJzAFU07uySerirF5FrM8/ACZ 1cSY2jJ8HMMiFAsC18C88AtqK1XTo8bjl5K2F47be52wc6Q3d93KDEkbZdTAoOG4gqR8 DtYsdZF8tscUdA2G2Vl/Kwk1KrkOGrxKr0txkP0BghbcRF0+vIZHtYXmn2CQawY1Eqpv OSRJCGWEhhuLYCXbx5FnT5MLwzsNcVC+BJxYQcJXBtub/8JU3FJXpz1B+IkPYVrCnkbt 0acreNKyHystSS79BKf6e2nt01XrT33yRqmEr08W04yfTY/lPEYKtafVUxbhQIT7HEA9 Lg0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720349654; x=1720954454; 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=t4zNRufwwT/TrxbOR4gV2QOmKOXRZvDSyFYKnOgFyDg=; b=CqehqujoSS0v3lKEo2AZgZNHFB+ptdYgvuKQgjvXrUjVPAptnZlZo6TmBQ4ghy7Fd/ sL57eeOA32RMiupk2xfscBPw8pPcGbJUC5pghcQ2ZBQ2RFjs6ilJt0rp9aAww4xWpQPj b0Hqt8g6WmGLTSewEfknCXvkF1TR+Lwqj0hN/gdrdIkfgt/NwB4CiKkd6442vvGmo2IT LoO/JJcchLwc5T1Kx8s0EFyYaYgnjARixkTfdxnByQ+ZXrFK9zKGlX7iBEbuKL+aHz8p XMvWaUcCJehuoxHBWQn6M3nEj8cMz2a3bn7z5ZVimOSJafnT37E/QBnvHRzc4VNvVLpI mv2Q== X-Forwarded-Encrypted: i=1; AJvYcCXi+LcTPiuu9gYTPYr2bxdW3htykz1TVNwjT7Rby7gVw3UzLUGisPfqptYpqDMLzX6otfRXkKkLzl/TaTHrrq0Q950= X-Gm-Message-State: AOJu0YwTc6YBtSgJtGP3GpySVwPK2mnvAiKtr2fhfpiG/noMvoek4pvG 2ycSsPoLA7VhtdsbMehlUnS7EzQyfsp+9ds7qhdeuJ8XVieHbjCzB6lsjFf07LPQ/+Ha8B54C4U cCi1m9i5dU69k8OkHraaGQyWzUAY= X-Google-Smtp-Source: AGHT+IFl4/Ie9WZbwZiu5JONXDeG5XPuy7cJdl2JxSSiF6oHoSof8Iana9C/jWqQT4Er5PNtdag6U1Cnv71LNo2ZN9o= X-Received: by 2002:a25:ef52:0:b0:e03:6346:ecf6 with SMTP id 3f1490d57ef6-e03c1b6a7c7mr8816539276.61.1720349654398; Sun, 07 Jul 2024 03:54:14 -0700 (PDT) MIME-Version: 1.0 References: <20240706022523.1104080-1-flintglass@gmail.com> <20240706103254.ffd02d7036fa3fe43dbed806@linux-foundation.org> In-Reply-To: <20240706103254.ffd02d7036fa3fe43dbed806@linux-foundation.org> From: Takero Funaki Date: Sun, 7 Jul 2024 19:54:04 +0900 Message-ID: Subject: Re: [PATCH v2 0/6] mm: zswap: global shrinker fix and proactive shrink To: Andrew Morton Cc: Johannes Weiner , Yosry Ahmed , Nhat Pham , Chengming Zhou , Jonathan Corbet , 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: zy1ot8aax4getksojy814idijws3uh4k X-Rspamd-Queue-Id: 4E5B81A0011 X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1720349655-583649 X-HE-Meta: U2FsdGVkX19gVTBo4qrZQWpLZxXL0Q+uE4y/Yv6bDNwXmmUXMQX56SZgDXj55seYAc7Z1WnDZOSPg6CArbGSLInF+ovHZ+V+g2a4kzktnANfxZUZmWIHB/pHFNkrZW4R/3O1G/T2E8sFwidnwKGIjW31O8D95O2kh55RWHbm4eWueyffKoqJhDhRfCQRJBd9oQPGdaesn08uOkhs9npEvdViKl04283+TDDUJ/EH8JMH7lHoNCwjYnaOwHQxO6SMj5DPBm915NgNOTlXz3SW63EqhU0i93Bzmof1YNx2ugRX2JMT30BS/eJujuRJlsjmxGjrfHR/BxrecgvIftp38rDuNcC/wfEMZBf/xFDALd8VOIX0ophDpCO+ybqyijLJb+svP9v4BmTyRvuXULkfJKh6VlZQMsQYs6rVNeeXaJJPqqJ1qVXYijK6qIB2pPIK3bmfXylkXIBz0IcATjEl6SaqXhOkECrGKLeQo3jWT1nsmdhsxl9J8m3sw+6zVYRjBsNrt6w+kGDX6OKgrL/+7vG0aZNHGqLp6jLBQZ5UCb/Y+37Sk9PzFs4e4WW4Gj9fhxt8pFdVNz607YhCqmCiKj2C5UZSjEjiQKo0nYlV2nnM/YT/89kteFaxEijLgw3kKRcNOmVI3Met+kqWbAj35FsYPSD3nfiQzwf/C0+1zGcgUOwUPJ7isw2cp+WlRXaSYWb2zWIaVbf4Cd0CcLZVFwzvsrPEgvMd5KqKNLk+4BZKY7yDybAlPOljz//7CwoEp0bksrAxyDS9iU8YdnN48HwiT5A75T26mtkWUofU44xFS7iGRXzZgVNvYTZ+DIunmKrDvXIJnzYqA4WYcTNzxOfzLlrv7P5MFdtPhtNeHB4PbjLkP9tuRdi5ASf2SwPlltI0einuG79glXqqWTlROeEzu3z1qCrvTl436XcNabfAqi9fitgfqU6l8ykTAXStZ6kWtc9QV0w3jzJ/Kqq 7WL1T1GG H+xTLrzyxzsGA8ZhcMAYD3Y0VyJSBDUd43Lo249ZH0eYn51CVHg5+eWUeoQyPX/1kcbT4zPOtnn3pYdIT52pttA4sDcH133avuwma8hmhs69lzKzYr0u1T945XYO6CWIA4OkZk/hQNLZUWweQFvXjYwWyh1Xb0hbZgcQzI80/ZMVK/QmPZsbL/zbjqkSnhOOguXBW3vGaiRnxb0khDEkqpCIUbsP4uqdQFbcCF7kC7pxLVyDMZNjRb5M1y/zsEcjcEDSEiBwJtZp1h3pVHzuo8hNvq4bdDAy68k9olyS2O+HGlFVGdLhUvARtXnj7p+CqN/Skjf2ciUGdTIgcc6xzlmoFJDvFs2ihvTR3 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: 2024=E5=B9=B47=E6=9C=887=E6=97=A5(=E6=97=A5) 2:32 Andrew Morton : > Seems that patches 1 & 2 might be worthy of backporting into earlier > kernels? Could you please provide a description of the > userspace-visible effects of the bugs so the desirability of such an > action can be better understood? Patch 1 and Patch 2 partially resolve the zswap global shrinker that leads to performance degradation on small systems. However, the fix uncovers another issue addressed in patches 3 to 6. Backporting only the two patches can be a tradeoff with possible performance degradation in some cases. I am not sure the possible issue can be acceptable. The visible issue is described in the cover letter: > Visible issue to resolve > ------------------------------- > The visible issue with the current global shrinker is that pageout/in > operations from active processes are slow when zswap is near its max > pool size. This is particularly significant on small memory systems > where total swap usage exceeds what zswap can store. This results in old > pages occupying most of the zswap pool space, with recent pages using > the swap disk directly. > > Root cause of the issue > ------------------------------- > This issue is caused by zswap maintaining the pool size near 100%. Since > the shrinker fails to shrink the pool to accept_threshold_percent, zswap > rejects incoming pages more frequently than it should. The rejected > pages are directly written to disk while zswap protects old pages from > eviction, leading to slow pageout/in performance for recent pages. Patches 1 and 2 partially resolve the issue by fixing iteration logic. With the two patches applied, zswap shrinker starts evicting pages once the pool limit is hit, as described in the current zswap documentation. However, this fix might not give performance improvement since it lacks proactive shrinking required to prepare spaces before pool limit is hit, implemented in patch 3. Unfortunately, the fix uncovers another issue described in the bottom half of the cover letter. Because the shrinker performs writeback simultaneously with pageout for rejected pages, the shrinker delays actual memory reclaim unnecessarily. The first issue masked the second by virtually disabling the global shrinker writeback. I think the second issue only occurs under severe memory pressure, but may degrade pageout performance as shown in the benchmark at the bottom of the cover letter.