From patchwork Thu May 30 10:19:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Usama Arif X-Patchwork-Id: 13680130 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 D7F6AC25B74 for ; Thu, 30 May 2024 10:21:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 019616B0092; Thu, 30 May 2024 06:21:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F0C396B0093; Thu, 30 May 2024 06:21:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DD2BA6B0095; Thu, 30 May 2024 06:21:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id BBB436B0092 for ; Thu, 30 May 2024 06:21:45 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 33136A278F for ; Thu, 30 May 2024 10:21:45 +0000 (UTC) X-FDA: 82174670970.12.D0AE7A7 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) by imf24.hostedemail.com (Postfix) with ESMTP id 75B39180020 for ; Thu, 30 May 2024 10:21:43 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jkRGI15T; spf=pass (imf24.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.167.172 as permitted sender) smtp.mailfrom=usamaarif642@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=1717064503; 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-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=BaRUgvIHUgZO6RMmzziKFreAcGVarRuht+4q5gP5AUg=; b=grxlJW3xwyOK57Pvi7hzXo2O0iyCAEsRjkJTPTVrfYRz3wQ7SckSm31HgFXOHsFYm35ta4 VLDJHFsmMzkKpbi12ECRAHXPp7FaKu6/H5DJsmFRZUhNJGNQvPRj76cHrRVWNBgkYTH+TD Geu/sJKvJ32IQlmZpJsC2RyUjR8JUGc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=jkRGI15T; spf=pass (imf24.hostedemail.com: domain of usamaarif642@gmail.com designates 209.85.167.172 as permitted sender) smtp.mailfrom=usamaarif642@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717064503; a=rsa-sha256; cv=none; b=ttcc9ALbfw6o1hFF0eRHtvWG+cKs3Army9FldWqk+A1TWg1nS+GnQz5Mgd9hYIt4uGBRK5 zFOC2dqtfkGv9V0LVruWjpi0REmwJCcDCGf7mi1TJ2EZ3+L7PW6AKDRd/KG9ec7r9WNeSl MJnUoj3h2HOkbAhrPspaUeeuFFo1eFo= Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3d1bf479c62so366607b6e.1 for ; Thu, 30 May 2024 03:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717064502; x=1717669302; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=BaRUgvIHUgZO6RMmzziKFreAcGVarRuht+4q5gP5AUg=; b=jkRGI15Tyixfpk4All8YW6saNhH/FoN9fhHHtuwBS576KHVvW1Vi7bkzzFNdOqDZwo T+fnOkHyb2DLwOJbu46X61anQdvhiu8mnaAqkI3qDJg3kv3MCkgWqNE1zxzEWJMgSUha 4nMY893OaS87q52wz/5RxXcvDybmWnk9JfFTpqnTvZ+a6cv4A1MBTvfvU7MZsSYDtoDB SvzjObnU6qqfkS3zIOjjPE2Oz/piWbfkXyIz58JiyogrQV72qEftzmCOlNsHQsNtk5+o wpzDIITkhUEbwUa57W1/W1whLd4jdb6lWEQQvhym6o1acvQ1Bkfin/SlwyLVlf/j/4DV Zt+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717064502; x=1717669302; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BaRUgvIHUgZO6RMmzziKFreAcGVarRuht+4q5gP5AUg=; b=h1zXhN0qV7icv5QCseBxYQkf2xgMG5A4j6CRoUAgsvTO+B4NoX3faJ8LrTpswO3UuG 3aJPwIc4KEzv1unb6kfTCDTBgsuG6fZZWLiU14SsXOlbKkaq7bcfPUZWX7RSuYHgFUJ0 VdSnuifU3WMiaLqCU4axHSW6GoYLIZELnhghviKO1UqLk9qTH3RdOuX6LmWBMPlcoBKB 1Qx6Xl14FT6LiQNGmT85OqA7HX3/FXmWZ9h1mPlZs84o9n7vXcckzAn3tbFnPsgkx53S DPGfrvrvFTnRrbKLLrEJT4s8BQPd3hCDw451tVJVvG3YkS941Lsqyi9KAnXmA+G65EqA 5ovw== X-Forwarded-Encrypted: i=1; AJvYcCXVYu/atYOMKoSiZPRiFjcyi9a0TuNIhHEl1G5pI5T7LBjdRWk6WF7yUjs0ajJV/GpSO7pNmHpTFcvDFqB1QFeQLUM= X-Gm-Message-State: AOJu0YyL/xm2ulA3QJOkud4XS8gL5DpbX1/gUdYpQOs5VKBNFb9T+mJQ iP26oyYiro3u3JDN6MuboTJOpckmv+hKwEy1UxFgLNWqNqmO/Qlh X-Google-Smtp-Source: AGHT+IH6QryCjy0Djphuea2ESS7I4qOgIlAxePO+g2CzT+eKa0mFtAJBmNKROYRYRX+tvQuk8uYzNg== X-Received: by 2002:a05:6808:13c8:b0:3c9:c509:c17 with SMTP id 5614622812f47-3d1dcc9d29amr2381208b6e.11.1717064502309; Thu, 30 May 2024 03:21:42 -0700 (PDT) Received: from localhost (fwdproxy-nao-113.fbsv.net. [2a03:2880:23ff:71::face:b00c]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6ac070f6897sm62085986d6.64.2024.05.30.03.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 May 2024 03:21:41 -0700 (PDT) From: Usama Arif To: akpm@linux-foundation.org Cc: hannes@cmpxchg.org, yosryahmed@google.com, nphamcs@gmail.com, chengming.zhou@linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@meta.com, Usama Arif Subject: [PATCH 0/2] mm: store zero pages to be swapped out in a bitmap Date: Thu, 30 May 2024 11:19:06 +0100 Message-ID: <20240530102126.357438-1-usamaarif642@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 75B39180020 X-Stat-Signature: 1kjujy3574rizwpna6384gcfe3u1ojtn X-Rspam-User: X-HE-Tag: 1717064503-769892 X-HE-Meta: U2FsdGVkX18xUHujT0N0GBhQdhc7jrGAMwo9igI3EtzT53/XWS1MT/8YuOpuIfu+OKR7B4t7u1iECEG9FrGrHKC4UQBWJS0LINBUaT4imq9eTeWysl4mkuqScA6+hui4N+5CVcjYd4S5N0LR1oERy/z37YXoS4pW/hH9tscawquNbppUbDlnSS43dKAaedq1uDljitnJyuJLa/eBSe0GyW5gK7v7QP08WGqOTabuIS2IQlptyxLZTJUvb/S9O/XiIv1jfZshi11CyPXX1EiqVruboRBjQ1Ero/sn9zJj1Y3RP7X9vARsmKUw7Ibh2jU7h2l3rCxUkYJDN3YRFhZibHqm9i819JNVUx1Svl38VDqTICJqSqurimij0o/M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bogosity: Ham, tests=bogofilter, spamicity=0.111279, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: As shown in the patchseries that introduced the zswap same-filled optimization [1], 10-20% of the pages stored in zswap are same-filled. This is also observed across Meta's server fleet. By using VM counters in swap_writepage (not included in this patchseries) it was found that less than 1% of the same-filled pages to be swapped out are non-zero pages. For conventional swap setup (without zswap), rather than reading/writing these pages to flash resulting in increased I/O and flash wear, a bitmap can be used to mark these pages as zero at write time, and the pages can be filled at read time if the bit corresponding to the page is set. When using zswap with swap, this also means that a zswap_entry does not need to be allocated for zero filled pages resulting in memory savings which would offset the memory used for the bitmap. A similar attempt was made earlier in [2] where zswap would only track zero-filled pages instead of same-filled. This patchseries adds zero-filled pages optimization to swap (hence it can be used even if zswap is disabled) and removes the same-filled code from zswap (as only 1% of the same-filled pages are non-zero), simplifying code. This patchseries is based on mm-unstable. [1] https://lore.kernel.org/all/20171018104832epcms5p1b2232e2236258de3d03d1344dde9fce0@epcms5p1/ [2] https://lore.kernel.org/lkml/20240325235018.2028408-1-yosryahmed@google.com/ Usama Arif (2): mm: store zero pages to be swapped out in a bitmap mm: remove code to handle same filled pages include/linux/swap.h | 1 + mm/page_io.c | 86 ++++++++++++++++++++++++++++++++++++++++++-- mm/swapfile.c | 10 ++++++ mm/zswap.c | 79 ++++------------------------------------ 4 files changed, 102 insertions(+), 74 deletions(-)