Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3009642lqp; Mon, 25 Mar 2024 16:50:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWliZqR0KxBH21BLm4c5OSGUsEog5kT7KoqPM52qkMqZaDlLmvYS7lmy2rP3G09eCTs0bMl7VwAhUvM2BfLXsUdN975gzRB4Sf/qVogsw== X-Google-Smtp-Source: AGHT+IH/AB2LlZhD/rakM5dRuNUzIgDZ31I52zNe+Dbw9/DGikd8WWJaugVFfAYyVcvWRJFKys8U X-Received: by 2002:a05:6a20:9597:b0:1a3:ca86:be8a with SMTP id iu23-20020a056a20959700b001a3ca86be8amr4154654pzb.57.1711410628029; Mon, 25 Mar 2024 16:50:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711410628; cv=pass; d=google.com; s=arc-20160816; b=XCuWRyCI/AJe4aY+SAhJJWLkAnFFwTQTJsTAIMKcPq4Q/q8OyNc+OSUizjjxUnEnSo a/8gG3ocBJVQks+awOHLdNvPQNOH6Oo0xbCkoYQRdKE7q9eyIY1MYpwtxwT7xj/jSe// ROoYUP7lkz5mkQ+Tgs9OTuDxlEQ+J66xAsNmE5NwiYXBhsCH0xmIpWbQwf4u8WnxGnLg jDQ3wg2WY09pQ+pSnpj7zqJJXrCeVZGNuwEBaoF0glSo5QnCN29AZcnGOrvf/Ig0Gf8q 4Yet+WHSiTQZ60aHAm0wx1vqWVIvKPCmTU28gaKqWp9pk76lNPNPy5AJOfSveNXFYbVh E+AA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=u7aBwaC4ODAeR/XYxC4V8jgRmUuIBcBfSCKvbyeibW0=; fh=388Ohl5cin06Xcg6MEo+jCt6C7BW0JtlSI8769NlrGw=; b=fu5qewDZAeyCdaRkHB6o4ke3Jzee+nrwBSxTIYo+OBvi4a1am3XF/IFxKVWfEgh4Oa NTUVXOhA/hzAMAZhKjO6bTV+T6FLETceP/78f21TR71V0hAZo8ir17YetdEvZ88kG33B B7ilatvctnu0ZFAC0mMrHcR2ugzBKj4tF4Ggrf09efBt5Ov/VN1mBg5TXIycRPUMVS6c ba5ft7/gG5MGgS2IIse3NrWYfyN3rEHO/nuGF5Cu/v9q7j1Dq+OCX5KcWaMaqpCVE6gr dU+DQ/nMYhULwGK07TzhZk7buwTJnTAQZ1z5/nqg3UER1q1Icykx+QwVGabzcCWzzzGD 5BZA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iey6gU2o; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-118183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118183-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id q8-20020a17090311c800b001e0e85b1e45si401368plh.427.2024.03.25.16.50.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 16:50:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=iey6gU2o; arc=pass (i=1 spf=pass spfdomain=flex--yosryahmed.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-118183-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118183-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id ACFEF2E70FB for ; Mon, 25 Mar 2024 23:50:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B76984D15; Mon, 25 Mar 2024 23:50:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="iey6gU2o" Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 24B9880C00 for ; Mon, 25 Mar 2024 23:50:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711410622; cv=none; b=B/J0Q/cRplPN5Aw+m0Gtaw30udlJ6o29VRjYf+gUuprEC8PzcSbH0RNmlX1ZGDF3oxgf9ycrEN/IwXAJlC6yZkwuo2OIxKhsz8uhjJCLhxyeVaQDFY31dC3zZf6F7BvwqL041i/dCIRaSFGKkJ5Ij9cv2SCn5JEgMEOd3B9W5aA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711410622; c=relaxed/simple; bh=I+qES3UJlPOzSxFqpz3x9sn9+78tIxxGG1ieiOOlj/Y=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=gUQqZRFW0BcvsSiw4tVCsenM+JnZUH8+CvSEbZLrKnc+VvEtgck2zJ0PEhjycBMtXG35BqSHyykmuY0bVc4Y8wfBhJctVifnw9iw8hf1nCQH8pMolOd7cV+aYpeBdKT+PKG1dRO4lRbyQ6r0TgQxEfocwXpe+zaJEili2YXtHQA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=iey6gU2o; arc=none smtp.client-ip=209.85.219.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--yosryahmed.bounces.google.com Received: by mail-yb1-f201.google.com with SMTP id 3f1490d57ef6-dbe9e13775aso8522886276.1 for ; Mon, 25 Mar 2024 16:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711410620; x=1712015420; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=u7aBwaC4ODAeR/XYxC4V8jgRmUuIBcBfSCKvbyeibW0=; b=iey6gU2oY5kI54lKa7u7x5rqI+Jk51kH+SRNHQuKz5vCQHvX/ZDL8sno7Q9v7kM+PS GftTaE18vECMAUgf/ctN7vk9QjtVPoydeD/S9h+bj82LQYRIpJ2H9jUWfZjbzYIS2aMB EdhS+CpSahI/QFOuIVco7Q3Gaa1oS/N4Zcy89xs5uCkjCwMd3Gc4xy7cPdq/M6cfHkSn qo5LlE6aPNC8dP8BMsmxG1Aah6MyPaabMAPH0gTVI/kr4mvLFRo9yzXlMYS87nbE2kFK SKcx3Q9lGQQXt62mcDvQNZ79HThdAa32Gyhwd12lRx9hKHq/v4ZEsObNPYa+3eBNhA1M UZXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711410620; x=1712015420; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=u7aBwaC4ODAeR/XYxC4V8jgRmUuIBcBfSCKvbyeibW0=; b=JY4Ciub4+fiOy0ZHXR2I0wqUoL2Mw72SkifHwj6959hm9VA7swy4cF2sIyl++DNSPK XeTZNzZOky6d5t6HilYIka4LUdDXEShYtuKAItmutd1NPsYJFuHa12jvxXto8wT9r4kv qfvGMplSLmDXyi4dvQTaL9ITDU3/6Ev9htiA/UXHT5JnbFTVhPI4udDnT7wMEplU0X+P c8kUNEoigeaZhm05ZxU2cNyTCUm7wQouAFeNn3ADsvM50cx9gf/iS+EoMQ52SsDNAH4P Bj12T/Uy4yEVcyup8wpnKarlZGU58lbWjLoLe4DWIaJHlQCGIgckZQlRdpifdd+9UsbQ QRXw== X-Forwarded-Encrypted: i=1; AJvYcCXosXepE7ukkVNBR4puOwS0aA1xdkrwuP11oLucv0Yf/8sBxUYNSgzye3U2CRWzsyVLLODBHgwCEgLyAlYcT71wdv5ocM9JVajT00OF X-Gm-Message-State: AOJu0Yw7Xk6AHhew5fOsulsiU/ZbY2onuQYQp5WOr0rJ2dnkxlIqZRzl GpTPtaMDhfKkX/72JY397abkpEqjcLp2g5dTOH23kvFqmyNtVd0MD73wVWIPpLSNuvisJJTmx6r K4gcU88kvsJoMis4yhQ== X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:20:ed76:c0a8:29b4]) (user=yosryahmed job=sendgmr) by 2002:a05:6902:2388:b0:dda:ce5f:b4c3 with SMTP id dp8-20020a056902238800b00ddace5fb4c3mr2112625ybb.1.1711410620214; Mon, 25 Mar 2024 16:50:20 -0700 (PDT) Date: Mon, 25 Mar 2024 23:50:08 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.44.0.396.g6e790dbe36-goog Message-ID: <20240325235018.2028408-1-yosryahmed@google.com> Subject: [RFC PATCH 0/9] zswap: store zero-filled pages more efficiently From: Yosry Ahmed To: Andrew Morton Cc: Johannes Weiner , Nhat Pham , Chengming Zhou , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yosry Ahmed Content-Type: text/plain; charset="UTF-8" This patch series drops the support for non-zero same-filled pages from zswap and makes storing zero-filled pages faster and more efficient. Non-zero same-filled pages should not be nearly as common as zero-filled pages, so dropping support for them in favor of improving the more common zero-filled pages makes sense. It also allows for a lot of code cleanups. Patch 1 is a small cleanup for zswap_store() cleanup path that also implies a small behavioral change. Patches 2-4 are groundword refactoring. Patch 5 removes the userspace tunable to enable same-filled pages handling. It arguably makes no sense anyway. Patch 6 drops the support for non-zero same-filled pages, and patch 7 allows for storing them more efficiently. Both of these patch cause around 1.4% improvement in the system time on kernbench. The kernel build test only produces around 1.5% zero-filled pages. Some real workloads are expected to have higher ratios of zero-filled pages and hence more improvement. They also save a little bit of memory. Exact numbers are in the commit logs. Patch 8 drops the limit checks before handling zero-filled pages and patch 9 does a followup cleanup of zswap_store() made possible by this series. This series is tagged as an RFC because it makes some potentially controversial decisions :) The series is based on a slightly outdated mm-unstable. Yosry Ahmed (9): mm: zswap: always shrink in zswap_store() if zswap_pool_reached_full mm: zswap: refactor storing to the tree out of zswap_store() mm: zswap: refactor limit checking from zswap_store() mm: zswap: move more same-filled pages checks outside of zswap_store() mm: zswap: remove zswap_same_filled_pages_enabled mm: zswap: drop support for non-zero same-filled pages handling mm: zswap: store zero-filled pages without a zswap_entry mm: zswap: do not check the global limit for zero-filled pages mm: zswap: use zswap_entry_free() for partially initialized entries mm/zswap.c | 297 +++++++++++++++++++++++++---------------------------- 1 file changed, 139 insertions(+), 158 deletions(-) -- 2.44.0.396.g6e790dbe36-goog